-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs * drop the sub mod * chore: gen * feat: scheduled and cron * chore: generate * release
- Loading branch information
Showing
33 changed files
with
5,776 additions
and
992 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Hatchet Python SDK | ||
|
||
This is the [Hatchet](https://hatchet.run) Python SDK. For usage, see the [docs](https://docs.hatchet.run/sdks/python-sdk/). | ||
This is the [Hatchet](https://hatchet.run) Python SDK. For usage, see the [docs](https://docs.hatchet.run). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from dotenv import load_dotenv | ||
|
||
from hatchet_sdk import Hatchet | ||
|
||
load_dotenv() | ||
|
||
hatchet = Hatchet() | ||
|
||
|
||
async def create_cron(): | ||
# ❓ Create | ||
cron_trigger = await hatchet.cron.aio.create( | ||
workflow_name="simple-cron-workflow", | ||
cron_name="customer-a-daily-report", | ||
expression="0 12 * * *", | ||
input={ | ||
"name": "John Doe", | ||
}, | ||
additional_metadata={ | ||
"customer_id": "customer-a", | ||
}, | ||
) | ||
|
||
id = cron_trigger.metadata.id # the id of the cron trigger | ||
# !! | ||
|
||
# ❓ Delete | ||
await hatchet.cron.aio.delete(cron_trigger=cron_trigger.metadata.id) | ||
# !! | ||
|
||
# ❓ List | ||
cron_triggers = await hatchet.cron.aio.list() | ||
# !! | ||
|
||
# ❓ Get | ||
cron_trigger = await hatchet.cron.aio.get(cron_trigger=cron_trigger.metadata.id) | ||
# !! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from dotenv import load_dotenv | ||
|
||
from hatchet_sdk import Hatchet | ||
|
||
load_dotenv() | ||
|
||
hatchet = Hatchet() | ||
|
||
# ❓ Create | ||
cron_trigger = hatchet.cron.create( | ||
workflow_name="simple-cron-workflow", | ||
cron_name="customer-a-daily-report", | ||
expression="0 12 * * *", | ||
input={ | ||
"name": "John Doe", | ||
}, | ||
additional_metadata={ | ||
"customer_id": "customer-a", | ||
}, | ||
) | ||
|
||
id = cron_trigger.metadata.id # the id of the cron trigger | ||
# !! | ||
|
||
# ❓ Delete | ||
hatchet.cron.delete(cron_trigger=cron_trigger.metadata.id) | ||
# !! | ||
|
||
# ❓ List | ||
cron_triggers = hatchet.cron.list() | ||
# !! | ||
|
||
# ❓ Get | ||
cron_trigger = hatchet.cron.get(cron_trigger=cron_trigger.metadata.id) | ||
# !! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import time | ||
|
||
from dotenv import load_dotenv | ||
|
||
from hatchet_sdk import Context, Hatchet | ||
|
||
load_dotenv() | ||
|
||
hatchet = Hatchet(debug=True) | ||
|
||
|
||
# ❓ Workflow Definition Cron Trigger | ||
# Adding a cron trigger to a workflow is as simple | ||
# as adding a `cron expression` to the `on_cron` | ||
# prop of the workflow definition | ||
@hatchet.workflow(on_cron="* * * * *") | ||
class CronWorkflow: | ||
@hatchet.step() | ||
def step1(self, context: Context): | ||
|
||
return { | ||
"time": "step1", | ||
} | ||
|
||
|
||
# !! | ||
|
||
|
||
def main(): | ||
workflow = CronWorkflow() | ||
worker = hatchet.worker("test-worker", max_runs=1) | ||
worker.register_workflow(workflow) | ||
worker.start() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from datetime import datetime, timedelta | ||
|
||
from dotenv import load_dotenv | ||
|
||
from hatchet_sdk import Hatchet | ||
from hatchet_sdk.clients.rest.models.scheduled_workflows import ScheduledWorkflows | ||
|
||
load_dotenv() | ||
|
||
hatchet = Hatchet() | ||
|
||
|
||
async def create_scheduled(): | ||
# ❓ Create | ||
scheduled_run = await hatchet.scheduled.aio.create( | ||
workflow_name="simple-workflow", | ||
trigger_at=datetime.now() + timedelta(seconds=10), | ||
input={ | ||
"data": "simple-workflow-data", | ||
}, | ||
additional_metadata={ | ||
"customer_id": "customer-a", | ||
}, | ||
) | ||
|
||
id = scheduled_run.metadata.id # the id of the scheduled run trigger | ||
# !! | ||
|
||
# ❓ Delete | ||
await hatchet.scheduled.aio.delete(scheduled=scheduled_run.metadata.id) | ||
# !! | ||
|
||
# ❓ List | ||
scheduled_runs = await hatchet.scheduled.aio.list() | ||
# !! | ||
|
||
# ❓ Get | ||
scheduled_run = await hatchet.scheduled.aio.get(scheduled=scheduled_run.metadata.id) | ||
# !! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from datetime import datetime, timedelta | ||
|
||
from dotenv import load_dotenv | ||
|
||
from hatchet_sdk import Hatchet | ||
|
||
load_dotenv() | ||
|
||
hatchet = Hatchet() | ||
|
||
# ❓ Create | ||
scheduled_run = hatchet.scheduled.create( | ||
workflow_name="simple-workflow", | ||
trigger_at=datetime.now() + timedelta(seconds=10), | ||
input={ | ||
"data": "simple-workflow-data", | ||
}, | ||
additional_metadata={ | ||
"customer_id": "customer-a", | ||
}, | ||
) | ||
|
||
id = scheduled_run.metadata.id # the id of the scheduled run trigger | ||
# !! | ||
|
||
# ❓ Delete | ||
hatchet.scheduled.delete(scheduled=scheduled_run.metadata.id) | ||
# !! | ||
|
||
# ❓ List | ||
scheduled_runs = hatchet.scheduled.list() | ||
# !! | ||
|
||
# ❓ Get | ||
scheduled_run = hatchet.scheduled.get(scheduled=scheduled_run.metadata.id) | ||
# !! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule hatchet
deleted from
f82137
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.