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

Image loading error handling #474

Merged
merged 4 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,10 @@ thumbnail-slider img {
overflow-y: hidden;
}

.modal-dialog pre {
max-height: 200px;
}

.text-weight-bold {
font-weight: 700;
}
Expand Down
11 changes: 6 additions & 5 deletions plugin/omero_iviewer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from os.path import splitext
from collections import defaultdict
from struct import unpack
import traceback

from omeroweb.api.api_settings import API_MAX_LIMIT
from omeroweb.decorators import login_required
Expand Down Expand Up @@ -498,19 +499,19 @@ def image_data(request, image_id, conn=None, **kwargs):
# Add extra parameters with units data
# Note ['pixel_size']['x'] will have size in MICROMETER
px = image.getPrimaryPixels().getPhysicalSizeX()
if (px is not None):
if (px is not None and 'pixel_size' in rv):
size = image.getPixelSizeX(True)
value = format_pixel_size_with_units(size)
rv['pixel_size']['unit_x'] = value[0]
rv['pixel_size']['symbol_x'] = value[1]
py = image.getPrimaryPixels().getPhysicalSizeY()
if (py is not None):
if (py is not None and 'pixel_size' in rv):
size = image.getPixelSizeY(True)
value = format_pixel_size_with_units(size)
rv['pixel_size']['unit_y'] = value[0]
rv['pixel_size']['symbol_y'] = value[1]
pz = image.getPrimaryPixels().getPhysicalSizeZ()
if (pz is not None):
if (pz is not None and 'pixel_size' in rv):
size = image.getPixelSizeZ(True)
value = format_pixel_size_with_units(size)
rv['pixel_size']['unit_z'] = value[0]
Expand All @@ -530,8 +531,8 @@ def image_data(request, image_id, conn=None, **kwargs):
rv['families'].append(fam.getValue())

return JsonResponse(rv)
except Exception as image_data_retrieval_exception:
return JsonResponse({'error': repr(image_data_retrieval_exception)})
except Exception:
return JsonResponse({'error': traceback.format_exc()})


@login_required()
Expand Down
41 changes: 41 additions & 0 deletions src/model/image_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import {noView} from 'aurelia-framework';
import Misc from '../utils/misc';
import Ui from '../utils/ui';
var escapeHtml = require('escape-html')
import {
APP_TITLE, CHANNEL_SETTINGS_MODE, INITIAL_TYPES, IVIEWER,
PROJECTION, REQUEST_PARAMS, WEBCLIENT, WEBGATEWAY
Expand Down Expand Up @@ -318,6 +319,13 @@ export default class ImageInfo {
this.image_id = response.id;
}

// validate response
// check for Exceptions and show error dialog.
const valid = this.validateImageInfo(response);
if (!valid) {
return;
}

// read initial request params
this.initializeImageInfo(response, refresh);
// check for a parent id (if not well)
Expand Down Expand Up @@ -360,6 +368,39 @@ export default class ImageInfo {
});
}

/**
* Checks that the imgData JSON response is valid, no exceptions etc.
*
* @private
* @param {Object} response the response object
* @memberof ImageInfo
* @return {Boolean} True if data is valid. Also shows dialogs with errors
*/
validateImageInfo(response) {

if (response.ConcurrencyException) {
Ui.showModalMessage(`<p>Image is not currently viewable</p>
<pre>ConcurrencyException</pre>
<small>A pyramid of zoom levels is not available. Generation may be in progress if this is enabled on your server.</small>`, "OK");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<small>A pyramid of zoom levels is not available. Generation may be in progress if this is enabled on your server.</small>`, "OK");
<small>A pyramid of zoom levels is not available. Please contact your administrator, see https://omero.readthedocs.io/en/stable/sysadmins/limitations.html#large-images.</small>`, "OK");

I realize this ^^^ is not ideal suggestion, but I am against making of false hopes - as we do not recommend pyramid generation to be enabled, we should not assume (as the present comment does) that "waiting it out" is a good/default option.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a side track... but those docs don't describe how to enable/disable pyramid generation. Do we have install docs that recommend and describe how to disable pyramid generation? This is likely to have an effect on how likely it is for a particular server to have pyramids disabled, since the default is still to be enabled, right?
Also those docs should mention https://www.glencoesoftware.com/products/ngff-converter/ .

Unfortunately it's not possible for a client to know if pyramids are disabled, since this gives a SecurityViolation:

conn.getConfigService().getConfigValue("omero.server.nodedescriptor")

How about.
"A pyramid of zoom levels is not available. Please contact your administrator if this does not resolve itself. See Limitations: Large Images"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property is actually "omero.server.nodedescriptors" and has been made user-visible since OMERO 5.6.6. Older versions of the server will definitely throw a SecurityViolation.

Note this is not necessarily the only way to disable the PixelData service e.g. you might have modified your templates manually but I think this is by far the option that is the most usable from an API perspective and the documentation should mostly likely document this workflow if any.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbesson Thanks for catching my typo!
When connected to nightshade I get:

>>> conn.getConfigService().getConfigValue("omero.server.nodedescriptors")
''

Which would indicate that pyramid generation is enabled there?
For outreach server I get

'master:Blitz-0,Indexer-0,Processor-0,Storm,Tables-0'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty value (default) means all services are enabled via configuration - see https://omero.readthedocs.io/en/stable/sysadmins/config.html#omero-server-nodedescriptors

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Since clients can access this, I'll load it from iviewer so we can show a more useful error message for ConcurrencyException. It probably makes sense that we do something similar in webclient too, but most useful would be the Importer, since you need to know at import time if you're importing a Big Image without pyramids.

return false;
}

if (response.error || response.Exception) {
const msg = response.error || response.Exception;
Ui.showModalMessage(`<p>Error loading Image data</p>
<pre>${escapeHtml(msg)}</pre>`, "OK");
return false;
}

if (response.channels == undefined || response.channels.length === 0) {
Ui.showModalMessage(`<p>No channel data loaded</p>
<pre>${escapeHtml(JSON.stringify(response, null, 4))}</pre>`, "OK");
return false;
}

return true;
}

/**
* Takes the response object and assigns the bits and pieces needed
* to the members
Expand Down