Skip to content

fix: resolve relative_to() ValueError on Windows when experiment dir is outside cwd#86

Open
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
YihanJIANG-lab:fix/windows-relative-path
Open

fix: resolve relative_to() ValueError on Windows when experiment dir is outside cwd#86
YihanJIANG-lab wants to merge 1 commit intoSakanaAI:mainfrom
YihanJIANG-lab:fix/windows-relative-path

Conversation

@YihanJIANG-lab
Copy link
Copy Markdown

On Windows, Path.relative_to(os.getcwd()) raises ValueError when the experiment directory is on a different drive or not under the current working directory. This replaces the strict call with a _safe_relpath() helper that falls back to os.path.relpath() and ultimately to the absolute path.

…is outside cwd

On Windows, when the experiment directory is not a subdirectory of the current
working directory (e.g., experiments/ vs AI-Scientist-v2/), Path.relative_to()
raises ValueError. This causes journal serialization to crash even after a
successful experiment run.

Add _safe_relpath() helper that tries relative_to() first, then falls back to
os.path.relpath(). Replace all 3 occurrences of .relative_to(os.getcwd()) in
Node.to_json() with this safe helper.

Fixes crash on Windows when running experiments in a directory structure where
the experiment output dir is not a subpath of cwd.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant