Skip to content

Commit b109470

Browse files
authored
Merge pull request #975 from hubmapconsortium/nickakhmetov/cat-1445-mark-image-pyramid-descendants-as-having-vis
NickAkhmetov/CAT-1445 Mark image pyramid descendants as having visualization (not just the parent)
2 parents 66bd6fa + 86bddef commit b109470

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/hubmap_translation/addl_index_transformations/portal/add_assay_details.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ def _add_pipeline(doc, assay_details):
142142
doc['pipeline'] = pipeline.group()
143143

144144

145+
def _set_soft_assaytype(doc, assay_details):
146+
if soft_assaytype := assay_details.get('assaytype'):
147+
doc['soft_assaytype'] = soft_assaytype
148+
doc['assay_display_name'] = [assay_details.get('description')]
149+
# Remove once the portal-ui has transitioned to use assay_display_name.
150+
doc['mapped_data_types'] = [assay_details.get('description')]
151+
doc['vitessce-hints'] = assay_details.get('vitessce-hints')
152+
153+
145154
def add_assay_details(doc, transformation_resources):
146155
if 'dataset_type' in doc:
147156
assay_details = _get_assay_details(doc, transformation_resources)
@@ -151,14 +160,7 @@ def add_assay_details(doc, transformation_resources):
151160

152161
_add_dataset_categories(doc, assay_details)
153162
_add_pipeline(doc, assay_details)
154-
155-
if soft_assaytype := assay_details.get('assaytype'):
156-
doc['soft_assaytype'] = soft_assaytype
157-
# Preserve the previous shape of mapped_data_types.
158-
doc['assay_display_name'] = [assay_details.get('description')]
159-
# Remove once the portal-ui has transitioned to use assay_display_name.
160-
doc['mapped_data_types'] = [assay_details.get('description')]
161-
doc['vitessce-hints'] = assay_details.get('vitessce-hints')
163+
_set_soft_assaytype(doc, assay_details)
162164

163165
error_msg = assay_details.get('error')
164166
if error_msg:
@@ -167,6 +169,10 @@ def add_assay_details(doc, transformation_resources):
167169
def get_assay_type_for_viz(doc):
168170
return assay_details
169171

172+
# Check if the doc's 'visualization' is already set to True
173+
if doc.get('visualization') is True:
174+
return
175+
170176
# Check if the main entity can be visualized by portal-visualization.
171177
has_viz = has_visualization(doc, get_assay_type_for_viz)
172178
doc['visualization'] = has_viz
@@ -195,9 +201,8 @@ def get_assay_type_for_descendants(descendant):
195201
for descendant in descendants:
196202
soft_assay_info = get_assay_type_for_descendants(descendant)
197203

198-
descendant['soft_assaytype'] = soft_assay_info.get('assaytype')
199-
descendant['vitessce-hints'] = soft_assay_info.get('vitessce-hints', [])
204+
_set_soft_assaytype(descendant, soft_assay_info)
200205

201206
if has_visualization(descendant, get_assay_type_for_descendants, parent_uuid):
202207
doc['visualization'] = True
203-
break
208+
descendant['visualization'] = True

src/hubmap_translation/addl_index_transformations/portal/tests/test_assay_details.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,15 @@ def test_transform_image_pyramid_parent(mocker):
212212
mock_image_pyramid_parent(),
213213
# request to get descendants of parent entity
214214
mock_image_pyramid_descendants(),
215-
# request to get assay details of descendant entity
215+
# request to get assay details of first descendant (uuid ending in 4919)
216216
mock_image_pyramid_support(),
217217
# portal-visualization re-requests parent entity details
218218
# to determine which type of image pyramid it is
219219
mock_image_pyramid_parent(),
220+
# request to get assay details of second descendant (uuid ending in 4918)
221+
mock_image_pyramid_support(),
222+
# portal-visualization re-requests parent entity details again
223+
mock_image_pyramid_parent(),
220224
])
221225
image_pyramid_input_doc = {
222226
'uuid': '69c70762689b20308bb049ac49653342',

0 commit comments

Comments
 (0)