pydantic-kedro
Advanced serialization for Pydantic models via Kedro and fsspec.
This package implements custom Kedro "datasets" for both "pure" and "arbitrary" Pydantic models. You can also use it stand-alone, using Kedro just for serializing other object types.
Please see the documentation for a tutorial and more examples.
Usage with Kedro
You can use the [PydanticAutoDataset][pydantic_kedro.PydanticAutoDataset]
or any other dataset from pydantic-kedro within your
Kedro catalog
to save your Pydantic models:
# conf/base/catalog.yml
my_pydantic_model:
type: pydantic_kedro.PydanticAutoDataset
filepath: folder/my_model
Direct Dataset Usage
This example works for "pure", JSON-safe Pydantic models via
PydanticJsonDataset:
from pydantic import BaseModel
# from pydantic.v1 import BaseModel # Pydantic V2
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
Standalone Usage
You can also use pydantic-kedro as a generic saving and loading engine for
Pydantic models:
from tempfile import TemporaryDirectory
from pydantic.v1 import BaseModel
from pydantic_kedro import load_model, save_model
class MyModel(BaseModel):
"""My custom model."""
name: str
# We can use any fsspec URL, so we'll make a temporary folder
with TemporaryDirectory() as tmpdir:
save_model(MyModel(name="foo"), f"{tmpdir}/my_model")
obj = load_model(f"{tmpdir}/my_model")
assert obj.name == "foo"
Metadata
Release files for pydantic-kedro 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pydantic-kedro-0.8.0.tar.gz | 31.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_kedro-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.4 kB
Release files / pydantic-kedro-0.8.0.tar.gz
| Download URL | pydantic-kedro-0.8.0.tar.gz |
|---|---|
| Size | 31.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ece5dae30006251edcf75dc3c1bddc1c37b874935e4d3cdbc2a10e2598e65de1
|
|
BLAKE2b-256 checksum How to use checksums |
aba6a2b2c2a7b367f02e601d3f32dea6961550df5b190361e0e29c636d6de093
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / pydantic_kedro-0.8.0-py3-none-any.whl
| Download URL | pydantic_kedro-0.8.0-py3-none-any.whl |
|---|---|
| Size | 22.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2652a7639119754c73f935f52557138a2b26d722208b0a5875093dc0b562854b
|
|
BLAKE2b-256 checksum How to use checksums |
a62dff942492a6061a8e5a70f69df6d8c25c6f90f7049339c3a9ef59a126bd0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for pydantic-kedro 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.