Blitz buildQuery params#4950
Conversation
|
@chris-allan If you could have a look at this when you get time, that would be great, thanks. And #4930 too (lower priority). Cheers. |
| return obj.getValue() | ||
|
|
||
| def _getQueryString(self): | ||
| def _getQueryString(self, opts=None): |
There was a problem hiding this comment.
As this is going to be used more extensively now and its return value has changed to a tuple the function needs pretty thorough documentation and we should definitely mark it for detailed review in the changelog. We have many examples where this method is overridden and/or its return value is used.
| opts = None | ||
| inputParams = None | ||
|
|
||
| if isinstance(params, dict): |
There was a problem hiding this comment.
I'm really not sure about this. At a minimum it needs documentation and to detailed review in the changelog as above. While it certainly keeps the prototype is it not feasible to add opts as an additional keyword argument?
There was a problem hiding this comment.
Understood. I wasn't sure about this either. I was just trying to avoid too many arguments, thinking that use of params would mostly be covered by opts instead (they cover mostly the same functionality). But it can get confusing in the implementation.
I'm happy to add opts as additional argument. Then there's the question of whether params or opts takes precedence (E.g. if you specify different pagination or owner in each)?
There was a problem hiding this comment.
Adding opts as a keyword argument is certainly preferable from my perspective. @aleksandra-tarkowska would probably like the opportunity to comment.
I think you can choose one and document it as taking precedence. Whichever one is the subset of the other is probably the a good candidate but I can see arguments both ways. That is, if you have the possibility to configure 50 things with opts and have params only able to configure 10 the settings from params should probably override those set in params if a call were made where both were present.
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from Annotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
Is loosing the details.group fetch here not a regression?
There was a problem hiding this comment.
See ce55154 in original PR #4945 for when and why details.group was removed from these queries. cc @joshmoore
There was a problem hiding this comment.
Cool, no problem. Just something we should document and probably schedule time to fix at a fundamental level. During work with omero-es I haven't noticed issues like this and I'm definitely loading multiple groups that are not the default group. So I guess it's a combination of factors?
/cc @aleksandra-tarkowska
There was a problem hiding this comment.
@chris-allan See https://trac.openmicroscopy.org/ome/ticket/11362#comment:9 for how to reproduce.
There was a problem hiding this comment.
could you add unit test as well
There was a problem hiding this comment.
@aleksandra-tarkowska Unit tests for every _getQueryString() would be a lot to add to this PR, but maybe just for the ones that handle opts parameter.
There was a problem hiding this comment.
why? we need one at least for parent. You could parametrize the test. In my opinion well written test is much better then the doc
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent join fetch obj.file") | ||
| query = ("select obj from FileAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from TimestampAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from TagAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from CommentAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from LongAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from DoubleAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
| "join fetch obj.details.group " | ||
| "join fetch obj.details.creationEvent") | ||
| query = ("select obj from TermAnnotation obj " | ||
| "join fetch obj.details.owner as owner " |
There was a problem hiding this comment.
As above. Is loosing the details.group fetch here not a regression?
|
Just as a bit of general feedback, having a large number of flake8 fixes embedded in the commits with code changes makes review incredibly time consuming. Every changed line has to be essentially checked on a character by character basis. Parenthetically, and I'm all for keeping a consistent and readable style, if flake8 is throwing up an error and telling us to replace this: with this: ... that's taking the pedantic style application way too far in my opinion and is going to create a lot of needless and conflict inducing churn in our repositories. /cc @sbesson, @joshmoore |
|
@chris-allan Yes, I had to add a lot of flake8 fixes because of travis failures in #4945, see https://travis-ci.org/openmicroscopy/openmicroscopy/jobs/176394210. |
|
Error found by @aleksandra-tarkowska at ome/omero-gallery#11 |
|
Regarding the flake8 fixes even just having those fixes themselves in a separate commit would have made it a lot easier. The reviewer can then work on a commit by commit basis after those changes have been applied and it's then much easier to see what has been changed. Was this code completely devoid of flake8 checking previously and thus we have all these changes to do or is it simply that one or more flake8 version increments have made certain stylistic or structural constructs more rigid? Edit: Yep, regarding the differences in |
|
@will-moore: wrt flake8 better to have a separate PR that we can merge quickly |
17ef783 to
1353f00
Compare
|
|
Thanks, @will-moore. I think the only thing I'd like to see added to the documentation are to explicitly define the supported set of |
|
@aleksandra-tarkowska I thought about that, but I don't think I really need a series of parameters for |
|
|
||
| @classmethod | ||
| @pytest.fixture(autouse=True) | ||
| def setup_class(cls, tmpdir, monkeypatch): |
There was a problem hiding this comment.
didn't you mean setup_method? setup_class and autouse doesn't sound right to me
| ice_config = tmpdir / "ice.config" | ||
| ice_config.write("omero.host=localhost\nomero.port=4064") | ||
| monkeypatch.setenv("ICE_CONFIG", ice_config) | ||
| cls.g = _BlitzGateway() |
There was a problem hiding this comment.
shouldn't you teardown that object
|
I've looked at turning I'll place my current work on this into a separate branch to create a new PR later. |
|
#4993 is ready to review, but I really need to get this PR merged first to clean up the changes. |
|
To check tomorrow if ome/omero-gallery#11 is working before merging |
|
"gallery" is back up on cowfish |
What this PR does
This is a subset of #4945 containing just the BlitzGateway and test changes.
This moves more logic for building queries to the BlitzGateway, to reduce duplication within api_query.py.
This means that the _getQueryString() for each BlitzGateway Wrapper object now returns a base query string, params and clauses. These are then augmented in conn.buildQuery(), which is used both by conn.getObjects() (and by the web /api_query.py - see #4945).
The params argument in
conn.getObjects("Project", params)can now be an
omero.sys.Parametersobject (as before) OR can be a dictionary of parameters to support additional filtering.E.g.
{'page': 1, 'limit': 100, 'order_by': 'name', 'owner': 1, 'project': 5}cc @chris-allan