-
Notifications
You must be signed in to change notification settings - Fork 864
Refactor trigger decorator and deploy time evaluation logic #2290
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
base: master
Are you sure you want to change the base?
Conversation
Netflix internal testing[4457218] @ 3b7ef8e |
Testing for OSS PR [1052] @ commit 3b7ef8e had 11 FAILUREs. |
3b7ef8e
to
05e0587
Compare
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.
A few minor comments. I haven't tested with the test flows yet but will look.
param_name, field_name = mapping | ||
if not is_stringish(param_name) or not is_stringish(field_name): | ||
raise MetaflowException( | ||
f"The *parameters* attribute for event {event_name} is invalid. " |
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 error message does not seem to properly reflect the condition here. You are actually checking the the content of the tuple are also strings. That too, this is a list of strings or tuples.
elif isinstance(parameters, dict): | ||
# {Union[func, param_name]: Union[func, param_name]} |
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 also seems like a wrong comment based on the error condition below.
|
||
Returns | ||
------- | ||
Union[Dict[Union[str, callable], Union[str, callable]], Callable] |
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.
return type seems too permissive. You are either returning a callable or a Dict[str, str]
Refactored
@trigger
logic and simplified the deploy time evaluation logic of@trigger
decorator. The current implementation is buggy and fails when runningtrigger4.py
in this gist here.For testing, refer to all the flows in this gist here. We can add few more tests as well if needed.
Change in contract:
Previously, we allowed deploy time functions (not documented anywhere) at various levels in the
@trigger
decorator. So something like this was possible:Now, we only allow specifying all of
parameters
as a deploy time function:These are also still allowed: