-
Notifications
You must be signed in to change notification settings - Fork 31
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
Don't use group -1 for luts_png #603
base: master
Are you sure you want to change the base?
Conversation
cc @Tom-TBT |
Thank you for the fix Will, sorry for that. |
@Tom-TBT This is some strange behaviour we are seeing ONLY on our production server (which has a very long history), but not on any other server we've tested on. So, nothing to apologise for! |
after investigation it seems that the wrong permissions are set for the |
We are seeing significant performance improvements with this change if the user's default group has a large number of users, so it seems to be worth including. |
Interesting. I'm curious, can you explain why the performance is affected here? |
@Tom-TBT The issue of slow cross-group queries when a user is in a big group are very low-level OMERO internals. I'm not sure if it's documented anywhere... Another issue we're finding is that we can't assume that omero-web installations will have caching enabled. The default behaviour is for caching to be disabled. Default is a dummy cache: omero-web/omeroweb/settings.py Line 456 in 96d1138
and configuring e.g. redis is described as optional: So, what is best to do? Options:
|
Tested setting the group to the
And logged-in to nightshade as However, this had no difference in performance compared with leaving the group as the user's default group. Only setting |
576d62d
to
eb71bb1
Compare
for more information, see https://pre-commit.ci
Could you please expand on how to test ? I went on merge-ci as user-3 to url https://merge-ci.openmicroscopy.org/web/webgateway/luts_png/ and it loaded. When I went to https://merge-ci.openmicroscopy.org/web/webgateway/luts_png/webgateway/luts_png/?cached=false then it loaded too. There was no perceptible speed differentce between the two cases ^^^ |
Discussed at web meeting today... |
README.rst
Outdated
cached in https://github.com/ome/omero-web/blob/master/omeroweb/webgateway/static/webgateway/json/luts.json. | ||
The LUTs in the `/luts_png/` will always correspond to the LUTs on the server as available in JSON | ||
from `/webgateway/luts/`. | ||
If new LUTs are added to the server and are not found in the `luts.json` then the `/luts_png/` will |
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.
again confusing.
luts.json is a visual representation i.e. name and associated png
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.
No, luts.json
is a json file (see this PR).
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.
I know, I should have said "holds a visual representation but If new LUTs are added to the server and are not found in the `luts.json
is not clear
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.
I rewrote the README - hopefully more clear now?
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.
Immediate thoughts while reading this proposal is that it brings us back to the coupling issues originally raised in #568. When new LUTs get added to the server, the following must happen
1- a release of OMERO.web with an updated luts.json
2- possibly a release of all web apps of the ecosystem to depend on the newest version of OMERO.web
Has there been any consideration about hybrid solution where the cached JSON would be retrieved and only the missing LUTs would be dynamically fetched from the server when retrieving the PNG representation?
README.rst
Outdated
|
||
The OMERO server ships with a set of look-up tables (LUTs) for rendering images. Users can also | ||
add their own LUTs to the server. The LUTs available on the server can be retrieved from the | ||
`/webgateway/luts/` endpoint as JSON data. |
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.
Although it certainly does not hurt to have this documentation here, it feels a bit at odds with the rest of the README.
Should https://omero.readthedocs.io/en/stable/developers/Web/WebGateway.html be extended to cover the LUT endpoints of the OMERO.web gateway?
The Upgrade of LUTS does not happen very often (first time) |
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.
I appreciate the LUT upgrade is not frequent and there is so much time we want to invest into the dynamic aspect. Especially if the next OMERO.web release will also include the upgraded JSON with the LUTs.
I was primaril asking as the dynamic loading is implemented in the /webgateway/luts&rgb=true
and this endpoint could possibly be used rather than loading the cache in /webgateway/luts_png
.
Performance-wise, comparing the timings of https://merge-ci.openmicroscopy.org/web/webgateway/luts/?rgb=true to https://merge-ci.openmicroscopy.org/web/static/webgateway/json/luts.json, the former call responds with a couple of 100 additional milliseconds (~574ms vs. 257ms). So there is an open question of which metrics is acceptable.
At the API level, the new rgb=true
parameters in the /webgateway/luts/
endpoint are backwards compatible. However, as described in the PR, the behavior of /webgateway/luts_png/
is completely modified. At minimum, the docstring should be updated to reflect the new expectation. This also raises the question of whether these changes are significant enough that they should be considered as backwards incompatible .
Testing wise, the previous implementation suggests updates to the LUT name/path would be reflected in these endpoints. Is this also true in the new implementation and should this be tested?
) | ||
# rgb = load_lut_to_rgb(conn, lut.id.val) | ||
lut_data = { | ||
"id": lut.id.val, |
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.
The LUT ID might vary from server to server. This is not a problem per se especially as you are using path+name
for normalizing but this means there is a mismatch between the cached JSON file and this endpoint - which can be seen for instance by comparing https://merge-ci.openmicroscopy.org/web/webgateway/luts/ with https://merge-ci.openmicroscopy.org/web/static/webgateway/json/luts.json
Should id
not omitted in the cache?
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.
Yes id
s will change, but are harmless. If we want to allow the easy copying of /webgateway/luts/?rgb=true
into the static luts.json
but ALSO exclude ids, then maybe we need another parameter ?ids=false
. Easy to do if worth it?
README.rst
Outdated
LUTs caching | ||
------------ | ||
|
||
The OMERO server ships with a set of look-up tables (LUTs) for rendering images. Users can also |
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.
Admin can add, not users since it is treated as a script
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.
Fixed in 961d307
Thanks for the in-depth reviews...
I actually think this would make a lot of sense. The performance issues we saw previously were because we were fetching all 47 LUTs from the server, whereas if you're only fetching 1 or 2 then this won't be a problem. This would mean the behaviour of The We could consider re-enabling the caching of the Updates to LUTs name/path will be reflected in the |
A test focusing on the OMERO API call will help in that case |
I think adding tests for the OMERO API (if they don't already exist) is probably outside the scope of this PR. To focus on what needs to be done on this PR:
EDIT: discussed 7th Feb web meeting - "Yes" to both those questions... |
To test the performance of loading 8 LUTs from the server, compare response times for NB: we always use |
Tested on merge-ci by alternatively running these 2 commands in the webclient Devtools Console, then checking the response times in the Network tab:
The To err on the side of safety, I suggest:
This is actually the current behaviour. So if this sounds good, I can update the README to explain this workflow then we should be good to go? |
I'll add the "new" LUTs into the static file now... |
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.
This PR tries to fix the LUT retrieval in two separate deployments configuration:
- if no OMERO.web cache backend is configured (via
omero.web.caches
), the implementation will always load the static JSON file and return a preview which might include white gaps if additional LUTs are present server-side unlessnew=true
is passed. This is consistent with my expectation i.e. the implementation should avoid reloading additional LUTs for every single request to the endpoint - if an OMERO.web cache backend is configured e.g. Redis
- if a cache entry with a key hashed from the list of LUTs exists and
cached=False
is not set, it is returned as a response - otherwise, as above the static JSON file is read and used to generate a preview image. White gaps might be present if there are more LUTs server-side than in the static JSON and
new=true
is not passed - the preview image is then stored in the cache
- if a cache entry with a key hashed from the list of LUTs exists and
My primary issue is associated with the second scenario and the impact of the double cache and the issues associated with troubleshooting and invalidating such a cache. One example of complex scenario:
- LUTs are added server-side e.g. via a new OMERO.server release
- OMERO.web is either not yet released or not deployed with an matching LUTs JSON file
- the first call to the LUT preview endpoint finds no cache associated with the new hash. The implementation regenerates a preview image including white gaps and stored in the cache
- every subsequent call to the endpoint will read the cached preview image with white gaps even if OMERO.web is upgraded with a new JSON including the new LUTs
- the only way to fix this situation would be to invalidate the cache
Is there a way to detect such a scenario and force the LUT loading as a one-off?
In general, the docstrings should be updated to describe the new logic has changed. The README addition is useful but as this is documenting an occasional workflow including possibly server-side change, I think it would be more relevant under https://omero.readthedocs.io/en/stable/.
omeroweb/webgateway/views.py
Outdated
if pathname in luts_by_pathname: | ||
lut_rgb = luts_by_pathname[pathname].get("rgb") | ||
new_img[(i * 10) : ((i + 1) * 10), :, :3] = lut_rgb | ||
elif request.GET.get("new") == "true": |
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.
I am unclear on the distinction of the cached
and new
query parameters. In particular, I would expect that calling cached=false
would also new=true
. Is there a scenario where we would like to have different combinations?
@sbesson If the I also think you're right about So, the
|
Issues that need addressing:
Proposed solution:
webgateway/static/json/luts.json
as the source for LUTs to build the dynamic/webgateway/luts_png/
(the/webgateway/luts_png/
still corresponds to the dynamic/luts/
JSON that comes from the server. Any LUTs from the server that are not in the staticluts.json
will be shown as white in/webgateway/luts_png/
./webgateway/luts/rgb=true
then the JSON produced will include thergb
values for each LUT. This uses the staticluts.json
, but if there are new LUTs coming from the server (NOT in theluts.json
) then we load those LUT files from the server.luts.json
is to simply take the JSON output from/webgateway/luts/rgb=true
and save it intowebgateway/static/json/luts.json
.NB: The static
luts.json
in this PR doesn't yet have the "new" LUTs recently added. This enables us to test a few things. Then, we can update theluts.json
with recent LUTs before merging this PR...To test:
/webgateway/luts/
- this will be unchanged from before. Compare to/webgateway/luts/?rgb=true
which hasrgb
for every LUT - each is an array of shape(256, 3)
. The recently added LUTs that are not yet in the staticluts.json
(e.g.cividis.lut
) are being generated on the fly from the server./webgateway/luts_png/
. This is now being generated from the rgb values in the staticluts.json
, instead of loading LUT files from the server. This is very fast, so caching functionality is no-longer needed (has been removed). You will see white gaps for LUTs that are not yet cached in the staticluts.json
. ]luts.json