close hdulist instead of keeping a reference in `DataModel`
Opened this issue · 0 comments
braingram commented
When opening a DataModel
stored in a FITS
file:
stdatamodels/src/stdatamodels/model_base.py
Lines 238 to 244 in 4041d5f
DataModel
will create a FileReference
for the hdulist
and keep it open. This appears to be unnecessary (adding a hdulist.close()
on line doesn't break any jwst unit tests). This makes sense because the call to from_fits
has to deal with the various quirks of FITS
and results in loading all contents from the FITS
file.
If we instead just close the hdulist a FileReference
is no longer needed.
If we take this one step further and use lazy_load=False
with asdf
we could entirely remove FileReference
and DataModel.close
which would simplify the DataModel
and ModelContainer
api (by no longer needing to close or keep track of closing files).