Skip to content

Commit

Permalink
Polish .with_exception_handling docstring (#32739)
Browse files Browse the repository at this point in the history
* replace 'record' with 'input' and fix example

* more tweaking
  • Loading branch information
hjtran authored Oct 15, 2024
1 parent 80cba56 commit 45490ac
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sdks/python/apache_beam/transforms/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ def with_exception_handling(
error_handler=None,
on_failure_callback: typing.Optional[typing.Callable[
[Exception, typing.Any], None]] = None):
"""Automatically provides a dead letter output for skipping bad records.
"""Automatically provides a dead letter output for saving bad inputs.
This can allow a pipeline to continue successfully rather than fail or
continuously throw errors on retry when bad elements are encountered.
Expand All @@ -1606,17 +1606,18 @@ def with_exception_handling(
For example, one would write::
good, bad = Map(maybe_error_raising_function).with_exception_handling()
good, bad = inputs | Map(maybe_erroring_fn).with_exception_handling()
and `good` will be a PCollection of mapped records and `bad` will contain
those that raised exceptions.
tuples of the form `(input, error_string`) for each input that raised an
exception.
Args:
main_tag: tag to be used for the main (good) output of the DoFn,
useful to avoid possible conflicts if this DoFn already produces
multiple outputs. Optional, defaults to 'good'.
dead_letter_tag: tag to be used for the bad records, useful to avoid
dead_letter_tag: tag to be used for the bad inputs, useful to avoid
possible conflicts if this DoFn already produces multiple outputs.
Optional, defaults to 'bad'.
exc_class: An exception class, or tuple of exception classes, to catch.
Expand All @@ -1635,9 +1636,9 @@ def with_exception_handling(
than a new process per element, so the overhead should be minimal
(and can be amortized if there's any per-process or per-bundle
initialization that needs to be done). Optional, defaults to False.
threshold: An upper bound on the ratio of records that can be bad before
threshold: An upper bound on the ratio of inputs that can be bad before
aborting the entire pipeline. Optional, defaults to 1.0 (meaning
up to 100% of records can be bad and the pipeline will still succeed).
up to 100% of inputs can be bad and the pipeline will still succeed).
threshold_windowing: Event-time windowing to use for threshold. Optional,
defaults to the windowing of the input.
timeout: If the element has not finished processing in timeout seconds,
Expand Down

0 comments on commit 45490ac

Please sign in to comment.