Skip to content

Commit

Permalink
refactor: get cpus_per_task from jobstep executor (#66)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Meesters <[email protected]>
  • Loading branch information
johanneskoester and cmeesters authored Apr 12, 2024
1 parent 80b4c8e commit ed010c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ keywords = ["snakemake", "plugin", "executor", "cluster", "slurm"]
[tool.poetry.dependencies]
python = "^3.11"
snakemake-interface-common = "^1.13.0"
snakemake-interface-executor-plugins = "^9.0.0"
snakemake-executor-plugin-slurm-jobstep = "^0.1.10"
snakemake-interface-executor-plugins = "^9.1.1"
snakemake-executor-plugin-slurm-jobstep = "^0.2.0"
throttler = "^1.2.2"

[tool.poetry.group.dev.dependencies]
Expand Down
14 changes: 2 additions & 12 deletions snakemake_executor_plugin_slurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
JobExecutorInterface,
)
from snakemake_interface_common.exceptions import WorkflowError
from snakemake_executor_plugin_slurm_jobstep import get_cpus_per_task


# Required:
Expand Down Expand Up @@ -126,18 +127,7 @@ def run_job(self, job: JobExecutorInterface):
# fixes #40 - set ntasks regarlless of mpi, because
# SLURM v22.05 will require it for all jobs
call += f" --ntasks={job.resources.get('tasks', 1)}"

cpus_per_task = job.threads
if job.resources.get("cpus_per_task"):
if not isinstance(cpus_per_task, int):
raise WorkflowError(
f"cpus_per_task must be an integer, but is {cpus_per_task}"
)
cpus_per_task = job.resources.cpus_per_task
# ensure that at least 1 cpu is requested
# because 0 is not allowed by slurm
cpus_per_task = max(1, cpus_per_task)
call += f" --cpus-per-task={cpus_per_task}"
call += f" --cpus-per-task={get_cpus_per_task(job)}"

if job.resources.get("slurm_extra"):
call += f" {job.resources.slurm_extra}"
Expand Down

0 comments on commit ed010c6

Please sign in to comment.