From a078cd3ad47e7339ba8aec2fc77aa99e31f9872a Mon Sep 17 00:00:00 2001 From: Matthijs van der Wild Date: Thu, 30 Apr 2026 21:56:22 +0100 Subject: [PATCH] Run CWL jobs that should be skipped on the leader CWL jobs that have a when condition that evaluates to False should not be executed. Currently anything that is not a Workflow or ExpressionTool will always run on a worker node, which means that the check on the Conditional is only done when the worker node is already allocated. If the job is instead run on the leader (local), the step won't be executed. Checking at the instantiation level makes it possible to determine dynamically if the step should be run on the leader or the worker. This prevents unnecessary overhead in scheduling systems. --- src/toil/cwl/cwltoil.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/toil/cwl/cwltoil.py b/src/toil/cwl/cwltoil.py index 726dda7098..c6e9e3aedb 100644 --- a/src/toil/cwl/cwltoil.py +++ b/src/toil/cwl/cwltoil.py @@ -2636,15 +2636,23 @@ def __init__( # If not using the Toil file store, output files just go directly to # their final homes their space doesn't need to be accounted per-job. + options_dict: dict = {} # type: ignore + run_local: bool = self.conditional.is_false(cwljob) + if not run_local: + options_dict["cores"] = req["cores"] + options_dict["memory"] = memory + options_dict["disk"] = int(total_disk) + options_dict["accelerators"] = accelerators + options_dict["preemptible"] = preemptible + super().__init__( - cores=req["cores"], - memory=memory, - disk=int(total_disk), - accelerators=accelerators, - preemptible=preemptible, tool_id=self.cwltool.tool["id"], parent_name=parent_name, - local=isinstance(tool, cwltool.command_line_tool.ExpressionTool), + local=( + isinstance(tool, cwltool.command_line_tool.ExpressionTool) + or run_local + ), + **options_dict, ) self.cwljob = cwljob