Skip to content

Commit 6c0e034

Browse files
Merge pull request #30 from InformaticsMatters/sc-3475
LaunchParameter changes
2 parents a3e8285 + c1ef2ec commit 6c0e034

File tree

4 files changed

+24
-30
lines changed

4 files changed

+24
-30
lines changed

tests/test_decoder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,20 +261,20 @@ def test_get_workflow_inputs_for_step_with_name_step1():
261261
# Arrange
262262

263263
# Act
264-
inputs = decoder.get_workflow_input_names_for_step(
264+
inputs = decoder.get_workflow_job_input_names_for_step(
265265
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "step1"
266266
)
267267

268268
# Assert
269269
assert len(inputs) == 1
270-
assert "candidateMolecules" in inputs
270+
assert "inputFile" in inputs
271271

272272

273273
def test_get_workflow_inputs_for_step_with_name_step2():
274274
# Arrange
275275

276276
# Act
277-
inputs = decoder.get_workflow_input_names_for_step(
277+
inputs = decoder.get_workflow_job_input_names_for_step(
278278
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "step2"
279279
)
280280

@@ -286,7 +286,7 @@ def test_get_workflow_inputs_for_step_with_unkown_step_name():
286286
# Arrange
287287

288288
# Act
289-
inputs = decoder.get_workflow_input_names_for_step(
289+
inputs = decoder.get_workflow_job_input_names_for_step(
290290
_SIMPLE_PYTHON_MOLPROPS_WITH_OPTIONS_WORKFLOW, "unknown"
291291
)
292292

workflow/decoder.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,20 @@ def get_variable_names(definition: dict[str, Any]) -> list[str]:
8282
return wf_variable_names
8383

8484

85-
def get_workflow_input_names_for_step(
85+
def get_workflow_job_input_names_for_step(
8686
definition: dict[str, Any], name: str
8787
) -> list[str]:
88-
"""Given a Workflow definition and a step name we return a list of workflow
89-
input variable names the step expects. To do this we iterate through the step's
90-
inputs to find those that are declared 'from->workflow-input'.
91-
92-
To get the input (a filename) the caller simply looks these names up
93-
in the variable map."""
88+
"""Given a Workflow definition and a step name we return a list of step Job input
89+
variable names the step expects. To do this we iterate through the step's
90+
inputs to find those that are declared 'from->workflow-input'."""
9491
inputs: list[str] = []
9592
for step in definition.get("steps", {}):
9693
if step["name"] == name and "inputs" in step:
9794
# Find all the workflow inputs.
9895
# This gives us the name of the workflow input variable
9996
# and the name of the step input (Job) variable.
10097
inputs.extend(
101-
step_input["from"]["workflow-input"]
98+
step_input["input"]
10299
for step_input in step["inputs"]
103100
if "from" in step_input and "workflow-input" in step_input["from"]
104101
)

workflow/workflow_abc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ class LaunchParameters:
4949
#
5050
# ["r-workflow-step-a04d", "r-workflow-step-d904"]
5151
running_workflow_step_prior_steps: list[str] | None = None
52-
# Workflow inputs (for this step Instance). These Workflow Inputs (files) are
53-
# expected to be present in the Project directory. It is simply a list of files
54-
# with the ability to rename them. For example, if the step requires "a.sdf"
55-
# from the Project directory (and renamed as 'input.sdf" in the step's
56-
# instance directory) the engine would provide the following list: -
52+
# Workflow step Job inputs (for this step Instance). These Workflow Inputs (files)
53+
# are a list of Job input variable names for file variables where the
54+
# file is expected to be present in the Project directory. It is simply a list of
55+
# Job variable names. The launcher is expected to find the 'value' of these
56+
# variables and then move the file to the instance directory.
5757
#
58-
# [("a.sdf", "input.sdf")]
59-
running_workflow_step_inputs: list[tuple[str, str]] | None = None
58+
# ["inputFile"]
59+
running_workflow_step_inputs: list[str] | None = None
6060
# The application ID (a custom resource name)
6161
# used to identify the 'type' of Instance to create.
6262
# For DM Jobs this will be 'datamanagerjobs.squonk.it'

workflow/workflow_engine.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040

4141
from .decoder import (
42-
get_workflow_input_names_for_step,
42+
get_workflow_job_input_names_for_step,
4343
get_workflow_output_values_for_step,
4444
set_step_variables,
4545
)
@@ -571,18 +571,15 @@ def _launch(
571571
# We must also identify workflow inputs that are required by the step we are
572572
# about to launch and pass those using a launch parameter. The launcher
573573
# will ensure these are copied into out instance directory before we are run.
574+
# We cannot provide the variable values (even though we have them) because
575+
# the DM passes input through 'InputHandlers', which may translate the value.
576+
# So we have to pass the name and let the DM move the files after
577+
# the InputHandler has run.
574578
#
575579
# 'running_workflow_step_inputs'
576-
# A list of string pairs (input/Project filename and output/Instance filename)
577-
# (with relative paths if appropriate.
578-
inputs: list[tuple[str, str]] = []
579-
for wf_input_name in get_workflow_input_names_for_step(wf, step_name):
580-
# The variable must be known.
581-
# It should have been checked by the time we get here!
582-
assert wf_input_name in variables
583-
# No name change of inputs in this version
584-
inputs.append((variables[wf_input_name], variables[wf_input_name]))
585-
580+
# A list of Job input variable names
581+
inputs: list[str] = []
582+
inputs.extend(iter(get_workflow_job_input_names_for_step(wf, step_name)))
586583
lp: LaunchParameters = LaunchParameters(
587584
project_id=project_id,
588585
name=step_name,

0 commit comments

Comments
 (0)