Skip to content

Commit b33a53f

Browse files
authored
Merge branch 'main' into instrument-jit
2 parents 6c83c34 + e4b9c74 commit b33a53f

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

codeflash/api/cfapi.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,37 @@ def get_blocklisted_functions() -> dict[str, set[str]] | dict[str, Any]:
342342
owner, repo = get_repo_owner_and_name()
343343
information = {"pr_number": pr_number, "repo_owner": owner, "repo_name": repo}
344344

345-
req = make_cfapi_request(endpoint="/verify-existing-optimizations", method="POST", payload=information)
346-
req.raise_for_status()
345+
req = make_cfapi_request(
346+
endpoint="/verify-existing-optimizations", method="POST", payload=information, suppress_errors=True
347+
)
348+
349+
if req.status_code >= 500:
350+
logger.error(f"Server error getting blocklisted functions: {req.status_code}")
351+
sentry_sdk.capture_message(f"Server error in verify-existing-optimizations: {req.status_code}")
352+
return {}
353+
if not req.ok:
354+
if req.status_code == 401:
355+
logger.debug(f"Not authorized to check blocklisted functions for {owner}/{repo} PR #{pr_number}")
356+
elif req.status_code == 404:
357+
logger.debug(f"PR #{pr_number} not found for {owner}/{repo}")
358+
else:
359+
logger.warning(f"Unexpected response {req.status_code} from verify-existing-optimizations")
360+
return {}
361+
347362
content: dict[str, list[str]] = req.json()
363+
364+
if "error" in content:
365+
logger.debug(f"No existing optimizations found for PR #{pr_number}")
366+
return {}
367+
368+
logger.debug(f"Found {len(content)} files with blocklisted functions for PR #{pr_number}")
369+
return {Path(k).name: {v.replace("()", "") for v in values} for k, values in content.items()}
370+
348371
except Exception as e:
349372
logger.error(f"Error getting blocklisted functions: {e}")
350373
sentry_sdk.capture_exception(e)
351374
return {}
352375

353-
return {Path(k).name: {v.replace("()", "") for v in values} for k, values in content.items()}
354-
355376

356377
def is_function_being_optimized_again(
357378
owner: str, repo: str, pr_number: int, code_contexts: list[dict[str, str]]

0 commit comments

Comments
 (0)