From af3d511d3d53bb377def40fbb9d7df2faad49bc8 Mon Sep 17 00:00:00 2001 From: William Moore Date: Sat, 24 Feb 2024 22:51:49 +0000 Subject: [PATCH] Don't lookup resolution levels for small images --- omeroweb/webgateway/marshal.py | 38 ++++++++++++++++++++-------------- omeroweb/webgateway/util.py | 6 +++--- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/omeroweb/webgateway/marshal.py b/omeroweb/webgateway/marshal.py index b341c827f3..6384746e2b 100644 --- a/omeroweb/webgateway/marshal.py +++ b/omeroweb/webgateway/marshal.py @@ -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: diff --git a/omeroweb/webgateway/util.py b/omeroweb/webgateway/util.py index 5151b23c3d..291b89be58 100644 --- a/omeroweb/webgateway/util.py +++ b/omeroweb/webgateway/util.py @@ -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