MCPcopy
hub / github.com/NVIDIA/TensorRT-LLM / queryFromOpenSearchDB

Method queryFromOpenSearchDB

jenkins/scripts/open_search_db.py:243–284  ·  view source on GitHub ↗

Query data from OpenSearchDB. :param json_data: Data to query, type dict or list. :param project: Name of the project. :return: dict, query result.

(json_data, project)

Source from the content-addressed store, hash-verified

241
242 @staticmethod
243 def queryFromOpenSearchDB(json_data, project) -> dict:
244 """
245 Query data from OpenSearchDB.
246
247 :param json_data: Data to query, type dict or list.
248 :param project: Name of the project.
249 :return: dict, query result.
250 """
251 use_poc_db = "sandbox" in project
252 if not OPEN_SEARCH_DB_BASE_URL:
253 OpenSearchDB.logger.info("OPEN_SEARCH_DB_BASE_URL is not set")
254 return None
255 if not use_poc_db and project not in READ_ACCESS_PROJECT_NAME:
256 OpenSearchDB.logger.info(
257 f"project {project} is not in read access project list: {json.dumps(READ_ACCESS_PROJECT_NAME)}"
258 )
259 return None
260 if not isinstance(json_data, str):
261 json_data_dump = json.dumps(json_data)
262 else:
263 json_data_dump = json_data
264 url = f"{OPEN_SEARCH_DB_BASE_URL}/opensearch/df-{project}-*/_search"
265 headers = {
266 "Content-Type": "application/json",
267 "Accept-Charset": "UTF-8"
268 }
269 retry_time = DEFAULT_RETRY_COUNT
270 while retry_time:
271 res = requests.get(url,
272 data=json_data_dump,
273 headers=headers,
274 timeout=QUERY_TIMEOUT_SECONDS)
275 if res.status_code in [200, 201, 202]:
276 return res
277 OpenSearchDB.logger.info(
278 f"OpenSearchDB query failed, will retry, error:{res.status_code} {res.text}"
279 )
280 retry_time -= 1
281 OpenSearchDB.logger.info(
282 f"Fail to queryFromOpenSearchDB after {retry_time} retry: {url}, json: {json_data_dump}, error: {res.text}"
283 )
284 return None
285
286 @staticmethod
287 def queryBuildIdFromOpenSearchDB(job_name, last_days=DEFAULT_LOOKBACK_DAYS):

Callers 5

queryJobEventsFunction · 0.80
query_regression_dataFunction · 0.80
query_history_dataFunction · 0.80

Calls 2

infoMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected