Skip to content

Report missing config files clearly - #442

Open
luciaquirke wants to merge 4 commits into
mainfrom
fix/missing-config-error
Open

Report missing config files clearly#442
luciaquirke wants to merge 4 commits into
mainfrom
fix/missing-config-error

Conversation

@luciaquirke

@luciaquirke luciaquirke commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

bergson <path> only enters config-file mode when os.path.isfile(path). A path that did not exist fell through to argparse, which reported:

error: argument prog.command: invalid choice: '/mnt/.../tune.yaml'
(choose from 'approxunrolling', 'build', 'ekfac', ...)

but the real problem is a missing file.

Change: decide config-file mode on whether the argument has YAML suffix or a directory separator

`bergson <path>` only entered config-file mode when `os.path.isfile(path)`
passed. A path that did not exist fell through to argparse, which reported it
against the subcommand choices:

    error: argument prog.command: invalid choice:
    '/mnt/.../tune.yaml' (choose from 'approxunrolling', 'build', ...)

That reads as "you typed a bad subcommand" when the real problem is a missing
file, and it sent two debugging sessions after the wrong thing — the config had
been deleted by a run-directory cleanup, which the message gave no hint of.

Decide config-file mode on the argument's shape instead: a YAML suffix or a
directory separator marks a config path, and a path-shaped argument that is not
a file now exits with

    bergson: no such config file: /mnt/.../tune.yaml

Bare words are still subcommands, so an unknown one keeps argparse's error and
its exit code 2. Both behaviours are covered by tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@luciaquirke luciaquirke changed the title Report a missing config file as such, not as an invalid subcommand Report missing config files clearly Aug 25, 2026
luciaquirke and others added 3 commits August 25, 2026 11:41
Replaced the _looks_like_config function with inline logic to check if the config_path resembles a config file.
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