Skip to content

Conversation

mohammedahmed18
Copy link
Contributor

@mohammedahmed18 mohammedahmed18 commented Sep 9, 2025

this will guarantee we have the correct root when raising PRs.

Copy link

github-actions bot commented Sep 9, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Robustness

Validate that pyproject_file_path is not None and points to an existing file before deriving project_root_from_pyproject_file; otherwise .parent may be incorrect or raise errors in edge cases (e.g., missing config).

    root = project_root_from_pyproject_file(pyproject_file_path)
    args.project_root = root
    args.tests_root = Path(args.tests_root).resolve()
    if args.benchmarks_root:
        args.benchmarks_root = Path(args.benchmarks_root).resolve()
    args.test_project_root = root
    if is_LSP_enabled():
        args.all = None
        return args
    return handle_optimize_all_arg_parsing(args)


def project_root_from_pyproject_file(pyproject_file_path: Path) -> Path:
    """Assume that the pyproject.toml file is in the root of the project."""
    return pyproject_file_path.parent
Config Assumption

project_root is now derived solely from the pyproject.toml path; ensure workflows that previously supported module-root-based resolution still behave correctly (e.g., multi-repo or nested module roots).

project_root = project_root_from_pyproject_file(found_config_path)

Copy link

github-actions bot commented Sep 9, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Resolve project root path

Normalize the returned path to an absolute, resolved path to avoid issues with
relative parents or symlinks. This ensures args.project_root and
args.test_project_root are consistent across modules that may chdir.

codeflash/cli_cmds/cli.py [221-223]

 def project_root_from_pyproject_file(pyproject_file_path: Path) -> Path:
     """Assume that the pyproject.toml file is in the root of the project."""
-    return pyproject_file_path.parent
+    return pyproject_file_path.parent.resolve()
Suggestion importance[1-10]: 6

__

Why: Returning a resolved absolute path can prevent issues with relative paths or symlinks and aligns with other path normalizations, but it's a minor robustness improvement rather than a critical fix.

Low
Resolve tracer project root

Resolve the returned root path to be absolute, matching how other paths are
normalized and preventing chdir-related issues during tracing. This keeps path
comparisons consistent.

codeflash/tracer.py [87]

-project_root = project_root_from_pyproject_file(found_config_path)
+project_root = project_root_from_pyproject_file(found_config_path).resolve()
Suggestion importance[1-10]: 6

__

Why: Ensuring the tracer uses an absolute resolved project root improves consistency and reduces chdir-related issues, but it's a small enhancement, not a correctness bug fix.

Low
General
Derive tests root independently

Avoid reusing a single root for both project and tests root if tests reside outside
the project root. Derive args.test_project_root from the tests base to prevent
incorrect path scoping in mixed repo layouts.

codeflash/cli_cmds/cli.py [209-215]

 root = project_root_from_pyproject_file(pyproject_file_path)
 args.project_root = root
 ...
-args.test_project_root = root
+args.test_project_root = Path(args.tests_root).resolve()
Suggestion importance[1-10]: 3

__

Why: While deriving args.test_project_root from args.tests_root might help in atypical repo layouts, the PR intentionally sets both to the same project root; without evidence from the diff that tests can be outside the project root, this is speculative.

Low

@mohammedahmed18 mohammedahmed18 requested a review from a team September 9, 2025 16:49
@misrasaurabh1
Copy link
Contributor

misrasaurabh1 commented Sep 9, 2025

assume that the pyproject.toml file defines the project root.

This assumption is wrong

@mohammedahmed18 mohammedahmed18 changed the title [FIX] set the project root to the pyproject.toml dir [FIX] Use Git root as project root when creating PRs Sep 9, 2025
@aseembits93
Copy link
Contributor

LGTM

@misrasaurabh1 misrasaurabh1 merged commit 922f714 into main Sep 11, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants