Skip to content

Commit

Permalink
fixed lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: sumana sree <[email protected]>
  • Loading branch information
sumana-2705 committed Oct 21, 2024
1 parent 8ff18ef commit 23e3696
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/pydantic_plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
```{eval-rst}
.. tags:: Pydantic, Flytekit
```
[Pydantic](https://pydantic.dev/) is a data validation and settings management library that leverages Python type annotations to enforce type hints at runtime. It provides user-friendly errors when data is invalid, making it easier to ensure data integrity.
[Pydantic](https://pydantic.dev/) is a data validation and settings management library that leverages Python type annotations to enforce type hints at runtime. It provides user-friendly errors when data is invalid, making it easier to ensure data integrity.

The Flytekit Pydantic plugin adds type support for Pydantic models, enabling seamless integration of data validation and settings management within Flyte tasks and workflows. This documentation demonstrates how to integrate Pydantic with Flytekit using the Flytekit Pydantic plugin.

## Installation
## Installation

To install the Flytekit Pydantic plugin, run the following command:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# Flyte leverages Pydantic for robust input validation and serialization, ensuring that task inputs are correctly structured.

# %%
from pydantic.v1 import BaseModel
from typing import List

from flytekit import task, workflow
from flytekit.types.file import FlyteFile
from typing import List
from pydantic.v1 import BaseModel


# %% [markdown]
# Let's first define a Pydantic model for training configuration.
Expand All @@ -21,6 +23,7 @@ class TrainConfig(BaseModel):
batch_size: int = 32 # Batch size for training
files: List[FlyteFile] # List of file inputs for training


# %% [markdown]
# Next, we use the Pydantic model in a Flyte task to train a model.
# %%
Expand All @@ -30,6 +33,7 @@ def train(cfg: TrainConfig):
for file in cfg.files:
print(f"Processing file: {file}")


# %% [markdown]
# Now we define a Flyte workflow that utilizes the training task.
# %%
Expand All @@ -38,6 +42,7 @@ def training_workflow(lr: float = 1e-3, batch_size: int = 32, files: List[FlyteF
cfg = TrainConfig(lr=lr, batch_size=batch_size, files=files)
train(cfg=cfg)


# %% [markdown]
# Finally, we execute the workflow with sample parameters.
# %%
Expand Down

0 comments on commit 23e3696

Please sign in to comment.