diff --git a/examples/python/bug_tests/payload_bug_on_replay/worker.py b/examples/python/bug_tests/payload_bug_on_replay/worker.py new file mode 100644 index 000000000..673a25ab7 --- /dev/null +++ b/examples/python/bug_tests/payload_bug_on_replay/worker.py @@ -0,0 +1,32 @@ +from pydantic import BaseModel + +from hatchet_sdk import Context, Hatchet, ParentCondition + + +class Input(BaseModel): + random_number: int + + +class StepOutput(BaseModel): + should_cancel: bool + + +hatchet = Hatchet(debug=True) + +payload_initial_cancel_bug_workflow = hatchet.workflow( + name="payload-initial-cancel-test", + input_validator=Input, +) + + +@payload_initial_cancel_bug_workflow.task() +def step1(input: Input, ctx: Context) -> StepOutput: + return StepOutput(should_cancel=ctx.retry_count == 0) + + +@payload_initial_cancel_bug_workflow.task( + parents=[step1], + cancel_if=[ParentCondition(parent=step1, expression="output.should_cancel")], +) +async def step2(input: Input, ctx: Context) -> StepOutput: + return StepOutput(should_cancel=False) diff --git a/examples/python/worker.py b/examples/python/worker.py index 24b71b8bc..3cd28f0b0 100644 --- a/examples/python/worker.py +++ b/examples/python/worker.py @@ -1,4 +1,7 @@ from examples.affinity_workers.worker import affinity_worker_workflow +from examples.bug_tests.payload_bug_on_replay.worker import ( + payload_initial_cancel_bug_workflow, +) from examples.bulk_fanout.worker import bulk_child_wf, bulk_parent_wf from examples.bulk_operations.worker import ( bulk_replay_test_1, @@ -75,6 +78,7 @@ def main() -> None: concurrency_cancel_newest_workflow, concurrency_cancel_in_progress_workflow, di_workflow, + payload_initial_cancel_bug_workflow, lifespan_task, simple, simple_durable,