Add ability to downgrade schema all the way to 0.6.10#342
Add ability to downgrade schema all the way to 0.6.10#342yarikoptic wants to merge 7 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #342 +/- ##
=======================================
Coverage 97.84% 97.84%
=======================================
Files 16 16
Lines 2042 2042
=======================================
Hits 1998 1998
Misses 44 44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@waxlamp here we are to get into that unpleasant situation to need to coordinate releasing since otherwise if client has this release more recent dandi-schema installed (possible with or without us pinning in client): we would get so the question(s)
|
How could this happen if you are pinning (For the record, it seems that the CLI does indeed pin
No problem, given that both the archive and the CLI are pinning to a specific version of This does mean we need to coordinate releasing versions of both that do use the new version, but I'm not sure how we can avoid that without solving the bigger problem of enabling automatic migration between schema versions.
I imagine it would be part of dandi/dandi-archive#2606 (see this comment). |
Simply because we are testing against these changes, which will give new version 0.7.0 -- that's the whole point. And it just reveals fragility of our tight binding of versions here and there and that pinning just a workaround for "user deployment" while developers, who need to test components where one is ahead of release, would get out of sync! What is critical here is that actually this new version would be just fine for dandi-cli... so I might reconsider and
then this would
well, I think there is overall misunderstanding as we actually/apparently do not auto migrate metadata at all ATM! Server does not really care much, and client started to demand exact match to avoid missing recently added new metadata to be extracted/uploaded. Since here we talk about releaseNotes which client is not concerned about, it should not be concerned about being 'outdated' from client's perspective, so no boost of
thanks for the pointers! Indeed, would make sense to boost in that PR to this new version simply to allow for this new feature (since you hard-pin). |
Server might need then to either wait until upgrade it becomes capable of
validating them or we might in the future to allow client to downgrade them (on
client; loselessly only) since server cannot yet handle them.
This behavior would facilitate testing of new releases of dandi-schema which now
would fail since we require 1-to-1 correspondence. See e.g.
dandi/dandi-schema#342 (comment)
Server might need then to either wait until upgrade it becomes capable of
validating them or we might in the future to allow client to downgrade them (on
client; loselessly only) since server cannot yet handle them.
This behavior would facilitate testing of new releases of dandi-schema which now
would fail since we require 1-to-1 correspondence. See e.g.
dandi/dandi-schema#342 (comment)
|
@waxlamp here is my solution on dandi-cli side which I am planing to merge/release to largely decouple back client and server in terms of dandi-schema: please chime in! With that PR, if I revert here to upgrade within 0.6.x -- dandi-cli tests must not be affected! for 0.7.x indeed would keep failing ATM but in principle we could relax there too ;-) |
ecd02f9 to
5fd99be
Compare
candleindark
left a comment
There was a problem hiding this comment.
Left a comment. Will provide more.
candleindark
left a comment
There was a problem hiding this comment.
Left a few more comments.
| # before migration | ||
| if not skip_validation: | ||
| _validate_obj_json(obj, _get_jsonschema_validator(obj_ver, "Dandiset")) | ||
| _validate_obj_json(obj, _get_jsonschema_validator(obj_version, "Dandiset")) |
There was a problem hiding this comment.
This migration function seems to expect the metadata instance to be a Dandiset instance.
There was a problem hiding this comment.
Validating PublishedDandiset instance may create a problem if #266 is put in. However, I guess we can have it specifically validate against the PublishDandiset schema if a PublishedDandiset instance is provided.
fcc2a99 to
43cb3f6
Compare
should be done in #342 first
@yarikoptic The CI tests are not triggered correctly. We are not even supposed to be testing against Python 3.9 at this point. I don't think there is anything wrong with the workflow yaml files. There is possible some problem with some settings in the |
|
@yarikoptic Can we have an updated top post regarding this PR #342 (comment)? I want the see are the eventual intended change and what are decided eventually. The booting of |
|
@yarikoptic - is there an associated issue that this PR is responding to? i can imagine from the the title, but the description doesn't tell me the goal/use-case of the PR. |
|
@satra probably the best relevant is @candleindark I updated description and title a little. Hopefully makes it clearer. I will rebase and push and see if testing "coverage" changes/gets unstuck. |
Add pytest marker registration for 'ai_generated' to avoid PytestUnknownMarkWarning when running tests marked with @pytest.mark.ai_generated. This marker is used to identify tests generated by AI assistants, allowing them to be filtered or selected separately if needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
46074f2 to
3811813
Compare
This change introduces the ability to downgrade metadata schemas to recent versions, allowing for more flexible schema version management. Key changes: - Allow migration to version 0.6.10 in addition to the current version - Implement SIMPLE_DOWNGRADES mechanism for safe field removal during downgrade - Remove restriction preventing downgrade to lower schema versions - Add validation to prevent data loss when downgrading with populated fields - Add comprehensive tests for downgrade functionality with releaseNotes field The downgrade mechanism ensures data integrity by raising an error if a field being removed during downgrade contains a non-empty value. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Conflicts: dandischema/metadata.py -- both wanted to always set schema version to migrated-to dandischema/tests/test_metadata.py -- just added tests conflicted placement
3811813 to
427310a
Compare
…trings - SIMPLE_DOWNGRADES: "0.6.11" -> "0.7.0" (no 0.6.11 was ever released) - Add sameAs to downgrade fields (added on master via PR #364) - Include str in empty-value check so releaseNotes="" is treated as empty - Rewrite test to use DANDI_SCHEMA_VERSION and minimal metadata dict (0.6.11 was not in ALLOWED_INPUT_SCHEMAS, basic_publishmeta needed instance_name positional arg) - Add test coverage for sameAs downgrade (empty list, non-empty list) Co-Authored-By: Claude Code 2.1.63 / Claude Opus 4.6 <noreply@anthropic.com>
|
FYI: I adjusted branch protection rules now and 3.9 can RiP ! |
|
rright, not ready to release
as client then should introduce use of this downgrading functionality... I guess we might need to go for a patch jump in schema version which should make it "legit" in the eye of the client which has a more relaxed logic now. |
I would need to re-review since I thought that client is ok with upload of "compatible" one and here we should validate just fine... later |

Reminder to myself: we run checks on no changes to schema only on PRs with "release" tag. Thus we did not run checks when we actually adjusted the schema in
Then I rushed merging #341
as I was not expecting surprises from adjusting labels (forgot about above).
The moral again, do not rush merging - let CI finish! ;)
I think the motivation/aspects are best captured in
migrateand make dandi-cli usemigrate! #343but overall -- to facilitate upload to "older" server which might not be yet aware of a new(er) schema.
Boosting "patch" for both schema and library since just a "minor addition of a new feature" (mostly to schema).TODOs