-
Notifications
You must be signed in to change notification settings - Fork 33
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
FilesetWrapper lazy loads Images and UsedFiles #405
Conversation
Maybe I am missing something obvious but shouldn't |
Thanks. Two additional questions:
|
I'm not sure if this is considered a breaking change, at least not to the BlitzGateway API. If you consider the API to extend to the underlying
then this will break. This is kinda edge-case behaviour, so I'm not sure that it justifies a major release, but if so then I think it's worth doing because it's important that the default behaviour of Using I'm happy to add opts for In the meantime I'll remove the |
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.
Tested against a representative IDR plate (1K images, 20K files) - see https://idr.openmicroscopy.org/webclient/?show=plate-10263
>>> from omero.gateway import BlitzGateway
>>> conn=BlitzGateway("public","public",host="idr.openmicroscopy.org",secure=True)
>>> conn.connect()
True
>>> fileset = conn.getObject("Fileset",6311594)
>>> fileset._obj._usedFilesLoaded
False
>>> fileset._obj._imagesLoaded
False
>>> print(len(fileset.copyImages()))
1152
>>> fileset._obj._imagesLoaded
True
>>> fileset._obj._usedFilesLoaded
False
>>> print(len(fileset.listFiles()))
23045
>>> fileset._obj._usedFilesLoaded
True
In terms of response time, getObject("Fileset", 6311594)
returned instantly while fileset.listFiles()
took several seconds.
Following up on the discussion in #405, internal fields prefixed with _
should not be considered as part of the public API inline. In that sense, I agree there is no change in behavior as accessing the images and files associated with a fileset should happen using the public copyImages()
and listFiles
APIs as described in https://omero.readthedocs.io/en/stable/developers/Python.html#filesets-added-in-omero-5-0. The only difference introduced by this PR is that these API calls will no longer return instantly due to the fetching and their response time will depend on the number of underlying objects. I'll leave others to comment but it might be worth mentioning this aspect in the docstring and/or the reference documentation.
Overall, I agree that the current behavior is dangerous especially when loading filesets with large numbers of images and/or plates and lazy loading addresses this issue.
Fixes #404.
When we do
conn.getObject('Fileset', fileset_id)
we don't try to load all Images and Files up front.Instead, these are lazily loaded as required using the same pattern as for other Wrapper objects.
Test that
fileset.copyImages()
andfileset.listFiles()
behaviour don't change:E.g. test script should show no change:
python test.py 123