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

close hdulist instead of keeping a reference in DataModel #300

Open
braingram opened this issue Apr 9, 2024 · 0 comments
Open

close hdulist instead of keeping a reference in DataModel #300

braingram opened this issue Apr 9, 2024 · 0 comments

Comments

@braingram
Copy link
Collaborator

When opening a DataModel stored in a FITS file:

if file_type == "fits":
hdulist = fits.open(init, memmap=memmap)
self._file_references.append(_FileReference(hdulist))
hdulist = self._migrate_hdulist(hdulist)
asdffile = fits_support.from_fits(
hdulist, self._schema, self._ctx, **kwargs
)

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant