Repository navigation
Make repair data always write --output, and read inlined references - #159
Conversation
With --no-dry-run --output OUT, OUT was written only when something was auto-fixed. When nothing needed fixing, or no evidence items were found, the command exited 0 with no OUT, so a pipeline reading it next failed or read a stale file (#143). OUT is now always written outside a dry run: the repaired data, or a byte-for-byte copy of the input when nothing changed. A .bak backup is made only when the input itself is overwritten, and an output naming the input with nothing to fix is left alone. An evidence item whose reference is an inlined object passed the whole mapping on as the reference id, and repair data crashed with AttributeError: 'CommentedMap' object has no attribute 'strip' (#138). The plugin's id reading is now a module-level extract_reference_id, which the plugin method and _extract_evidence_items both use. A reference that names no single id (a list, or an object without a text id) is skipped with a warning naming the item, rather than crashing. Fixes #143 Fixes #138 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qm4PkMsSN3FVpzvBdZYahC
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
|
I can't re-run the job from here ( The test jobs are still running. I'll keep watching. Generated by Claude Code |
|
Claude finished @caufieldjh's task in 59s —— View job PR Review: Make
|
From the PR review: - _extract_evidence_items reads reference, then reference_id, each in turn, so a reference object with no id no longer hides a usable reference_id beside it. - A test covers fixes that cannot be placed back: the input is left alone and --output still gets an unchanged copy. - The --output docs say plainly that the input is untouched only when --output is given, and _same_file notes that symlinks are followed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qm4PkMsSN3FVpzvBdZYahC
|
Addressed the review in c3545d3:
Docs: the Full suite: 2304 passed. Doctests, mypy and ruff are clean. Generated by Claude Code |
|
Claude finished @caufieldjh's task in 42s —— View job PR Review (re-review after c3545d3)
Summary: The new commit deals with the earlier review's points 1, 4 and 5 and with the docs wording. I found nothing blocking. LGTM. What c3545d3 changes
Minor notes (non-blocking)
Other checks
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qm4PkMsSN3FVpzvBdZYahC
|
Notes from the re-review of c3545d3:
Generated by Claude Code |
|
Claude finished @caufieldjh's task in 34s —— View job PR Review (re-review after 4c70efd)
Summary: 4c70efd only changes a comment. It answers note 2 from my last review: the comment in One small wording point (non-blocking)
Still open, fine as follow-ups
Other checks
|
|
On the Generated by Claude Code |
Fixes #143. Fixes #138.
Both are bugs in
repair data(cli/repair.py).#143:
--no-dry-run -o OUTdidn't write OUT when there was nothing to fixOUT was written only inside
if not dry_run and report.auto_fixed_count > 0. That left two paths that exited 0 with no OUT: an input that needed no fixes, and the early exit when no evidence items were found. A pipeline that reads OUT next would then fail, or read a stale file from an earlier run._copy_unchanged), so ruamel round-tripping can't change anything. The message saysWrote OUT (no changes)..bakbackup is made only when the input itself is overwritten. With-oelsewhere, the input is never touched, so a backup of it served no purpose.-onaming the input, with nothing to fix, leaves the file alone. Copying a file onto itself would otherwise be an error.-oand nothing applied: the input isn't rewritten. Before, if the report counted auto-fixes but none could be put back into the data, the input was rewritten anyway and backed up for nothing. Now the command reports! N auto-fix(es) could not be placed back in the dataand leaves the file untouched.The docs (
reference/cli.md,how-to/repair-validation-errors.md) now describe this.#138:
repair datacrashed on an inlined reference object_extract_evidence_itemspassedreference: {id: ..., title: ...}on whole as the reference id. The repair then crashed withAttributeError: 'CommentedMap' object has no attribute 'strip'. The repo's owntests/data/test_data_invalid.yamluses that shape._extract_reference_idis now a module-levelextract_reference_idinplugins/reference_validation_plugin.py. It sits outside theif _LINKML_AVAILABLEblock, sorepair datadoesn't need LinkML installed. The plugin method delegates to it, and_extract_evidence_itemsuses it, so the two read references the same way. That's what the issue suggested.id, and a non-text id. All of these used to crash the same way. A repair needs the one reference the quote came from, so picking one from a list could repair against the wrong paper.With this, the issue's reproduction (
repair data tests/data/test_data_invalid.yaml -s tests/data/test_schema.yaml) prints a repair report instead of a traceback.Not in this PR
#143 also notes that
--schemaand--target-classare accepted but unused. The issue thread suggested splitting that out, so this PR leaves it alone.Tests
tests/test_repair_data_output.pywas written first, and 10 of its tests failed onmain. They're real CLI runs against the fixture cache, so nothing is fetched.-ogets a byte-identical copy and no.bakis made;-owrites nothing;-oleaves the input and its backup alone;-onaming the input with nothing to fix leaves it unchanged;-oand nothing to fix, the input isn't rewritten.id:survives;idandreference_idinside the object are both read;evidence[0];Full suite: 2302 passed. Doctests, mypy and ruff are clean.
Generated by Claude Code