-
Notifications
You must be signed in to change notification settings - Fork 781
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
Deploy time triggers #2133
Deploy time triggers #2133
Conversation
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.
Haven't fully finished the main function but I think it needs a bit more work (and some structure to reason about). It is a bit convoluted (not the function, just the logic) so we need to be careful and think clearly (ie: write things out :) ).
@@ -312,6 +422,13 @@ def flow_init( | |||
"The *project_branch* attribute of the *flow* is not a string" | |||
) | |||
self.triggers.append(result) | |||
elif callable(self.attributes["flow"]) and not isinstance( |
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.
nit: here and other similar place: we probably want to also allow DeployTimeField (ie: not raise incorrect type). I don't think it happens but in terms of logic, we are ok with a deploytimefield.
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.
We had this check in our old trigger code in metaflow-custom, so I kept it
metaflow/plugins/events_decorator.py
Outdated
param_value, DeployTimeField | ||
): | ||
new_param_value = DeployTimeField( | ||
"param", [list, dict], None, param_value, False |
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.
nit: I'd call it "parameters" as well here since that is what the user is passing.
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.
Also, it seems parameters can be a tuple or a list or a dict (here you just added list and dict).
We do lose the check on tuple of size 2 here but maybe we get it back later.
metaflow/plugins/events_decorator.py
Outdated
# Case were trigger is a function that returns a list of events | ||
# Need to do this bc we need to iterate over list later | ||
if isinstance(trigger, DeployTimeField): | ||
if isinstance(deploy_time_eval(trigger), list): |
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.
Calling deploy_time_eval
twice. Also, at the top level, something that is a deploy-time field will be:
- a string (so needs to be handled like line 96)
- a dictionary (single event in dict form)
- a list of the two things above (when it is pushed as events)
So for string, that is done (we create the proper entry and done). For dictionary, we may need further processing of the elements (so continue). For list, add each element as above.
metaflow/plugins/events_decorator.py
Outdated
for trigger in self.triggers: | ||
old_trigger = trigger | ||
# Entire event is a function (returns either string or dict) | ||
if isinstance(trigger, DeployTimeField): |
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 should not happen since we removed the DeployTimeField in the first step. Now we need to go inside each dict (we either have a fully resolved dict or a dict with some portions that are not yet evaluated).
6687a18
to
d7211ef
Compare
metaflow/flowspec.py
Outdated
for deco in flow_decorators(self): | ||
if deco.name == "trigger": | ||
for trig in deco.triggers: | ||
print(trig) |
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.
is this for debugging purposes only? can be removed in that case.
same goes for the changes in _vendor
, and what looks to be a local vscode config(?)
metaflow/plugins/events_decorator.py
Outdated
new_trigger_params[key] = value | ||
trigger["parameters"] = new_trigger_params | ||
self.triggers[self.triggers.index(old_trigger)] = trigger | ||
print(self.triggers) |
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 print seems unnecessary
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 a minor nit to clean it up a tad more but otherwise no concern.
This reverts commit 50298d7.
https://docs.google.com/document/d/1-g-hPK5XC7sPmExXqFhxPTVAwnlPYyNKnmWaYIKvxb8/edit?tab=t.0#heading=h.6lt86ol75edp