Skip to content

Commit 0376974

Browse files
author
Alan Christie
committed
fix: Removed workflow variables (not needed)
1 parent d95fb58 commit 0376974

File tree

5 files changed

+27
-15
lines changed

5 files changed

+27
-15
lines changed

tests/job-definitions/job-definitions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ jobs:
119119

120120
rdkit-molprops:
121121
command: >-
122-
rdkit-molprops.py --inputFile {{ inputFile }} --outputFile {{ outputFile }} --name {{ name }} --value {{ value }}
122+
addcol.py --inputFile {{ inputFile }} --outputFile {{ outputFile }} --name {{ name }} --value {{ value }}
123123
124124
cluster-butina:
125125
command: >-
126-
rdkit-molprops.py --inputFile {{ inputFile }} --outputFile {{ outputFile }} --name {{ name }} --value {{ value }}
126+
addcol.py --inputFile {{ inputFile }} --outputFile {{ outputFile }} --name {{ name }} --value {{ value }}

tests/jobs/addcol.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import argparse
2+
3+
parser = argparse.ArgumentParser(
4+
prog="addcol",
5+
description="Takes a SMILES string and writes it to a file",
6+
)
7+
parser.add_argument("-i", "--inputFile", required=True)
8+
parser.add_argument("-o", "--outputFile", required=True)
9+
parser.add_argument("-n", "--name", required=True)
10+
parser.add_argument("-v", "--value", required=True)
11+
args = parser.parse_args()
12+
13+
with open(args.inputFile, "rt", encoding="utf8") as input_file:
14+
content = input_file.read()
15+
with open(args.outputFile, "wt", encoding="utf8") as output_file:
16+
output_file.write(content)

tests/jobs/cluster-butina.py

Whitespace-only changes.

tests/jobs/rdkik-molprops.py

Whitespace-only changes.

workflow/workflow_engine.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _handle_workflow_start_message(self, r_wfid: str) -> None:
139139
# Launch the first step.
140140
# If there's a launch problem the step (and running workflow) will have
141141
# and error, stopping it. There will be no Pod event as the launch has failed.
142-
self._launch(wf=wf_response, rwf=rwf_response, rwfs_id=r_wfsid, step=first_step)
142+
self._launch(rwf=rwf_response, rwfs_id=r_wfsid, step=first_step)
143143

144144
def _handle_pod_message(self, msg: PodMessage) -> None:
145145
"""Handles a PodMessage. This is a message that signals the completion of a
@@ -263,7 +263,6 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
263263
)
264264

265265
self._launch(
266-
wf=wf_response,
267266
rwf=rwf_response,
268267
rwfs_id=r_wfsid,
269268
step=next_step,
@@ -286,7 +285,6 @@ def _validate_step_command(
286285
self,
287286
*,
288287
step: dict[str, Any],
289-
workflow_variables: dict[str, Any] | None,
290288
running_workflow_variables: dict[str, Any] | None = None,
291289
) -> str | dict[str, Any]:
292290
"""Returns an error message if the command isn't valid.
@@ -328,7 +326,7 @@ def _validate_step_command(
328326
# 'decode()' method to do this. It returns a tuple (str and boolean).
329327
# If the boolean is True then the command can be compiled
330328
# (i.e. it has no missing variables) and the launcher should not complain
331-
# about the command (as we'll pass the same variables to it).
329+
# about the command (as we'll pass the same variables to it.
332330
# If the returned boolean is False then we can expect the returned str
333331
# to contain an error message.
334332
#
@@ -337,17 +335,13 @@ def _validate_step_command(
337335
# (in descending order of priority) from...
338336
#
339337
# 1. The RunningWorkflow
340-
# 2. The Workflow
341-
# 3. The Job Step Specification Variables
338+
# 2. The Job Step Specification Variables
342339
#
343340
# If variable 'x' is defined in all three then the RunningWorkflow's
344341
# value must be used.
345342

346343
# Get any variables from the step specification.
347344
all_variables = step_spec.pop("variables") if "variables" in step_spec else {}
348-
# Merge workflow variables on top of these
349-
if workflow_variables:
350-
all_variables |= workflow_variables
351345
# Merge running workflow variables on top of these
352346
if running_workflow_variables:
353347
all_variables |= running_workflow_variables
@@ -360,7 +354,6 @@ def _validate_step_command(
360354
def _launch(
361355
self,
362356
*,
363-
wf: dict[str, Any],
364357
rwf: dict[str, Any],
365358
rwfs_id: str,
366359
step: dict[str, Any],
@@ -370,12 +363,15 @@ def _launch(
370363

371364
_LOGGER.info("Validating step command: %s (step=%s)...", rwf_id, step_name)
372365

373-
# Now check the step command can be executed (by decoding it)
374-
workflow_variables: dict[str, Any] | None = wf.get("variables")
366+
# Now check the step command can be executed
367+
# (by trying to decoding the Job command).
368+
#
369+
# We pass in the workflow variables (these are provided by the user
370+
# when the workflow is run. All workflow variables will be present in the
371+
# running workflow record)
375372
running_workflow_variables: dict[str, Any] | None = rwf.get("variables")
376373
error_or_variables: str | dict[str, Any] = self._validate_step_command(
377374
step=step,
378-
workflow_variables=workflow_variables,
379375
running_workflow_variables=running_workflow_variables,
380376
)
381377
if isinstance(error_or_variables, str):

0 commit comments

Comments
 (0)