Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set parameters for running flow instead of any imported #1691

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion metaflow/flowspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from types import FunctionType, MethodType
from typing import Any, Callable, List, Optional, Tuple

from . import cmd_with_io
from . import cmd_with_io, parameters
from .parameters import DelayedEvaluationParameter, Parameter
from .exception import (
MetaflowException,
Expand Down Expand Up @@ -100,6 +100,9 @@ def __init__(self, use_cli=True):
self._graph = FlowGraph(self.__class__)
self._steps = [getattr(self, node.name) for node in self._graph]

# This must be set before calling cli.main() below (or specifically, add_custom_parameters)
parameters.parameters = [p for _, p in self._get_parameters()]

if use_cli:
# we import cli here to make sure custom parameters in
# args.py get fully evaluated before cli.py is imported.
Expand Down
7 changes: 1 addition & 6 deletions metaflow/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
],
)

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


Expand Down Expand Up @@ -335,7 +331,6 @@ def __init__(
"Parameter *%s*: Separator is only allowed "
"for string parameters." % name
)
parameters.append(self)

def option_kwargs(self, deploy_mode):
kwargs = self.kwargs
Expand Down
2 changes: 1 addition & 1 deletion test_runner
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -o errexit -o nounset -o pipefail
install_deps() {
for version in 2 3;
do
python$version -m pip install .
python$version -m pip install .
done
}

Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
[testenv]
allowlist_externals = ./test_runner
commands = ./test_runner