Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

truly support pydantic v2 without shims #1662

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft

Conversation

technillogue
Copy link
Contributor

to avoid vendoring or forking fastapi, we need to actually use the v2 pydantic models. this aims to detect which pydantic version is used and reimplement cog types for pydantic 2

@technillogue technillogue force-pushed the syl/pydantic-v2 branch 3 times, most recently from f9bd152 to ca18776 Compare May 13, 2024 23:48
@technillogue technillogue marked this pull request as draft May 14, 2024 00:54
@technillogue technillogue force-pushed the syl/pydantic-v2 branch 2 times, most recently from 11aea8c to d01d74a Compare May 14, 2024 05:24
python/cog/predictor.py Outdated Show resolved Hide resolved
python/cog/predictor.py Outdated Show resolved Hide resolved
python/cog/predictor.py Outdated Show resolved Hide resolved
python/cog/schema.py Show resolved Hide resolved
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
…low for a value of None. It does not mean that the field has a default value of None. (This is a breaking change from V1.)

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
…ctly

Signed-off-by: technillogue <technillogue@gmail.com>
… and generating schemas

Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
Signed-off-by: technillogue <technillogue@gmail.com>
@yorickvP
Copy link
Contributor

The annotation is hopeless, typing.Annotated was added in python 3.9 and also doesn't seem to like being isinstance'd.

Tests in the commit before that are mainly failing because of openapi schema changes in 3.1.0: {'openapi': '3.1.0'} != {'openapi': '3.0.2'}, and also ge vs limit_value

@technillogue
Copy link
Contributor Author

technillogue commented May 20, 2024

thanks! unfortunately CI only shows the tip of the iceberg. this PR should ideally figure out how to test this with both old and new pydantic, because those have completely different pytest errors. there is something completely incorrect about the v2 validators. some of the main errors that I don't know how to approach are:

FAILED python/tests/server/test_http_output.py::test_output_file[client0] - AttributeError: 'pydantic_core._pydantic_core.SerializationIterator' object has no attribute 'decode'
FAILED python/tests/server/test_http.py::test_train_openapi_specification[client0] - pydantic.errors.PydanticInvalidForJsonSchema: Cannot generate a JsonSchema for core_schema.PlainValidatorFunctionSchema ({'type': 'no-info', 'function': <bound method Path.validate of <class 'cog.types.Path'>>})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants