Skip to content

Commit

Permalink
Merge pull request ome#281 from cneves/feature/export_dryrun
Browse files Browse the repository at this point in the history
improve gateway image export
  • Loading branch information
joshmoore committed Aug 14, 2012
2 parents 41a0acc + 2c450e1 commit bae84d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions components/tools/OmeroPy/src/omero/gateway/__init__.py
Expand Up @@ -6059,6 +6059,13 @@ def getPixelRange (self):
else:
return (0, pmax-1)

@assert_pixels
def requiresPixelsPyramid (self):
pixels_id = self._obj.getPrimaryPixels().getId().val
rp = self._conn.createRawPixelsStore()
rp.setPixelsId(pixels_id, True, self._conn.SERVICE_OPTS)
return rp.requiresPixelsPyramid()

@assert_pixels
def getPrimaryPixels (self):
"""
Expand Down
16 changes: 16 additions & 0 deletions components/tools/OmeroWeb/omeroweb/webgateway/views.py
Expand Up @@ -810,12 +810,17 @@ def render_ome_tiff (request, ctx, cid, conn=None, **kwargs):
"""
Renders the OME-TIFF representation of the image(s) with id cid in ctx (i)mage,
(d)ataset, or (p)roject.
For multiple images export, images that require pixels pyramid (big images) will be silently skipped.
If exporting a single big image or if all images in a multple image export are big,
a 404 will be triggered.
A request parameter dryrun can be passed to return the count of images that would actually be exported.
@param request: http request
@param ctx: 'p' or 'd' or 'i'
@param cid: Project, Dataset or Image ID
@param conn: L{omero.gateway.BlitzGateway} connection
@return: http response wrapping the tiff (or zip for multiple files), or redirect to temp file/zip
if dryrun is True, returns count of images that would be exported
"""
server_id = request.session['connector'].server_id
imgs = []
Expand Down Expand Up @@ -854,6 +859,17 @@ def render_ome_tiff (request, ctx, cid, conn=None, **kwargs):
raise Http404
imgs.append(obj)

imgs = filter(lambda x: not x.requiresPixelsPyramid(), imgs)

if request.REQUEST.get('dryrun', False):
rv = simplejson.dumps(len(imgs))
c = request.REQUEST.get('callback', None)
if c is not None and not kwargs.get('_internal', False):
rv = '%s(%s)' % (c, rv)
return HttpResponse(rv, mimetype='application/javascript')

if len(imgs) == 0:
raise Http404
if len(imgs) == 1:
obj = imgs[0]
key = '_'.join((str(x.getId()) for x in obj.getAncestry())) + '_' + str(obj.getId()) + '_ome_tiff'
Expand Down

0 comments on commit bae84d0

Please sign in to comment.