Skip to content

fix: skip workspace version warning outside a workspace (no config/) #191

Closed

Description

@Jammy2211

Overview

autonerves.workspace.check_version runs on every import of autofit / autogalaxy / autolens with workspace_root defaulting to the current working directory. Run from a plain data directory (no workspace at all), it finds no version floor and warns "Cannot verify the workspace ...". Reported by external contributor @HRSAstro in https://github.com/orgs/PyAutoLabs/discussions/13 (comment PyAutoLabs/.github#13 (comment)). The fix makes the no-floor branch silent when the directory does not look like a workspace.

Plan

  • When no version floor is found, stay silent if the directory is a package source checkout (as today) or has no config/ directory (not a workspace).
  • A directory with a config/ but no version keys still warns: that is a genuinely misconfigured workspace.
  • No walk-up to a parent workspace: a workspace script run from a subdirectory goes from a false warning to silent, same as outside a workspace.
  • Update the check_version and _is_source_checkout docstrings.
  • Tests: the existing bare-dir warning test creates config/ first; add a bare-dir-is-silent test and a config/-present-no-keys-warns test; red on unfixed source first, then green.

Tier: judge — merge mode: human /prm

Detailed implementation plan

Work Classification: Library
Worktree root: ~/Code/PyAutoLabs-wt/workspace-version-warning-outside-workspace/

Affected Repositories

  • PyAutoNerves (primary)

Branch Survey

Repository Current Branch Dirty?
./organs/PyAutoNerves main clean

Suggested branch: feature/workspace-version-warning-outside-workspace

Implementation Steps

  1. autonerves/workspace.py: add _looks_like_workspace(root) returning (root / "config").is_dir() (every workspace ships config/; version.txt is already consumed earlier in check_version).
  2. In check_version's no-floor branch:
    if floor_version is None or floor_version == "":
        if _is_source_checkout(root) or not _looks_like_workspace(root):
            return
        _warn_once(_missing_version_warning(root, library_version))
        return
  3. Update the check_version docstring (no-floor paragraph) and _is_source_checkout's docstring to describe both silent cases.
  4. Tests in test_autonerves/test_workspace.py:
    • test_missing_sources_warns: create tmp_path / "config" first (still warns).
    • new test_missing_sources_without_config_dir_is_silent: bare tmp dir under warnings.simplefilter("error") emits nothing (must fail on unfixed source).
    • new test_config_dir_without_general_yaml_or_version_txt_warns.
    • Source-checkout tests and test_yaml_without_version_key_falls_through_to_warning unaffected.
  5. Run the full autonerves suite.

Key Files

  • autonerves/workspace.py — check_version, _is_source_checkout, new _looks_like_workspace
  • test_autonerves/test_workspace.py — tests

Reliance check

No repo asserts the warning text. Heart (workspace-validation.yml), Hands (release.yml) and PyAutoLens subprocess tests only set PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1; unaffected. Risk: a real workspace clone missing config/ stops warning — not a realistic layout.

Original Prompt

Click to expand starting prompt

autonerves check_version warns 'Cannot verify the workspace' from directories that are not a workspace

Type: bug
Target: PyAutoNerves
Repos:

  • PyAutoNerves
    Themes:
  • config
  • community
    Autonomy: supervised
    Priority: low
    Status: draft
    Filed: 2026-10-07
    Difficulty: small
    Consequence: judge
    Witness: with a bare tmp dir (no config/, no version.txt, no setup.py/pyproject.toml) as cwd, check_version("2026.8.17.1") emits no warning (under warnings.simplefilter("error")); a tmp dir with an empty config/ dir still warns; the existing test_missing_sources_warns is updated to create config/ first and still passes.
    Review-minutes: 4
    Unattended: ready
    Source: GitHub Discussion https://github.com/orgs/PyAutoLabs/discussions/13 (external contributor @HRSAstro, pyuvimage), comment Streaming visibilities for memory efficiency .github#13 (comment); technical review 2026-10-07 (Item D, accept).

Request (verbatim)

  • Running a plain script from a data directory triggers the autonerves workspace version warning. It's harmless, but it might be worth skipping when there is no workspace config at all.

What

check_version (autonerves/workspace.py:175) defaults root = Path.cwd(); with no config/general.yaml version keys and no version.txt it warns unless _is_source_checkout(root) (:98, setup.py/pyproject.toml). A plain data directory has none, so _warn_once(_missing_version_warning(...)) (:250-253 region) fires. It runs on import of autofit/autogalaxy/autolens (autofit/__init__.py:175, autogalaxy/__init__.py:141, autolens/__init__.py:163); autoarray does not call it.

Plan

  1. In the no-floor branch:
    if floor_version is None or floor_version == "":
        if _is_source_checkout(root) or not _looks_like_workspace(root):
            return
    
    with _looks_like_workspace(root) = (root / "config").is_dir() (every workspace ships config/; version.txt is already consumed above). A config/ with no version keys still warns (genuinely misconfigured; keeps test_yaml_without_version_key_falls_through_to_warning).
  2. Update the check_version docstring (:198-202) and _is_source_checkout's.
  3. No walk-up to a parent workspace root: a workspace script run from a subdirectory goes from a false warning to silent (floor unchecked, same as outside a workspace); walking up could find an unrelated parent config/.

Tests (organs/PyAutoNerves/test_autonerves/test_workspace.py): test_missing_sources_warns (:31) uses a bare tmp_path and will flip — create config/ first; add test_missing_sources_without_config_dir_is_silent; add "config/ present, no general.yaml, no version.txt → warns". Source-checkout tests (:37, :47) unaffected.

Reliance check: no repo asserts the warning text. Heart (workspace-validation.yml:77), Hands (release.yml:474,776) and PyAutoLens subprocess tests (test_tracer_fields.py:527,649, test_analysis_point_gradient_mode.py:214) only set PYAUTO_SKIP_WORKSPACE_VERSION_CHECK=1; unaffected. Risk: a real workspace clone missing config/ stops warning — not a realistic layout.

Activity

  1. Jammy2211 commented on Oct 7, 2026

    @Jammy2211
    CollaboratorAuthor

    Library PR opened: #192 (tests: 241 passed; new silent test red on unfixed source first). Workspace impact: none — option (iii). Tier judge → human /prm.

  2. Jammy2211 commented on Oct 7, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped — merged in #192 (merge commit 91c2d0e).

    check_version now stays silent when the working directory is not a workspace (no config/ directory), so running a plain script from a data directory no longer emits the workspace version warning. A config/ with no version keys still warns.

    Pending release: lands in the next PyAutoNerves release. Reported via https://github.com/orgs/PyAutoLabs/discussions/13 (thanks @HRSAstro).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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