Skip to content

Commit

Permalink
[Ready for review] Add explicit max length control for foreach value. (
Browse files Browse the repository at this point in the history
…#1733)

* add explicit max length

* make foreach value string len max a configurable thing
  • Loading branch information
darinyu authored Feb 20, 2024
1 parent 2bb998b commit 314d6f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metaflow/flowspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from .graph import FlowGraph
from .unbounded_foreach import UnboundedForeachInput
from .metaflow_config import INCLUDE_FOREACH_STACK
from .metaflow_config import INCLUDE_FOREACH_STACK, MAXIMUM_FOREACH_VALUE_CHARS

# For Python 3 compatibility
try:
Expand Down Expand Up @@ -529,7 +529,7 @@ def _is_primitive_type(item):
)

value = item if _is_primitive_type(item) else reprlib.Repr().repr(item)
return basestring(value)
return basestring(value)[:MAXIMUM_FOREACH_VALUE_CHARS]

def next(self, *dsts: Callable[..., None], **kwargs) -> None:
"""
Expand Down
2 changes: 2 additions & 0 deletions metaflow/metaflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
# Controls whether to include foreach stack information in metadata.
# TODO(Darin, 05/01/24): Remove this flag once we are confident with this feature.
INCLUDE_FOREACH_STACK = from_conf("INCLUDE_FOREACH_STACK", False)
# Maximum length of the foreach value string to be stored in each ForeachFrame.
MAXIMUM_FOREACH_VALUE_CHARS = from_conf("MAXIMUM_FOREACH_VALUE_CHARS", 30)

###
# Organization customizations
Expand Down

0 comments on commit 314d6f4

Please sign in to comment.