Skip to content
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

Merged
merged 25 commits into from
Nov 22, 2024
Merged

Deploy time triggers #2133

merged 25 commits into from
Nov 22, 2024

Conversation

Copy link
Contributor

@romain-intel romain-intel left a 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 :) ).

metaflow/parameters.py Outdated Show resolved Hide resolved
@@ -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(
Copy link
Contributor

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.

Copy link
Contributor Author

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/util.py Outdated Show resolved Hide resolved
param_value, DeployTimeField
):
new_param_value = DeployTimeField(
"param", [list, dict], None, param_value, False
Copy link
Contributor

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.

Copy link
Contributor

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 Show resolved Hide resolved
metaflow/plugins/events_decorator.py Outdated Show resolved Hide resolved
metaflow/plugins/events_decorator.py Outdated Show resolved Hide resolved
# 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):
Copy link
Contributor

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.

for trigger in self.triggers:
old_trigger = trigger
# Entire event is a function (returns either string or dict)
if isinstance(trigger, DeployTimeField):
Copy link
Contributor

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).

metaflow/plugins/events_decorator.py Outdated Show resolved Hide resolved
Comment on lines 196 to 199
for deco in flow_decorators(self):
if deco.name == "trigger":
for trig in deco.triggers:
print(trig)
Copy link
Collaborator

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(?)

new_trigger_params[key] = value
trigger["parameters"] = new_trigger_params
self.triggers[self.triggers.index(old_trigger)] = trigger
print(self.triggers)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this print seems unnecessary

Copy link
Contributor

@romain-intel romain-intel left a 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.

metaflow/plugins/events_decorator.py Outdated Show resolved Hide resolved
@romain-intel romain-intel merged commit 50298d7 into master Nov 22, 2024
29 checks passed
@romain-intel romain-intel deleted the deploy_time_triggers branch November 22, 2024 18:22
savingoyal added a commit that referenced this pull request Nov 27, 2024
savingoyal added a commit that referenced this pull request Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants