2525# Author: Komal Thareja (kthare10@renci.org)
2626from __future__ import annotations
2727
28+ import json
2829import random
2930import threading
3031import traceback
@@ -2234,16 +2235,11 @@ def query(self, *, p: dict) -> dict:
22342235 raise BrokerException (error_code = ExceptionErrorCode .INVALID_ARGUMENT ,
22352236 msg = f"query_action { query_action } " )
22362237
2237- if query_action != Constants .QUERY_ACTION_DISCOVER_BQM :
2238+ if query_action not in (Constants .QUERY_ACTION_DISCOVER_BQM ,
2239+ Constants .QUERY_ACTION_DISCOVER_BQM_SUMMARY ):
22382240 raise BrokerException (error_code = ExceptionErrorCode .INVALID_ARGUMENT ,
22392241 msg = f"query_action { query_action } " )
22402242
2241- bqm_format = p .get (Constants .BROKER_QUERY_MODEL_FORMAT , None )
2242- if bqm_format is not None :
2243- bqm_format = GraphFormat (int (bqm_format ))
2244- else :
2245- bqm_format = GraphFormat .GRAPHML
2246-
22472243 start = p .get (Constants .START , None )
22482244 if start :
22492245 start = datetime .strptime (start , Constants .LEASE_TIME_FORMAT )
@@ -2254,6 +2250,35 @@ def query(self, *, p: dict) -> dict:
22542250 excludes = p .get (Constants .EXCLUDES , None )
22552251 includes = p .get (Constants .INCLUDES , None )
22562252
2253+ # Handle JSON summary path — bypasses graph construction entirely
2254+ if query_action == Constants .QUERY_ACTION_DISCOVER_BQM_SUMMARY :
2255+ try :
2256+ if self .query_cbm is not None :
2257+ plugin = AggregatedBQMPlugin (actor = self .actor , logger = self .logger )
2258+ summary = plugin .plug_produce_bqm_summary (
2259+ cbm = self .query_cbm , query_level = query_level ,
2260+ start = start , end = end , includes = includes , excludes = excludes
2261+ )
2262+ result [Constants .BROKER_QUERY_MODEL ] = json .dumps (summary )
2263+ result [Constants .QUERY_RESPONSE_STATUS ] = "True"
2264+ else :
2265+ result [Constants .BROKER_QUERY_MODEL ] = ""
2266+ result [Constants .QUERY_RESPONSE_STATUS ] = "False"
2267+ result [Constants .QUERY_RESPONSE_MESSAGE ] = "Resource(s) not found"
2268+ except Exception as e :
2269+ self .logger .error (traceback .format_exc ())
2270+ self .logger .error (e )
2271+ result [Constants .BROKER_QUERY_MODEL ] = ""
2272+ result [Constants .QUERY_RESPONSE_STATUS ] = "False"
2273+ result [Constants .QUERY_RESPONSE_MESSAGE ] = str (e )
2274+ return result
2275+
2276+ bqm_format = p .get (Constants .BROKER_QUERY_MODEL_FORMAT , None )
2277+ if bqm_format is not None :
2278+ bqm_format = GraphFormat (int (bqm_format ))
2279+ else :
2280+ bqm_format = GraphFormat .GRAPHML
2281+
22572282 try :
22582283 if self .query_cbm is not None :
22592284 graph = self .query_cbm .get_bqm (query_level = query_level , start = start , end = end , includes = includes ,
0 commit comments