Skip to content

Commit e0a80e9

Browse files
always assume the pyproject.toml file is in the root of the project
1 parent f085fe1 commit e0a80e9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,24 @@ def process_pyproject_config(args: Namespace) -> Namespace:
203203
assert path_obj.exists(), f"ignore-paths config must be a valid path. Path {path} does not exist"
204204
normalized_ignore_paths.append(path_obj.resolve())
205205
args.ignore_paths = normalized_ignore_paths
206-
# Project root path is one level above the specified directory, because that's where the module can be imported from
207206
args.module_root = Path(args.module_root).resolve()
208207
# If module-root is "." then all imports are relatives to it.
209208
# in this case, the ".." becomes outside project scope, causing issues with un-importable paths
210-
args.project_root = project_root_from_module_root(args.module_root, pyproject_file_path)
209+
root = project_root_from_pyproject_file(pyproject_file_path)
210+
args.project_root = root
211211
args.tests_root = Path(args.tests_root).resolve()
212212
if args.benchmarks_root:
213213
args.benchmarks_root = Path(args.benchmarks_root).resolve()
214-
args.test_project_root = project_root_from_module_root(args.tests_root, pyproject_file_path)
214+
args.test_project_root = root
215215
if is_LSP_enabled():
216216
args.all = None
217217
return args
218218
return handle_optimize_all_arg_parsing(args)
219219

220220

221-
def project_root_from_module_root(module_root: Path, pyproject_file_path: Path) -> Path:
222-
if pyproject_file_path.parent == module_root:
223-
return module_root
224-
return module_root.parent.resolve()
221+
def project_root_from_pyproject_file(pyproject_file_path: Path) -> Path:
222+
"""Assume that the pyproject.toml file is in the root of the project."""
223+
return pyproject_file_path.parent
225224

226225

227226
def handle_optimize_all_arg_parsing(args: Namespace) -> Namespace:

codeflash/tracer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pathlib import Path
2020
from typing import TYPE_CHECKING
2121

22-
from codeflash.cli_cmds.cli import project_root_from_module_root
22+
from codeflash.cli_cmds.cli import project_root_from_pyproject_file
2323
from codeflash.cli_cmds.console import console
2424
from codeflash.code_utils.code_utils import get_run_tmp_file
2525
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE
@@ -84,7 +84,7 @@ def main(args: Namespace | None = None) -> ArgumentParser:
8484
parsed_args.outfile = Path(parsed_args.outfile).resolve()
8585
outfile = parsed_args.outfile
8686
config, found_config_path = parse_config_file(parsed_args.codeflash_config)
87-
project_root = project_root_from_module_root(Path(config["module_root"]), found_config_path)
87+
project_root = project_root_from_pyproject_file(found_config_path)
8888
if len(unknown_args) > 0:
8989
try:
9090
result_pickle_file_path = get_run_tmp_file("tracer_results_file.pkl")

0 commit comments

Comments
 (0)