91
91
get_step ,
92
92
get_step_predefined_variable_connections ,
93
93
get_step_prior_step_connections ,
94
+ get_step_specification ,
94
95
get_step_workflow_variable_connections ,
95
96
is_workflow_input_variable ,
96
97
is_workflow_output_variable ,
@@ -590,10 +591,16 @@ def _prepare_step(
590
591
assert connector .in_ in self ._predefined_variables
591
592
prime_variables [connector .out ] = self ._predefined_variables [connector .in_ ]
592
593
593
- # Using the "plumbing" again add any that relate to values used in prior steps.
594
+ # Using the "plumbing" again so that we can add any variables
595
+ # that relate to values used in prior steps.
594
596
#
595
- # The decoder gives us a map indexed by prior step name that's a list of
596
- # "in"/"out" connectors as before.
597
+ # The decoder gives us a set of "in"/"out" connectors as above
598
+ # indexed by the prior step name.
599
+ #
600
+ # 'inputs' here are not copied to our step's instance directory,
601
+ # instead we need to prefix any 'input' with the instance directory for the
602
+ # step the input belongs to. e.g. "file.txt" will become
603
+ # ".instance-0000/file.txt".
597
604
prior_step_plumbing : dict [str , list [Connector ]] = (
598
605
get_step_prior_step_connections (step_definition = step_definition )
599
606
)
@@ -604,19 +611,44 @@ def _prepare_step(
604
611
# For a combiner step we only need to inspect the first instance of
605
612
# the prior step (the default replica value is '0').
606
613
# We assume all the combiner's prior (parallel) instances
607
- # have the same variables and values.
614
+ # have the same variables and values. Combiners handle inputs from
615
+ # prior steps differently - i.e. they must use a directory 'glob'
616
+ # due to the uncontrolled number of prior steps.
608
617
prior_step , _ = self ._wapi_adapter .get_running_workflow_step_by_name (
609
618
name = prior_step_name ,
610
619
running_workflow_id = rwf_id ,
611
620
)
612
621
assert prior_step
613
- assert "variables" in prior_step
622
+ assert "instance_directory" in prior_step
623
+ p_instance_dir : str = prior_step ["instance_directory" ]
624
+ # Get prior step Job (tro look for inputs)
625
+ # (if we're not a combiner)
626
+ p_job_inputs : dict [str , Any ] = {}
627
+ if not we_are_a_combiner :
628
+ p_step_spec : dict [str , Any ] = get_step_specification (
629
+ wf , prior_step_name
630
+ )
631
+ _LOGGER .info ("get_step_specification() got %s\n " , str (p_step_spec ))
632
+ p_job , _ = self ._wapi_adapter .get_job (
633
+ collection = p_step_spec ["collection" ],
634
+ job = p_step_spec ["job" ],
635
+ version = p_step_spec ["version" ],
636
+ )
637
+ _LOGGER .info ("API.get_job() got %s\n " , str (p_job ))
638
+ assert p_job
639
+ p_job_inputs = job_definition_decoder .get_inputs (p_job )
614
640
# Copy "in" value to "out"...
641
+ # (prefixing inputs with instance directory if required)
642
+ assert "variables" in prior_step
615
643
for connector in connections :
616
644
assert connector .in_ in prior_step ["variables" ]
617
- prime_variables [connector .out ] = prior_step ["variables" ][connector .in_ ]
645
+ value : str = prior_step ["variables" ][connector .in_ ]
646
+ if not we_are_a_combiner and connector .in_ in p_job_inputs :
647
+ # Prefix with prior-step instance directory
648
+ value = f"{ p_instance_dir } /{ value } "
649
+ prime_variables [connector .out ] = value
618
650
619
- # The step's prime variables are now set.
651
+ # Our step's prime variables are now set.
620
652
621
653
# Before we return these to the caller do we have enough
622
654
# to satisfy the step Job's command? It's a simple check -
0 commit comments