Skip to content

Add ability to downgrade schema all the way to 0.6.10#342

Open
yarikoptic wants to merge 7 commits intomasterfrom
release-schema
Open

Add ability to downgrade schema all the way to 0.6.10#342
yarikoptic wants to merge 7 commits intomasterfrom
release-schema

Conversation

@yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Oct 27, 2025

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

Boosting "patch" for both schema and library since just a "minor addition of a new feature" (mostly to schema).

TODOs

@yarikoptic yarikoptic added minor Increment the minor version when merged release Create a release when this pr is merged labels Oct 27, 2025
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (8dff37f) to head (c1d0661).

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           
Flag Coverage Δ
unittests 97.84% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yarikoptic yarikoptic requested review from satra and waxlamp October 27, 2025 19:55
@yarikoptic
Copy link
Member Author

yarikoptic commented Oct 27, 2025

@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

ERROR tests/test_upload.py::test_upload_sync[False-False] - dandi.exceptions.SchemaVersionError: Server requires schema version 0.6.10; client only supports 0.7.0.  You may need to upgrade dandi and/or dandischema.

so the question(s)

  • do you see any problem with us aiming to update versioned depends/release dandi-archive ATM?
  • should we provide PR or you will?

@waxlamp
Copy link
Member

waxlamp commented Oct 29, 2025

@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

ERROR tests/test_upload.py::test_upload_sync[False-False] - dandi.exceptions.SchemaVersionError: Server requires schema version 0.6.10; client only supports 0.7.0.  You may need to upgrade dandi and/or dandischema.

How could this happen if you are pinning dandischema in the client (other than a user going out of their way to forcibly upgrade dandischema in their virtual environment after installing dandi-cli)?

(For the record, it seems that the CLI does indeed pin dandischema to a minor version.)

so the question(s)

  • do you see any problem with us aiming to update versioned depends/release dandi-archive ATM?

No problem, given that both the archive and the CLI are pinning to a specific version of dandischema already.

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.

  • should we provide PR or you will?

I imagine it would be part of dandi/dandi-archive#2606 (see this comment).

@yarikoptic
Copy link
Member Author

@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

ERROR tests/test_upload.py::test_upload_sync[False-False] - dandi.exceptions.SchemaVersionError: Server requires schema version 0.6.10; client only supports 0.7.0.  You may need to upgrade dandi and/or dandischema.

How could this happen if you are pinning dandischema in the client (other than a user going out of their way to forcibly upgrade dandischema in their virtual environment after installing dandi-cli)?

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

  • relax in dandi-cli to require the same MAJOR.MINOR only, not MAJOR.MINOR.PATCH (potentially with some hardcoded minimal we need since we were not consistent all the time before in 0.6 series)
  • make this to release 0.6.11 not 0.7.0 schema, so we absorb within MAJOR.MINOR even backward compatible enhancements . If we need server to demand newer client (e.g. we know client extracts new important metadata), we can demand via /server-info but IMHO there is no way to demand matching schema version

then this would

  • pass testing as long as we do not introduce backward compatible changes! and that is where cli might need to account for them

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.

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 minimal client version is needed.

  • should we provide PR or you will?

I imagine it would be part of dandi/dandi-archive#2606 (see this comment).

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).

yarikoptic added a commit to dandi/dandi-cli that referenced this pull request Oct 30, 2025
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)
yarikoptic added a commit to dandi/dandi-cli that referenced this pull request Oct 30, 2025
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)
@yarikoptic
Copy link
Member Author

@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 ;-)

@yarikoptic yarikoptic changed the title Release new schema 0.7.0 for addition of the releaseNotes Release new schema 0.6.11 for addition of the releaseNotes Nov 3, 2025
@yarikoptic yarikoptic changed the title Release new schema 0.6.11 for addition of the releaseNotes Add ability to downgrade schema to 0.6.10 (no releaseNotes) and release new schema 0.6.11 for addition of the releaseNotes Nov 13, 2025
Copy link
Member

@candleindark candleindark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment. Will provide more.

Copy link
Member

@candleindark candleindark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration function seems to expect the metadata instance to be a Dandiset instance.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yarikoptic yarikoptic changed the title Add ability to downgrade schema to 0.6.10 (no releaseNotes) and release new schema 0.6.11 for addition of the releaseNotes Add ability to downgrade schema to 0.6.10 Nov 21, 2025
@yarikoptic yarikoptic removed the release Create a release when this pr is merged label Nov 21, 2025
yarikoptic added a commit that referenced this pull request Mar 3, 2026
@candleindark
Copy link
Member

Screenshot 2026-03-03 at 1 14 17 PM

@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 Settings panel in this repo which I don't have access to. @bendichter may be able to provide some hint. I think he helped us solved a similar issue before.

@candleindark
Copy link
Member

@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 DANDI_SCHEMA_VERSION version as a minor bump is no longer accurate, for example.

@satra
Copy link
Member

satra commented Mar 4, 2026

@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.

@yarikoptic yarikoptic changed the title Add ability to downgrade schema to 0.6.10 Add ability to downgrade schema all the way to 0.6.10 Mar 4, 2026
@yarikoptic
Copy link
Member Author

@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>
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
…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>
@yarikoptic
Copy link
Member Author

FYI: I adjusted branch protection rules now and 3.9 can RiP !

@yarikoptic yarikoptic added the release Create a release when this pr is merged label Mar 4, 2026
@yarikoptic
Copy link
Member Author

rright, not ready to release

ERROR tests/test_upload.py::test_upload_nonzarr_to_zarr_path - dandi.exceptions.SchemaVersionError: Server uses older incompatible schema version 0.7.0; client supports 0.8.0.

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.

@yarikoptic
Copy link
Member Author

FAILED tests/test_download.py::test_download_newest_version - ValueError: Dandiset 000077 is Valid: {
    "asset_validation_errors": [
        {
            "field": "",
            "message": "Metadata version 0.7.1 is not allowed. Allowed are: 0.4.4, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.10, 0.7.0.",
            "path": "file.txt"
        },
        {
            "field": "",
            "message": "Metadata version 0.7.1 is not allowed. Allowed are: 0.4.4, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.10, 0.7.0.",
            "path": "subdir1/apple.txt"
        },
        {
            "field": "",
            "message": "Metadata version 0.7.1 is not allowed. Allowed are: 0.4.4, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.10, 0.7.0.",
            "path": "subdir2/banana.txt"
        },
        {
            "field": "",
            "message": "Metadata version 0.7.1 is not allowed. Allowed are: 0.4.4, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.10, 0.7.0.",
            "path": "subdir2/coconut.txt"
        }
    ],

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged release Create a release when this pr is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants