-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch exposure pipeline to use ModelLibrary instead of a list of mod…
…els (#1525)
- Loading branch information
Showing
7 changed files
with
197 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update exposure pipeline to use ModelLibrary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix exposure pipeline handling of all saturated inputs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import pytest | ||
import roman_datamodels.datamodels as rdm | ||
import roman_datamodels.maker_utils as mk | ||
|
||
from romancal.associations.asn_from_list import asn_from_list | ||
from romancal.datamodels.library import ModelLibrary | ||
from romancal.pipeline import ExposurePipeline | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def input_value(request, tmp_path): | ||
match request.param: | ||
case "datamodel_fn": | ||
model = mk.mk_datamodel(rdm.RampModel) | ||
fn = tmp_path / "model.asdf" | ||
model.save(fn) | ||
return fn | ||
case "datamodel": | ||
return mk.mk_datamodel(rdm.RampModel) | ||
case "asn_fn": | ||
model = mk.mk_datamodel(rdm.RampModel) | ||
model.meta.filename = "foo.asdf" | ||
model.save(tmp_path / model.meta.filename) | ||
asn = asn_from_list([model.meta.filename], product_name="foo_out") | ||
base_fn, contents = asn.dump(format="json") | ||
asn_filename = tmp_path / base_fn | ||
with open(asn_filename, "w") as f: | ||
f.write(contents) | ||
return asn_filename | ||
case "library": | ||
return ModelLibrary([mk.mk_datamodel(rdm.RampModel)]) | ||
case value: | ||
raise Exception(f"Invalid parametrization: {value}") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"input_value, expected_output_type", | ||
[ | ||
("datamodel_fn", rdm.DataModel), | ||
("datamodel", rdm.DataModel), | ||
("asn_fn", ModelLibrary), | ||
("library", ModelLibrary), | ||
], | ||
indirect=["input_value"], | ||
) | ||
def test_input_to_output(input_value, expected_output_type): | ||
""" | ||
Test that for a particular input_value (as parametrized indirectly | ||
through the input_value fixtrue) the output is the expected type. | ||
""" | ||
pipeline = ExposurePipeline() | ||
# don't fetch references | ||
pipeline.prefetch_references = False | ||
# skip all steps | ||
[setattr(getattr(pipeline, k), "skip", True) for k in pipeline.step_defs] | ||
output_value = pipeline(input_value) | ||
assert isinstance(output_value, expected_output_type) |
Oops, something went wrong.