From c329450128e71e37f2a8d77d7e967b9dec0b580a Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Mon, 23 Jun 2025 11:19:42 +0200 Subject: [PATCH 1/2] fix: better handling of allowed rules in combination with snakemake >=9.6.2 --- pyproject.toml | 2 +- .../executors/real.py | 57 +++++++++++-------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5fcff41..a508be6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ license = { text = "MIT" } readme = "README.md" requires-python = ">=3.11" dependencies = [ - "snakemake-interface-common>=1.17.4", + "snakemake-interface-common>=1.19.0", "throttler>=1.2.2", "argparse-dataclass>=2.0.0", ] diff --git a/snakemake_interface_executor_plugins/executors/real.py b/snakemake_interface_executor_plugins/executors/real.py index 5a4c365..aaf8af0 100644 --- a/snakemake_interface_executor_plugins/executors/real.py +++ b/snakemake_interface_executor_plugins/executors/real.py @@ -5,6 +5,8 @@ from abc import abstractmethod from typing import Dict + +from snakemake_interface_common import at_least_snakemake_version from snakemake_interface_executor_plugins.executors.base import ( AbstractExecutor, SubmittedJobInfo, @@ -78,32 +80,39 @@ def additional_general_args(self): return [] def get_job_args(self, job: JobExecutorInterface, **kwargs): + + + unneeded_temp_files = list(self.workflow.dag.get_unneeded_temp_files(job)) + arg_list = [ + format_cli_arg( + "--target-jobs", encode_target_jobs_cli_args(job.get_target_spec()) + ), + # Restrict considered rules for faster DAG computation. + format_cli_arg( + "--allowed-rules", + job.rules, + quote=False, + # Via this fix: https://github.com/snakemake/snakemake/pull/3640 + # --allowed-rules can be always used. The fix is released in + # snakemake 9.6.2. Before, --allowed-rules had to be skipped + # for jobs that have been updated after checkpoint evaluation. + skip=job.is_updated and not at_least_snakemake_version("9.6.2"), + ), + # Ensure that a group uses its proper local groupid. + format_cli_arg("--local-groupid", job.jobid, skip=not job.is_group()), + format_cli_arg("--cores", kwargs.get("cores", self.cores)), + format_cli_arg("--attempt", job.attempt), + format_cli_arg("--force-use-threads", not job.is_group()), + format_cli_arg( + "--unneeded-temp-files", + unneeded_temp_files, + skip=not unneeded_temp_files, + ), + ] + return join_cli_args( - [ - format_cli_arg( - "--target-jobs", encode_target_jobs_cli_args(job.get_target_spec()) - ), - # Restrict considered rules for faster DAG computation. - # This does not work for updated jobs because they need - # to be updated in the spawned process as well. - format_cli_arg( - "--allowed-rules", - job.rules, - quote=False, - skip=job.is_updated, - ), - # Ensure that a group uses its proper local groupid. - format_cli_arg("--local-groupid", job.jobid, skip=not job.is_group()), - format_cli_arg("--cores", kwargs.get("cores", self.cores)), - format_cli_arg("--attempt", job.attempt), - format_cli_arg("--force-use-threads", not job.is_group()), - format_cli_arg( - "--unneeded-temp-files", - unneeded_temp_files, - skip=not unneeded_temp_files, - ), - ] + arg_list ) @property From 73ee7acacbb74bf74186e66844056a63e796be67 Mon Sep 17 00:00:00 2001 From: Johannes Koester Date: Mon, 23 Jun 2025 11:22:16 +0200 Subject: [PATCH 2/2] fmt --- .../executors/real.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/snakemake_interface_executor_plugins/executors/real.py b/snakemake_interface_executor_plugins/executors/real.py index aaf8af0..bfc072d 100644 --- a/snakemake_interface_executor_plugins/executors/real.py +++ b/snakemake_interface_executor_plugins/executors/real.py @@ -80,9 +80,6 @@ def additional_general_args(self): return [] def get_job_args(self, job: JobExecutorInterface, **kwargs): - - - unneeded_temp_files = list(self.workflow.dag.get_unneeded_temp_files(job)) arg_list = [ format_cli_arg( @@ -94,8 +91,8 @@ def get_job_args(self, job: JobExecutorInterface, **kwargs): job.rules, quote=False, # Via this fix: https://github.com/snakemake/snakemake/pull/3640 - # --allowed-rules can be always used. The fix is released in - # snakemake 9.6.2. Before, --allowed-rules had to be skipped + # --allowed-rules can be always used. The fix is released in + # snakemake 9.6.2. Before, --allowed-rules had to be skipped # for jobs that have been updated after checkpoint evaluation. skip=job.is_updated and not at_least_snakemake_version("9.6.2"), ), @@ -111,9 +108,7 @@ def get_job_args(self, job: JobExecutorInterface, **kwargs): ), ] - return join_cli_args( - arg_list - ) + return join_cli_args(arg_list) @property def job_specific_local_groupid(self):