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

api experimenters groups #196

Merged
merged 5 commits into from
Jun 16, 2020
Merged

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Mar 6, 2020

Porting BlitzGateway code from ome/openmicroscopy#5315

This adds options for NOT loading the groupExperimenterMap when loading Groups and Experimenters.
Using the opts argument:

groups = conn.getObjects("ExperimenterGroup", opts={'load_experimenters': False})
experimenters = conn.getObjects("Experimenter", opts={'load_experimentergroups': False})

Providing more control over loading of groups/experimenters was also part of proposed performance improvements in ome/openmicroscopy#6081 (not merged).

This will allow us to support experimenters and groups URLs e.g. api/v0/m/experimenters/1/ without unnecessary loading of groups - see #196

Tests added at ome/openmicroscopy#6224

@will-moore will-moore changed the title conn.getObjects() for Experimenters and Groups don't load children by default api experimenters groups Mar 6, 2020
@sbesson
Copy link
Member

sbesson commented Mar 12, 2020

The introduction of an option to switch between various behaviors of the API is certainly very useful. Has there been any discussion about not modifying the default behavior i.e. constructing this change as a backwards-compatible API addition that downstream clients could consume rather than a breaking change?

@manics
Copy link
Member

manics commented Mar 12, 2020

Would this be released as omero-py 6.0.0? Alternatively the gateway could be broken out into a separate package.

Are there any other objects that might benefit from a similar option? If so it'd be nice to avoid option keys being added adhoc, it's difficult enough as it is to find out about the extra options to some BlitzGateway methods.

@will-moore
Copy link
Member Author

