Skip to main content

Kedro

Project description

pydantic-kedro

Advanced serialization for Pydantic models via Kedro and fsspec.

This package implements custom Kedro "datasets" for both "pure" and "arbitrary" Pydantic models.

Please see the docs for a tutorial and more examples.

Minimal Example

This example works for "pure", JSON-safe Pydantic models via PydanticJsonDataSet:

from pydantic import BaseModel
from pydantic_kedro import PydanticJsonDataSet


class MyPureModel(BaseModel):
    """Your custom Pydantic model with JSON-safe fields."""

    x: int
    y: str


obj = MyPureModel(x=1, y="why?")

# Create an in-memory (temporary) file via `fsspec` and save it
ds = PydanticJsonDataSet("memory://temporary-file.json")
ds.save(obj)

# We can re-load it from the same file
read_obj = ds.load()
assert read_obj.x == 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic-kedro-0.1.2.tar.gz (19.7 kB view hashes)

Uploaded Source

Built Distribution

pydantic_kedro-0.1.2-py3-none-any.whl (11.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page