From 62e94520d65c1a1de53d10252d36a6a032c055af Mon Sep 17 00:00:00 2001 From: Darin Yu Date: Sun, 13 Oct 2024 23:50:08 +0000 Subject: [PATCH] do not let default decospec overwrite existing --with --- metaflow/cli.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/metaflow/cli.py b/metaflow/cli.py index 498ea1b74b2..05b8d344652 100644 --- a/metaflow/cli.py +++ b/metaflow/cli.py @@ -138,7 +138,20 @@ def config_merge_cb(ctx, param, value): splits = DECOSPECS.split() if len(splits) == len(value) and all([a == b for (a, b) in zip(splits, value)]): return value - return tuple(list(value) + DECOSPECS.split()) + + # Another special case where DECOSPECS collides with existing value. + # In this case, we do not want the implicitly added DECOSPECS overwrites the value. + # We dedupe based on the decorator name. + existing_decospecs = set() + for val in value: + existing_decospecs.add(val.split(":")[0]) + + filtered_decospecs = [] + for s in DECOSPECS.split(): + deco_name = s.split(":")[0] + if deco_name not in existing_decospecs: + filtered_decospecs.append(s) + return tuple(list(value) + filtered_decospecs) @click.group() @@ -851,6 +864,8 @@ def before_run(obj, tags, decospecs): decorators._attach_decorators(obj.flow, all_decospecs) obj.graph = FlowGraph(obj.flow.__class__) + print("graph: ", obj.graph) + obj.check(obj.graph, obj.flow, obj.environment, pylint=obj.pylint) # obj.environment.init_environment(obj.logger) @@ -958,6 +973,7 @@ def start( monitor=None, **deco_options ): + print("decospecs: ", decospecs) global echo if quiet: echo = echo_dev_null