Skip to content

Commit 8bf9f5c

Browse files
committed
slight fixes
1 parent 7d33b94 commit 8bf9f5c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

codeflash/optimization/function_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def optimize_function(self) -> Result[BestOptimization, str]:
134134
with helper_function_path.open(encoding="utf8") as f:
135135
helper_code = f.read()
136136
original_helper_code[helper_function_path] = helper_code
137-
if has_any_async_functions(code_context.code_to_optimize_with_helpers):
137+
if has_any_async_functions(code_context.read_writable_code):
138138
return Failure("Codeflash does not support async functions in the code to optimize.")
139139
code_print(code_context.read_writable_code)
140140

tests/test_get_helper_code.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
217217
f.write(code)
218218
f.flush()
219219
file_path = Path(f.name).resolve()
220+
project_root_path = file_path.parent.resolve()
220221
function_to_optimize = FunctionToOptimize(
221222
function_name="__call__",
222223
file_path=file_path,
@@ -227,7 +228,7 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
227228
test_config = TestConfig(
228229
tests_root="tests",
229230
tests_project_rootdir=Path.cwd(),
230-
project_root_path=file_path.parent.resolve(),
231+
project_root_path=project_root_path,
231232
test_framework="pytest",
232233
pytest_cmd="pytest",
233234
)
@@ -241,7 +242,7 @@ def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R:
241242
assert code_context.helper_functions[0].qualified_name == "AbstractCacheBackend.get_cache_or_call"
242243
assert (
243244
code_context.testgen_context_code
244-
== f'''```python:{file_path.name}
245+
== f'''```python:{file_path.relative_to(project_root_path)}
245246
_P = ParamSpec("_P")
246247
_KEY_T = TypeVar("_KEY_T")
247248
_STORE_T = TypeVar("_STORE_T")

0 commit comments

Comments
 (0)