Skip to content

Commit

Permalink
Moved creation_action to an on_read_trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckKollar committed Nov 29, 2023
1 parent a111808 commit 1dd0999
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion entity-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ components:
dbgap_study_url:
type: string
description: 'A URL linking the dataset to the particular study on dbGap it belongs to'
creation_action_activity:
creation_action:
type: string
description: 'The associated action that represents the creation of that dataset'
Upload:
Expand Down
6 changes: 0 additions & 6 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4669,12 +4669,6 @@ def query_target_entity(id, user_token):

# Make a new query against neo4j
entity_dict = schema_neo4j_queries.get_entity(neo4j_driver_instance, uuid)
# entity_type is found in shared_entity_properties in provenance_schema.yaml
if entity_dict.get('entity_type') == 'Dataset':
# Entities.Dataset already has a creation_action property which is processed in a different manner
# see provenance_schema.yaml and code in this file.
entity_dict['creation_action_activity'] =\
schema_neo4j_queries.get_entity_creation_action_activity(neo4j_driver_instance, uuid)

# The uuid exists via uuid-api doesn't mean it also exists in Neo4j
if not entity_dict:
Expand Down
5 changes: 1 addition & 4 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,10 @@ ENTITIES:
type: string
transient: true
immutable: true
on_read_trigger: get_creation_action_activity
description: "The activity that was performed."
before_property_create_validators:
- validate_creation_action
creation_action_activity:
type: string
transient: true
description: "The creation action associated with the output activity of the dataset"
description:
type: string
description: "Free text description of the dataset"
Expand Down
14 changes: 14 additions & 0 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,20 @@ def get_next_revision_uuid(property_key, normalized_type, user_token, existing_d
return property_key, next_revision_uuid


def get_creation_action_activity(property_key, normalized_type, user_token, existing_data_dict, new_data_dict):
if 'uuid' not in existing_data_dict:
raise KeyError("Missing 'uuid' key in 'existing_data_dict' during calling 'get_creation_action_activity()' trigger method.")

uuid: str = existing_data_dict['uuid']
logger.info(f"Executing 'get_creation_action_activity()' trigger method on uuid: {uuid}")

neo4j_driver_instance = schema_manager.get_neo4j_driver_instance()
creation_action_activity =\
schema_neo4j_queries.get_entity_creation_action_activity(neo4j_driver_instance, uuid)

return property_key, creation_action_activity


"""
Trigger event method to commit thumbnail file saved that were previously uploaded via ingest-api
Expand Down

0 comments on commit 1dd0999

Please sign in to comment.