From 98695d4d0a94af48afdfd88286325e2e50033794 Mon Sep 17 00:00:00 2001 From: Nichollette Date: Thu, 31 Oct 2024 12:42:08 -0400 Subject: [PATCH] added conditional for new key set --- src/utils/metakg/parser.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/metakg/parser.py b/src/utils/metakg/parser.py index 3d96219..8abc48d 100644 --- a/src/utils/metakg/parser.py +++ b/src/utils/metakg/parser.py @@ -146,13 +146,9 @@ def extract_metakgedges(self, ops, extra_data=None): smartapi_data = op["association"]["smartapi"] url = (smartapi_data.get("meta") or {}).get("url") or extra_data.get("url") _id = smartapi_data.get("id") or extra_data.get("id") - edge = { "subject": op["association"]["input_type"], "object": op["association"]["output_type"], - # check if required, apply logic accordingly - # "subject_prefix": op["association"]["input_id"], - # "object_prefix": op["association"]["output_id"], "predicate": op["association"]["predicate"], "api": { "name": op["association"]["api_name"], @@ -169,6 +165,11 @@ def extract_metakgedges(self, ops, extra_data=None): # "username": (smartapi_data.get("meta") or {}).get("username"), }, } + # Conditionally add subject_prefix and object_prefix if they exist + if "input_id" in op["association"]: + edge["subject_prefix"] = op["association"]["input_id"] + if "output_id" in op["association"]: + edge["object_prefix"] = op["association"]["output_id"] # include bte-specific edge metadata bte = {} for attr in ["query_operation", "response_mapping"]: