-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Conversation
WorkflowHandler.run_step()
so user manually emits Event to start next step in worfklow
@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() |
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.
I think we should probably delete this test and delete Workflow.run_step()
now? To support this with the re-factor then we could either:
-
Maintain an older version of
_start()
that doesn't contain the newstepwise
logic and point thisWorkflow.run_step()
to it -
Update the
Worfklow.run_step()
to have a similar refactor toWorkflowHandler.run_step()
.
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.
Maybe we should just delete run_step()
on the workflow object? (Or at least, delete the implementation and point users towards the updated syntax?)
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I deleted Workflow.run_step
. I don't think it was worth it to update to point to new code as it would change the functionality of this already deprecated method drastically. As such, keeping it would not really provide any benefits to users who were still using this deprecated method.
d438030
to
fea868a
Compare
WorkflowHandler.run_step()
so user manually emits Event to start next step in worfklowWorkflowHandler.run_step()
so user manually emits Event to start next step in worfklow
retval = self.ctx.get_result() | ||
# Check if we're done | ||
if not t.done(): | ||
continue |
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!
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.
This looks pretty good to me!
With this
- users ensure step-by-step runtime
- can modify/edit events before emitting them, or even emit more events on the fly
- can modify the context state in between steps
…o start next step in worfklow (run-llama#16277) * initial version of stepwise working * remove stepwise deprecated test * remove print * better naming * add docstring to WorkflowHandler * revert Workflow.run_step * fix check for when Workflow is done or if step raised error * fix error handling * fix error handling * update docs * delete Workflow.run_step
Description
Currently run_step() is able to run a Workflow steps one at a time, however, it doesn't really provide the user the ability to control the step-by-step execution. In other words, the user isn't able to control when a step ends and thus when to trigger to the next event.
Acceptance Criteria:
The user is able to end the current step by emitting the appropriate event, which then kicks off the next step.
Current Design:
NOTE:
Workflow.run_step
since this invokes_start(stepwise=True)
which has been modified in this re-factor.Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration