Skip to content

Commit

Permalink
Feat: Docs for Pydantic Support (#1099)
Browse files Browse the repository at this point in the history
* feat: docs for pydantic

* fix: lint
  • Loading branch information
hatchet-temporary authored Dec 6, 2024
1 parent 1499668 commit e2ac89e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions frontend/docs/pages/sdks/python-sdk/pydantic.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { GithubSnippet, getSnippets } from "@/components/code";

export const PydanticPy = {
path: "examples/pydantic/worker.py",
};

export const getStaticProps = ({}) => getSnippets([PydanticPy]);

# Pydantic Support

Hatchet allows for you to optionally validate workflow inputs and step outputs using [Pydantic](https://docs.pydantic.dev/latest/).

### Usage

To enable Pydantic for validation, you'll need to:

1. Provide an `input_validator` as a parameter to your `workflow`.
2. Add return type hints for your `steps`.

In addition, for improved IDE support and static type checking, you'll need to use `typing.cast` to cast the `workflow_input` and `step_output` to their correct type.

### Example Usage

<GithubSnippet src={PydanticPy} target="Pydantic" />

0 comments on commit e2ac89e

Please sign in to comment.