-
Notifications
You must be signed in to change notification settings - Fork 71
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
Workflow init #634
Closed
Closed
Workflow init #634
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dandavison
force-pushed
the
workflow-init
branch
from
September 5, 2024 13:38
eb5b02c
to
5a14416
Compare
cretz
reviewed
Sep 5, 2024
dandavison
force-pushed
the
workflow-init
branch
from
September 6, 2024 19:32
5a14416
to
d39d854
Compare
dandavison
force-pushed
the
workflow-init
branch
from
September 17, 2024 15:44
d39d854
to
e79a340
Compare
dandavison
force-pushed
the
workflow-init
branch
from
September 17, 2024 20:00
e79a340
to
16395b4
Compare
Merged
Superseded by #645. Closing this PR as the next iteration's implementation is very different and most of the description and discussion in this PR does not apply. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #600
This PR makes it possible to define a workflow class
__init__
method that will receive the workflow input positional args (i.e. the same workflow input args that are passed to the@workflow.run
method). One way in which this is useful is that it allows the workflow to initialize itself in a way that uses the workflow input but is guaranteed to have occurred before any signal or update handler runs (at the start of a workflow execution, these handlers can start to execute before the main@workflow.run
method).In order to opt in to the new functionality, you must define the
__init__
method so that its parameters exactly match those of the@workflow.run
method. And your@workflow.run
method parameters must be defined in a way that requires arguments (so you can't use e.g.def my_run(self, *args)
with this feature).The parameter names need not be the same, but in all other respects the two parameter lists must be identical:
*
or/
syntax, then you must use that syntax in the same way in each signature.list[str]
thenlist
is not acceptable on the other.Backwards compatibility
The implementation is based on assessing whether the workflow class could be instantiated as
cls()
, without arguments. If so, then we do that. This means that behavior will be unchanged for all existing Python workflow definitions that work today: for such code there should be no new exceptions at import time, or at run-time, and the change should not break replay of existing workflows.It's possible that a Python workflow definition that does not work today because it demands extra arguments that are not supplied, finds itself suddenly working because it is given workflow arguments.
It's more likely however that such a workflow definition finds that the error is reported earlier -- at import time, rather than at workflow run-time.
How this was tested