Repository navigation
fix(cli): actionable errors for an unwritable run directory and a missing structure (R10 F02/F03) - #109
Merged
Conversation
…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.
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
R10 §R01 requires "disk full / permission denied" to fail with a reported reason. The existing
OutputDirectoryInUseErrorpath (already caught by the CLI, already turned into a non-zero exit) is the right channel, so the lock/mkdir step now raises it:F02 —
runsays only "no structure file specified"mliport run --incar other/task/INCAR.mliportfrom 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:The lookup semantics are deliberately unchanged (a task folder is run from inside itself;
--incaronly anchorsresults/and a relativeOUTPUT_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 --checkclean.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.