@@ -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+
145154def 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
0 commit comments