Skip to content

Commit

Permalink
Merge pull request #1576 from girder/flat-mount
Browse files Browse the repository at this point in the history
Use flat mount paths where possible.
  • Loading branch information
manthey authored Jul 15, 2024
2 parents 9f0fa4a + f049329 commit f58e07c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Improvements

- Improve plottable data endpoint to better fetch adjacent items and annotations ([#1573](../../pull/1573), [#1574](../../pull/1574))), [#1575](../../pull/1575)))
- Support Girder flat-mount paths ([#1576](../../pull/1576))

## 1.29.2

Expand Down
22 changes: 22 additions & 0 deletions girder/girder_large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,26 @@ def unbindGirderEventsByHandlerName(handlerName):
events.unbind(eventName, handlerName)


def patchMount():
try:
import girder.cli.mount

def _flatItemFile(self, item):
return next(File().collection.aggregate([
{'$match': {'itemId': item['_id']}},
] + ([
{'$addFields': {'matchLI': {'$eq': ['$_id', item['largeImage']['fileId']]}}},
] if 'largeImage' in item and 'expected' not in item['largeImage'] else []) + [
{'$addFields': {'matchName': {'$eq': ['$name', item['name']]}}},
{'$sort': {'matchLI': -1, 'matchName': -1, '_id': 1}},
{'$limit': 1},
]), None)

girder.cli.mount.ServerFuse._flatItemFile = _flatItemFile
except Exception:
pass


class LargeImagePlugin(GirderPlugin):
DISPLAY_NAME = 'Large Image'
CLIENT_SOURCE_PATH = 'web_client'
Expand Down Expand Up @@ -727,3 +747,5 @@ def load(self, info):

search._allowedSearchMode.pop('li_metadata', None)
search.addSearchMode('li_metadata', metadataSearchHandler)

patchMount()
6 changes: 5 additions & 1 deletion girder/girder_large_image/girder_tilesource.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import os
import re

Expand Down Expand Up @@ -99,7 +100,10 @@ def _getLargeImagePath(self):
pass
if not largeImagePath:
try:
largeImagePath = File().getGirderMountFilePath(largeImageFile)
largeImagePath = File().getGirderMountFilePath(
largeImageFile,
**({'preferFlat': True} if 'preferFlat' in inspect.signature(
File.getGirderMountFilePath).parameters else {}))
except FilePathException:
pass
if not largeImagePath:
Expand Down
6 changes: 5 additions & 1 deletion utilities/tasks/large_image_tasks/tasks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import logging
import os
import shutil
Expand Down Expand Up @@ -128,7 +129,10 @@ def convert_image_job(job):
inputPath = None
if not fileObj.get('imported'):
try:
inputPath = File().getGirderMountFilePath(fileObj)
inputPath = File().getGirderMountFilePath(
fileObj,
**({'preferFlat': True} if 'preferFlat' in inspect.signature(
File.getGirderMountFilePath).parameters else {}))
except Exception:
pass
inputPath = inputPath or File().getLocalFilePath(fileObj)
Expand Down

0 comments on commit f58e07c

Please sign in to comment.