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

Do away with datamodel.close() #9180

Open
stscijgbot-jp opened this issue Feb 12, 2025 · 0 comments
Open

Do away with datamodel.close() #9180

stscijgbot-jp opened this issue Feb 12, 2025 · 0 comments

Comments

@stscijgbot-jp
Copy link
Collaborator

Issue JP-3883 was created on JIRA by Ned Molter:

There are several long-standing issues with datamodel.close(); see

spacetelescope/stdatamodels#29

spacetelescope/stdatamodels#300

spacetelescope/stdatamodels#311

In short, close() doesn't actually free everything from memory until garbage collection, certain attributes of the model are still accessible after close(), and the FileReference object that is tracked by open() and close() would be unnecessary if we just made open() call hdulist.close() after the whole model was loaded into the datamodel (ObjectNode) structure.

Therefore, if we also 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).  If a particular use-case wished to release the datamodel from memory before garbage collection, simply del model would be the recommended way to do so, just like with every other Python object.

This change would effectively close the door on the potential to lazy-load datamodels through the datamodels.open() interface.  However, lazy loading from fits is currently not supported, and supporting it would be more difficult than providing an API for loading headers, which is already proposed in https://jira.stsci.edu/browse/JP-3882 

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

No branches or pull requests

1 participant