Skip to content

fix(cli): actionable errors for an unwritable run directory and a missing structure (R10 F02/F03) - #109

Merged
hydrogen1222 merged 2 commits into
mainfrom
fix/aud-410-diagnostics
Nov 17, 2026
Merged

hydrogen1222 merged 2 commits into
mainfrom
fix/aud-410-diagnostics

Conversation

@hydrogen1222

Copy link
Copy Markdown
Owner

Two failure paths found while executing #75 Rev 10 (§R01 fault injection, §R03 diagnostics) that produced a Python traceback or a dead-end message instead of the actionable Error: ... line every other refusal produces.

F03 — read-only run directory raises a traceback

$ chmod 555 out && mliport run --incar INCAR.mliport --output out
Traceback (most recent call last):
  ...
  File "mliport/run_directory.py", line 85, in run_directory_lock
PermissionError: [Errno 13] Permission denied: 'out/.mliport-run.lock'

R10 §R01 requires "disk full / permission denied" to fail with a reported reason. The existing OutputDirectoryInUseError path (already caught by the CLI, already turned into a non-zero exit) is the right channel, so the lock/mkdir step now raises it:

Error: Cannot write in output directory /tmp/x/out: Permission denied. Choose a writable --output directory, or fix its permissions.

F02 — run says only "no structure file specified"

mliport run --incar other/task/INCAR.mliport from another directory searches the default names (POSCAR, CONTCAR, structure.cif, structure.xyz) in the current directory and said nothing about that. The message now names the candidates and the directory:

Error: No structure file specified and no default found
       Searched for POSCAR, CONTCAR, structure.cif, structure.xyz in /home/me/work
       Pass the structure as an argument, or run the command from the folder that holds it.

The lookup semantics are deliberately unchanged (a task folder is run from inside itself; --incar only anchors results/ and a relative OUTPUT_DIR, as #104 documented). This is a diagnostics fix, not a behaviour change — if the owner prefers the structure default to follow the INCAR folder instead, that is a separate decision and should be raised on #75.

Tests

  • tests/mliport/mliport/test_run_directory.py::test_unwritable_output_directory_is_reported_not_raised_as_a_traceback (skips as root, where the permission bits do not deny access).
  • tests/mliport/mliport/test_cli.py::test_missing_default_structure_says_what_was_searched.

Local: full suite 2312 passed, 48 skipped; ruff@0.5.1 check / format --check clean.

DATA IMPACT: none (no output is written in either case; no default, unit, dtype, task/head or PBC change).

Tracking: #75 Rev 10 findings R10-F02 / R10-F03.

Merge requires owner authorization.

…actionably

Two failure paths from the R10 stabilisation round that ended in a Python
traceback or a one-line dead end instead of the actionable `Error: ...` every
other refusal produces:

* A run directory that exists but cannot be written (read-only, wrong owner,
  full disk) raised a bare `PermissionError` from the lock-file open, so the
  CLI exited with a traceback. The lock/mkdir step now reports
  `Cannot write in output directory <dir>: <reason>` through the existing
  `OutputDirectoryInUseError` path, which the CLI already prints and turns into
  a non-zero exit code.
* `mliport run --incar other/task/INCAR.mliport` from the wrong directory only
  said "No structure file specified and no default found". It now names the
  candidates it looked for and the directory it looked in, and states that the
  command has to run from the folder that holds the structure. The lookup
  semantics are unchanged (the defaults stay current-directory relative).

No behaviour change beyond the message and error type of these two refusals: no
default, unit, dtype, task/head, PBC or provenance semantic is touched, and no
output is written in either case.

Tests: `tests/mliport/mliport/test_run_directory.py` gains a read-only
directory case (skipped for root, where permission bits do not deny access) and
`tests/mliport/mliport/test_cli.py` pins the improved no-structure message.
Full suite locally: 2312 passed, 48 skipped; ruff check/format clean.

DATA IMPACT: none.

Tracking: #75 R10 R01/R03 (findings R10-F02/F03).
The new permission test called `os.geteuid()` unconditionally, which does not
exist on Windows, so collecting the suite there would have failed on an
AttributeError rather than skipping. The case now carries an explicit
`skipif(os.name != "posix")` (permission bits are what it exercises) and the
root guard uses `getattr(os, "geteuid", ...)` defensively.

Test-only change: no production code, no behavioural change.
@hydrogen1222
hydrogen1222 merged commit fb2935c into main Nov 17, 2026
12 checks passed
@hydrogen1222
hydrogen1222 deleted the fix/aud-410-diagnostics branch November 17, 2026 14:58
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