Skip to content

Commit

Permalink
Stick to established returning for reduce images
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdstein committed May 21, 2024
1 parent 5c9471c commit 64a8aa6
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 25 deletions.
3 changes: 2 additions & 1 deletion mirar/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 16 additions & 2 deletions mirar/pipelines/base_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_forced_photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions tests/test_sedmv2_stellar_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_sedmv2_transient_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions tests/test_summer_imsub_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_summer_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wfau_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_winter_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_wirc_imsub_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 1 addition & 3 deletions tests/test_wirc_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 64a8aa6

Please sign in to comment.