-
Notifications
You must be signed in to change notification settings - Fork 10
[MRG] adding snakemake --profile
#33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mr-eyes
wants to merge
7
commits into
dib-lab:latest
Choose a base branch
from
mr-eyes:patch-1
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+98
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f572333
Create snakemake_profiles.md
mr-eyes a139137
Update snakemake_profiles.md
mr-eyes d163c2d
Update snakemake_profiles.md
mr-eyes b3bc6f0
Update README.md
mr-eyes c0bcfea
Update README.md
mr-eyes 18622fa
Example + custom profile
mr-eyes ffe66e4
Update snakemake_profiles.md
mr-eyes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
[Using Snakemake](snakemake-slurm.md) | ||
|
||
[Using Snakemake profiles](snakemake_profiles.md) | ||
|
||
[Magic commands and informative links](magic-commands.md) | ||
|
||
The appropriate help mailing list is [email protected] - the list | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Snakemake profiles | ||
|
||
While https://github.com/dib-lab/farm-notes/blob/latest/snakemake-slurm.md works greatly, Snakemake has deprectated the `--cluster-config` and replaced with `--profile`. | ||
|
||
Here's a simple example of setting this up globally on a user account. | ||
|
||
```bash | ||
mkdir -p ~/.config/snakemake/slurm | ||
touch ~/.config/snakemake/slurm/{config.yaml,slurm-status.py} | ||
chmod +x ~/.config/snakemake/slurm/slurm-status.py | ||
``` | ||
|
||
**~/.config/snakemake/slurm/config.yaml** | ||
|
||
```yaml | ||
cluster: | ||
mkdir -p logs/{rule}/ && | ||
sbatch | ||
--cpus-per-task={threads} | ||
--mem={resources.mem_mb} | ||
--time={resources.time} | ||
--job-name=smk-{rule} | ||
--output=logs/{rule}/{jobid}.out | ||
--error=logs/{rule}/{jobid}.err | ||
--partition={resources.partition} | ||
--parsable | ||
default-resources: | ||
- mem_mb=2000 | ||
- time=480 | ||
- partition=low2 | ||
- threads=1 | ||
jobs: 100 | ||
latency-wait: 60 | ||
local-cores: 8 | ||
restart-times: 1 | ||
max-jobs-per-second: 20 | ||
keep-going: True | ||
rerun-incomplete: True | ||
printshellcmds: True | ||
scheduler: greedy | ||
use-conda: True | ||
conda-frontend: mamba | ||
cluster-status: ~/.config/snakemake/slurm/slurm-status.py | ||
max-status-checks-per-second: 10 | ||
``` | ||
|
||
**~/.config/snakemake/slurm/slurm-status.py** | ||
```python | ||
#!/usr/bin/env python3 | ||
import subprocess | ||
import sys | ||
jobid = sys.argv[-1] | ||
output = str(subprocess.check_output("sacct -j %s --format State --noheader | head -1 | awk '{print $1}'" % jobid, shell=True).strip()) | ||
running_status=["PENDING", "CONFIGURING", "COMPLETING", "RUNNING", "SUSPENDED", "PREEMPTED"] | ||
if "COMPLETED" in output: | ||
print("success") | ||
elif any(r in output for r in running_status): | ||
print("running") | ||
else: | ||
print("failed") | ||
``` | ||
|
||
**Run** | ||
|
||
``` | ||
snakemake -s <snakfile> --profile slurm | ||
|
||
``` | ||
|
||
### Create your own profile | ||
|
||
The example above is just a usage demo that you can modify. You can create a new parameter in the `sbatch` command as `{resources.new_parameter}` and then use the `new_parameter` in the resources section of a snakemake rule. | ||
|
||
**Example:** | ||
|
||
In `~/.config/snakemake/slurm/config.yaml` append the following parameter to the sbatch command, then use it in the snakemake rule `resources`. | ||
|
||
```yaml | ||
--nodes={resources.nodes} | ||
``` | ||
|
||
```python | ||
rule test_rule: | ||
threads: 64 | ||
resources: | ||
- partition = 'med2' # med2 partition | ||
- mem_mb = 350 * 1024 # 350GB | ||
- time = 2 * 24 * 60 # two days | ||
- nodes = 2 # Two nodes <- new parameter | ||
``` | ||
|
||
Please note that `job name` = `rule name`, and all log files are written in `logs/job_name/job_id`. Multiple runs to the same rule will override the old log file. | ||
|
||
<hr> | ||
|
||
_Thanks to https://fame.flinders.edu.au/blog/2021/08/02/snakemake-profiles-updated_ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.