mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-07 17:29:39 -06:00
* feat: expand conditional docs * feat: initial cancellation work + fixing some broken links * feat: docs on cancellation * python: fix cancellation * python: cruft * chore: version * feat: python example * fix: TS cancellation examples * fix: lint * feat: go example * feat: half-baked ts conditional logic workflow * feat: add ts example conditional workflow * feat: go example * feat: go example * fix: cancellation test * fix: thanks, copilot! * Update frontend/docs/pages/home/conditional-workflows.mdx Co-authored-by: Gabe Ruttner <gabriel.ruttner@gmail.com> * fix: lint * chore: lint * fix: longer sleep --------- Co-authored-by: Gabe Ruttner <gabriel.ruttner@gmail.com>
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import asyncio
|
|
|
|
import pytest
|
|
|
|
from examples.dag.worker import dag_workflow
|
|
from hatchet_sdk import Hatchet
|
|
|
|
|
|
@pytest.mark.asyncio()
|
|
async def test_list_runs(hatchet: Hatchet) -> None:
|
|
dag_result = await dag_workflow.aio_run()
|
|
|
|
runs = await hatchet.runs.aio_list(
|
|
limit=10_000,
|
|
only_tasks=True,
|
|
)
|
|
|
|
for v in dag_result.values():
|
|
assert v in [r.output for r in runs.rows]
|
|
|
|
|
|
@pytest.mark.asyncio()
|
|
async def test_get_run(hatchet: Hatchet) -> None:
|
|
dag_ref = await dag_workflow.aio_run_no_wait()
|
|
|
|
await asyncio.sleep(5)
|
|
|
|
run = await hatchet.runs.aio_get(dag_ref.workflow_run_id)
|
|
|
|
assert dag_workflow.config.name in run.run.display_name
|
|
assert run.run.status.value == "COMPLETED"
|
|
assert len(run.shape) == 4
|
|
assert {t.name for t in dag_workflow.tasks} == {t.task_name for t in run.shape}
|
|
|
|
|
|
@pytest.mark.asyncio()
|
|
async def test_list_workflows(hatchet: Hatchet) -> None:
|
|
workflows = await hatchet.workflows.aio_list(
|
|
workflow_name=dag_workflow.config.name, limit=1, offset=0
|
|
)
|
|
|
|
assert workflows.rows
|
|
assert len(workflows.rows) == 1
|
|
|
|
workflow = workflows.rows[0]
|
|
|
|
"""Using endswith because of namespacing in CI"""
|
|
assert workflow.name.endswith(dag_workflow.config.name)
|
|
|
|
fetched_workflow = await hatchet.workflows.aio_get(workflow.metadata.id)
|
|
|
|
"""Using endswith because of namespacing in CI"""
|
|
assert fetched_workflow.name.endswith(dag_workflow.config.name)
|
|
assert fetched_workflow.metadata.id == workflow.metadata.id
|