Skip to content

Absolute author-specific project path in configs causes FileNotFoundError on import #4

@PauAltur

Description

@PauAltur

Running the CLI can fail because some configs contain an absolute, author-specific project path (e.g. /home/suraj/...). The import helper is passed that path and attempts to find __init__.py there, causing a FileNotFoundError on other machines.

Environment:

  • Repo: DINOv2-3D-Med
  • OS: Windows
  • Command used:
    python -m scripts.run fit --config_file=./configs/train.yaml,./configs/models/primus.yaml,./configs/datasets/amos.yaml

Reproduction steps:

  1. From the repository run the command above.
  2. Observe traceback ending with:
    FileNotFoundError: No __init__.py in U:\home\suraj\Repositories\DINOv2_3D\__init__.py

Actual behavior:

  • import_module_from_path is passed an absolute path pointing to the original author’s home directory; that path does not exist and the import fails.

Expected behavior:

  • project should resolve to the local repository root (or a user-specified path on the current machine), not an author-specific absolute path.
  • If project is relative (e.g. "."), resolve it relative to the repo root or CWD.
  • Error messages should include the attempted path and a hint on how to fix it.

Root cause:

  • One or more config files include an absolute project path referencing the author's machine. scripts/run.py passes that value to utils/imports.import_module_from_path which expects a package directory containing __init__.py. The absolute path is invalid on other machines so the helper raises FileNotFoundError.

Proposed fixes:

  1. Update configs to avoid absolute author-specific paths (use project: "." or env/template variables).
  2. Harden scripts/run.py:
    • Normalize and resolve project (expanduser, resolve) and treat relative paths relative to repo root or script location.
    • Provide a clearer error message if __init__.py is missing (show attempted path and guidance).
  3. Search repository for and remove any remaining hardcoded /home/suraj paths.

Workaround:

  • Set project: "." in configs and run the command from the repository root, or set project to the absolute path of your local repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions