From 96f52719fa99a2e2506b3a422240dc2867f59852 Mon Sep 17 00:00:00 2001 From: Sakari Ikonen <64256562+saikonen@users.noreply.github.com> Date: Sat, 11 Jan 2025 12:15:59 +0200 Subject: [PATCH] fix: remove step level decospecs (#2203) * Remove step level decospecs This was not used anywhere and step is an internal command. Also added clarifying comments around attaching decospecs --------- Co-authored-by: Romain Cledat --- metaflow/cli.py | 5 +++++ metaflow/cli_components/run_cmds.py | 2 ++ metaflow/cli_components/step_cmd.py | 13 ------------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/metaflow/cli.py b/metaflow/cli.py index 40b55a6a52d..3a8dc4ecaa9 100644 --- a/metaflow/cli.py +++ b/metaflow/cli.py @@ -504,6 +504,11 @@ def start( # *after* the run decospecs so that they don't take precedence. In other # words, for the same decorator, we want `myflow.py run --with foo` to # take precedence over any other `foo` decospec + + # Note that top-level decospecs are used primarily with non run/resume + # options as well as with the airflow/argo/sfn integrations which pass + # all the decospecs (the ones from top-level but also the ones from the + # run/resume level) through the tl decospecs. ctx.obj.tl_decospecs = list(decospecs or []) # initialize current and parameter context for deploy-time parameters diff --git a/metaflow/cli_components/run_cmds.py b/metaflow/cli_components/run_cmds.py index a7568e74159..bf77d16ad1f 100644 --- a/metaflow/cli_components/run_cmds.py +++ b/metaflow/cli_components/run_cmds.py @@ -39,6 +39,8 @@ def before_run(obj, tags, decospecs): + list(obj.environment.decospecs() or []) ) if all_decospecs: + # These decospecs are the ones from run/resume PLUS the ones from the + # environment (for example the @conda) decorators._attach_decorators(obj.flow, all_decospecs) decorators._init(obj.flow) # Regenerate graph if we attached more decorators diff --git a/metaflow/cli_components/step_cmd.py b/metaflow/cli_components/step_cmd.py index bb4df976e7c..4b40c9e5e54 100644 --- a/metaflow/cli_components/step_cmd.py +++ b/metaflow/cli_components/step_cmd.py @@ -77,14 +77,6 @@ default=None, help="Run id of the origin flow, if this task is part of a flow being resumed.", ) -@click.option( - "--with", - "decospecs", - multiple=True, - help="Add a decorator to this task. You can specify this " - "option multiple times to attach multiple decorators " - "to this task.", -) @click.option( "--ubf-context", default="none", @@ -112,7 +104,6 @@ def step( max_user_code_retries=None, clone_only=None, clone_run_id=None, - decospecs=None, ubf_context="none", num_parallel=None, ): @@ -136,10 +127,6 @@ def step( raise CommandException("Function *%s* is not a step." % step_name) echo("Executing a step, *%s*" % step_name, fg="magenta", bold=False) - if decospecs: - decorators._attach_decorators_to_step(func, decospecs) - decorators._init(ctx.obj.flow) - step_kwargs = ctx.params # Remove argument `step_name` from `step_kwargs`. step_kwargs.pop("step_name", None)