1515import libcst as cst
1616from pydantic .dataclasses import dataclass
1717
18- from codeflash .api .cfapi import get_blocklisted_functions
18+ from codeflash .api .cfapi import get_blocklisted_functions , make_cfapi_request
1919from codeflash .cli_cmds .console import DEBUG_MODE , console , logger
2020from codeflash .code_utils .code_utils import (
2121 is_class_defined_in_file ,
2222 module_name_from_file_path ,
2323 path_belongs_to_site_packages ,
2424)
25- from codeflash .code_utils .git_utils import get_git_diff
25+ from codeflash .code_utils .env_utils import get_pr_number
26+ from codeflash .code_utils .git_utils import get_git_diff , get_repo_owner_and_name
2627from codeflash .discovery .discover_unit_tests import discover_unit_tests
2728from codeflash .models .models import FunctionParent
2829from codeflash .telemetry .posthog_cf import ph
@@ -473,8 +474,7 @@ def check_optimization_status(
473474 Returns:
474475 Tuple of (filtered_functions_dict, remaining_count)
475476 """
476- import requests
477-
477+ logger .info ("entering function" )
478478 # Build the code_contexts dictionary for the API call
479479 code_contexts = {}
480480 path_to_function_map = {}
@@ -492,18 +492,18 @@ def check_optimization_status(
492492
493493 try :
494494 # Call the optimization check API
495- response = requests .post (
496- "http://your-api-endpoint/is_code_being_optimized_again" , # Replace with actual endpoint
497- json = {
495+ logger .info ("Checking status" )
496+ response = make_cfapi_request (
497+ "/is-already-optimized" ,
498+ "POST" ,
499+ {
498500 "owner" : owner ,
499501 "repo" : repo ,
500- "pr_number" : str ( pr_number ) ,
502+ "pr_number" : pr_number ,
501503 "code_contexts" : code_contexts
502- },
503- timeout = 30
504+ }
504505 )
505506 response .raise_for_status ()
506-
507507 result = response .json ()
508508 already_optimized_paths = set (result .get ("already_optimized_paths" , []))
509509
@@ -535,10 +535,8 @@ def filter_functions(
535535 project_root : Path ,
536536 module_root : Path ,
537537 disable_logs : bool = False ,
538- owner : str | None = None ,
539- repo : str | None = None ,
540- pr_number : int | None = None ,
541538) -> tuple [dict [Path , list [FunctionToOptimize ]], int ]:
539+ logger .info ("filtering functions boogaloo" )
542540 blocklist_funcs = get_blocklisted_functions ()
543541 # Remove any function that we don't want to optimize
544542
@@ -600,6 +598,10 @@ def filter_functions(
600598
601599 # Check optimization status if repository info is provided
602600 already_optimized_count = 0
601+ repository = git .Repo (Path .cwd (), search_parent_directories = True )
602+ owner , repo = get_repo_owner_and_name (repository )
603+ pr_number = get_pr_number ()
604+ print (owner , repo , pr_number )
603605 if owner and repo and pr_number is not None :
604606 path_based_functions , functions_count = check_optimization_status (
605607 path_based_functions , owner , repo , pr_number
0 commit comments