Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some support for opening SSC models #448

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/448.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for opening SSC models using ``rdm_open``.
11 changes: 11 additions & 0 deletions src/roman_datamodels/datamodels/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,16 @@
if (model_type := type(asdf_file.tree["roman"])) in MODEL_REGISTRY:
return MODEL_REGISTRY[model_type](asdf_file, **kwargs)

# Check if the datamodel is a GDPS datamodel
try:
import roman_gdps # noqa: F401
except ImportError as err:
asdf_file.close()
raise ImportError("Please install roman-gdps to allow opening GDPS datamodels") from err

# We assume at this point that an asdf file with `roman` key is a GDPS datamodel
if "roman" in asdf_file.tree:
return asdf_file.tree["roman"]

Check warning on line 120 in src/roman_datamodels/datamodels/_utils.py

View check run for this annotation

Codecov / codecov/patch

src/roman_datamodels/datamodels/_utils.py#L119-L120

Added lines #L119 - L120 were not covered by tests

asdf_file.close()
raise TypeError(f"Unknown datamodel type: {model_type}")
1 change: 1 addition & 0 deletions tests/test_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def test_read_pattern_properties():
rdm_open(Path(__file__).parent / "data" / "photmjsm.asdf")


@pytest.mark.xfail(reason="We currently do not have a way to identify if a datamodel is a GDPS datamodel")
def test_rdm_open_non_datamodel():
from roman_datamodels.datamodels import open as rdm_open

Expand Down
Loading