Skip to content

Commit 57debc3

Browse files
committed
refactor reserved_params list
1 parent 9b2c595 commit 57debc3

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

metaflow/parameters.py

+24-20
Original file line numberDiff line numberDiff line change
@@ -289,26 +289,8 @@ def __init__(
289289

290290
# TODO: check that the type is one of the supported types
291291
param_type = self.kwargs["type"] = self._get_type(kwargs)
292-
reserved_params = [
293-
"params",
294-
"with",
295-
"max-num-splits",
296-
"max_num_splits",
297-
"max-workers",
298-
"max_workers",
299-
"tag",
300-
"run-id-file",
301-
"run_id_file",
302-
"namespace",
303-
"obj",
304-
"decospecs",
305-
"max-log-size",
306-
"max_log_size",
307-
"tags",
308-
"user_namespace",
309-
]
310-
311-
if self.name in reserved_params:
292+
293+
if self.name in _reserved_params():
312294
raise MetaflowException(
313295
"Parameter name '%s' is a reserved "
314296
"word. Please use a different "
@@ -383,6 +365,28 @@ def __getitem__(self, x):
383365
pass
384366

385367

368+
def _reserved_params():
369+
reserved_params = [
370+
"params",
371+
"with",
372+
"tag",
373+
"namespace",
374+
"obj",
375+
"tags",
376+
"decospecs",
377+
"run-id-file",
378+
"max-num-splits",
379+
"max-workers",
380+
"max-log-size",
381+
"user-namespace",
382+
]
383+
reserved = set(reserved_params)
384+
# due to the way Click maps cli args to function args we also want to add underscored params to the set
385+
for param in reserved_params:
386+
reserved.add(param.replace("-", "_"))
387+
return reserved
388+
389+
386390
def add_custom_parameters(deploy_mode=False):
387391
# deploy_mode determines whether deploy-time functions should or should
388392
# not be evaluated for this command

0 commit comments

Comments
 (0)