From 556f074d625342d1f788abeecba9b0d9df980154 Mon Sep 17 00:00:00 2001 From: Eddie Schlafly Date: Fri, 17 Nov 2023 09:44:35 -0500 Subject: [PATCH 1/4] Update resample test to use new files. --- romancal/regtest/test_resample.py | 52 +++++++------------------------ 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/romancal/regtest/test_resample.py b/romancal/regtest/test_resample.py index 70c16512b..7b5e93b41 100644 --- a/romancal/regtest/test_resample.py +++ b/romancal/regtest/test_resample.py @@ -11,55 +11,27 @@ from .regtestdata import compare_asdf - -def create_asn_file( - output_filename: str = "resample_output.asdf", - members_filename_list: list = None, -): - asn_dict = { - "asn_type": "None", - "asn_rule": "DMS_ELPP_Base", - "version_id": "null", - "code_version": "0.9.1.dev28+ge987cc9.d20230106", - "degraded_status": "No known degraded exposures in association.", - "program": "noprogram", - "constraints": "No constraints", - "asn_id": "a3001", - "target": "none", - "asn_pool": "test_pool_name", - "products": [ - { - "name": output_filename, - "members": [ - {"expname": x, "exptype": "science"} for x in members_filename_list - ], - } - ], - } - asn_content = json.dumps(asn_dict) - asn_file_path = "sample_asn.json" - asn_file = StringIO() - asn_file.write(asn_content) - with open(asn_file_path, mode="w") as f: - print(asn_file.getvalue(), file=f) - - return asn_file_path +from romancal.associations import asn_from_list @metrics_logger("DMS342", "DMS343", "DMS344", "DMS345") @pytest.mark.bigdata def test_resample_single_file(rtdata, ignore_asdf_paths): input_data = [ - "r0000501001001001001_01101_0001_WFI02_cal_proc_resample.asdf", - "r0000501001001001001_01101_0002_WFI02_cal_proc_resample.asdf", + "r0000101001001001001_01101_0001_WFI01_cal.asdf", + "r0000101001001001001_01101_0002_WFI01_cal.asdf", ] - output_data = "resample_output_resamplestep.asdf" - truth_data = "resample_truth_resamplestep.asdf" + output_data = "mosaic_resamplestep.asdf" [rtdata.get_data(f"WFI/image/{data}") for data in input_data] - rtdata.get_truth(f"truth/WFI/image/{truth_data}") - - rtdata.input = create_asn_file(members_filename_list=input_data) + rtdata.get_truth(f"truth/WFI/image/{output_data}") + + asn = asn_from_list.asn_from_list(input_data, product_name="mosaic") + asnfn = "mosaic.json" + _, serialized = asn.dump() + with open(asnfn, 'w') as outfile: + outfile.write(serialized) + rtdata.input = asnfn rtdata.output = output_data # instantiate ResampleStep (for running and log access) From 8a4c311d8bd0175b61e775bccb72822946bd1513 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:41:46 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- romancal/regtest/test_resample.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/romancal/regtest/test_resample.py b/romancal/regtest/test_resample.py index 7b5e93b41..52387b52d 100644 --- a/romancal/regtest/test_resample.py +++ b/romancal/regtest/test_resample.py @@ -1,18 +1,14 @@ -import json -from io import StringIO - import numpy as np import pytest from metrics_logger.decorators import metrics_logger from roman_datamodels import datamodels as rdm +from romancal.associations import asn_from_list from romancal.resample.resample_step import ResampleStep from romancal.stpipe import RomanStep from .regtestdata import compare_asdf -from romancal.associations import asn_from_list - @metrics_logger("DMS342", "DMS343", "DMS344", "DMS345") @pytest.mark.bigdata @@ -29,7 +25,7 @@ def test_resample_single_file(rtdata, ignore_asdf_paths): asn = asn_from_list.asn_from_list(input_data, product_name="mosaic") asnfn = "mosaic.json" _, serialized = asn.dump() - with open(asnfn, 'w') as outfile: + with open(asnfn, "w") as outfile: outfile.write(serialized) rtdata.input = asnfn rtdata.output = output_data From 8966899859cdc0c0ec564e61a579690ff447d886 Mon Sep 17 00:00:00 2001 From: Eddie Schlafly Date: Fri, 17 Nov 2023 11:49:17 -0500 Subject: [PATCH 3/4] Store asn file in artifactory rather than making it in the test. --- romancal/regtest/test_resample.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/romancal/regtest/test_resample.py b/romancal/regtest/test_resample.py index 7b5e93b41..cfa6ad707 100644 --- a/romancal/regtest/test_resample.py +++ b/romancal/regtest/test_resample.py @@ -24,13 +24,10 @@ def test_resample_single_file(rtdata, ignore_asdf_paths): output_data = "mosaic_resamplestep.asdf" [rtdata.get_data(f"WFI/image/{data}") for data in input_data] + asnfn = "mosaic_asn.json" + rtdata.get_data(f"WFI/image/{asnfn}") rtdata.get_truth(f"truth/WFI/image/{output_data}") - asn = asn_from_list.asn_from_list(input_data, product_name="mosaic") - asnfn = "mosaic.json" - _, serialized = asn.dump() - with open(asnfn, 'w') as outfile: - outfile.write(serialized) rtdata.input = asnfn rtdata.output = output_data From 79d9b6a246054f274395a75cae6debc0a04cdb95 Mon Sep 17 00:00:00 2001 From: Eddie Schlafly Date: Fri, 17 Nov 2023 11:50:54 -0500 Subject: [PATCH 4/4] Remove old import. --- romancal/regtest/test_resample.py | 1 - 1 file changed, 1 deletion(-) diff --git a/romancal/regtest/test_resample.py b/romancal/regtest/test_resample.py index 19642a302..5fdda5130 100644 --- a/romancal/regtest/test_resample.py +++ b/romancal/regtest/test_resample.py @@ -3,7 +3,6 @@ from metrics_logger.decorators import metrics_logger from roman_datamodels import datamodels as rdm -from romancal.associations import asn_from_list from romancal.resample.resample_step import ResampleStep from romancal.stpipe import RomanStep