From 56aa6dbc8e7eef8584d0c614891e3a97e101d3ed Mon Sep 17 00:00:00 2001 From: DerekFurstPitt Date: Thu, 4 Apr 2024 15:54:24 -0400 Subject: [PATCH 1/2] Added internal trigger header so that the validator for updating datasets can be bypassed for component datasets when their update is subsequent to an update of their parent multi-assay split dataset --- src/schema/schema_constants.py | 2 ++ src/schema/schema_triggers.py | 1 + src/schema/schema_validators.py | 16 +++++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/schema/schema_constants.py b/src/schema/schema_constants.py index 7aa41151..afe9d55f 100644 --- a/src/schema/schema_constants.py +++ b/src/schema/schema_constants.py @@ -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' diff --git a/src/schema/schema_triggers.py b/src/schema/schema_triggers.py index ae5bb117..3091b081 100644 --- a/src/schema/schema_triggers.py +++ b/src/schema/schema_triggers.py @@ -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) diff --git a/src/schema/schema_validators.py b/src/schema/schema_validators.py index f78732f7..9fceb663 100644 --- a/src/schema/schema_validators.py +++ b/src/schema/schema_validators.py @@ -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") """ From 45f0b8df7a72b7fc53fe6fa3cc1d22dd265d0125 Mon Sep 17 00:00:00 2001 From: DerekFurstPitt Date: Thu, 4 Apr 2024 16:03:03 -0400 Subject: [PATCH 2/2] Changed entity_api_url in example config and added more descriptive text --- src/instance/app.cfg.example | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/instance/app.cfg.example b/src/instance/app.cfg.example index f3c1fc0e..cab2a1fc 100644 --- a/src/instance/app.cfg.example +++ b/src/instance/app.cfg.example @@ -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 /