[ 
https://issues.apache.org/jira/browse/BEAM-3956?focusedWorklogId=87382&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-87382
 ]

ASF GitHub Bot logged work on BEAM-3956:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Apr/18 00:48
            Start Date: 04/Apr/18 00:48
    Worklog Time Spent: 10m 
      Work Description: robertwb commented on a change in pull request #4959: 
[BEAM-3956] Preserve stacktraces for Python exceptions
URL: https://github.com/apache/beam/pull/4959#discussion_r179001282
 
 

 ##########
 File path: sdks/python/apache_beam/runners/common.py
 ##########
 @@ -522,17 +522,20 @@ def _reraise_augmented(self, exn):
     step_annotation = " [while running '%s']" % self.step_name
     # To emulate exception chaining (not available in Python 2).
     original_traceback = sys.exc_info()[2]
+    stacktrace_text = '\n' + '\n'.join(traceback.format_exception(
+        type(exn), exn, original_traceback))
     try:
       # Attempt to construct the same kind of exception
       # with an augmented message.
-      new_exn = type(exn)(exn.args[0] + step_annotation, *exn.args[1:])
+      new_exn = type(exn)(exn.args[0] + step_annotation + stacktrace_text,
+                          *exn.args[1:])
       new_exn._tagged_with_step = True  # Could raise attribute error.
     except:  # pylint: disable=bare-except
       # If anything goes wrong, construct a RuntimeError whose message
       # records the original exception's type and message.
       new_exn = RuntimeError(
           traceback.format_exception_only(type(exn), exn)[-1].strip()
-          + step_annotation)
+          + step_annotation + stacktrace_text)
       new_exn._tagged_with_step = True
     six.raise_from(new_exn, original_traceback)
 
 Review comment:
   Rather than string-ifying the traceback, we could use 
six.reraise(type(new_exn), new_exn, original_traceback).

----------------------------------------------------------------
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: 87382)
    Time Spent: 2h  (was: 1h 50m)

> 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: 2h
>  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)

Reply via email to