Skip to content

Commit

Permalink
Merge pull request #478 from sennetconsortium/maxsibilla/fix-sources-…
Browse files Browse the repository at this point in the history
…test

Modifying get_sources_associated_entity to handle the casting of embe…
  • Loading branch information
maxsibilla authored Sep 25, 2024
2 parents b00bf3e + a4a14e9 commit 4ccee32
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/schema/schema_neo4j_queries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ast

from neo4j.exceptions import TransactionError
import logging

Expand Down Expand Up @@ -2142,4 +2144,10 @@ def get_sources_associated_entity(neo4j_driver, uuid, filter_out = None):
# Convert the neo4j node into Python dict
results = nodes_to_dicts(record[record_field_name])

for result in results:
if 'metadata' in result and result['metadata'] != '{}':
result['metadata'] = ast.literal_eval(result['metadata'])
else:
result.pop('metadata', None)

return results
13 changes: 2 additions & 11 deletions src/schema/schema_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3536,12 +3536,8 @@ def set_dataset_sources(property_key, normalized_type, user_token, existing_data
str: The target property key
list: The list of sources associated with a dataset
"""
sources = schema_neo4j_queries.get_sources_associated_entity(schema_manager.get_neo4j_driver_instance(), existing_data_dict['uuid'])
for source in sources:
if 'metadata' in source and source['metadata'] != '{}':
source['metadata'] = ast.literal_eval(source['metadata'])
else:
source.pop('metadata', None)
sources = schema_neo4j_queries.get_sources_associated_entity(schema_manager.get_neo4j_driver_instance(),
existing_data_dict['uuid'])
return property_key, sources


Expand Down Expand Up @@ -3569,11 +3565,6 @@ def set_sample_source(property_key, normalized_type, user_token, existing_data_d
"""
sources = schema_neo4j_queries.get_sources_associated_entity(schema_manager.get_neo4j_driver_instance(),
existing_data_dict['uuid'])
for source in sources:
if 'metadata' in source and source['metadata'] != '{}':
source['metadata'] = ast.literal_eval(source['metadata'])
else:
source.pop('metadata', None)
return property_key, sources[0]


Expand Down

0 comments on commit 4ccee32

Please sign in to comment.