Skip to content

Commit 8188a0c

Browse files
committed
Add docs.
1 parent 0bc9fa7 commit 8188a0c

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

README.rst

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,29 @@ Development
4848

4949
The most convenient way to develop on HistomicsUI is to use the `devops scripts from the Digital Slide Archive <https://github.com/DigitalSlideArchive/digital_slide_archive/tree/master/devops>`_.
5050

51+
Annotations and Metadata from Jobs
52+
----------------------------------
53+
54+
This handles ingesting annotations and metadata that are uploaded and associating them with existing large image items in the Girder database. These annotations and metadata re commonly generated through jobs, such as HistomicTK tasks, but can also be added manually.
55+
56+
If a file is uploaded to the Girder system that includes a ``reference`` record, and that ``reference`` record contains an ``identifier`` field and a ``fileId`` field, specific identifiers can be used to ingest the results. If a ``userId`` is specified in the ``reference`` record, permissions for adding the annotation or metadata are associated with that user.
57+
58+
Metadata
59+
========
60+
61+
Identifiers ending in ``ItemMetadata`` are loaded and then set as metadata on the associated item that contains the specified file. Conceptually, this is the same as calling the ``PUT`` ``item/{id}/metadata`` endpoint.
62+
63+
Annotations
64+
===========
65+
66+
Identifiers ending in ``AnnotationFile`` are loaded as annotations, associated with the item that contains the specified file. Conceptually, this is the same as uploaded the file via the annotation endpoints for the item associated with the specified ``fileId``.
67+
68+
If the annotation file contains any annotations with elements that contain ``girderId`` values, the ``girderId`` values can be ``identifier`` values from files that were uploaded with a ``reference`` record that contains a matching ``uuid`` field. The ``uuid`` field is required for this, but is treated as an arbitrary string.
69+
70+
5171
Funding
5272
-------
53-
This work is funded in part by the NIH grant U24-CA194362-01_.
73+
This work was funded in part by the NIH grant U24-CA194362-01_.
5474

5575
.. _HistomicsUI: https://github.com/DigitalSlideArchive/HistomicsUI
5676
.. _Docker: https://www.docker.com/

histomicsui/handlers.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,29 @@ def _itemFromEvent(event, identifierEnding, itemAccessLevel=AccessType.READ):
5959
return {'item': item, 'user': user, 'file': image, 'uuid': reference.get('uuid')}
6060

6161

62-
def resolveAnnotationGirderIds(event, results, data, girderIds):
62+
def resolveAnnotationGirderIds(event, results, data, possibleGirderIds):
6363
"""
6464
If an annotation has references to girderIds, resolve them to actual ids.
6565
6666
:param event: a data.process event.
6767
:param results: the results from _itemFromEvent,
6868
:param data: annotation data.
69-
:param girderIds: a list of annotation elements with girderIds needing
70-
resolution.
69+
:param possibleGirderIds: a list of annotation elements with girderIds
70+
needing resolution.
7171
:returns: True if all ids were processed.
7272
"""
73+
# Exclude actual girderIds from resolution
74+
girderIds = []
75+
for element in possibleGirderIds:
76+
# This will throw an exception if the girderId isn't well-formed as an
77+
# actual id.
78+
try:
79+
if Item().load(element['girderId'], level=AccessType.READ, force=True) is None:
80+
girderIds.append(element)
81+
except Exception:
82+
girderIds.append(element)
83+
if not len(girderIds):
84+
return True
7385
idRecord = _recentIdentifiers.get(results.get('uuid'))
7486
if idRecord and not all(element['girderId'] in idRecord for element in girderIds):
7587
idRecord['_reprocess'] = lambda: process_annotations(event)

0 commit comments

Comments
 (0)