Skip to content

Commit c9cfaac

Browse files
committed
macos symlink shenanigans
1 parent 84b4054 commit c9cfaac

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

codeflash/code_utils/code_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ def get_qualified_name(module_name: str, full_qualified_name: str) -> str:
173173

174174
def module_name_from_file_path(file_path: Path, project_root_path: Path, *, traverse_up: bool = False) -> str:
175175
try:
176-
relative_path = file_path.relative_to(project_root_path)
176+
relative_path = file_path.resolve().relative_to(project_root_path.resolve())
177177
return relative_path.with_suffix("").as_posix().replace("/", ".")
178178
except ValueError:
179179
if traverse_up:
180180
parent = file_path.parent
181181
while parent not in (project_root_path, parent.parent):
182182
try:
183-
relative_path = file_path.relative_to(parent)
183+
relative_path = file_path.resolve().relative_to(parent.resolve())
184184
return relative_path.with_suffix("").as_posix().replace("/", ".")
185185
except ValueError:
186186
parent = parent.parent

codeflash/context/code_context_extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def extract_code_markdown_context_from_files(
334334
helpers_of_fto.get(file_path, set()) | helpers_of_helpers.get(file_path, set())
335335
),
336336
)
337-
code_string_context = CodeString(code=code_context, file_path=file_path.relative_to(project_root_path))
337+
code_string_context = CodeString(code=code_context, file_path=file_path.resolve().relative_to(project_root_path.resolve()))
338338
code_context_markdown.code_strings.append(code_string_context)
339339
# Extract code from file paths containing helpers of helpers
340340
for file_path, helper_function_sources in helpers_of_helpers_no_overlap.items():
@@ -365,7 +365,7 @@ def extract_code_markdown_context_from_files(
365365
project_root=project_root_path,
366366
helper_functions=list(helpers_of_helpers_no_overlap.get(file_path, set())),
367367
)
368-
code_string_context = CodeString(code=code_context, file_path=file_path.relative_to(project_root_path))
368+
code_string_context = CodeString(code=code_context, file_path=file_path.resolve().relative_to(project_root_path.resolve()))
369369
code_context_markdown.code_strings.append(code_string_context)
370370
return code_context_markdown
371371

codeflash/result/create_pr.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def existing_tests_source_for(
8585
):
8686
print_optimized_runtime = format_time(optimized_tests_to_runtimes[filename][qualified_name])
8787
print_original_runtime = format_time(original_tests_to_runtimes[filename][qualified_name])
88-
print_filename = filename.relative_to(tests_root).as_posix()
88+
print_filename = filename.resolve().relative_to(tests_root.resolve()).as_posix()
8989
greater = (
9090
optimized_tests_to_runtimes[filename][qualified_name]
9191
> original_tests_to_runtimes[filename][qualified_name]
@@ -192,9 +192,9 @@ def check_create_pr(
192192
if pr_number is not None:
193193
logger.info(f"Suggesting changes to PR #{pr_number} ...")
194194
owner, repo = get_repo_owner_and_name(git_repo)
195-
relative_path = explanation.file_path.relative_to(root_dir).as_posix()
195+
relative_path = explanation.file_path.resolve().relative_to(root_dir.resolve()).as_posix()
196196
build_file_changes = {
197-
Path(p).relative_to(root_dir).as_posix(): FileDiffContent(
197+
Path(p).resolve().relative_to(root_dir.resolve()).as_posix(): FileDiffContent(
198198
oldContent=original_code[p], newContent=new_code[p]
199199
)
200200
for p in original_code
@@ -243,10 +243,10 @@ def check_create_pr(
243243
if not check_and_push_branch(git_repo, git_remote, wait_for_push=True):
244244
logger.warning("⏭️ Branch is not pushed, skipping PR creation...")
245245
return
246-
relative_path = explanation.file_path.relative_to(root_dir).as_posix()
246+
relative_path = explanation.file_path.resolve().relative_to(root_dir.resolve()).as_posix()
247247
base_branch = get_current_branch()
248248
build_file_changes = {
249-
Path(p).relative_to(root_dir).as_posix(): FileDiffContent(
249+
Path(p).resolve().relative_to(root_dir.resolve()).as_posix(): FileDiffContent(
250250
oldContent=original_code[p], newContent=new_code[p]
251251
)
252252
for p in original_code

tests/test_code_context_extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ def get_system_details():
18201820
hashing_context = code_ctx.hashing_code_context
18211821
# The expected contexts
18221822
expected_read_write_context = f"""
1823-
```python:{main_file_path.relative_to(opt.args.project_root)}
1823+
```python:{main_file_path.resolve().relative_to(opt.args.project_root.resolve())}
18241824
import utility_module
18251825
18261826
class Calculator:
@@ -2089,7 +2089,7 @@ def select_precision(precision, fallback_precision):
20892089
else:
20902090
return DEFAULT_PRECISION
20912091
```
2092-
```python:{main_file_path.relative_to(opt.args.project_root)}
2092+
```python:{main_file_path.resolve().relative_to(opt.args.project_root.resolve())}
20932093
import utility_module
20942094
20952095
class Calculator:

0 commit comments

Comments
 (0)