-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule_workflow.py
37 lines (31 loc) · 920 Bytes
/
schedule_workflow.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
# @@@SNIPSTART data-pipeline-schedule-workflow-python
import asyncio
from datetime import timedelta
from temporalio.client import (
Client,
Schedule,
ScheduleActionStartWorkflow,
ScheduleIntervalSpec,
ScheduleSpec,
ScheduleState,
)
from activities import TASK_QUEUE_NAME
from your_workflow import TemporalCommunityWorkflow
async def main():
client = await Client.connect("localhost:7233")
await client.create_schedule(
"top-stories-every-10-hours",
Schedule(
action=ScheduleActionStartWorkflow(
TemporalCommunityWorkflow.run,
id="temporal-community-workflow",
task_queue=TASK_QUEUE_NAME,
),
spec=ScheduleSpec(
intervals=[ScheduleIntervalSpec(every=timedelta(hours=10))]
),
),
)
if __name__ == "__main__":
asyncio.run(main())
# @@@SNIPEND