Closed jwodder closed 7 months ago
Patch coverage: 100.00
% and project coverage change: +0.01
:tada:
Comparison is base (
845cb17
) 97.71% compared to head (37965fe
) 97.72%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
which methods do we actually use and can't we have some "shim" compatibility layer until we simply declare pydantic 2.0 to be the minimal supported version?
@yarikoptic I'm not certain that trying to support pydantic 1.x and 2.x at the same time is worthwhile.
For the record, the repositories under the dandi org that use pydantic are:
tools/populate_dandiset_asset_yamls.py
: Does not specify a versionsetup.py
and their recursive dependencies) should continue to use pydantic 1.x even after 2.x comes out, up until dandischema and zarr-checksum both permit use with pydantic 2.x.pydantic >= 1.9.0
. However, it depends on dandischema
and zarr_checksum
, which both specify an upper bound on pydantic of < 2.0
(and these are the only recursive dependencies that require pydantic), and so pip will either complain or (worse) backtrack if a user tries to install both dandi-cli and pydantic 2.0 in the same environment.
pydantic >= 1.8.1, < 2.0
tools/backups2datalad/
: Requires pydantic >= 1.8, < 2.0
tools/get-upload-status.py
: Requires pydantic >= 1.7, < 2.0
pydantic >= 1.8, < 2.0
pydantic >= 1.7, < 2.0
pydantic >= 1.10.2, < 2.0
- We should be strongly encouraging users to only install dandi in a fresh virtualenv or Conda environment
overall: we can't really encourage such things, especially because dandi is also a library. E.g. if some tool (or even downstream internal script) would requires already pydantic 2.0 or would not be ready to upgrade to it yet -- we can't just demand them to either use outdated dandi (which might not be "good enough") or downgrade back to 1.x pydantic since dandi is not ready yet. IMHO it was quite a bad decision from pydantic team to just break API without some compatibility shim with a DeprecationWarning and thus a more "gentle" deprecation cycle.
FWIW: I filed https://github.com/pydantic/pydantic/issues/5792
@jwodder - we got an answer at https://github.com/pydantic/pydantic/issues/5792#issuecomment-1562687862 and presumably with https://github.com/pydantic/pydantic/pull/5480 merged , I believe as http://github.com/samuelcolvin/pydantic/commit/e78dd92cf896797215d6d9870511a2d89941f87b
which is included in the v2.0a3~4. Could you please look at feasibility to keep dandischema compatible with both v1 and v2 by keeping using pydantic.v1
from that v2.0 pre-release?
@yarikoptic I believe that using any v1-specific features under v2 will result in DeprecationWarnings, which will have to be ignored by the pytest configurations for dandischema, dandi-cli, and any other similarly-configured test suites.
Ignoring by test suites is IMHO an acceptable cost during transition
@yarikoptic Remind me why we want to support both v1 and v2 at the same time in the first place.
so we could avoid needing < 2.0
in version specification of all components and bring them all up to compatibility with v2 in due time without needing to orchestrate transition of them at the same time. I see it as
<2.0
where they aren't compatible with v2 ( so we better do that ASAP anyways)>2.0a3
and remove <2.0
one component at a time, right away<2.0
removed -- stop using the shim in them one at a time.IMHO this would be smoother than striving to do migration in 1 go across all of those and who knows what to do with downstreams.
@yarikoptic At the moment, the pydantic.v1
namespace (added to the codebase on May 17) is not present in the latest pydantic 2.0 alpha release (made on May 5), so I cannot test support for both versions.
so I cannot test support for both versions.
can always be installed directly from git for testing, e.g. even from some specific committish to avoid "fluctuations" and later switch to pre-release whenever a2
is out.
FWIW, I thought to ask for a2
but it seems that overall pydantic release seems to be close, at least according to https://github.com/pydantic/pydantic/issues/5919 , so we better hurry with adding all the version restrictions and v1/v2 compatibility shimming.
@yarikoptic I've gotten the tests to pass with both v1 and v2 of pydantic, but the type-checking is failing with both. I've posted https://github.com/pydantic/pydantic/discussions/5971 to ask for a solution.
@jwodder , I don't want the typing check oddity to stop us prepare in time. Could we just skip that check inline in that location for now and get back to it whenever mypy folks reply?
@yarikoptic There are multiple failing checks all over the code, and it's only going to get worse when we try to apply this approach to other dandi packages.
closing this in relation to #203
Part of #176.
Note that we cannot make the code compatible with both pydantic 1.x and 2.x, as all pydantic instance methods have been renamed.