Skip to content

Commit 11472ed

Browse files
authored
Merge pull request #692 from hubmapconsortium/Derek-Furst/provenance-skip
Derek furst/provenance skip
2 parents 1eaec14 + f18cb5e commit 11472ed

File tree

2 files changed

+2
-35
lines changed

2 files changed

+2
-35
lines changed

src/app.py

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -769,42 +769,9 @@ def get_entity_provenance(id):
769769
# Normalize the raw provenance nodes based on the yaml schema
770770
normalized_provenance_dict = {
771771
'relationships': raw_provenance_dict['relationships'],
772-
'nodes': []
772+
'nodes': raw_provenance_dict['nodes']
773773
}
774774

775-
for node_dict in raw_provenance_dict['nodes']:
776-
# The schema yaml doesn't handle Lab nodes, just leave it as is
777-
if (node_dict['label'] == 'Entity') and (node_dict['entity_type'] != 'Lab'):
778-
# Generate trigger data
779-
# Skip some of the properties that are time-consuming to generate via triggers:
780-
# director_ancestor for Sample, and direct_ancestors for Dataset
781-
# Also skip next_revision_uuid and previous_revision_uuid for Dataset to avoid additional
782-
# checks when the target Dataset is public but the revisions are not public
783-
properties_to_skip = [
784-
'direct_ancestors',
785-
'direct_ancestor',
786-
'next_revision_uuid',
787-
'previous_revision_uuid'
788-
]
789-
790-
# We'll need to return all the properties (except the ones to skip from above list)
791-
# including those generated by `on_read_trigger` to have a complete result
792-
# The 'on_read_trigger' doesn't really need a token
793-
complete_entity_dict = schema_manager.get_complete_entity_result(token, node_dict, properties_to_skip)
794-
795-
# Filter out properties not defined or not to be exposed in the schema yaml
796-
normalized_entity_dict = schema_manager.normalize_entity_result_for_response(complete_entity_dict)
797-
798-
# Now the node to be used by provenance is all regulated by the schema
799-
normalized_provenance_dict['nodes'].append(normalized_entity_dict)
800-
elif node_dict['label'] == 'Activity':
801-
# Normalize Activity nodes too
802-
normalized_activity_dict = schema_manager.normalize_activity_result_for_response(node_dict)
803-
normalized_provenance_dict['nodes'].append(normalized_activity_dict)
804-
else:
805-
# Skip Entity Lab nodes
806-
normalized_provenance_dict['nodes'].append(node_dict)
807-
808775
provenance_json = provenance.get_provenance_history(uuid, normalized_provenance_dict, auth_helper_instance)
809776

810777
# Response with the provenance details

src/app_neo4j_queries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def get_provenance(neo4j_driver, uuid, depth):
577577
# More info on apoc.path.subgraphAll() procedure: https://neo4j.com/labs/apoc/4.0/graph-querying/expand-subgraph/
578578
query = (f"MATCH (n:Entity) "
579579
f"WHERE n.uuid = '{uuid}' "
580-
f"CALL apoc.path.subgraphAll(n, {{ {max_level_str} relationshipFilter:'<ACTIVITY_INPUT|<ACTIVITY_OUTPUT' }}) "
580+
f"CALL apoc.path.subgraphAll(n, {{ {max_level_str} relationshipFilter:'<ACTIVITY_INPUT|<ACTIVITY_OUTPUT', labelFilter:'-Lab' }}) "
581581
f"YIELD nodes, relationships "
582582
f"WITH [node in nodes | node {{ .*, label:labels(node)[0] }} ] as nodes, "
583583
f"[rel in relationships | rel {{ .*, fromNode: {{ label:labels(startNode(rel))[0], uuid:startNode(rel).uuid }}, toNode: {{ label:labels(endNode(rel))[0], uuid:endNode(rel).uuid }}, rel_data: {{ type: type(rel) }} }} ] as rels "

0 commit comments

Comments
 (0)