Skip to content

Commit

Permalink
Merge pull request #109 from LSSTDESC/issue/108/gen_command_line
Browse files Browse the repository at this point in the history
added generate_stage_command to Pipeline
  • Loading branch information
joezuntz authored Jun 4, 2024
2 parents 92b2c0f + 865bb76 commit 3af9d97
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions ceci/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,38 @@ def make_flow_chart(self, filename):
else:
graph.draw(filename, prog="dot")

def generate_stage_command(self, stage_name, **kwargs):
"""Generate the command to run one stage in this pipeline
Paramaeters
-----------
stage_name: str
The name of the stage
kwargs: dict
Used to override pipeline inputs
"""
try:
sec = self.stage_execution_config[stage_name]
except KeyError as msg:
raise KeyError(f'Failed to find stage named {stage_name} in {list(self.stage_execution_config.keys())}') from msg

if sec.stage_obj is not None:
the_stage = sec.stage_obj
else:
for i, stage_name_ in self.stage_names:
if stage_name == stage_name_:
idx = i
break
if idx is None:
raise KeyError(f'Failed to find stage named {stage_name} in {self.stage_names}')
the_stage = self.stages[idx]

all_inputs = self.pipeline_files.copy()
all_inputs.update(**kwargs)

outputs = the_stage.find_outputs(self.run_config["output_dir"])
return sec.generate_full_command(all_inputs, outputs, self.stages_config)


class DryRunPipeline(Pipeline):
"""A pipeline subclass which just does a dry-run, showing which commands
Expand Down

0 comments on commit 3af9d97

Please sign in to comment.