Skip to content

Commit

Permalink
Don't lookup resolution levels for small images
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Feb 25, 2024
1 parent 0305cf7 commit af3d511
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
38 changes: 22 additions & 16 deletions omeroweb/webgateway/marshal.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,22 +351,28 @@ def pixel_size_in_microns(method):
rv = None
raise

# big images
if load_re(image, rv):
levels = image._re.getResolutionLevels()
tiles = levels > 1
rv["tiles"] = tiles
if tiles:
width, height = image._re.getTileSize()
zoomLevelScaling = image.getZoomLevelScaling()
rv.update(
{"tile_size": {"width": width, "height": height}, "levels": levels}
)
if zoomLevelScaling is not None:
rv["zoomLevelScaling"] = zoomLevelScaling

if init_zoom < 0:
init_zoom = levels + init_zoom
# If image is big - need to load RE to get resolution levels
# NB: some small images like OME-Zarr can have pyramids
# but these will be ignored

# TEMP - for A/B testing only use size test if ID is odd number!
if image.id % 1 == 0 and not image.requiresPixelsPyramid():
rv["tiles"] = False
else:
if load_re(image, rv):
levels = image._re.getResolutionLevels()
tiles = levels > 1
rv["tiles"] = tiles
if tiles:
width, height = image._re.getTileSize()
zoomLevelScaling = image.getZoomLevelScaling()
rv.update(
{"tile_size": {"width": width, "height": height}, "levels": levels}
)
if zoomLevelScaling is not None:
rv["zoomLevelScaling"] = zoomLevelScaling
if init_zoom < 0:
init_zoom = levels + init_zoom
rv["init_zoom"] = init_zoom

if key is not None and rv is not None:
Expand Down
6 changes: 3 additions & 3 deletions omeroweb/webgateway/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ def load_re(image, rsp_dict=None):
try:
reOK = image._prepareRenderingEngine()
if not reOK:
# rsp_dict["Error"] = "Failed to prepare Rendering Engine for imageMarshal"
rsp_dict["Error"] = "Failed to prepare Rendering Engine for imageMarshal"
logger.debug("Failed to prepare Rendering Engine for imageMarshal")
except omero.ConcurrencyException as ce:
backOff = ce.backOff
# rsp_dict["ConcurrencyException"] = {"backOff": backOff}
rsp_dict["ConcurrencyException"] = {"backOff": backOff}
except Exception as ex: # Handle everything else.
# rsp_dict["Exception"] = ex.message
rsp_dict["Exception"] = ex.message
logger.error(traceback.format_exc())
return reOK

Expand Down

0 comments on commit af3d511

Please sign in to comment.