-
Notifications
You must be signed in to change notification settings - Fork 26
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
Put context around model opening. #97
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module changelog and other administrivia, LGTM.
Sorry for any confusion. I should clarify that the blocks containing data for non-quantity/unit arrays are still lazy loaded. For example, if I make a level 2 image with: roman_datamodels.maker_utils.mk_level2_image(filepath='foo.asdf') Then open the file (with current roman_datamodels main) and look at the blocks I see several loaded and several unloaded: m = rdd.open('foo.asdf')
print(m._asdf._blocks._internal_blocks) outputs
I see identical output when using af = asdf.open('foo.asdf')
print(af._blocks._internal_blocks) Examining the file I see block 9 is for 'data' which is a quantity (and not lazy loaded) whereas block 10 is for 'dq' which is not a quantity (and is lazy loaded). Let me know what I can do to help clarify this situation. It seems to be a result of asdf-astropy forcing the creation of an array before creating the quantity and astropy converting to an array if the provided value is not a subclass of ndarray (which asdf's NDArrayType is not currently). |
Thanks Brett. Thanks for the clarification; yes, I meant the ndarrays associated with the units. I do think we want to support lazy-loading quantities with units so that things like this metadata query can happen without reading large chunks of the file. That will be a separate ticket, though. It sounds like asdf-astropy is the relevant repository? Would you mind filing the ticket? I just don't want to forget that this is something we should address at some point. |
Thanks for the reply. Happy to open an issue: astropy/asdf-astropy#190 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides all the other administrivia, the change itself LGTM.
Would be nice to have this PR finished and merged in the next release of |
I think the issue being resolved here was fixed in Lines 844 to 852 in 824863e
The romancal regtest run for #142 https://plwishmaster.stsci.edu:8081/job/RT/job/Roman-Developers-Pull-Requests/608/ also contains no ResourceWarning s. @schlafly would you take a look at the above PR and regtest run to see if it addressed the issuse? Thanks!
|
Wonderful, thanks Brett, happy to close this. |
stpipe currently leaves some files open due to this block, which trigger
ResourceWarning: unclosed file
in the Roman regression tests. This PR adds a context manager around the model opening to close these files. This eliminates the ResourceWarnings in romancal.I have not run any detailed tests against stpipe, but wanted to be able to point people to this PR, thus the draft status.
In the context of Roman I am told that opening a model with units triggers also opening all of the associated binary extensions (lazy loading isn't used there?). So pulling these parameters ends up being pretty expensive. But we need to address that on the Roman side.