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

Revert "Deploy time triggers" #2153

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions metaflow/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,22 @@ def __call__(self, deploy_time=False):
return self._check_type(val, deploy_time)

def _check_type(self, val, deploy_time):

# it is easy to introduce a deploy-time function that accidentally
# returns a value whose type is not compatible with what is defined
# in Parameter. Let's catch those mistakes early here, instead of
# showing a cryptic stack trace later.

# note: this doesn't work with long in Python2 or types defined as
# click types, e.g. click.INT
TYPES = {bool: "bool", int: "int", float: "float", list: "list", dict: "dict"}
TYPES = {bool: "bool", int: "int", float: "float", list: "list"}

msg = (
"The value returned by the deploy-time function for "
"the parameter *%s* field *%s* has a wrong type. "
% (self.parameter_name, self.field)
)

if isinstance(self.parameter_type, list):
if not any(isinstance(val, x) for x in self.parameter_type):
msg += "Expected one of the following %s." % TYPES[self.parameter_type]
raise ParameterFieldTypeMismatch(msg)
return str(val) if self.return_str else val
elif self.parameter_type in TYPES:
if self.parameter_type in TYPES:
if type(val) != self.parameter_type:
msg += "Expected a %s." % TYPES[self.parameter_type]
raise ParameterFieldTypeMismatch(msg)
Expand Down
12 changes: 4 additions & 8 deletions metaflow/plugins/argo/argo_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,7 @@ def _process_triggers(self):
params = set(
[param.name.lower() for var, param in self.flow._get_parameters()]
)
trigger_deco = self.flow._flow_decorators.get("trigger")[0]
trigger_deco.format_deploytime_value()
for event in trigger_deco.triggers:
for event in self.flow._flow_decorators.get("trigger")[0].triggers:
parameters = {}
# TODO: Add a check to guard against names starting with numerals(?)
if not re.match(r"^[A-Za-z0-9_.-]+$", event["name"]):
Expand Down Expand Up @@ -564,11 +562,9 @@ def _process_triggers(self):

# @trigger_on_finish decorator
if self.flow._flow_decorators.get("trigger_on_finish"):
trigger_on_finish_deco = self.flow._flow_decorators.get(
"trigger_on_finish"
)[0]
trigger_on_finish_deco.format_deploytime_value()
for event in trigger_on_finish_deco.triggers:
for event in self.flow._flow_decorators.get("trigger_on_finish")[
0
].triggers:
# Actual filters are deduced here since we don't have access to
# the current object in the @trigger_on_finish decorator.
triggers.append(
Expand Down
Loading
Loading