-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-factor WorkflowHandler.run_step()
so user manually emits Event to start next step in worfklow
#16277
Re-factor WorkflowHandler.run_step()
so user manually emits Event to start next step in worfklow
#16277
Changes from all commits
756732f
c91b145
e80e74f
ceef62d
fea868a
38ba385
ef875e8
1588bf9
be481de
35a9edb
d886c49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,54 +37,31 @@ async def test_workflow_run(workflow): | |
assert result == "Workflow completed" | ||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_deprecated_workflow_run_step(workflow): | ||
workflow._verbose = True | ||
|
||
# First step | ||
result = await workflow.run_step() | ||
assert result is None | ||
assert not workflow.is_done() | ||
|
||
# Second step | ||
result = await workflow.run_step() | ||
assert result is None | ||
assert not workflow.is_done() | ||
|
||
# Final step | ||
result = await workflow.run_step() | ||
assert not workflow.is_done() | ||
assert result is None | ||
|
||
# Cleanup step | ||
result = await workflow.run_step() | ||
assert result == "Workflow completed" | ||
assert workflow.is_done() | ||
Comment on lines
-40
to
-62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably delete this test and delete
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should just delete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should just delete it at this point tbh. I think if we point it to the updated syntax means that we're changing how this Workflow.run_step() behaves and not sure if we should do that since its already deprecated. If you and @masci are fine with updating the logic of this and still marking it as deprecated then I'd be happy to adjust accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I deleted |
||
|
||
|
||
@pytest.mark.asyncio() | ||
async def test_workflow_run_step(workflow): | ||
handler = workflow.run(stepwise=True) | ||
|
||
result = await handler.run_step() | ||
assert result is None | ||
event = await handler.run_step() | ||
assert isinstance(event, OneTestEvent) | ||
assert not handler.is_done() | ||
handler.ctx.send_event(event) | ||
|
||
result = await handler.run_step() | ||
assert result is None | ||
event = await handler.run_step() | ||
assert isinstance(event, LastEvent) | ||
assert not handler.is_done() | ||
handler.ctx.send_event(event) | ||
|
||
result = await handler.run_step() | ||
assert result is None | ||
event = await handler.run_step() | ||
assert isinstance(event, StopEvent) | ||
assert not handler.is_done() | ||
handler.ctx.send_event(event) | ||
|
||
result = await handler.run_step() | ||
assert result is None | ||
assert not handler.is_done() | ||
event = await handler.run_step() | ||
assert event is None | ||
|
||
result = await handler.run_step() | ||
assert result == "Workflow completed" | ||
result = await handler | ||
assert handler.is_done() | ||
assert result == "Workflow completed" | ||
|
||
|
||
@pytest.mark.asyncio() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, is this check actually needed? If a StopEvent is emitted, we don't care if other tasks are still running right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yes, good point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I had to modify this slightly as it wasn't handling any errors raised in a step correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes make sense!