Skip to main content

dagster-pydantic

This is a naive approach for using Pydantic types for Dagster Type Checking. The package dagster_pydantic includes a really simple validation factory. Pydanitc is not built as a data validation library, it's actually a great parser and an OK validator in that order.

The purpose of this validation step is to ensure the shape of the model is correct before the data is consumed by the next op. Pydantic will stop you during the instantiation of your model if the data is not up to spec but if you want to check if the shape of the parsed data will match the model, that's where the validation layer comes in.

Usage

class MyPydanticModel(BaseModel):
    """
    This is a Pydantic model.
    """
    a: int
    b: str


MyPydanticModelDT = pydantic_to_dagster_type(MyPydanticModel)

@op(out=Out(MyPydanticModelDT))
def get_model():
    model = MyPydanticModel(
        a = 1,
        b = "hello"
    )
    # This should fail type checking in the Dagit UI.
    model.b = {} # type: ignore
    return model

This code will result in:

A typechecking error in the dagit UI

Without this integration, you wouldn't see that typechecking error in the console and the next op will consume a dict in place of a str.

Developing

First, install Just

$ just install

This will run two poetry commands in your current terminal, one that configures venvs to be in the project directory so the dependencies are accessable from your local environment. The other will install the dependencies.

$ just shell

This opens a current shell into your poetry virtual env.

Running tests

$ just test # This only runs pytest

Disclaimer

I've only had my hands on Dagster for a few weeks. I love the declarative framework, and the focus on flexibility + developer velocity. I am a bit iffy on the pricing and what's offered in the "Standard plan", but otherwise I'm so impressed by the open-source project.

That being said, I'm a noobie. This is my first integration and also my first Python module, so feel free to drop an issue if there's something I'm missing.

Release files for dagster-pydantic 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dagster-pydantic 0.1.0
File Size Uploaded
dagster_pydantic-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dagster-pydantic 0.1.0
File Interpreter ABI Platform
dagster_pydantic-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.4 kB

Release files / dagster_pydantic-0.1.0.tar.gz

Download URL dagster_pydantic-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a120bb79290de6764b6daaf231d0ca62c3f1913f627c6c77d0ec143437e3dc95
BLAKE2b-256 checksum
How to use checksums
f62132d76a6e64ae10b3058614577ef3715a64d0072ec98352e1823822e8de62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.1 Darwin/21.3.0

Release files / dagster_pydantic-0.1.0-py3-none-any.whl

Download URL dagster_pydantic-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b3af527296f414fa16be865cdef3d7acb3deefad43465a9b526b13f90ae349ae
BLAKE2b-256 checksum
How to use checksums
bd325b6a4dca2ceb4c379820469a5b7d53ca186cced8870a4081b14dc0c60955
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.1 Darwin/21.3.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page