[
https://issues.apache.org/jira/browse/BEAM-3956?focusedWorklogId=87799&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-87799
]
ASF GitHub Bot logged work on BEAM-3956:
----------------------------------------
Author: ASF GitHub Bot
Created on: 04/Apr/18 22:59
Start Date: 04/Apr/18 22:59
Worklog Time Spent: 10m
Work Description: shoyer commented on issue #4959: [BEAM-3956] Preserve
stacktraces for Python exceptions
URL: https://github.com/apache/beam/pull/4959#issuecomment-378771136
OK, I've implemented (2), using the stringified traceback as the error field
of the `InstructionResponse` proto.
I dropped the original error message because it can always be found on the
last line of the traceback.
Example of tracebacks sent back from a worker:
<details>
Note the "RuntimeError: Traceback" line about 12 lines down:
```python-traceback
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/universal_local_runner.py",
line 245, in run
).run_via_runner_api(self._pipeline_proto)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/fn_api_runner.py",
line 218, in run_via_runner_api
return self.run_stages(*self.create_stages(pipeline_proto))
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/fn_api_runner.py",
line 837, in run_stages
pcoll_buffers, safe_coders).process_bundle.metrics
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/fn_api_runner.py",
line 938, in run_stage
self._progress_frequency).process_bundle(data_input, data_output)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/fn_api_runner.py",
line 1131, in process_bundle
raise RuntimeError(result.error)
RuntimeError: Traceback (most recent call last):
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/sdk_worker.py",
line 119, in _execute
response = task()
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/sdk_worker.py",
line 154, in <lambda>
self._execute(lambda: worker.do_instruction(work), work)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/sdk_worker.py",
line 200, in do_instruction
request.instruction_id)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/sdk_worker.py",
line 217, in process_bundle
processor.process_bundle(instruction_id)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/bundle_processor.py",
line 286, in process_bundle
op.start()
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 238, in start
self.output(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 159, in output
cython.cast(Receiver,
self.receivers[output_index]).receive(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 85, in receive
cython.cast(Operation, consumer).process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 392, in process
self.dofn_receiver.receive(o)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 488, in receive
self.process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 496, in process
self._reraise_augmented(exn)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 540, in _reraise_augmented
six.reraise(type(new_exn), new_exn, original_traceback)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 494, in process
self.do_fn_invoker.invoke_process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 284, in invoke_process
windowed_value, self.process_method(windowed_value.value))
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 595, in process_outputs
self.main_receivers.receive(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 85, in receive
cython.cast(Operation, consumer).process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 392, in process
self.dofn_receiver.receive(o)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 488, in receive
self.process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 496, in process
self._reraise_augmented(exn)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 540, in _reraise_augmented
six.reraise(type(new_exn), new_exn, original_traceback)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 494, in process
self.do_fn_invoker.invoke_process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 284, in invoke_process
windowed_value, self.process_method(windowed_value.value))
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 595, in process_outputs
self.main_receivers.receive(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 85, in receive
cython.cast(Operation, consumer).process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/worker/operations.py",
line 392, in process
self.dofn_receiver.receive(o)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 488, in receive
self.process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 496, in process
self._reraise_augmented(exn)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 540, in _reraise_augmented
six.reraise(type(new_exn), new_exn, original_traceback)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 494, in process
self.do_fn_invoker.invoke_process(windowed_value)
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/common.py",
line 284, in invoke_process
windowed_value, self.process_method(windowed_value.value))
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/transforms/core.py",
line 972, in <lambda>
wrapper = lambda x: [fn(x)]
File
"/usr/local/google/home/shoyer/open-source/beam/sdks/python/apache_beam/runners/portability/universal_local_runner_test.py",
line 91, in raise_error
raise RuntimeError('x')
RuntimeError: x [while running 'StageC']
```
</details>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 87799)
Time Spent: 4.5h (was: 4h 20m)
> Stacktraces from exceptions in user code should be preserved in the Python SDK
> ------------------------------------------------------------------------------
>
> Key: BEAM-3956
> URL: https://issues.apache.org/jira/browse/BEAM-3956
> Project: Beam
> Issue Type: Bug
> Components: sdk-py-core
> Reporter: Stephan Hoyer
> Priority: Major
> Time Spent: 4.5h
> Remaining Estimate: 0h
>
> Currently, Beam's Python SDK loses stacktraces for exceptions. It does
> helpfully add a tag like "[while running StageA]" to exception error
> messages, but that doesn't include the stacktrace of Python functions being
> called.
> Including the full stacktraces would make a big difference for the ease of
> debugging Beam pipelines when things go wrong.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)