Skip to content

Commit a46f4a3

Browse files
madhur-obmaxzheng
andauthored
Set parameters for running flow instead of any imported (Netflix#1691)
* Set parameters for running flow instead of any imported This fixes the issue where parameters for multiple imported flows are displayed instead of the running one when multple flows are in the same file with parameters. Also: 1. Change to use Exception as bare except is bad practice / fails flake8. 2. Switch to editable/develop install so any code changes would be effective without reinstalling. Much faster to iterate changes. * suggested changes * restore except blocks --------- Co-authored-by: Max Zheng <[email protected]>
1 parent 60693bf commit a46f4a3

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

metaflow/flowspec.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from types import FunctionType, MethodType
88
from typing import Any, Callable, List, Optional, Tuple
99

10-
from . import cmd_with_io
10+
from . import cmd_with_io, parameters
1111
from .parameters import DelayedEvaluationParameter, Parameter
1212
from .exception import (
1313
MetaflowException,
@@ -100,6 +100,9 @@ def __init__(self, use_cli=True):
100100
self._graph = FlowGraph(self.__class__)
101101
self._steps = [getattr(self, node.name) for node in self._graph]
102102

103+
# This must be set before calling cli.main() below (or specifically, add_custom_parameters)
104+
parameters.parameters = [p for _, p in self._get_parameters()]
105+
103106
if use_cli:
104107
# we import cli here to make sure custom parameters in
105108
# args.py get fully evaluated before cli.py is imported.

metaflow/parameters.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131
],
3232
)
3333

34-
# currently we execute only one flow per process, so we can treat
35-
# Parameters globally. If this was to change, it should/might be
36-
# possible to move these globals in a FlowSpec (instance) specific
37-
# closure.
38-
parameters = []
34+
parameters = [] # Set by FlowSpec.__init__()
3935
context_proto = None
4036

4137

@@ -335,7 +331,6 @@ def __init__(
335331
"Parameter *%s*: Separator is only allowed "
336332
"for string parameters." % name
337333
)
338-
parameters.append(self)
339334

340335
def option_kwargs(self, deploy_mode):
341336
kwargs = self.kwargs

test_runner

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o errexit -o nounset -o pipefail
55
install_deps() {
66
for version in 2 3;
77
do
8-
python$version -m pip install .
8+
python$version -m pip install .
99
done
1010
}
1111

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
[testenv]
44
allowlist_externals = ./test_runner
55
commands = ./test_runner
6-

0 commit comments

Comments
 (0)