Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dataset Activity.creation_action to ENTITY.Dataset as creation_action_activity #574

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions entity-api-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ components:
dbgap_study_url:
type: string
description: 'A URL linking the dataset to the particular study on dbGap it belongs to'
creation_action:
type: string
description: 'The associated action that represents the creation of that dataset'
Upload:
type: object
properties:
Expand Down
4 changes: 4 additions & 0 deletions src/instance/app.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ UUID_API_URL = 'http://uuid-api:8080'
# Works regardless of the trailing slash
INGEST_API_URL = 'https://ingest-api.dev.hubmapconsortium.org'

# URL for talking to Ontology API (default for DEV)
# Works regardless of the trailing slash
ONTOLOGY_API_URL = 'https://ontology-api.dev.hubmapconsortium.org'
yuanzhou marked this conversation as resolved.
Show resolved Hide resolved

# A list of URLs for talking to multiple Search API instances (default value used for docker deployment, no token needed)
# Works regardless of the trailing slash /
SEARCH_API_URL_LIST = ['http://search-api:8080']
Expand Down
1 change: 1 addition & 0 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions src/schema/schema_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def load_provenance_schema(valid_yaml_file):
with open(valid_yaml_file) as file:
schema_dict = yaml.safe_load(file)

logger.info("Schema yaml file loaded successfully")
logger.info(f"Provenance Schema yaml file loaded successfully from {valid_yaml_file} :)")

return schema_dict

Expand Down Expand Up @@ -1794,4 +1794,4 @@ def _create_request_headers(user_token):
auth_header_name: auth_scheme + ' ' + user_token
}

return headers_dict
return headers_dict
14 changes: 14 additions & 0 deletions src/schema/schema_neo4j_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,20 @@ def get_entity_type(neo4j_driver, entity_uuid: str) -> str:
return None


def get_entity_creation_action_activity(neo4j_driver, entity_uuid: str) -> str:
query: str = f"MATCH (ds {{uuid:'{entity_uuid}'}})<-[:ACTIVITY_OUTPUT]-(a:Activity) RETURN a.creation_action"

logger.info("======get_entity_creation_action() query======")
logger.info(query)

with neo4j_driver.session() as session:
record = session.read_transaction(execute_readonly_tx, query)
if record and len(record) == 1:
return record[0]

return None


"""
Create or recreate one or more linkages (via Activity nodes)
between the target entity node and the direct ancestor nodes in neo4j
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