Files
hatchet/sdks/python/examples/priority/trigger.py
Matt Kaye 80137736af Feat: Priority (#1513)
* feat: initial work wiring up priorities

* fix: add default to default prio in the db

* feat: wire priority through api on wf creation

* feat: extend python test

* feat: priority for scheduled workflows

* feat: wire priority through python api

* feat: more wiring priority through the api

* feat: I think it works?

* feat: e2e test for priority

* it works!

* feat: expand tests for default priorities

* feat: e2e scheduling test

* fix: skip broken test for now

* fix: lint

* feat: add priority columns to cron and schedule ref  tables

* feat: update inserts to include prio

* feat: wire up more apis

* feat: more wiring

* feat: wire up more rest api fields

* chore: cruft

* fix: more wiring

* fix: lint

* chore: gen + wire up priorities

* fix: retries

* fix: try changing fixture scope

* chore: bump version again

* feat: send priority with action payload

* fix: generate script

* Feat  priority ts (#1518)

* feat: initial work wiring up priorities

* fix: add default to default prio in the db

* feat: wire priority through api on wf creation

* feat: extend python test

* feat: priority for scheduled workflows

* feat: wire priority through python api

* feat: more wiring priority through the api

* feat: I think it works?

* feat: e2e test for priority

* it works!

* feat: expand tests for default priorities

* feat: e2e scheduling test

* chore: minor version for priority

* fix: skip broken test for now

* fix: lint

* feat: add priority columns to cron and schedule ref  tables

* feat: update inserts to include prio

* feat: wire up more apis

* feat: more wiring

* feat: wire up more rest api fields

* chore: cruft

* fix: more wiring

* fix: lint

* chore: gen + wire up priorities

* fix: increase timeout

* fix: retries

* fix: try changing fixture scope

* chore: generate

* fix: set schedule priority

* feat: priority

* fix: move priority to wf

* release: 1.2.0

* rm log

* fix: import

* fix: add priority to step

---------

Co-authored-by: mrkaye97 <mrkaye97@gmail.com>

* fix: add dummy runs to priority test to prevent race conditions

* fix: non-breaking field

* fix: gen

* feat: initial pass at docs

* feat: priority in go sdk

* feat: initial work on go example

* fix: doc examples

* fix: proofread

* chore: version

* feat: go sdk

* fix: lint

* fix: declarations and add back RunAsChild

* fix: child workflows

* fix: namespace

* fix: faster child workflows

* fix: sticky

* add back run as child

---------

Co-authored-by: Gabe Ruttner <gabriel.ruttner@gmail.com>
Co-authored-by: Alexander Belanger <alexander@hatchet.run>
2025-04-14 16:22:00 -04:00

54 lines
1.5 KiB
Python

from datetime import datetime, timedelta
from examples.priority.worker import priority_workflow
from hatchet_sdk import ScheduleTriggerWorkflowOptions, TriggerWorkflowOptions
priority_workflow.run_no_wait()
# ❓ Runtime priority
low_prio = priority_workflow.run_no_wait(
options=TriggerWorkflowOptions(
## 👀 Adding priority and key to metadata to show them in the dashboard
priority=1,
additional_metadata={"priority": "low", "key": 1},
)
)
high_prio = priority_workflow.run_no_wait(
options=TriggerWorkflowOptions(
## 👀 Adding priority and key to metadata to show them in the dashboard
priority=3,
additional_metadata={"priority": "high", "key": 1},
)
)
# !!
# ❓ Scheduled priority
schedule = priority_workflow.schedule(
run_at=datetime.now() + timedelta(minutes=1),
options=ScheduleTriggerWorkflowOptions(priority=3),
)
cron = priority_workflow.create_cron(
cron_name="my-scheduled-cron",
expression="0 * * * *",
priority=3,
)
# !!
# ❓ Default priority
low_prio = priority_workflow.run_no_wait(
options=TriggerWorkflowOptions(
## 👀 Adding priority and key to metadata to show them in the dashboard
priority=1,
additional_metadata={"priority": "low", "key": 2},
)
)
high_prio = priority_workflow.run_no_wait(
options=TriggerWorkflowOptions(
## 👀 Adding priority and key to metadata to show them in the dashboard
priority=3,
additional_metadata={"priority": "high", "key": 2},
)
)