Skip to content

Commit b0fd195

Browse files
committed
Clean context on each invocation
1 parent b5fee83 commit b0fd195

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Project-specific rules
2+
build/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

main.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ def generate_next_attempt(test_results: str) -> None:
8787
_out.write(response.content)
8888

8989

90+
def teardown() -> None:
91+
codegen_path = os.path.join(".", "generated")
92+
build_path = os.path.join(".", "build")
93+
if not os.path.exists(build_path):
94+
os.makedirs(build_path)
95+
with open(os.path.join(codegen_path, "test_class.py"), "r+") as generated_file:
96+
with open(os.path.join(build_path, "test_class.py"), "w+") as _out:
97+
_out.write(generated_file.read())
98+
generated_file.truncate(0)
99+
100+
90101
def chat() -> None:
91102
generate_first_attempt()
92103
for _ in range(5):
@@ -95,6 +106,7 @@ def chat() -> None:
95106
generate_next_attempt(test_results)
96107
else:
97108
break
109+
teardown()
98110
print("Done! All tests are passing, or there is some problem with the test suite itself.")
99111

100112
@app.command()

0 commit comments

Comments
 (0)