diff --git a/docs/user_guide/data_types_and_io/accessing_attributes.md b/docs/user_guide/data_types_and_io/accessing_attributes.md index 75dad9ff3d..82b2345ad5 100644 --- a/docs/user_guide/data_types_and_io/accessing_attributes.md +++ b/docs/user_guide/data_types_and_io/accessing_attributes.md @@ -23,7 +23,7 @@ To begin, import the required dependencies and define a common task for subseque ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 1-10 +:lines: 1-9 ``` ## List @@ -35,7 +35,7 @@ Flyte currently does not support output promise access through list slicing. ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 14-23 +:lines: 13-22 ``` ## Dictionary @@ -43,7 +43,7 @@ Access the output dictionary by specifying the key. ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 27-35 +:lines: 26-34 ``` ## Data class @@ -51,7 +51,7 @@ Directly access an attribute of a dataclass. ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 39-53 +:lines: 38-51 ``` ## Complex type @@ -59,14 +59,14 @@ Combinations of list, dict and dataclass also work effectively. ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 57-80 +:lines: 55-78 ``` You can run all the workflows locally as follows: ```{literalinclude} /examples/data_types_and_io/data_types_and_io/attribute_access.py :caption: data_types_and_io/attribute_access.py -:lines: 84-88 +:lines: 82-86 ``` ## Failure scenario diff --git a/docs/user_guide/data_types_and_io/index.md b/docs/user_guide/data_types_and_io/index.md index d8e72dabce..c554b08acd 100644 --- a/docs/user_guide/data_types_and_io/index.md +++ b/docs/user_guide/data_types_and_io/index.md @@ -114,7 +114,7 @@ Here's a breakdown of these mappings: - Use ``pyspark.DataFrame`` as a type hint. * - ``pydantic.BaseModel`` - ``Map`` - - To utilize the type, install the ``flytekitplugins-pydantic`` plugin. + - To utilize the type, install the ``pydantic>2`` module. - Use ``pydantic.BaseModel`` as a type hint. * - ``torch.Tensor`` / ``torch.nn.Module`` - File @@ -144,7 +144,7 @@ flytefile flytedirectory structureddataset dataclass -pydantic +pydantic_basemodel accessing_attributes pytorch_type enum_type diff --git a/docs/user_guide/data_types_and_io/pydantic.md b/docs/user_guide/data_types_and_io/pydantic_basemodel.md similarity index 82% rename from docs/user_guide/data_types_and_io/pydantic.md rename to docs/user_guide/data_types_and_io/pydantic_basemodel.md index c9647213fd..4191e06c8e 100644 --- a/docs/user_guide/data_types_and_io/pydantic.md +++ b/docs/user_guide/data_types_and_io/pydantic_basemodel.md @@ -1,4 +1,4 @@ -(pydantic)= +(pydantic_basemodel)= # Pydantic BaseModel @@ -6,21 +6,22 @@ .. tags:: Basic ``` -When you've multiple values that you want to send across Flyte entities, and you want them to have, you can use a `pydantic.BaseModel`. -Note: -You can put Dataclass and FlyteTypes (FlyteFile, FlyteDirectory, FlyteSchema, and StructuredDataset) in a pydantic BaseModel. +When you have multiple values that you want to send across Flyte entities, and you want them to have, you can use a `pydantic.BaseModel`. :::{important} Pydantic BaseModel V2 only works when you are using flytekit version >= v1.14.0. ::: :::{important} -If you're using Flytekit version >= v1.14.0 and you want to produce protobuf struct literal for pydantic basemodels, +If you're using Flytekit version >= v1.14.0 and you want to produce protobuf struct literal for Pydantic BaseModels, you can set environment variable `FLYTE_USE_OLD_DC_FORMAT` to `true`. -For more details, you can refer the MSGPACK IDL RFC: https://github.com/flyteorg/flyte/blob/master/rfc/system/5741-binary-idl-with-message-pack.md +For more details, you can refer the MESSAGEPACK IDL RFC: https://github.com/flyteorg/flyte/blob/master/rfc/system/5741-binary-idl-with-message-pack.md ::: +```{note} +You can put Dataclass and FlyteTypes (FlyteFile, FlyteDirectory, FlyteSchema, and StructuredDataset) in a pydantic BaseModel. +``` ```{note} To clone and run the example code on this page, see the [Flytesnacks repo][flytesnacks]. @@ -40,14 +41,14 @@ Build your custom image with ImageSpec: ``` ## Python types -We define a `dataclass` with `int`, `str` and `dict` as the data types. +We define a `pydantic basemodel` with `int`, `str` and `dict` as the data types. ```{literalinclude} /examples/data_types_and_io/data_types_and_io/pydantic_basemodel.py :caption: data_types_and_io/pydantic_basemodel.py :pyobject: Datum ``` -You can send a `dataclass` between different tasks written in various languages, and input it through the Flyte console as raw JSON. +You can send a `pydantic basemodel` between different tasks written in various languages, and input it through the Flyte console as raw JSON. :::{note} All variables in a data class should be **annotated with their type**. Failure to do should will result in an error.