Skip to content

Commit

Permalink
adding empty attributes lists to node and edge bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Apr 3, 2024
1 parent 7fc2903 commit b0d4611
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PLATER/services/util/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,17 @@ def transform_attributes(self, trapi_message):
self.format_attribute_trapi(trapi_message.get('knowledge_graph', {}).get('nodes', {}), node=True)
self.format_attribute_trapi(trapi_message.get('knowledge_graph', {}).get('edges', {}))
for r in trapi_message.get("results", []):
# add an attributes list to every node binding, remove query_id when it's redundant with the actual id
for node_binding_list in r["node_bindings"].values():
for node_binding in node_binding_list:
node_binding["attributes"] = []
if ('query_id' in node_binding) and (node_binding['query_id'] == node_binding['id']):
del node_binding['query_id']
# add an attributes list to every edge binding
for analysis in r['analyses']:
for edge_binding_list in analysis['edge_bindings'].values():
for edge_binding in edge_binding_list:
edge_binding["attributes"] = []
# add resource id
for analyses in r["analyses"]:
analyses["resource_id"] = self.provenance
Expand Down

0 comments on commit b0d4611

Please sign in to comment.