Skip to content

Commit

Permalink
test(pipeline): ensure multiple output pipeline tasks are supported
Browse files Browse the repository at this point in the history
  • Loading branch information
jrs65 authored and ljgray committed Aug 6, 2024
1 parent b4cfc46 commit 86d3fa7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion caput/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ def _setup_tasks(self):
# Validate that all inputs have a corresponding output key.
self._validate_task_inputs()

# Setup all tasks in the task listk
# Setup all tasks in the task list
for ii, task_spec in enumerate(self.task_specs):
try:
# Load the task instance and add it to the pipeline
Expand Down
21 changes: 20 additions & 1 deletion caput/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def setup(self, requires=None):

def process(self, _input):
"""Run process."""
print("Cooking %s %s eggs." % (self.style, input))
print("Cooking %s %s eggs." % (self.style, _input))

def finish(self):
"""Run finish."""
Expand Down Expand Up @@ -124,6 +124,25 @@ def write_output(self, filename, output, file_format=None, **kwargs):
style: 'fried'
"""

multi_eggs_pipeline_conf = """
---
pipeline:
tasks:
- type: caput.tests.conftest.GetEggs
params: eggs_params
out: [color, egg]
- type: caput.tests.conftest.CookEggs
params: cook_params
in: egg
- type: caput.tests.conftest.CookEggs
params: cook_params
in: color
eggs_params:
eggs: [['green', 'duck'], ['blue', 'ostrich']]
cook_params:
style: 'fried'
"""


def run_pipeline(parameters=None, configstr=eggs_pipeline_conf):
"""Run `caput.scripts.runner run` with given parameters and config.
Expand Down
7 changes: 7 additions & 0 deletions caput/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ def test_pipeline():
result = conftest.run_pipeline()
print(result.output)
assert result.exit_code == 0


def test_pipeline_multiple_outputs():
"""Test running a very simple pipeline with a multi-output task."""
result = conftest.run_pipeline(configstr=conftest.multi_eggs_pipeline_conf)
print(result.output)
assert result.exit_code == 0

0 comments on commit 86d3fa7

Please sign in to comment.