Repository navigation
fix(runs): export names a directory of the run it cannot list in its left-out note (#1618) - #1655
Conversation
…left-out note (intel#1618) `runs export` names the files of the run directory that run.json does not list by walking it with `os.walk` and no `onerror`, so a subdirectory it could not list (mode 111, non-root) was skipped and the note `left out: N file(s) in the run directory ...` was not printed for the files in it. The export exited 0 with the same bundle and nothing said a directory was not read. `_unlisted` now records each directory the walk cannot list, as a path under the root like the other `Collected` paths, and `collect` returns them in a new `Collected.unreadable`. `runs export` prints `left out: N directory|directories in the run directory that cannot be listed (first: ...)` on stderr after the file line. The bundle, its bundle.json, the exit code and the output for a run directory with no unlistable directory are unchanged. A run directory that itself cannot be listed never reaches the walk: the runs scan already refuses that export with exit 2. The `tasks run --harness command` half of intel#1618 is fixed by the open change to `harnesses/command.py` and is not touched here. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the unlistable-directory diagnostic change.
No open issues 🎉
What changed in this PR
0 new findings; nothing to fix.
This PR fixes the runs export portion of #1618 by reporting directories it cannot list, without changing bundle contents or exit codes.
Changes:
- Collects unlistable directory paths and reports them on stderr.
- Adds regression tests for singular, plural, and fully listable cases.
- Documents the new diagnostic.
| File | Description |
|---|---|
dokimi/tests/test_runs_export_unlistable.py |
Tests diagnostics and unchanged bundle bytes. |
dokimi/dokimi/runs/bundle.py |
Records and sorts unlistable directory paths. |
dokimi/dokimi/commands/runs_bundle.py |
Prints the directory warning. |
dokimi/docs/runs.md |
Documents the warning. |
dokimi/changelog.d/20261205_100000_runs-export-unlistable-dir.md |
Records the export fix. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 5 selected item(s). CI at Test notes (2)
Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1655 +/- ##
==========================================
- Coverage 96.49% 96.48% -0.01%
==========================================
Files 569 569
Lines 75249 75257 +8
Branches 12980 12981 +1
==========================================
+ Hits 72613 72614 +1
- Misses 1611 1614 +3
- Partials 1025 1029 +4
🚀 New features to boost your workflow:
|
vchamarthi
left a comment
There was a problem hiding this comment.
Approving d35d8c2.
What I checked: the 3 changed tests pass, and fail on main as expected; the full test suite passes with main merged in (35,965 tests), apart from failures main has too; it merges cleanly onto main; when I changed the code on purpose, the tests caught all 5 changes.
Summary
#1618 names two sites that skip a directory they cannot list (mode
000or111, non-root user) and give a smaller result with no error or note. This PR fixesruns export:_unlistedinruns/bundle.pywalked the run directory withos.walkand noonerror, so a subdirectory it could not list was skipped and the noteleft out: N file(s) in the run directory that run.json does not listwas not printed for the files in it. On main, withnightly-7/extra/f.txtlistable, stderr hasleft out: 1 file in the run directory that run.json does not list (first: nightly-7/extra/f.txt); afterchmod 000 nightly-7/extrathat line is gone, the export exits 0 with the same 4 files, and nothing says a directory was not read. Now stderr hasleft out: 1 directory in the run directory that cannot be listed (first: nightly-7/extra).The other site,
tasks run --harness command(_find_reward), is fixed by the open #1635, not here: this PR does not touchharnesses/command.py. #1618 closes with this PR while that half lands with #1635.Fix option taken: the walk records the directories it cannot list (
onerror) and the left-out note gets a line for them, as the issue's second option says. The first line (files) is unchanged.Closes #1618
Changes
runs/bundle.py:_unlistedwalks with anonerrorthat records each directory it could not list, as a path under the root like the otherCollectedpaths;collectreturns them, sorted, in the newCollected.unreadable.commands/runs_bundle.py:cmd_runs_exportprintsleft out: N directory|directories in the run directory that cannot be listed (first: ...)on stderr after the file line, when there is any.docs/runs.md: theruns exportbullet names the new line.tests/test_runs_export_unlistable.py(new file, sincetests/test_runs_bundle.pyis at 984 lines and the growth cap is 1000): one directory (bundle bytes equal the listable run's), two directories (plural,Collected.unreadable), and a listable run printing no such line.Risk
None for a run directory with no unlistable directory: the output is unchanged. For one with such a directory, stderr gains one line; the exit code (0), the bundle's bytes and its
bundle.jsonare unchanged and no schema changes. A run directory that itself cannot be listed does not reach this walk: the runs scan cannot read itsrun.jsonentry, and export refuses with exit 2 (no artifact under the runs root ... has the run_id ...; 1 entry under the root could not be read), as on main.Testing
On Linux, at
d35d8c24(onmain4deffc0):make ci-local: 38 passed, 0 failed, 16 skipped. Skipped steps are those that need a real runner, docker, semgrep, micromamba or a PR number.Collected.unreadablegiven as[]there): 2 failed, 1 passed; the first failure isassert [] == ['left out: 1 directory in the run directory that cannot be listed (first: nightly-7/extra)']. The third test is a guard that a listable run prints no such line.onerrorfails the one- and two-directory tests; naming the run directory instead of the unlistable one fails both; alwaysdirectoryfails the plural assertion; returning the run directory when none is unlistable fails the no-line test and the one-directory test.fix/encoding-ruleonmain4deffc0:pytest -n auto35924 passed, 28 skipped,mypyclean,ruff checkclean.Open questions
None.
Revert
A plain revert restores the old behaviour (no note for an unlistable directory). Nothing is stored.
Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)