-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Raise TriggerFail from triggers and add a "message" attribute to all states #67
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
Conversation
In one version of this, I had different states take different arguments. For example, |
prefect/engine/executors/base.py
Outdated
def set_state(self, current_state: State, state: State, data: Any = None) -> State: | ||
return state(data) | ||
def set_state( | ||
self, current_state: State, state: State, data: Any = None, message: str = None |
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.
message
will sometimes be an actual Exception
as well.
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.
Good point. I'm not too familiar with passing errors around as strings (maybe the traceback is lost?)-- do you think it's preferable to change the type signature to message: Union[str, Exception]
or to call this function as set_state(message=str(e))
?
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 from what I remember, we changed from str(e)
because that drops the exception type and only returns the exception's message. Maybe we could use repr(e)
though? I'm game to try it with all strings first and try to keep states lean, although I do wonder how a user would debug a failing task with no traceback.
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.
Setting the exception is common enough, let's just make it Union type annotation for now. I am removing this method anyway in my proposed executor/state refactor
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.
Sounds good!
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.
LGTM (assuming tests pass)
Following up on #59, this PR does two major things:
Converts triggers to raise a new
TRIGGERFAIL
signal that, in turn, sets aTriggerFail
state, which closes Update trigger functions to useTriggerFailed
#61.Trapping this error highlighted the importance of being able to pass an optional
message
with each state, in addition to its data attribute, that helps explain how and why it came to be. So state now takes two (optional) arguments:data
andmessage
.In addition, it adds a bunch of tests for states