Repository navigation
fix(repos): a task, batch or authoring directory that cannot be listed is an error, not an empty result #1639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - **Four repo-eval readers refuse a directory they cannot list instead of reading it as empty** — an eval `tasks` directory at mode `0o111` gave `no task under eval/tasks`, `repo report` and `repo compare` of a batch directory reported no missing cell and no unsupported one, the check of a batch against another execution found none and let `repo run` resume or report with the cells of two executions mixed, and `eval tasks generate --from prs` or `--from history` did not see the tasks already in `--out-dir` and authored the pull request again. Each now stops with `cannot list <directory>: Permission denied`: `repo report` and `repo compare` exit 2, `repo run` and `eval tasks generate` refuse and exit 1 as they do for their other unusable inputs. A missing directory still has no entries. |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,7 @@ | |||||||||||
| from pathlib import Path | ||||||||||||
| from typing import Any | ||||||||||||
|
|
||||||||||||
| from dokimi.digest_entries import children_holding | ||||||||||||
| from dokimi.eval.sign_flip import round_off_zero | ||||||||||||
| from dokimi.measure import as_float, is_number | ||||||||||||
| from dokimi.provenance import STATUSES, UNKNOWN | ||||||||||||
|
|
@@ -201,13 +202,22 @@ | |||||||||||
| raise CellFileError(f"{path} has no usable `batch`") | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def _cell_files(batch_dir: Path, name: str) -> list[Path]: | ||||||||||||
| """``batch_dir/<cell>/name`` for each cell that has it, sorted; a :class:`CellFileError` naming ``batch_dir`` when | ||||||||||||
| it cannot be listed (a missing one has no cell).""" | ||||||||||||
| try: | ||||||||||||
| return children_holding(batch_dir, "*", name) | ||||||||||||
| except OSError as exc: | ||||||||||||
| raise CellFileError(f"cannot list {batch_dir}: {exc.strerror or exc}") from exc | ||||||||||||
|
antonwolfy marked this conversation as resolved.
Resolved
Comment on lines
+210
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must fix (blocking): A cell at mode Also at: I tested this suggestion: it fixes the problem, and the tests still pass.
Suggested change
DetailsMain returns |
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def load_cells(batch_dir: Path) -> tuple[list[dict[str, Any]], list[str]]: | ||||||||||||
| """Finished cells (their ``result.json``) and the names of missing ones.""" | ||||||||||||
| started = {p.parent.name for p in _cell_files(batch_dir, "meta.json")} # first: it names a directory that cannot be listed | ||||||||||||
| plan_path = batch_dir / "_eval" / "plan.json" | ||||||||||||
| planned = _planned_cells(plan_path) if plan_path.is_file() else set() | ||||||||||||
| started = {p.parent.name for p in batch_dir.glob("*/meta.json")} | ||||||||||||
| finished = [] | ||||||||||||
| for path in sorted(batch_dir.glob("*/result.json")): | ||||||||||||
| for path in _cell_files(batch_dir, "result.json"): | ||||||||||||
| rec = _read_object(path) | ||||||||||||
| _fail_unmeasurable_score(rec) | ||||||||||||
| _check_cell(path, rec) | ||||||||||||
|
|
@@ -218,7 +228,7 @@ | |||||||||||
| rec["score_task"] = bool(rec["score_task"] if "score_task" in rec else rec["grade"]["score_only"]) | ||||||||||||
| finished.append(rec) | ||||||||||||
| done = {r["cell"] for r in finished} | ||||||||||||
| unsupported = {p.parent.name for p in batch_dir.glob(f"*/{UNSUPPORTED_FILE}")} | ||||||||||||
| unsupported = {p.parent.name for p in _cell_files(batch_dir, UNSUPPORTED_FILE)} | ||||||||||||
| return finished, sorted((planned | started) - done - unsupported) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
@@ -252,7 +262,7 @@ | |||||||||||
| def load_unsupported(batch_dir: Path) -> list[dict[str, Any]]: | ||||||||||||
| """Cells the runner did not run on a host that missed their task's ``host`` requirements.""" | ||||||||||||
| out = [] | ||||||||||||
| for path in sorted(batch_dir.glob(f"*/{UNSUPPORTED_FILE}")): | ||||||||||||
| for path in _cell_files(batch_dir, UNSUPPORTED_FILE): | ||||||||||||
| if (path.parent / "result.json").is_file(): | ||||||||||||
| continue | ||||||||||||
| rec = _read_object(path) | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ | |
| from typing import Any | ||
|
|
||
| from dokimi import process | ||
| from dokimi.digest_entries import children_holding | ||
| from dokimi.process_io import exact_path_text | ||
|
|
||
| from .arms import ArmError, Skill, resolve_skills, tree_sha256 | ||
|
|
@@ -264,7 +265,10 @@ | |
| No task at all is refused: a check or run over none would report 0/0 as a pass.""" | ||
| eval_dir, tasks = manifest.run_paths() | ||
| tasks_dir = content_dir / PurePosixPath(tasks).relative_to(eval_dir) | ||
| found = {p.parent.name: p for p in sorted(tasks_dir.glob("*/task.json"))} | ||
| try: | ||
| found = {p.parent.name: p for p in children_holding(tasks_dir, "*", "task.json")} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. blocking: An inaccessible sibling blocks an explicitly selected task
How to check: With one valid selected task and a sibling directory at mode |
||
| except OSError as exc: # a directory that cannot be listed is not one with no task | ||
| raise PrepError(f"cannot list {tasks_dir}: {exc.strerror or exc}") from exc | ||
| if not found: | ||
| raise PrepError(f"no task under {manifest.tasks} (no */task.json): nothing to check or run") | ||
| wanted = ids or sorted(found) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Copyright (C) 2026 Intel Corporation | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """#1507: ``children_holding`` lists ``<child>/<name>`` as ``glob`` did, a link included, and raises what it cannot look up.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
| from dokimi.cli import build_parser | ||
| from dokimi.digest_entries import children_holding | ||
| from tests.cli_refusal import refusal | ||
|
|
||
|
|
||
| def _names(root, hits): | ||
| return [str(p.relative_to(root)) for p in hits] | ||
|
|
||
|
|
||
| def test_a_dangling_or_looping_leaf_link_is_a_hit_like_the_glob_found_it(tmp_path): | ||
| for child in ("dangling", "loop", "file", "dir"): | ||
| (tmp_path / child).mkdir() | ||
| os.symlink("nowhere", tmp_path / "dangling" / "result.json") | ||
| os.symlink("result.json", tmp_path / "loop" / "result.json") | ||
| (tmp_path / "file" / "result.json").write_text("{}") | ||
| (tmp_path / "dir" / "result.json").mkdir() | ||
| assert _names(tmp_path, children_holding(tmp_path, "*", "result.json")) == [ | ||
| "dangling/result.json", "dir/result.json", "file/result.json", "loop/result.json"] | ||
| assert _names(tmp_path, children_holding(tmp_path, "*", "result.json")) == sorted( | ||
| str(p.relative_to(tmp_path)) for p in tmp_path.glob("*/result.json")) | ||
|
|
||
|
|
||
| def test_an_absent_name_a_child_that_is_no_directory_and_a_missing_root_are_no_hit(tmp_path): | ||
| (tmp_path / "empty").mkdir() | ||
| (tmp_path / "plain").write_text("not a directory") | ||
| assert children_holding(tmp_path, "*", "result.json") == [] | ||
| assert children_holding(tmp_path / "missing", "*", "result.json") == [] | ||
|
|
||
|
|
||
| def test_a_child_that_is_a_link_loop_is_no_hit_as_for_the_glob(tmp_path): | ||
| os.symlink("loop", tmp_path / "loop") | ||
| assert children_holding(tmp_path, "*", "result.json") == [] | ||
| assert list(tmp_path.glob("*/result.json")) == [] | ||
|
|
||
|
|
||
| def test_a_child_that_cannot_be_searched_raises(tmp_path): | ||
| child = tmp_path / "cell1" | ||
| child.mkdir() | ||
| (child / "result.json").write_text("{}") | ||
| child.chmod(0) | ||
| try: | ||
| try: | ||
| os.stat(child / "result.json") | ||
| except PermissionError: | ||
| with pytest.raises(PermissionError): | ||
| children_holding(tmp_path, "*", "result.json") | ||
| else: | ||
| pytest.skip("this process searches a mode 0 directory (root)") | ||
| finally: | ||
| child.chmod(0o700) | ||
|
|
||
|
|
||
| def test_a_batch_directory_that_cannot_be_searched_is_refused_naming_it_on_every_python(tmp_path): | ||
| from dokimi.repos.report import CellFileError, load_cells | ||
|
|
||
| batch = tmp_path / "b1" | ||
| batch.mkdir() | ||
| batch.chmod(0) | ||
| try: | ||
| try: | ||
| os.stat(batch / "_eval") | ||
| except PermissionError: | ||
| with pytest.raises(CellFileError, match=f"cannot list {batch}: Permission denied"): | ||
| load_cells(batch) | ||
| else: | ||
| pytest.skip("this process searches a mode 0 directory (root)") | ||
| finally: | ||
| batch.chmod(0o700) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("link",["nowhere", "result.json"], ids=["dangling", "looping"]) | ||
| def test_report_reads_a_leaf_link_it_cannot_follow_and_refuses_it_naming_the_file(tmp_path, capsys, link): | ||
| cell = tmp_path / "b1" / "t__a__m__r1" | ||
| cell.mkdir(parents=True) | ||
| os.symlink(link, cell / "result.json") | ||
| with refusal() as exc: | ||
| args = build_parser().parse_args(["repo", "report", str(tmp_path / "b1")]) | ||
| args.func(args) | ||
| assert exc.code == 2 | ||
| assert f"cannot read {cell / 'result.json'}" in capsys.readouterr().err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: A cell due for replacement can fail the identity check
dokimi/dokimi/repos/batch_ledger.py:169Thereplacingfilter runs after the new helper has probed all result paths.How to check: With a mode-
000cell inreplacing, base permits the identity check and head raisesExecutionMismatchbefore it checksreplacing.Expected: Apply the
replacingfilter before probing a cell’sresult.json, so the identity check covers cells the run will keep.