Skip to content

Commit

Permalink
Add Dataset Activity.creation_action to ENTITY.Dataset as creation_ac…
Browse files Browse the repository at this point in the history
…tion_activity
  • Loading branch information
ChuckKollar committed Nov 28, 2023
1 parent cddb990 commit a111808
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
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_activity:
type: string
description: 'The associated action that represents the creation of that dataset'
Upload:
type: object
properties:
Expand Down
6 changes: 6 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4669,6 +4669,12 @@ 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
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'

# 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
4 changes: 4 additions & 0 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ ENTITIES:
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
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

0 comments on commit a111808

Please sign in to comment.