mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-05-01 23:20:09 -05:00
08f49031be
* fix: version * feat: first pass at new base rest client * fix: typing * fix: base client cleanup * feat: basic runs client * fix: finally!! * feat: helper functions for uuid and metadata conversion and api format fix * fix: patches * feat: run list apis * feat: add bulk replay and cancel * feat: replays and cancels * feat: result getter * feat: cron client * feat: scheduled workflows * feat: rate limit * refactor: don't export admin client anymore * feat: add a bunch more clients and remove the old `rest` thing * fix: scheduled workflow trigger time * fix: emptymodel default * refactor: stop passing pooled workflow run listener around everywhere * fix: more cleanup of context * refactor: remove unused stuff from runner * unwind: keep passing listeners around * fix: rm some unused stuff * fix: example * feat: metrics api * feat: a couple tests * feat: more default emptymodels * fix: tests * [Docs]: Misc. Python Migration Guide Issues, Rate limits, V1 new features (#1417) * fix: misc python migration guide * feat: rate limits docs * fix: lint * fix: lint * feat: skeleton * feat: add a bunch of docs * feat: bulk replay and cancel docs * fix: add task output to example * fix: otel docs + naming * fix: lint * fix: rm timeout * feat: initial python sdk guide * fix: raise on dupe on failure or on success * fix: dags docs * feat: 1.0.1
42 lines
943 B
Python
42 lines
943 B
Python
# ❓ Setup
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
from hatchet_sdk import BulkCancelReplayOpts, Hatchet, RunFilter, V1TaskStatus
|
|
|
|
hatchet = Hatchet()
|
|
|
|
workflows = hatchet.workflows.list()
|
|
|
|
assert workflows.rows
|
|
|
|
workflow = workflows.rows[0]
|
|
|
|
# !!
|
|
|
|
# ❓ List runs
|
|
workflow_runs = hatchet.runs.list(workflow_ids=[workflow.metadata.id])
|
|
# !!
|
|
|
|
# ❓ Replay by run ids
|
|
workflow_run_ids = [workflow_run.metadata.id for workflow_run in workflow_runs.rows]
|
|
|
|
bulk_replay_by_ids = BulkCancelReplayOpts(ids=workflow_run_ids)
|
|
|
|
hatchet.runs.bulk_replay(bulk_replay_by_ids)
|
|
# !!
|
|
|
|
# ❓ Replay by filters
|
|
bulk_replay_by_filters = BulkCancelReplayOpts(
|
|
filters=RunFilter(
|
|
since=datetime.today() - timedelta(days=1),
|
|
until=datetime.now(),
|
|
statuses=[V1TaskStatus.RUNNING],
|
|
workflow_ids=[workflow.metadata.id],
|
|
additional_metadata={"key": "value"},
|
|
)
|
|
)
|
|
|
|
hatchet.runs.bulk_replay(bulk_replay_by_filters)
|
|
# !!
|