You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: [Python/ML] RunInference.with_exception_handling() documents Exception tuple while emitting str, and shared.Shared fails on dict models #41351
Two related runtime issues affect custom error handling and ModelHandler implementations in apache_beam.ml.inference.RunInference:
RunInference.with_exception_handling() docstring vs runtime type mismatch (sdks/python/apache_beam/ml/inference/base.py:1795-1806 vs transforms/core.py:1624, 2550):
RunInference.with_exception_handling() documents failed_inferences, failed_preprocessing, and failed_postprocessing as PCollection[tuple[failed batch, exception]].
At runtime, _ExceptionHandlingWrapperDoFn (transforms/core.py:2550) emits (element, traceback.format_exc()) where the second tuple element is a str, not an Exception instance — causing downstream dead-letter transforms that inspect exc.args or type(exc).__name__ to fail.
(Additionally, on batched inference, a single poison-pill element in a batch of N fails all N elements and evicts/reloads the entire model in memory per lines 1829-1830.)
Custom ModelHandler.load_model() returning a dict crashes shared.Shared.acquire() (sdks/python/apache_beam/utils/shared.py:136):
_ExceptionHandlingWrapperDoFn formats traceback.format_exc() as str while RunInference.with_exception_handling() documents exception objects; and shared.py calls weakref.ref(result) without wrapping non-weakrefable containers or raising an actionable error pointing to ModelHandler.load_model().
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Hi, I'd like to work on this. I'd wrap models that can't be weakly referenced (dict, list) in a small holder in _RunInferenceDoFn._load_model before they reach shared.Shared, and fix the with_exception_handling() docstring to describe the (type, repr, traceback) tuple that's actually emitted, with tests for both.
Activity
schizophrenicmaniac commentedon Nov 16, 2026
.take-issue
Hi, I'd like to work on this. I'd wrap models that can't be weakly referenced (dict, list) in a small holder in _RunInferenceDoFn._load_model before they reach shared.Shared, and fix the with_exception_handling() docstring to describe the (type, repr, traceback) tuple that's actually emitted, with tests for both.