Repository navigation
Records: content hashes, and named *.lion.json - #396
Open
AnderBiguri wants to merge 3 commits into
Open
AnderBiguri wants to merge 3 commits into
AnderBiguri wants to merge 3 commits into
Conversation
spec.write adds lion_sha256, the hash of the record's content (key order and indentation don't change it), and spec.read warns when a file no longer matches it. Model files, reconstructor files, test records, comparisons and packages are written this way. A model's .pt holds the hash of its .json (metadata_sha256), checked before the model is built: a .json not saved with its .pt warns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LiEbBn1tapdKM5EG8V2As2
The environment test's file with another commit, like test_spec's from other versions, is written with spec.write and its .pt's hash (helpers.resave), not edited by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LiEbBn1tapdKM5EG8V2As2
Every record LION writes (model files, reconstructor files, test records, comparisons, packages and their records) is named `*.lion.json`, to say it is LION's and not to be edited. File names are given without the suffix; a name ending in `.json` is used as given. Other JSON (LIONParameter.save, Geometry.save, the datasets' preprocessing files) stays `.json`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LiEbBn1tapdKM5EG8V2As2
This branch has not been deployed
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.
LION's records are not meant to be edited by hand. This PR does two things about it:
*.lion.json.What changes
Every record LION writes holds its content's hash,
lion_sha256. This covers:comparison.lion.jsonandrecords/);They are written by a new
spec.write(path, value).spec.readwarns when a file's content no longer matches its hash. The warning reads: "… was changed after LION wrote it: its records may no longer describe what was saved. Change things withparameters_from_fileorinstantiate(file, **arguments), not by editing the file". The hash is of the content (sorted keys, compact), so re-indenting or reordering a file doesn't warn.A model's
.ptholds the hash of its.lion.json(metadata_sha256).LIONmodel.loadandload_checkpointcheck it before building the model. So a.lion.jsonthat wasn't saved with its.pt(copied from another run, say) warns before it causes any load error.Records are named
*.lion.json:model.lion.json+model.pt,reconstructor.lion.json,test.lion.json, a package'spackage.lion.json,experiment.lion.json,data/training.lion.json, and so on. The name stays JSON for editors and viewers, but says the file is LION's.spec.record_file,spec.weights_fileandspec.file_base.model.save("results/model"),load("results/model")). A name ending in.jsonis used as given..json:LIONParameter.save,Geometry.save, and the datasets' preprocessing files.Files without the hash keys load as before.
metadata.md, the CHANGELOG,docs/developers.rst, the demos and the paper scripts' "already trained" checks are updated.Nothing changes for results. Files gain one key each (two for a model's pair).
Saved files are renamed. A model saved before this has a
model.jsonfile, and LION now looks formodel.lion.json. Rename it, or load it with the.jsonpath. There is no backwards compatibility before v1.0.Tests
test_spec:test_an_edited_file_warnschecks:.lion.jsonfrom another save warns on load.helpers.resave).On holly:
git fetch && git checkout utils/record-checksum && git pull && pytest pytests/ -n auto. No script: nothing numerical changes.https://claude.ai/code/session_01LiEbBn1tapdKM5EG8V2As2
Generated by Claude Code