Skip to content

Make OFF run-directory initialization OS-agnostic on Windows via pathlib#30

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-running-off-on-windows
Draft

Make OFF run-directory initialization OS-agnostic on Windows via pathlib#30
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-running-off-on-windows

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown

OFF aborted on Windows when OFF_PATH was unset because directory fallback logic depended on os.environ["PWD"] (Unix-specific). This change switches fallback resolution to pathlib + Path.cwd() so run-directory initialization works consistently across platforms.

  • Root path resolution in OFF.__dir_init__

    • Replaced string-based path construction with Path composition.
    • Kept precedence: explicit data folderOFF_PATH/runs → cwd-based fallback.
    • Preserved existing 03_Code special case using Path.cwd().name == "03_Code" and cwd.parent / "runs".
  • Directory and root tracking cleanup

    • Replaced brittle string slicing ([:-len("runs/")]) with root_path.parent.
    • Normalized sim_dir construction via root_path / f"off_run_{run_id}".
    • Switched directory creation to Path(...).mkdir(parents=True, exist_ok=True).
  • Focused regression coverage

    • Added tests that validate fallback behavior when OFF_PATH is missing:
      • cwd fallback to <cwd>/runs
      • 03_Code fallback to <parent>/runs
    • Tests intentionally set PWD to an unrelated value to verify logic no longer depends on it.
cwd = Path.cwd()
if cwd.name == "03_Code":
    root_path = Path(data_dir) if data_dir else cwd.parent / "runs"
else:
    root_path = Path(data_dir) if data_dir else cwd / "runs"

Copilot AI linked an issue Jun 19, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix running OFF on Windows by using os.getcwd() Make OFF run-directory initialization OS-agnostic on Windows via pathlib Jun 19, 2026
@ivovs-tud ivovs-tud self-requested a review June 19, 2026 14:55
Comment thread test_off_dir_init.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

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.

Running OFF on Windows

3 participants