Files
hatchet/examples/python/dataclasses/worker.py
github-actions[bot] f12c3e96ce chore: regenerate examples (#2477)
Co-authored-by: GitHub Action <action@github.com>
2025-11-01 00:28:24 +01:00

32 lines
521 B
Python

from dataclasses import dataclass
from typing import Literal
from hatchet_sdk import Context, EmptyModel, Hatchet
@dataclass
class Input:
name: str
@dataclass
class Output:
message: str
hatchet = Hatchet(debug=True)
@hatchet.task(input_validator=Input)
def say_hello(input: Input, ctx: Context) -> Output:
return Output(message=f"Hello, {input.name}!")
def main() -> None:
worker = hatchet.worker("test-worker", workflows=[say_hello])
worker.start()
if __name__ == "__main__":
main()