From 23e3696b642811cd7bdd15bc32e6c5af1fabd8f7 Mon Sep 17 00:00:00 2001 From: sumana sree Date: Mon, 21 Oct 2024 10:07:33 +0530 Subject: [PATCH] fixed lint errors Signed-off-by: sumana sree --- examples/pydantic_plugin/README.md | 4 ++-- .../pydantic_plugin/pydantic_integration_example.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/pydantic_plugin/README.md b/examples/pydantic_plugin/README.md index 45bdd8119..f53ab0007 100644 --- a/examples/pydantic_plugin/README.md +++ b/examples/pydantic_plugin/README.md @@ -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: diff --git a/examples/pydantic_plugin/pydantic_plugin/pydantic_integration_example.py b/examples/pydantic_plugin/pydantic_plugin/pydantic_integration_example.py index 0c52f58c8..23a253829 100644 --- a/examples/pydantic_plugin/pydantic_plugin/pydantic_integration_example.py +++ b/examples/pydantic_plugin/pydantic_plugin/pydantic_integration_example.py @@ -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. @@ -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. # %% @@ -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. # %% @@ -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. # %%