<#3131 publish pandera deck> Pull request opened b...
# flyte-github
c
#3131 publish pandera deck Pull request opened by cosmicBboy Tracking issue https://linear.app/unionai/issue/DX-1315/update-pandera-flytekit-plugin-to-use-streaming-decks Why are the changes needed? Changes support publishing the pandera deck even when a validation error is raised What changes were proposed in this pull request? Call
Deck.publish
in the pandera type transformer. How was this patch tested? Created local flyte cluster with •
make -C docker/sandbox-bundled build
on flyte master branch •
flytectl demo start --image flyte-sandbox:latest
Then ran the following script `foo.py`: import typing from typing import Annotated import json import pandas as pd import pandera as pa from flytekit import ImageSpec, task, workflow from flytekitplugins.pandera import ValidationConfig from pandera.typing import DataFrame, Series custom_image = ImageSpec( apt_packages=["git"], packages=[ "git+https://github.com/flyteorg/flytekit@9ebc57e27#subdirectory=plugins/flytekit-pandera", "scikit-learn", "pyarrow", ], registry="localhost:30000", ) class InSchema(pa.DataFrameModel): hourly_pay: float = pa.Field(ge=7) hours_worked: float = pa.Field(ge=10) number: int another_number: int @pa.check("hourly_pay", "hours_worked") def check_numbers_are_positive(cls, series: Series) -> Series[bool]: """Defines a column-level custom check.""" return series > 0 class Config: coerce = True class IntermediateSchema(InSchema): total_pay: float @pa.dataframe_check def check_total_pay(cls, df: DataFrame) -> Series[bool]: """Defines a dataframe-level custom check.""" return df["total_pay"] == df["hourly_pay"] * df["hours_worked"] class OutSchema(IntermediateSchema): worker_id: Series[str] = pa.Field() config = ValidationConfig(on_error="error") def fn(df: DataFrame[InSchema]): ... @task(container_image=custom_image, enable_deck=True, deck_fields=[]) def json_to_dataframe(data: str) -> Annotated[DataFrame[InSchema], config]: """Helper task to convert a dictionary input to a dataframe.""" data = json.loads(data) return pd.DataFrame(data) @task(container_image=custom_image, enable_deck=True, deck_fields=[]) def total_pay(df: Annotated[DataFrame[InSchema], config]) -> Annotated[DataFrame[IntermediateSchema], config]: # noqa : F811 return df.assign(total_pay=df.hourly_pay * df.hours_worked) @task(container_image=custom_image, enable_deck=True, deck_fields=[]) def add_ids( df: Annotated[DataFrame[IntermediateSchema], config], worker_ids: typing.List[str], ) -> Annotated[DataFrame[OutSchema], config]: return df # return df.assign(worker_id=worker_ids) @workflow def process_data( # noqa : F811 data: str = '{"hourly_pay": [1, 8, 9], "hours_worked": [30.5, 40.0, -1.0], "number": ["a", "b", "c"], "another_number": ["d", "e", "f"]}', worker_ids: typing.List[str] = ["a", "b", "c"], ) -> Annotated[DataFrame[OutSchema], config]: return add_ids(df=total_pay(df=json_to_dataframe(data=data)), worker_ids=worker_ids) Run with pyflyte run --remote foo.py process_data Screenshots image Check all the applicable boxes • I updated the documentation accordingly. • All new and existing tests passed. • All commits are signed-off. Related PRs Docs link Summary by Bito Enhancement to Pandera plugin implementing automatic real-time deck publication, enabling immediate visibility of validation results regardless of validation status. The update removes redundant documentation, modifies deck creation logic for immediate publication, and updates flytekit dependency to version 1.15.0b2 to support new functionality. Unit tests added: False Estimated effort to review (1-5, lower is better): 1 flyteorg/flytekit