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

JP-3721: Simplify ModelContainer #8831

Merged
merged 117 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
5a82f06
add ModelLibrary
braingram Jun 18, 2024
98fb07f
update tweakreg to use ModelLibrary
braingram Jun 20, 2024
395298d
remove minimize_memory option for skymatch
braingram Jun 20, 2024
4b2ce13
update skymatch to use ModelLibrary
braingram Jun 20, 2024
018e3ce
temporary ModelContainer to and from ModelLibrary converter, assign_m…
emolter Jul 18, 2024
74b6607
replaced container with library in resample
emolter Jul 22, 2024
9233dd2
Revert "temporary ModelContainer to and from ModelLibrary converter, …
emolter Jul 29, 2024
bd6207b
put in nogroupid try except statements
emolter Jul 29, 2024
5c3cfc3
ModelLibrary for resample imaging, ModelContainer for resample spec
emolter Jul 29, 2024
c1615dd
Merge remote-tracking branch 'braingram/outlier_detection_steps' into…
emolter Jul 30, 2024
b4a7ce1
fixing problems from merge of outlier detection changes
emolter Jul 30, 2024
36c2b40
outlier detection to ModelLibrary for imaging modes
emolter Jul 30, 2024
c78841a
small fix to resample_spec
emolter Jul 30, 2024
9cdf2b7
Merge remote-tracking branch 'upstream/master' into JP-3690
emolter Jul 30, 2024
3103f82
convert to ModelLibrary and back again in resample_spec_step to avoid…
emolter Jul 30, 2024
2f85218
bugfixes for outlier detection unit tests
emolter Jul 31, 2024
570dc26
expose on_disk for all steps, some cleanup to passing libraries betwe…
emolter Jul 31, 2024
ad9902d
using map_function where applicable, more unit test bug fixes
emolter Jul 31, 2024
3d4fa0d
fix typo in pyproject.toml
emolter Jul 31, 2024
3db69d3
bump version of stpipe
emolter Jul 31, 2024
5ca774e
mark ModelLibrary as not part of stdatamodels
emolter Jul 31, 2024
d694178
added changelog entry
emolter Jul 31, 2024
6066f2b
first draft of docs changes
emolter Jul 31, 2024
48b1050
fixing regtest failures for spec3 pipeline, adding library to mtwcs
emolter Aug 1, 2024
99ef2f6
integrate assign_mtwcs changes with spec3 pipeline
emolter Aug 1, 2024
55262c0
debug coron3 pipeline
emolter Aug 2, 2024
f3ae92e
emptying data arrays in input to model_blender inside resample
emolter Aug 2, 2024
e27acc2
decreasing memory usage of outlier step using profiler
emolter Aug 2, 2024
d6c1642
revert refactor that introduced a bug in resample
emolter Aug 2, 2024
189b375
update skymatch input spec
emolter Aug 12, 2024
a2dd947
bugfix for failed asdf load of recursive wcs transform
emolter Aug 12, 2024
4307f22
Merge branch 'master' into JP-3690
emolter Aug 13, 2024
1ca5c9b
small changes from memory profiling and review
emolter Aug 13, 2024
6f08b61
bugfix for failed to load area extension and other metadata
emolter Aug 14, 2024
b124a8b
handle asn_table and asn_pool metadata properly
emolter Aug 14, 2024
62bacbd
make ind_asn_type case-insensitive
emolter Aug 14, 2024
30dcb3f
fix output filenames from outlier_detection
emolter Aug 14, 2024
5e9e672
bugfix for HDRTAB association info in i2d files
emolter Aug 15, 2024
f87809e
re-add python 3.13 pin that was accidentally clobbered
emolter Aug 15, 2024
ca62baf
reverting accidental clobber of stcal pin dependency
emolter Aug 15, 2024
d47ef4b
updates after reviews by myself and by @braingram
emolter Aug 16, 2024
26e5436
ruff style check
emolter Aug 16, 2024
8f902b7
call img.area
emolter Aug 19, 2024
33d66c9
bugfixes for remove s2d files and for mtimage regtest
emolter Aug 19, 2024
b357edc
Merge branch 'master' into JP-3690
emolter Aug 20, 2024
f35725a
attempted fix for resample and source_catalog result filenames
emolter Aug 20, 2024
4ed0892
remove setting of asn pool and table name in resample
emolter Aug 20, 2024
79f91c6
pushing bad things to remote to diagnose regtest
emolter Aug 20, 2024
3fd25fc
yet another attempt to fix filename issue
emolter Aug 20, 2024
28fa217
attempt to propagate fix also into source_catalog
emolter Aug 20, 2024
1863ef1
bugfix for updating table and pool name in library._assign_member_to_…
emolter Aug 21, 2024
cb5594e
fixes based on @braingram review
emolter Aug 21, 2024
099580c
fix ruff style check and remove unnecessary comment
emolter Aug 21, 2024
6ff67d3
fix unit test and revert changes to file naming
emolter Aug 22, 2024
6cad768
new attempted fix of output filenames
emolter Aug 23, 2024
91b1b19
removed one more manual change to output file naming
emolter Aug 23, 2024
bf069ed
changed has_groups conditional to reflect master branch
emolter Aug 23, 2024
5a44905
attempted fix single regtest failure for miri image3 crf files
emolter Aug 23, 2024
e828ebc
Merge branch master into JP-3690
emolter Aug 27, 2024
5272ac9
fixes per @melanieclarke comments
emolter Aug 27, 2024
a4d4dda
first draft of minimal container
emolter Aug 29, 2024
b176520
added basic context management
emolter Aug 29, 2024
cb59904
merge JP-3690
emolter Aug 29, 2024
2afe670
merge master into JP-3690
emolter Aug 30, 2024
04e2fa5
fixed failure to raise NoGroupID for in-memory models with None for o…
emolter Aug 30, 2024
fff437c
start to modify pipelines to account for container changes
emolter Aug 30, 2024
f8c0596
Merge branch 'JP-3690' into JP-3721
emolter Sep 5, 2024
36ab34d
Merge branch 'master' into JP-3690
emolter Sep 5, 2024
22fb9c9
Merge branch 'JP-3690' into JP-3721
emolter Sep 5, 2024
53635c1
fix file naming with sourcemodelcontainer
emolter Sep 5, 2024
225c21e
removed schema url from container
emolter Sep 5, 2024
1b1e50b
Merge branch 'master' into JP-3721
emolter Sep 6, 2024
71a2a3b
removed some instances of container.meta
emolter Sep 6, 2024
a115695
Merge branch 'master' into JP-3721
emolter Sep 10, 2024
fca4449
Merge branch 'master' into JP-3721
emolter Sep 11, 2024
d876ad5
small fixes to metadata setting and tests
emolter Sep 11, 2024
7121335
Merge remote-tracking branch 'upstream/master' into JP-3721
emolter Sep 17, 2024
b439bb7
Merge remote-tracking branch 'upstream/master' into JP-3721
emolter Sep 17, 2024
f6ed4b8
in the middle of fixing filename issues
emolter Sep 17, 2024
a5d529e
Merge branch 'master' of https://github.com/spacetelescope/jwst into …
emolter Sep 19, 2024
cec0ba6
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Sep 23, 2024
7c4d949
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Sep 25, 2024
8b0be05
fix stpipe unit tests
emolter Sep 25, 2024
a4f22f3
draft fix for JP-2038
emolter Sep 26, 2024
ecf4b0f
fix master background unit and regression test failures
emolter Sep 26, 2024
52c9fb8
fix regtest errors in niriss wfss stemming from extract_1d
emolter Sep 26, 2024
80ae0f3
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Sep 26, 2024
3e5deda
fix badpix_selfcal regtest failure
emolter Sep 26, 2024
a893d5e
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Sep 26, 2024
92cf6cc
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Sep 30, 2024
23670f9
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 7, 2024
b463a99
revert changes that badly attempted fix for relative paths in asn
emolter Oct 7, 2024
02ceca9
fixes from Perry review
emolter Oct 7, 2024
d8cf47f
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 8, 2024
5d6dce7
fix filename issues with nirspec ifu outlier detection
emolter Oct 8, 2024
6fbf9e0
add docs for container vs library
emolter Oct 8, 2024
bbb12f3
small fixes from self-review
emolter Oct 8, 2024
150c41b
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 9, 2024
736ecb9
update pyproject.toml
emolter Oct 9, 2024
3cd76d8
bugfix to avoid calling save_model directly on container
emolter Oct 9, 2024
9560544
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 10, 2024
b09cfec
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 10, 2024
a14ea56
restore save method to container
emolter Oct 10, 2024
d4ec182
added note to docs about lists
emolter Oct 11, 2024
7e3dbd4
fixes from self review
emolter Oct 11, 2024
0256900
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 14, 2024
64c1b5a
fix readthedocs build
emolter Oct 14, 2024
f089558
make mypy happy
emolter Oct 14, 2024
4e36d0f
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 16, 2024
7fab46c
fixes per @melanieclarke review
emolter Oct 16, 2024
4082992
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 16, 2024
80e7dcd
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 17, 2024
0363da4
restore save_model_func to save method and added unit test
emolter Oct 17, 2024
66f2b04
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 17, 2024
f32afb8
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter Oct 18, 2024
03f74cd
Add default file naming for list input to container, plus small chang…
emolter Oct 18, 2024
74762e5
fix default file name logic
emolter Oct 18, 2024
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/8831.datamodels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove memory-saving options from ModelContainer
39 changes: 37 additions & 2 deletions docs/jwst/stpipe/devel_io_design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,50 @@ Many of the JWST calibration steps and pipelines expect an
:ref:`Association <associations>` file as input. When opened with
:meth:`~jwst.stpipe.step.Step.open_model`, a
:class:`~jwst.datamodels.ModelContainer` is returned. `ModelContainer`
is, among other features, a list-like object where each element is the
`DataModel` of each member of the association. The `meta.asn_table` is
is a list-like object where each element is the
`DataModel` of each member of the association. The `asn_table` attribute is
populated with the association data structure, allowing direct access
to the association itself. The association file, as well as the files
listed in the association file, must be in the input directory.

