Skip to content

Commit 1cc986c

Browse files
committed
make foreach value string len max a configurable thing
1 parent e8a81c4 commit 1cc986c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

metaflow/flowspec.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818
from .graph import FlowGraph
1919
from .unbounded_foreach import UnboundedForeachInput
20-
from .metaflow_config import INCLUDE_FOREACH_STACK
20+
from .metaflow_config import INCLUDE_FOREACH_STACK, MAXIMUM_FOREACH_VALUE_CHARS
2121

2222
# For Python 3 compatibility
2323
try:
@@ -519,7 +519,6 @@ def _get_foreach_item_value(self, item: Any):
519519
str
520520
The value to use for the item.
521521
"""
522-
MAXIMUM_VALUE_CHARACTERS = 30
523522

524523
def _is_primitive_type(item):
525524
return (
@@ -530,7 +529,7 @@ def _is_primitive_type(item):
530529
)
531530

532531
value = item if _is_primitive_type(item) else reprlib.Repr().repr(item)
533-
return basestring(value)[:MAXIMUM_VALUE_CHARACTERS]
532+
return basestring(value)[:MAXIMUM_FOREACH_VALUE_CHARS]
534533

535534
def next(self, *dsts: Callable[..., None], **kwargs) -> None:
536535
"""

metaflow/metaflow_config.py

+2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205
# Controls whether to include foreach stack information in metadata.
206206
# TODO(Darin, 05/01/24): Remove this flag once we are confident with this feature.
207207
INCLUDE_FOREACH_STACK = from_conf("INCLUDE_FOREACH_STACK", False)
208+
# Maximum length of the foreach value string to be stored in each ForeachFrame.
209+
MAXIMUM_FOREACH_VALUE_CHARS = from_conf("MAXIMUM_FOREACH_VALUE_CHARS", 30)
208210

209211
###
210212
# Organization customizations

0 commit comments

Comments
 (0)