Skip to content

Commit 275d8d2

Browse files
committed
inline reserved param set generation
1 parent 57debc3 commit 275d8d2

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

metaflow/parameters.py

+20-23
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,26 @@ def __init__(
290290
# TODO: check that the type is one of the supported types
291291
param_type = self.kwargs["type"] = self._get_type(kwargs)
292292

293-
if self.name in _reserved_params():
293+
reserved_params = [
294+
"params",
295+
"with",
296+
"tag",
297+
"namespace",
298+
"obj",
299+
"tags",
300+
"decospecs",
301+
"run-id-file",
302+
"max-num-splits",
303+
"max-workers",
304+
"max-log-size",
305+
"user-namespace",
306+
]
307+
reserved = set(reserved_params)
308+
# due to the way Click maps cli args to function args we also want to add underscored params to the set
309+
for param in reserved_params:
310+
reserved.add(param.replace("-", "_"))
311+
312+
if self.name in reserved:
294313
raise MetaflowException(
295314
"Parameter name '%s' is a reserved "
296315
"word. Please use a different "
@@ -365,28 +384,6 @@ def __getitem__(self, x):
365384
pass
366385

367386

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-
390387
def add_custom_parameters(deploy_mode=False):
391388
# deploy_mode determines whether deploy-time functions should or should
392389
# not be evaluated for this command

0 commit comments

Comments
 (0)