You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should still expose some flexibility to build JSON schemas for packages which used Pydantic V1.
The args_schema_version can be set by one of these:
Explicitly set to pydantic_v1 -> use "legacy" tools (the ones based on pydantic.v1 imports). Note that this is not guaranteed to work in case you re-use fractal-tasks-core task-argument models, as they will soon be moved to Pydantic V2 (ref Move core-library and tasks to Pydantic V2 #790).
Explicitly set to pydantic_v2 -> use new tools
Unset -> read the Pydantic version at import time (during manifest generation), and pick one of the previous two cases.
Note that I would keep this flexibility as a legacy feature, with the plan of deprecating it in favor of Pydantic-V2-only at some point in the future (when we assess that no relevant task package depends on Pydantic V1).
As we've known for a while, Pydantic V2 generates anyOf properties for e.g. Optional[str] arguments (ref #375). Within https://github.com/fractal-analytics-platform/fractal-tasks-core/tree/remove-anyof-from-pydantic-v2-schema, I am preparing several possible customizations of PydanticV2 schema generation (one is notably missing, namely the one where we postprocess the schema) to generate schemas that are identical or similar to the pydantic_v1 ones -- see snippet below. These solutions are working, for simple examples, but I'll need to test more systematically on the whole fractal-tasks-core (as of #790 - cc @lorenzocerrone) and/or on the other packages we use for testing JSON-schema generation.
This should still expose some flexibility to build JSON schemas for packages which used Pydantic V1.
The
args_schema_version
can be set by one of these:pydantic_v1
-> use "legacy" tools (the ones based onpydantic.v1
imports). Note that this is not guaranteed to work in case you re-use fractal-tasks-core task-argument models, as they will soon be moved to Pydantic V2 (ref Move core-library and tasks to Pydantic V2 #790).pydantic_v2
-> use new toolsNote that I would keep this flexibility as a legacy feature, with the plan of deprecating it in favor of Pydantic-V2-only at some point in the future (when we assess that no relevant task package depends on Pydantic V1).
As we've known for a while, Pydantic V2 generates
anyOf
properties for e.g.Optional[str]
arguments (ref #375). Within https://github.com/fractal-analytics-platform/fractal-tasks-core/tree/remove-anyof-from-pydantic-v2-schema, I am preparing several possible customizations of PydanticV2 schema generation (one is notably missing, namely the one where we postprocess the schema) to generate schemas that are identical or similar to thepydantic_v1
ones -- see snippet below. These solutions are working, for simple examples, but I'll need to test more systematically on the whole fractal-tasks-core (as of #790 - cc @lorenzocerrone) and/or on the other packages we use for testing JSON-schema generation.fractal-tasks-core/fractal_tasks_core/dev/lib_args_schemas_pydantic_v2.py
Lines 126 to 209 in 022501c
The text was updated successfully, but these errors were encountered: