Skip to content

Commit

Permalink
Add an endpoint to list Girder tile sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Feb 11, 2020
1 parent ddf32e1 commit 89fa015
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Unreleased

### Features
- Added a GET large_image/sources endpoint to list versions of all installed sources

## Version 1.0.2

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Migration from Girder 2 to Girder 3
If you are migrating a Girder 2 instance with Large Image to Girder 3, you need to do a one time database update. Specifically, one of the tile sources' internal name changed.

Access the Girder Mongo database. The command for this in a simple installation is::

mongo girder

Update the tile source name by issuing the Mongo command::
Expand Down
27 changes: 27 additions & 0 deletions girder/girder_large_image/rest/large_image_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import datetime
import json
import psutil
import sys
import time
from six.moves import range

Expand All @@ -38,6 +39,7 @@
from large_image import cache_util

from .. import constants
from .. import girder_tilesource
from ..models.image_item import ImageItem


Expand Down Expand Up @@ -217,6 +219,7 @@ def __init__(self):
self.route('GET', ('cache', ), self.cacheInfo)
self.route('PUT', ('cache', 'clear'), self.cacheClear)
self.route('GET', ('settings',), self.getPublicSettings)
self.route('GET', ('sources',), self.listSources)
self.route('GET', ('thumbnails',), self.countThumbnails)
self.route('PUT', ('thumbnails',), self.createThumbnails)
self.route('DELETE', ('thumbnails',), self.deleteThumbnails)
Expand Down Expand Up @@ -409,3 +412,27 @@ def deleteIncompleteTiles(self, params):
ImageItem().delete(item)
result['removed'] += 1
return result

@describeRoute(
Description('List all Girder tile sources with associated extensions, '
'mime types, and versions. Lower values indicate a '
'higher priority for an extension of mime type with that '
'source.')
)
@access.public
def listSources(self, params):
results = {}
for key, source in girder_tilesource.AvailableGirderTileSources.items():
results[key] = {}
results[key]['extensions'] = {
k if k else 'default': v for k, v in source.extensions.items()}
results[key]['mimeTypes'] = {
k if k else 'default': v for k, v in source.mimeTypes.items()}
for cls in source.__mro__:
try:
if sys.modules[cls.__module__].__version__:
results[key]['version'] = sys.modules[cls.__module__].__version__
break
except Exception:
pass
return results
8 changes: 8 additions & 0 deletions girder/test_girder/test_large_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,11 @@ def testAssociateImageCaching(server, admin, user, fsAssetstore):
resp = server.request(path='/large_image/associated_images', user=admin)
assert utilities.respStatus(resp) == 200
assert resp.json == 0


@pytest.mark.usefixtures('unbindLargeImage')
@pytest.mark.plugin('large_image')
def testListSources(server):
resp = server.request(path='/large_image/sources')
assert resp.json['tiff']['extensions']['tiff'] > 0
assert resp.json['tiff']['version'] is not None

0 comments on commit 89fa015

Please sign in to comment.