Repository navigation
Add a registry of dandi-archive features used only where supported - #1970
Closed
yarikoptic-gitmate wants to merge 5 commits into
Closed
yarikoptic-gitmate wants to merge 5 commits into
yarikoptic-gitmate wants to merge 5 commits into
Conversation
dandi-cli talks to several independently deployed dandi-archive instances, which gain new features at different times. Register such features in dandi/server_features.py as ServerFeature entries (CODENAME, description, refs, base_version, released_version, and a side-effect free sense function), and ask DandiAPIClient.server_features whether the server supports one. Support is decided once per client: - not, if the CODENAME is listed in DANDI_DEVEL_DISABLE_SERVER_FEATURES; - by the server version, if it is a dandi-archive release (development versions and versions of forks cannot be compared with releases); - otherwise by sensing; code which finds out by using a feature can record() it. routes_endpoint() probes for an API endpoint by comparing OPTIONS responses for it and for a path no server routes. Register ALLOWED_SCHEMA_VERSIONS, now used by check_schema_version(), and BULK_DELETE (dandi-archive#2920) for dandi-cli#1960 to use. A weekly "Survey server features" workflow runs test_survey (marked server_features_survey, skipped without --server-features-survey), which fails once all known instances support a registered feature, i.e., once its fallback can be removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU
…dandiapi dandi.dandiapi imports dandi.server_features, so the latter importing DandiAPIClient back (even only under TYPE_CHECKING) made CodeQL report a module-level cyclic import. Declare instead, as the APIClient Protocol, the few attributes of a DandiAPIClient which the module needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU
…her than '...' CodeQL reports a bare '...' body as a statement which has no effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1970 +/- ##
==========================================
+ Coverage 90.88% 90.97% +0.08%
==========================================
Files 92 94 +2
Lines 14244 14515 +271
==========================================
+ Hits 12946 13205 +259
- Misses 1298 1310 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The survey test runs only with --server-features-survey (weekly), so its logic, now in _survey(), is otherwise never run. Test it with mocked servers: support everywhere, an unreachable instance, a failing sense function, and missing support. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU
#1973 removed the fallback to dandischema's ALLOWED_INPUT_SCHEMAS for servers not reporting allowed_schema_versions: such a server now accepts no older client schema. With no prior implementation left to choose, the ALLOWED_SCHEMA_VERSIONS registry entry, its sensing function and its tests go, and check_schema_version() is master's. BULK_DELETE stays the one registered feature. DEVELOPMENT.md keeps master's LINC paragraph and its rule for removing a fallback once no known instance needs it, combined with the registry's description. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU
Member
|
ok, I will back-shelf it for now, especially since bulk delete is not even finalized yet... may be later we will work on this. |
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.
This is the follow-up planned in #1963. It adds a registry of the dandi-archive features which dandi-cli uses only where the server supports them, and adds the weekly survey and the disabling env var that it described.
What it adds
dandi/server_features.pyServerFeaturerecords, for each feature:base_version: the dandi-archive release the feature was developed on top of;released_version: the release that added it, once known;sense(client): a function that checks for the feature without changing anything on the server.SERVER_FEATURES.APIClientProtocol(api_url,session,server_info,get_url()) rather than importingdandi.dandiapi, which imports it; CodeQL flags the cycle even underTYPE_CHECKING.DandiAPIClient.server_featuresdecides, once per client:.supports("CODENAME") -> bool..resolve()also says how the answer was reached:disabled,version,sensedorrecorded..record("CODENAME", supported)lets code that found out by using the feature update the answer.How support is decided
Disabled, if the CODENAME is listed in
DANDI_DEVEL_DISABLE_SERVER_FEATURES(comma- or space-separated), e.g.BULK_DELETE. Unknown names are warned about and ignored.By version, only if
/api/info/'sversionis a clean dandi-archive release:version >= released_version: supported;version < released_version: not supported;version <= base_version: not supported.Development versions (sandbox instances) and versions with a post or local part (forks) do not count as releases, because they can't be compared with dandi-archive's. EMBER reports
0.0.post1.dev7927+g9e4606812and LINC0.0.post6586+g39387b8, so in practice only DANDI's own instances are decided by version.Otherwise by
sense().routes_endpoint(client, path)is a probe that does not modify anything. It sendsOPTIONStopathand to a sibling path that no server has, then compares status and content type.Registered feature:
BULK_DELETE(dandi/dandi-archive#2920, which is unmerged and based on 1.0.19).routes_endpoint()on/dandisets/000000/versions/draft/assets/bulk-delete/.ALLOWED_SCHEMA_VERSIONSand sentcheck_schema_version()'s fallback through the registry. Remove dandi-archive compatibility kludges that no known instance needs #1973 has since removed that fallback, so the merge with master dropped the entry and kept master'scheck_schema_version(). This PR no longer changesdandi/dandiapi.pybeyond addingserver_features.Survey of known instances.
test_survey[CODENAME]checks every instance inknown_instancesexcept the local Docker one.server_features_surveyand skipped unless--server-features-surveyis given..github/workflows/server-features.yml: weekly (Mondays 05:23 UTC), on demand, and on PRs that touch the registry. Its run on this PR gave the table below.Docs
dandi.server_featuresis added.Checked against live servers
The survey job on this PR, before the merge with master, produced:
From the environment this was prepared in, only
lincbrain.orgwas reachable; DANDI and EMBER hosts were blocked by its network policy.BULK_DELETEisno (sensed)(also after the merge), and they lackallowed_schema_versions.routes_endpoint()returnsTruefor routes LINC has (…/assets/paths/,/zarr/);Falsefor…/assets/bulk-delete/and for a made-up path.test_local_archivechecks the probe against the Docker archive (dandiarchive/dandiarchive-api) in CI'sdandi-apijobs. Docker Hub rate-limited the image pull here.Notes
client.server_features.supports("BULK_DELETE")instead of inferring support from a 404. That 404 can't tell an old server from a missing version.DandiAPIClient, likeserver_info. The DEVELOPMENT.md: require backward compatible support of new dandi-archive features #1963 plan suggested keying them by API URL across clients. Per client is simpler to reason about and to test, and the CLI uses one client per command; I can switch if preferred.x-amz-tagginghandling in Zarr upload, which senses from each presigned URL rather than once per server;_get_instance()'s/server-info→/api/info/fallback, which happens before a client has any server info.Testing
test_server_features.py(new,ai_generated):record(), unknown CODENAMEs, the probe's responses, registry hygiene, and the survey's report;test_local_archive, against the Docker archive;test_survey[BULK_DELETE].--server-features-survey(LINC rowsno (sensed), others unreachable);-W;-m "not obolibrary"), before the merge with master: 916 passed, 26 failed. All 26 failures are tests that needdandiarchive.org, which that environment's network policy blocks (proxy errors and timeouts); CI runs them with network access.test_server_features.py, thecheck_schema_version()and downgrade tests intest_dandiapi.py, the_check_attempts_and_sleep()tests, the survey, pre-commit, mypy and the docs build with-Wall pass.🤖 Generated with Claude Code
https://claude.ai/code/session_014sJtxzEPbSxycxetp4DquU