Upload folder using huggingface_hub
Browse filesFiles changed (4)
34 unmodified lines3536373838394041129 unmodified lines17117217317417517617717817918018118217617718318418518618718825 unmodified lines21421521620921021121721821922022122222322422522634 unmodified linesGATES: CONFIRMED (9 gates: 9 CONFIRMED, 0 REJECTED, 0 ABSTAIN)
```
The gate runner is where this bundle states its numbers out loud: 9 gates, 75 tests across 9 files,
The gate runner is where this bundle states its numbers out loud: 9 gates, 77 tests across 9 files,
18 files under `nodes/`, and a kernel it does not carry. `tools/publish_dataset.py` re-derives every
one of those numbers from the tree it is standing in and stops the upload when the card and the code
beside it disagree.129 unmodified lines```
$ python -B -m lingologos_python patterns scan --workspace fixtures/pattern_lab \
--pattern chain-to-registry
chain-to-registry: 1 hit(s) in this workspace
src/registry.py::render
src/registry.py dispatch registry of 'render'
tests/test_registry.py lock test 'test_render_dispatches_through_a_registry' appended after 'test_render_rejects_an_unknown_kind'
why: the branch for 'short' returns format_short
why: the branch for 'long' returns format_long
why: the branch for 'json' returns format_json
```
This prints one hit, `src/registry.py::render`, with the two edits it would apply: the chain of `if`
and `elif` that becomes a mapping of handlers, and the lock test appended to `tests/test_registry.py`.
The hit names the function, and under it the two edits the card would apply: the chain of `if` and `elif`
that becomes a mapping of handlers, and the lock test appended to `tests/test_registry.py`. `--json`
prints the same answer as data, with the `search` and `replace` text of every edit beside it.
`render_pair`, in the same file, is not listed: its chain is not in the shape the card claims, and a
card that does not claim a shape does not touch it.
25 unmodified lines --search "def load(path):" --replace "def load(path: Path) -> dict:" --dry-run
```
and so do `create --file ... --content-file ...`, `delete`, and `verify --file ...`, which reports a
verdict for a file without asking for a change. With `--strict-tools` the run demands `mypy` and `ruff`
and answers `ABSTAIN` when they are not installed, instead of reporting a check that never happened.
and so does `create --file ... --content-file ...`. The command line has no `delete` verb: deleting is a
`delete_file` transaction on the session and on the kernel, exercised in `tests/test_session.py`, and it
is not offered as a command from here. `verify --file ...` reports a verdict for a file without asking
for a change. With `--strict-tools` the run demands `mypy` and `ruff`: a gate that cannot run abstains,
and the session answers UNKNOWN with the reason `GATE_ABSTAIN` instead of reporting a check that never
happened.
`check-adapter` says whether the Python adapter holds the contract of the kernel, and exits non-zero
when it does not.
224 unmodified lines225226227228228229230231232233234235236237238239240241242243244245246247230231248249250251252253254255256257258259260224 unmodified lines if args.action == "scan": found = scan_pattern(root, args.pattern) if args.json: print(json.dumps({"pattern": args.pattern, "targets": found}, indent=2)) print( json.dumps( { "pattern": args.pattern, "hits": [ { "target": target, "rule": hit.rule, "edits": [asdict(edit) for edit in hit.edits], "evidence": list(hit.evidence), "reason_code": hit.reason_code, } for target, hit in found ], }, indent=2, sort_keys=True, ) ) else: for item in found: print(item) if not found: print("no function in this workspace has the shape of this card") else: print("%s: %d hit(s) in this workspace" % (args.pattern, len(found))) for target, hit in found: print(" %s" % target) for edit in hit.edits: print(" %-26s %s" % (edit.file, edit.label)) for line in hit.evidence: print(" why: %s" % line) return 0 session = PythonWorkspaceSession(args.workspace, strict_tools=args.strict_tools) res = session.apply_pattern(args.pattern, target=args.target, commit=not args.dry_run)105 unmodified lines106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147105 unmodified lines assert "render_pair" not in proc.stdout
def test_patterns_scan_shows_the_edits_a_hit_would_apply_and_dumps_nothing() -> None: proc = run_cli("patterns", "scan", "--workspace", str(LAB), "--pattern", "chain-to-registry") assert proc.returncode == 0, proc.stdout + proc.stderr lines = [line.strip() for line in proc.stdout.splitlines() if line.strip()] assert lines[0] == "chain-to-registry: 1 hit(s) in this workspace" assert lines[1] == "src/registry.py::render" assert lines[2].startswith("src/registry.py") assert lines[3].startswith("tests/test_registry.py") assert any(line.startswith("why:") for line in lines) for noise in ("RuleHit", "Edit(", "evidence=", "Traceback"): assert noise not in proc.stdout
def test_patterns_scan_json_carries_the_edits_a_reader_can_act_on() -> None: proc = run_cli( "patterns", "scan", "--workspace", str(LAB), "--pattern", "chain-to-registry", "--json", ) assert proc.returncode == 0, proc.stdout + proc.stderr payload: Dict[str, Any] = json.loads(proc.stdout) assert payload["pattern"] == "chain-to-registry" assert len(payload["hits"]) == 1 hit = payload["hits"][0] assert hit["target"] == "src/registry.py::render" assert hit["rule"] == "chain-to-registry" assert [edit["file"] for edit in hit["edits"]] == ["src/registry.py", "tests/test_registry.py"] for edit in hit["edits"]: assert edit["search"] and edit["replace"] and edit["label"] assert hit["evidence"] and all(hit["evidence"])
def test_patterns_scan_says_so_when_nothing_in_the_workspace_qualifies() -> None: proc = run_cli("patterns", "scan", "--workspace", str(SAMPLE), "--pattern", "chain-to-registry") assert proc.returncode == 0, proc.stdout + proc.stderr13 unmodified lines141516171718192021 unmodified lines424344454546474840 unmodified lines899091929293949495969713 unmodified linesThis bundle carries no kernel. It carries one corpus of its own, the ten pattern cases under`patterns/`, generated from the rules and the fixture beside them, and the card states theirdenominator rather than letting ten rows look like a benchmark. Every number the card states (9 gates,75 tests, 18 node files, the staged file count) is re-derived from this tree before a single object is77 tests, 18 node files, the staged file count) is re-derived from this tree before a single object isuploaded. A card that contradicts the code beside it stops the run instead of publishing.
The folder README is the body of the dataset card. A short list of wording pairs turns the sentences21 unmodified linesEXPECTED_FILES = 66 # the staged tree: 66 files of this folder, the card replacing README.mdEXPECTED_HUB_OBJECTS = 67 # those 66 plus the .gitattributes the hub addsEXPECTED_GATES = 9EXPECTED_TESTS = 75EXPECTED_TESTS = 77EXPECTED_TEST_FILES = 9EXPECTED_NODE_FILES = 18EXPECTED_GATE_LINE = "GATES: CONFIRMED (9 gates: 9 CONFIRMED, 0 REJECTED, 0 ABSTAIN)"40 unmodified lines "\"What this bundle needs from the codex kernel\" below says how the two find each other.", ), ( "The gate runner is where this bundle states its numbers out loud: 9 gates, 75 tests across 9 files,\n" "The gate runner is where this bundle states its numbers out loud: 9 gates, 77 tests across 9 files,\n" "18 files under `nodes/`, and a kernel it does not carry.", "The gate runner is where this bundle states its numbers out loud: 9 gates, 75 tests across 9 files,\n" "The gate runner is where this bundle states its numbers out loud: 9 gates, 77 tests across 9 files,\n" "18 files under `nodes/`, and a kernel it does not carry. `tools/publish_dataset.py` re-derives every\n" "one of those numbers from the tree it is standing in and stops the upload when the card and the code\n" "beside it disagree.",README.md+18-6
lingologos_python/cli.py+27-3
tests/test_cli.py+36
tools/publish_dataset.py+4-4