From 07124bd1544705cc3e2a4b5a5085f095cc0404d6 Mon Sep 17 00:00:00 2001 From: Mohammed Nafees Date: Mon, 16 Mar 2026 13:13:01 +0100 Subject: [PATCH] all python async --- .../python/scheduled/programatic-async.py | 25 +++++++++++++++++ frontend/docs/pages/v1/cron-runs.mdx | 6 ++-- frontend/docs/pages/v1/scheduled-runs.mdx | 14 ++++++---- .../examples/scheduled/programatic-async.py | 28 +++++++++++++++++++ 4 files changed, 64 insertions(+), 9 deletions(-) diff --git a/examples/python/scheduled/programatic-async.py b/examples/python/scheduled/programatic-async.py index abe9d3931..7a8314f73 100644 --- a/examples/python/scheduled/programatic-async.py +++ b/examples/python/scheduled/programatic-async.py @@ -1,6 +1,7 @@ from datetime import datetime, timedelta, timezone from hatchet_sdk import Hatchet +from hatchet_sdk.clients.rest.models.scheduled_run_status import ScheduledRunStatus hatchet = Hatchet() @@ -20,6 +21,12 @@ async def create_scheduled() -> None: scheduled_run.metadata.id # the id of the scheduled run trigger + # > Reschedule + await hatchet.scheduled.aio_update( + scheduled_id=scheduled_run.metadata.id, + trigger_at=datetime.now(tz=timezone.utc) + timedelta(hours=1), + ) + # > Delete await hatchet.scheduled.aio_delete(scheduled_id=scheduled_run.metadata.id) @@ -30,3 +37,21 @@ async def create_scheduled() -> None: scheduled_run = await hatchet.scheduled.aio_get( scheduled_id=scheduled_run.metadata.id ) + + id = scheduled_run.metadata.id + + # > Bulk Delete + await hatchet.scheduled.aio_bulk_delete(scheduled_ids=[id]) + + await hatchet.scheduled.aio_bulk_delete( + workflow_id="workflow_id", + statuses=[ScheduledRunStatus.SCHEDULED], + additional_metadata={"customer_id": "customer-a"}, + ) + + # > Bulk Reschedule + await hatchet.scheduled.aio_bulk_update( + [ + (id, datetime.now(tz=timezone.utc) + timedelta(hours=2)), + ] + ) diff --git a/frontend/docs/pages/v1/cron-runs.mdx b/frontend/docs/pages/v1/cron-runs.mdx index f357c5885..aeddf07f4 100644 --- a/frontend/docs/pages/v1/cron-runs.mdx +++ b/frontend/docs/pages/v1/cron-runs.mdx @@ -84,7 +84,7 @@ Cron triggers can be created via the API at runtime, useful when the schedule is - + @@ -109,7 +109,7 @@ A cron trigger is deleted by passing its ID to the delete method. - + @@ -133,7 +133,7 @@ Returns all cron triggers matching the provided criteria. - + diff --git a/frontend/docs/pages/v1/scheduled-runs.mdx b/frontend/docs/pages/v1/scheduled-runs.mdx index 73ceee430..f80dc907e 100644 --- a/frontend/docs/pages/v1/scheduled-runs.mdx +++ b/frontend/docs/pages/v1/scheduled-runs.mdx @@ -24,7 +24,7 @@ Scheduled runs can be created programmatically. This gives an option for the tri - + @@ -48,7 +48,7 @@ The API returns a scheduled run object whose ID should be persisted. It is requi - + @@ -65,7 +65,7 @@ The API returns a scheduled run object whose ID should be persisted. It is requi - + @@ -82,7 +82,7 @@ The API returns a scheduled run object whose ID should be persisted. It is requi - + @@ -111,8 +111,10 @@ Hatchet supports bulk delete and bulk reschedule operations for scheduled runs. - - + + None: scheduled_run.metadata.id # the id of the scheduled run trigger # !! + # > Reschedule + await hatchet.scheduled.aio_update( + scheduled_id=scheduled_run.metadata.id, + trigger_at=datetime.now(tz=timezone.utc) + timedelta(hours=1), + ) + # !! + # > Delete await hatchet.scheduled.aio_delete(scheduled_id=scheduled_run.metadata.id) # !! @@ -34,3 +42,23 @@ async def create_scheduled() -> None: scheduled_id=scheduled_run.metadata.id ) # !! + + id = scheduled_run.metadata.id + + # > Bulk Delete + await hatchet.scheduled.aio_bulk_delete(scheduled_ids=[id]) + + await hatchet.scheduled.aio_bulk_delete( + workflow_id="workflow_id", + statuses=[ScheduledRunStatus.SCHEDULED], + additional_metadata={"customer_id": "customer-a"}, + ) + # !! + + # > Bulk Reschedule + await hatchet.scheduled.aio_bulk_update( + [ + (id, datetime.now(tz=timezone.utc) + timedelta(hours=2)), + ] + ) + # !!