18
18
from plain2code_arguments import parse_arguments
19
19
from plain2code_console import console
20
20
from plain2code_state import CONFORMANCE_TESTS_DEFINITION_FILE_NAME , ConformanceTestsUtils , ExecutionState , RunState
21
+ from plain2code_utils import RetryOnlyFilter
21
22
from system_config import system_config
22
23
23
24
TEST_SCRIPT_EXECUTION_TIMEOUT = 120 # 120 seconds
@@ -884,7 +885,10 @@ def render_functional_requirement( # noqa: C901
884
885
changed_files .add (file_name )
885
886
886
887
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 ,
888
892
)
889
893
break
890
894
@@ -907,12 +911,20 @@ def render_functional_requirement( # noqa: C901
907
911
# Phase 3: Refactor the source code if needed.
908
912
console .info ("[b]Refactoring the generated code...[/b]" )
909
913
num_refactoring_iterations = 0
910
- while num_refactoring_iterations < MAX_REFACTORING_ITERATIONS :
914
+ while True :
911
915
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
+
912
925
if args .verbose :
913
926
console .info (f"\n Refactoring iteration { num_refactoring_iterations } ." )
914
927
915
- existing_files = file_utils .list_all_text_files (args .build_folder )
916
928
existing_files_content = file_utils .get_existing_files_content (args .build_folder , existing_files )
917
929
if args .verbose :
918
930
console .print_files (
@@ -1043,23 +1055,29 @@ def render_functional_requirement( # noqa: C901
1043
1055
1044
1056
def render (args , run_state : RunState ):
1045
1057
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
+
1046
1068
# Try to load logging configuration from YAML file
1047
1069
if os .path .exists (LOGGING_CONFIG_PATH ):
1048
1070
try :
1049
1071
with open (LOGGING_CONFIG_PATH , "r" ) as f :
1050
1072
config = yaml .safe_load (f )
1051
1073
logging .config .dictConfig (config )
1052
1074
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 ) } " )
1055
1077
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 ())
1063
1081
1064
1082
formatter = IndentedFormatter ("%(levelname)s:%(name)s:%(message)s" )
1065
1083
console_handler = logging .StreamHandler ()
0 commit comments