From 1b543a06fd4834e055cde43efb8c9a20d5d573f1 Mon Sep 17 00:00:00 2001 From: Richard Shaw Date: Mon, 5 Feb 2024 16:30:01 -0800 Subject: [PATCH] test(pipeline): ensure multiple output pipeline tasks are supported --- caput/pipeline.py | 2 +- caput/tests/conftest.py | 21 ++++++++++++++++++++- caput/tests/test_pipeline.py | 7 +++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/caput/pipeline.py b/caput/pipeline.py index 946bec8f..5bd666e8 100644 --- a/caput/pipeline.py +++ b/caput/pipeline.py @@ -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 diff --git a/caput/tests/conftest.py b/caput/tests/conftest.py index 3272ba5d..eb590cd4 100644 --- a/caput/tests/conftest.py +++ b/caput/tests/conftest.py @@ -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.""" @@ -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. diff --git a/caput/tests/test_pipeline.py b/caput/tests/test_pipeline.py index ccef8d63..22d7b28b 100644 --- a/caput/tests/test_pipeline.py +++ b/caput/tests/test_pipeline.py @@ -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