1818from plain2code_arguments import parse_arguments
1919from plain2code_console import console
2020from plain2code_state import CONFORMANCE_TESTS_DEFINITION_FILE_NAME , ConformanceTestsUtils , ExecutionState , RunState
21+ from plain2code_utils import RetryOnlyFilter
2122from system_config import system_config
2223
2324TEST_SCRIPT_EXECUTION_TIMEOUT = 120 # 120 seconds
@@ -884,7 +885,10 @@ def render_functional_requirement( # noqa: C901
884885 changed_files .add (file_name )
885886
886887 git_utils .add_all_files_and_commit (
887- args .build_folder , functional_requirement_text , frid , run_state .render_id
888+ args .build_folder ,
889+ f"{ git_utils .FUNCTIONAL_REQUIREMENT_IMPLEMENTED_COMMIT_MESSAGE .format (frid )} \n \n { functional_requirement_text } " ,
890+ frid ,
891+ run_state .render_id ,
888892 )
889893 break
890894
@@ -907,12 +911,20 @@ def render_functional_requirement( # noqa: C901
907911 # Phase 3: Refactor the source code if needed.
908912 console .info ("[b]Refactoring the generated code...[/b]" )
909913 num_refactoring_iterations = 0
910- while num_refactoring_iterations < MAX_REFACTORING_ITERATIONS :
914+ while True :
911915 num_refactoring_iterations += 1
916+
917+ existing_files = file_utils .list_all_text_files (args .build_folder )
918+
919+ if num_refactoring_iterations > MAX_REFACTORING_ITERATIONS :
920+ console .info (
921+ f"Refactoring iterations limit of { MAX_REFACTORING_ITERATIONS } reached for functional requirement { frid } ."
922+ )
923+ break
924+
912925 if args .verbose :
913926 console .info (f"\n Refactoring iteration { num_refactoring_iterations } ." )
914927
915- existing_files = file_utils .list_all_text_files (args .build_folder )
916928 existing_files_content = file_utils .get_existing_files_content (args .build_folder , existing_files )
917929 if args .verbose :
918930 console .print_files (
@@ -1043,23 +1055,29 @@ def render_functional_requirement( # noqa: C901
10431055
10441056def render (args , run_state : RunState ):
10451057 if args .verbose :
1058+
1059+ logging .basicConfig (level = logging .DEBUG )
1060+ logging .getLogger ("urllib3" ).setLevel (logging .WARNING )
1061+ logging .getLogger ("httpx" ).setLevel (logging .WARNING )
1062+ logging .getLogger ("httpcore" ).setLevel (logging .WARNING )
1063+ logging .getLogger ("anthropic" ).setLevel (logging .WARNING )
1064+ logging .getLogger ("langsmith" ).setLevel (logging .WARNING )
1065+ logging .getLogger ("git" ).setLevel (logging .WARNING )
1066+ logging .getLogger ("anthropic._base_client" ).setLevel (logging .DEBUG )
1067+
10461068 # Try to load logging configuration from YAML file
10471069 if os .path .exists (LOGGING_CONFIG_PATH ):
10481070 try :
10491071 with open (LOGGING_CONFIG_PATH , "r" ) as f :
10501072 config = yaml .safe_load (f )
10511073 logging .config .dictConfig (config )
10521074 console .info (f"Loaded logging configuration from { LOGGING_CONFIG_PATH } " )
1053- except Exception :
1054- pass
1075+ except Exception as e :
1076+ console . warning ( f"Failed to load logging configuration from { LOGGING_CONFIG_PATH } : { str ( e ) } " )
10551077
1056- logging .basicConfig (level = logging .DEBUG )
1057-
1058- logging .getLogger ("urllib3" ).setLevel (logging .WARNING )
1059- logging .getLogger ("httpx" ).setLevel (logging .WARNING )
1060- logging .getLogger ("httpcore" ).setLevel (logging .WARNING )
1061- logging .getLogger ("anthropic" ).setLevel (logging .WARNING )
1062- logging .getLogger ("langsmith" ).setLevel (logging .WARNING )
1078+ # if we have debug level for anthropic._base_client to debug, catch only logs relevant to retrying (ones that are relevant for us)
1079+ if logging .getLogger ("anthropic._base_client" ).level == logging .DEBUG :
1080+ logging .getLogger ("anthropic._base_client" ).addFilter (RetryOnlyFilter ())
10631081
10641082 formatter = IndentedFormatter ("%(levelname)s:%(name)s:%(message)s" )
10651083 console_handler = logging .StreamHandler ()
0 commit comments