Skip to content

Commit

Permalink
Merge pull request #653 from hubmapconsortium/Derek-Furst/sync-compon…
Browse files Browse the repository at this point in the history
…ent-datasets

Added internal trigger header so that the validator
  • Loading branch information
yuanzhou authored Apr 4, 2024
2 parents 2b34a0f + 45f0b8d commit 06a8a4a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/instance/app.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ INGEST_API_URL = 'https://ingest-api.dev.hubmapconsortium.org'
# Works regardless of the trailing slash
ONTOLOGY_API_URL = 'https://ontology-api.dev.hubmapconsortium.org'

# URL for talking to Entity API (default for DEV)
ENTITY_API_URL = 'https://entity-api.dev.hubmapconsortium.org'
# URL for talking to Entity API (default for Localhost)
# This is the same URL base where entity-api is running. This is useful in places where a call for one entity
# necessitates subsequent calls for other entities.
ENTITY_API_URL = 'http://localhost:5002'

# 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 /
Expand Down
2 changes: 2 additions & 0 deletions src/schema/schema_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ class SchemaConstants(object):
MEMCACHED_TTL = 7200

INGEST_API_APP = 'ingest-api'
COMPONENT_DATASET = 'component-dataset'
INGEST_PIPELINE_APP = 'ingest-pipeline'
HUBMAP_APP_HEADER = 'X-Hubmap-Application'
INTERNAL_TRIGGER = 'X-Internal-Trigger'
DATASET_STATUS_PUBLISHED = 'published'

ACCESS_LEVEL_PUBLIC = 'public'
Expand Down
1 change: 1 addition & 0 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ def sync_component_dataset_status(property_key, normalized_type, user_token, exi
url = schema_manager.get_entity_api_url() + SchemaConstants.ENTITY_API_UPDATE_ENDPOINT + '/' + child_uuid
header = schema_manager._create_request_headers(user_token)
header[SchemaConstants.HUBMAP_APP_HEADER] = SchemaConstants.INGEST_API_APP
header[SchemaConstants.INTERNAL_TRIGGER] = SchemaConstants.COMPONENT_DATASET
response = requests.put(url=url, headers=header, json=status_body)


Expand Down
16 changes: 9 additions & 7 deletions src/schema/schema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,15 @@ def validate_no_duplicates_in_list(property_key, normalized_entity_type, request


def validate_dataset_not_component(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict):
neo4j_driver_instance = schema_manager.get_neo4j_driver_instance()
uuid = existing_data_dict['uuid']
creation_action = schema_neo4j_queries.get_entity_creation_action_activity(neo4j_driver_instance, uuid)
if creation_action == 'Multi-Assay Split':
raise ValueError(f"Unable to modify existing {existing_data_dict['entity_type']}"
f" {existing_data_dict['uuid']}. Can not change status on component datasets directly. Status"
f"change must occur on parent multi-assay split dataset")
headers = request.headers
if not headers.get(SchemaConstants.INTERNAL_TRIGGER) == SchemaConstants.COMPONENT_DATASET:
neo4j_driver_instance = schema_manager.get_neo4j_driver_instance()
uuid = existing_data_dict['uuid']
creation_action = schema_neo4j_queries.get_entity_creation_action_activity(neo4j_driver_instance, uuid)
if creation_action == 'Multi-Assay Split':
raise ValueError(f"Unable to modify existing {existing_data_dict['entity_type']}"
f" {existing_data_dict['uuid']}. Can not change status on component datasets directly. Status"
f"change must occur on parent multi-assay split dataset")


"""
Expand Down

0 comments on commit 06a8a4a

Please sign in to comment.