I'd like to change the default behaviour to make it more consistent with other parts of the API.
E.g. conn.getObject("Project", id).name doesn't load Datasets.
Currently, conn.getObject("Experimenter', id).firstName loads all the Groups which is unexpected and can be slow if user is in lots of groups.
Same for conn.getObject("ExperimenterGroup', id).name. We don't want that to load lots of users by default.
I guess if we're not ready to release a breaking change, then the default load_experimenters and load_experimentergroups could be True. Then we can flip the default at the time of the next major release.

We have similar flags for Wells (load_images), Images (load_pixels, load_channels) and ROIs (load_shapes).

These options are mentioned in the _getQueryString() method of each class, e.g. https://downloads.openmicroscopy.org/omero/5.5.1/api/python/omero/omero.gateway.html#omero.gateway._ImageWrapper._getQueryString but certainly documentation of these could be improved.

This is more consistent to use the omero.model name ExperimenterGroups
@will-moore
Copy link
Member Author

Now we're loading groupExperimenterMap by default (no breaking change). Description updated.
And tests updated at ome/openmicroscopy#6224

@joshmoore
Copy link
Member

👍 for the non-breakingness. The contortions that were needed (with the hot swapping, etc) make me thing that this could all use a refactoring at some point in the future, but it looks like the impact of this PR is as intended.

Generally, good to go though I note that the tests weren't included from ome/openmicroscopy#6224 due to:

No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

I've relaunched, but you might want to recheck.

@will-moore
Copy link
Member Author

@will-moore
Copy link
Member Author

Travis failing with

INTERNALERROR>     sugar_reporter = SugarTerminalReporter(standard_reporter)
INTERNALERROR>   File "/home/travis/build/ome/omero-py/.tox/py36/lib/python3.6/site-packages/pytest_sugar.py", line 214, in __init__
INTERNALERROR>     self.writer = self._tw
INTERNALERROR> AttributeError: can't set attribute
ERROR: InvocationError for command /home/travis/build/ome/omero-py/.tox/py36/bin/pytest -n4 -m 'not broken' --reruns 5 -rf test (exited with code 3)

@manics
Copy link
Member

manics commented Apr 1, 2020

Travis tests are still broken in this repo #198

@joshmoore
Copy link
Member

Yup, more hands/eyes trying to figure #198 out welcome.

@will-moore will-moore closed this Apr 5, 2020
@will-moore will-moore reopened this Apr 5, 2020
@will-moore
Copy link
Member Author

Fixed a bug found when adding more tests to ome/openmicroscopy#6224

@joshmoore
Copy link
Member

Not sure what the travis failure was. Relaunched.

@will-moore will-moore closed this Jun 2, 2020
@will-moore will-moore reopened this Jun 2, 2020
@will-moore
Copy link
Member Author

I used to be able to re-launch jobs from within travis, but I don't see that option now so I just have to close and open the PR...

@will-moore
Copy link
Member Author

Google-ing for the tox failure found someone who fixed it like this: googleapis/google-cloud-python#1103 (comment)

@joshmoore
Copy link
Member

Re-opening with #216 merged.

@joshmoore joshmoore closed this Jun 4, 2020
@joshmoore joshmoore reopened this Jun 4, 2020
@joshmoore
Copy link
Member

@will-moore @manics : re-opening with #216 in fixed the issue.

@jburel
Copy link
Member

jburel commented Jun 8, 2020

Looking at the implementation methods like getObject(Experimenters) it might be a good idea to think of pushing the logic to AdminService e.g. public List<Experimenter> lookupExperimenters() and offer similar flexibility to the method so both Java/Python will have similar implementation.

@will-moore
Copy link
Member Author

getObject() uses the same logic for all the different types it handles. It would be quite tricky and messy to use the Admin Service for some queries and the Query Service for others.
But nothing prevents us from also adding functionality to the Admin Service.

@jburel
Copy link
Member

jburel commented Jun 8, 2020

I understand that but I think using the relevant service when possible instead of directly using the "queryService" is an approach that simplify the maintenance.

@will-moore will-moore mentioned this pull request Jun 9, 2020
@will-moore
Copy link
Member Author

using the relevant service when possible instead of directly using the "queryService"

This is not the approach we've taken with the BlitzGateway.
conn.getObject() and conn.getObjects() return different subclasses of BlitzObjectWrappers. Each class knows the query needed by iQuery to load the underlying omero.model objects. The base query from each object uses the correct syntax (e.g the selected object itself is obj) so that the query can be extended, e.g. filtering or ordering by obj.attribute. The query returned by each wrapper class is passed to the query service.

If every class used a different service for loading different objects, there would be no consistency and much more complex maintenance.

@jburel
Copy link
Member

jburel commented Jun 9, 2020

If every class used a different service for loading different objects, there would be no consistency and much more complex maintenance.

I am not convinced by that. A change in the model as we have seen in the past implies multiple locations to update: the service and the "iquery" usage.
I am not suggesting to change the approach but the "adminService" methods should not be forgotten.

@will-moore
Copy link
Member Author

So is this good to merge or any suggested changes?

@jburel
Copy link
Member

jburel commented Jun 11, 2020

The default behaviour is preserved (load experimenter). Could you add an issue for AdminService so we keep a record and work on maybe adding the functionality to the AdminService.
I will check with him tomorrow to see if @sbesson wants to include this PR in the release he is preparing.

@sbesson
Copy link
Member

sbesson commented Jun 11, 2020

Assuming this PR is approved, I am happy to move forward with anomero-py 5.7.0 release including this API addition as well as the chown gateway one. I will review other mergeable PRs tonight.

@will-moore
Copy link
Member Author

Created issue at ome/openmicroscopy#6238

@sbesson
Copy link
Member

sbesson commented Jun 16, 2020

Thanks @will-moore. @jburel okay to get this merged with the issue created?

@jburel
Copy link
Member

jburel commented Jun 16, 2020

Happy to include it in the coming release

@sbesson sbesson merged commit 2110193 into ome:master Jun 16, 2020
@sbesson sbesson added this to the 5.7.0 milestone Jun 16, 2020
@sbesson
Copy link
Member

sbesson commented Jun 16, 2020

@will-moore can you prepare a CHANGELOG PR for all merged PRs in the 5.7.0 milestone and we can work together on the release of omero-py?

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

Successfully merging this pull request may close these issues.

5 participants