To read in a list of files, or an association file, as an association,
use the `load_as_level2_asn` or `load_as_level3_asn` methods.

ModelContainer vs ModelLibrary
``````````````````````````````

Some steps in the pipeline, namely any steps involved in the Stage 3 Imaging pipeline,
rely on the :class:`~jwst.datamodels.ModelLibrary` class instead of the
:class:`~jwst.datamodels.ModelContainer` class to process association-type data.
The `ModelLibrary` class is purpose-built for enabling memory-saving options in the
image3 pipeline and is only recommended when working with large associations.
Additional documentation on the `ModelLibrary` class can be found in the
`stpipe ModelLibrary documentation <https://stpipe.readthedocs.io/en/latest/model_library.html>`_.

Developers should keep in mind that a `list` is a perfectly valid input and output to a
pipeline or step, and if association metadata is not needed, using a list is preferred
to using a ModelContainer in most cases. Initializing a ModelContainer from a list of
models (as opposed to an association or dictionary) is supported but almost never necessary.

ModelContainer Changes in JWST 1.17
```````````````````````````````````

In JWST 1.17, the `ModelContainer` class was de-scoped in light of the introduction of the
`ModelLibrary` class in JWST 1.16. The `ModelContainer` class is still the recommended class
for handling association-type data, but it is no longer a subclass of `JWSTDataModel`. The
following changes in behavior are noteworthy:

* The `ModelContainer` class no longer has a `meta` attribute. The association data is now
stored in the top-level `asn_table` attribute, along with several other association-relevant
attributes including `asn_table_name`, `asn_pool_name`, `asn_exptypes`, `asn_n_members`,
`asn_file_path`. Note that `asn_table` is now a dictionary, not an `ObjectNode`.
* All infrastructure that attempted memory savings in the `ModelContainer` class has been removed.
Use the `ModelLibrary` class if memory-saving options are needed.
* The `ModelContainer` class is still a list-like object.
* The `ModelContainer` class is still the default class returned by stdatamodels `open()`.
melanieclarke marked this conversation as resolved.
Show resolved Hide resolved
* The `ModelContainer` class can still be used as a context manager, such that `with open(asn_file.json)`
still works.
melanieclarke marked this conversation as resolved.
Show resolved Hide resolved

Input Source
------------

Expand Down
2 changes: 0 additions & 2 deletions jwst/badpix_selfcal/badpix_selfcal_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class BadpixSelfcalStep(Step):
"""

def save_model(self, model, *args, **kwargs):
"""Override save_model to suppress index 0 when save_model is True
"""
kwargs["idx"] = None
return Step.save_model(self, model, *args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion jwst/cube_build/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
self.output_name = 'Temp'
self.input_models = input_models
if not single: # find the name of the output file from the association
self.output_name = input_models.meta.asn_table.products[0].name
self.output_name = input_models.asn_table["products"][0]["name"]

Check warning on line 92 in jwst/cube_build/data_types.py

View check run for this annotation

Codecov / codecov/patch

jwst/cube_build/data_types.py#L92

Added line #L92 was not covered by tests
melanieclarke marked this conversation as resolved.
Show resolved Hide resolved
else:
# close files opened above
self.close()
Expand Down
Loading
Loading