-
Notifications
You must be signed in to change notification settings - Fork 57
/
starter.py
39 lines (32 loc) · 1.08 KB
/
starter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import asyncio
import logging
from datetime import datetime
from ipaddress import IPv4Address
from temporalio.client import Client
from pydantic_converter.converter import pydantic_data_converter
from pydantic_converter.worker import MyPydanticModel, MyWorkflow
async def main():
logging.basicConfig(level=logging.INFO)
# Connect client using the Pydantic converter
client = await Client.connect(
"localhost:7233", data_converter=pydantic_data_converter
)
# Run workflow
result = await client.execute_workflow(
MyWorkflow.run,
[
MyPydanticModel(
some_ip=IPv4Address("127.0.0.1"),
some_date=datetime(2000, 1, 2, 3, 4, 5),
),
MyPydanticModel(
some_ip=IPv4Address("127.0.0.2"),
some_date=datetime(2001, 2, 3, 4, 5, 6),
),
],
id=f"pydantic_converter-workflow-id",
task_queue="pydantic_converter-task-queue",
)
logging.info("Got models from client: %s" % result)
if __name__ == "__main__":
asyncio.run(main())