diff --git a/mirar/__main__.py b/mirar/__main__.py index 59fc969ba..913b700ca 100644 --- a/mirar/__main__.py +++ b/mirar/__main__.py @@ -158,10 +158,11 @@ night=night, ) - batches, errorstack, processors = pipe.reduce_images( + batches, errorstack = pipe.reduce_images( catch_all_errors=not args.failfast, ) + processors = pipe.get_latest_configuration() flowify(processors, pipe.get_flowchart_output_path(), include_stats=True) if args.postprocessconfig is not None: diff --git a/mirar/pipelines/base_pipeline.py b/mirar/pipelines/base_pipeline.py index dbf88d33f..96e50fcb7 100644 --- a/mirar/pipelines/base_pipeline.py +++ b/mirar/pipelines/base_pipeline.py @@ -72,6 +72,7 @@ def __init__( if not isinstance(selected_configurations, list): selected_configurations = [selected_configurations] self.selected_configurations = selected_configurations + self.latest_configuration = None @classmethod def __init_subclass__(cls, **kwargs): @@ -183,6 +184,17 @@ def set_configuration( logger.debug("Pipeline initialisation complete.") return processors + def get_latest_configuration(self) -> list[BaseProcessor]: + """ + Get the latest configuration used by the pipeline + + :return: list of processors + """ + if self.latest_configuration is None: + raise ValueError("No configuration has been set yet.") + + return self.latest_configuration + @staticmethod def download_raw_images_for_night(night: str | int): """ @@ -238,7 +250,7 @@ def reduce_images( output_error_path: Optional[str] = None, catch_all_errors: bool = True, selected_configurations: Optional[str | list[str]] = None, - ) -> tuple[Dataset, ErrorStack, list[BaseProcessor]]: + ) -> tuple[Dataset, ErrorStack]: """ Function to process a given dataset. @@ -296,11 +308,13 @@ def reduce_images( all_processors += processors + self.latest_configuration = all_processors + err_stack.summarise_error_stack(output_path=output_error_path) err_stack.summarise_error_stack_tsv( output_path=output_error_path.with_suffix(".tsv") ) - return dataset, err_stack, all_processors + return dataset, err_stack def postprocess_configuration( self, diff --git a/tests/test_errors.py b/tests/test_errors.py index 543eb2d1e..44a10aa0c 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -33,7 +33,7 @@ def setUp(self): def test_pipeline(self): self.logger.info("\n\n Testing summer pipeline \n\n") - _, errorstack, _ = pipeline.reduce_images( + _, errorstack = pipeline.reduce_images( Dataset(ImageBatch()), catch_all_errors=True ) diff --git a/tests/test_forced_photometry.py b/tests/test_forced_photometry.py index 9398dce08..4b4572446 100644 --- a/tests/test_forced_photometry.py +++ b/tests/test_forced_photometry.py @@ -79,7 +79,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing forced photometry \n\n") - res, _, _ = pipeline.reduce_images( + res, _ = pipeline.reduce_images( dataset=Dataset(ImageBatch()), catch_all_errors=False ) self.assertEqual(len(res), 1) diff --git a/tests/test_sedmv2_stellar_pipeline.py b/tests/test_sedmv2_stellar_pipeline.py index a3ebea302..37539a434 100644 --- a/tests/test_sedmv2_stellar_pipeline.py +++ b/tests/test_sedmv2_stellar_pipeline.py @@ -97,9 +97,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing SEDMv2 stellar pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) self.assertEqual(len(res), 29) diff --git a/tests/test_sedmv2_transient_pipeline.py b/tests/test_sedmv2_transient_pipeline.py index 27d628dcc..1db96065c 100644 --- a/tests/test_sedmv2_transient_pipeline.py +++ b/tests/test_sedmv2_transient_pipeline.py @@ -72,9 +72,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing SEDMv2 transient pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) # Cleanup output_dir = get_output_dir("sedmv2/20230526") diff --git a/tests/test_summer_imsub_pipeline.py b/tests/test_summer_imsub_pipeline.py index b19d8c8c1..45c36beba 100644 --- a/tests/test_summer_imsub_pipeline.py +++ b/tests/test_summer_imsub_pipeline.py @@ -39,9 +39,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing summer pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) self.assertEqual(len(res), 1) diff --git a/tests/test_summer_pipeline.py b/tests/test_summer_pipeline.py index 20b1ce837..731b10670 100644 --- a/tests/test_summer_pipeline.py +++ b/tests/test_summer_pipeline.py @@ -66,9 +66,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing summer pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) # Cleanup - delete non-empty ouptut dir output_dir = get_output_dir(dir_root="summer/20220402") diff --git a/tests/test_wfau_references.py b/tests/test_wfau_references.py index 4b94be602..538839b89 100644 --- a/tests/test_wfau_references.py +++ b/tests/test_wfau_references.py @@ -60,7 +60,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing WINTER reference building pipeline \n\n") - res, _, _ = run_winter_reference_build_pipeline( + res, _ = run_winter_reference_build_pipeline( subdet_id=0, field_id=TEST_WINTER_FIELD_ID, catch_all_errors=False ) diff --git a/tests/test_winter_pipeline.py b/tests/test_winter_pipeline.py index da1e05f92..132938569 100644 --- a/tests/test_winter_pipeline.py +++ b/tests/test_winter_pipeline.py @@ -103,9 +103,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing winter pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) # Cleanup - delete ouptut dir output_dir = get_output_dir(dir_root="winter/20230726") diff --git a/tests/test_wirc_imsub_pipeline.py b/tests/test_wirc_imsub_pipeline.py index 4200737dd..17c1f11d2 100644 --- a/tests/test_wirc_imsub_pipeline.py +++ b/tests/test_wirc_imsub_pipeline.py @@ -131,7 +131,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing wirc imsub pipeline \n\n") - res, _, _ = pipeline.reduce_images( + res, _ = pipeline.reduce_images( dataset=Dataset(ImageBatch()), catch_all_errors=False ) diff --git a/tests/test_wirc_pipeline.py b/tests/test_wirc_pipeline.py index 4b6d81d07..289a002bd 100644 --- a/tests/test_wirc_pipeline.py +++ b/tests/test_wirc_pipeline.py @@ -94,9 +94,7 @@ def test_pipeline(self): """ self.logger.info("\n\n Testing wirc pipeline \n\n") - res, _, _ = pipeline.reduce_images( - Dataset([ImageBatch()]), catch_all_errors=False - ) + res, _ = pipeline.reduce_images(Dataset([ImageBatch()]), catch_all_errors=False) self.assertEqual(len(res), 1)