Skip to content

Commit

Permalink
Adding as a transient property for activities to support updating pro…
Browse files Browse the repository at this point in the history
…cessing_information via a PUT
  • Loading branch information
maxsibilla committed Oct 3, 2023
1 parent 28df7dd commit d79929a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,12 +1327,12 @@ def update_entity(id):
# Get target entity and return as a dict if exists
entity_dict = query_target_entity(id, user_token)

json_data_dict = check_for_metadata(entity_dict.get('entity_type'), user_token)
verify_ubkg_properties(json_data_dict)

# Normalize user provided entity_type
normalized_entity_type = schema_manager.normalize_entity_type(entity_dict['entity_type'])

json_data_dict = check_for_metadata(normalized_entity_type, user_token)
verify_ubkg_properties(json_data_dict)

# Note, we don't support entity level validators on entity update via PUT
# Only entity create via POST is supported at the entity level

Expand Down Expand Up @@ -1389,7 +1389,7 @@ def update_entity(id):
# Generate 'before_update_trigger' data and update the entity details in Neo4j
merged_updated_dict = update_object_details('ENTITIES', request, normalized_entity_type, user_token, json_data_dict, entity_dict)

# Handle linkages update via `after_update_trigger` methods
# Handle linkages update via `after_update_trigger` methods
if has_direct_ancestor_uuids:
after_update(normalized_entity_type, user_token, merged_updated_dict)
elif normalized_entity_type == 'Upload':
Expand Down
6 changes: 6 additions & 0 deletions src/schema/provenance_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ ACTIVITIES:
description: "The information describing how this dataset was processed (e.g. the DAG provenance list describing the various tools used during an ingest-pipeline run to generate a derived dataset)"
before_create_trigger: set_processing_information
before_update_trigger: set_processing_information
# Allows us to set processing_information when metadata is passed in the payload
metadata:
type: json_string # dict
description: "The metadata returned from the processing at data submission time."
transient: true
before_update_trigger: set_processing_information
#TODO: We will possibly create additional activity types with different attributes

####################################################################################################
Expand Down
3 changes: 2 additions & 1 deletion src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,8 @@ def set_processing_information(property_key, normalized_type, user_token, existi
metadata_to_return = {}
metadata = schema_manager.convert_str_to_data(new_data_dict['metadata'])
metadata_to_return['dag_provenance_list'] = metadata['dag_provenance_list']
return property_key, metadata_to_return
# Need to hard set `processing_information` as this gets called when `metadata` is passed in the payload
return 'processing_information', metadata_to_return
except requests.exceptions.RequestException as e:
raise requests.exceptions.RequestException(e)

Expand Down

0 comments on commit d79929a

Please sign in to comment.