Skip to content

Commit

Permalink
Store configs as dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-intel committed Dec 17, 2024
1 parent a7bf3d5 commit 7c1922e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metaflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class and related decorators.

from .parameters import Parameter, JSONTypeClass, JSONType

from .user_configs.config_parameters import Config, config_expr
from .user_configs.config_parameters import Config, ConfigValue, config_expr
from .user_configs.config_decorators import CustomFlowDecorator, CustomStepDecorator

# data layer
Expand Down
5 changes: 5 additions & 0 deletions metaflow/flowspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .graph import FlowGraph
from .unbounded_foreach import UnboundedForeachInput
from .user_configs.config_decorators import (
ConfigValue,
CustomFlowDecorator,
CustomStepDecorator,
MutableFlow,
Expand Down Expand Up @@ -310,6 +311,10 @@ def _set_constants(self, graph, kwargs, config_options):
if isinstance(val, DelayedEvaluationParameter):
val = val()
val = val.split(param.separator) if val and param.separator else val
if isinstance(val, ConfigValue):
# We store config values as dict so they are accessible with older
# metaflow clients. It also makes it easier to access.
val = val.to_dict()
setattr(self, var, val)
parameters_info.append({"name": var, "type": param.__class__.__name__})

Expand Down
2 changes: 1 addition & 1 deletion metaflow/user_configs/config_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def __init__(
self._computed_value = None

def load_parameter(self, v):
return v
return ConfigValue(v)

def _store_value(self, v: Any) -> None:
self._computed_value = v
Expand Down

0 comments on commit 7c1922e

Please sign in to comment.