You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "robertwb (via GitHub)" <gi...@apache.org> on 2024/05/14 00:16:06 UTC

[PR] Better mixed Java/Python error messages for external transforms. [beam]

robertwb opened a new pull request, #31284:
URL: https://github.com/apache/beam/pull/31284

   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Go tests](https://github.com/apache/beam/workflows/Go%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #31284:
URL: https://github.com/apache/beam/pull/31284#issuecomment-2109105306

   Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment `assign set of reviewers`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "chamikaramj (via GitHub)" <gi...@apache.org>.
chamikaramj commented on code in PR #31284:
URL: https://github.com/apache/beam/pull/31284#discussion_r1601962595


##########
sdks/python/apache_beam/transforms/external.py:
##########
@@ -750,7 +751,7 @@ def expand(self, pvalueish):
     with ExternalTransform.service(expansion_service) as service:
       response = service.Expand(request)
       if response.error:
-        raise RuntimeError(response.error)
+        raise RuntimeError(_sanitize_java_traceback(response.error))

Review Comment:
   Probably let's also add a unit test ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb merged PR #31284:
URL: https://github.com/apache/beam/pull/31284


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on code in PR #31284:
URL: https://github.com/apache/beam/pull/31284#discussion_r1601129052


##########
sdks/python/apache_beam/transforms/external.py:
##########
@@ -750,7 +751,7 @@ def expand(self, pvalueish):
     with ExternalTransform.service(expansion_service) as service:
       response = service.Expand(request)
       if response.error:
-        raise RuntimeError(response.error)
+        raise RuntimeError(_sanitize_java_traceback(response.error))

Review Comment:
   No. We don't actually delete anything, just copy the (hopefully) relevent bits to the bottom of the wall of text. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on PR #31284:
URL: https://github.com/apache/beam/pull/31284#issuecomment-2135887604

   Any more concerns before getting this merged?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "robertwb (via GitHub)" <gi...@apache.org>.
robertwb commented on code in PR #31284:
URL: https://github.com/apache/beam/pull/31284#discussion_r1610533126


##########
sdks/python/apache_beam/transforms/external.py:
##########
@@ -750,7 +751,7 @@ def expand(self, pvalueish):
     with ExternalTransform.service(expansion_service) as service:
       response = service.Expand(request)
       if response.error:
-        raise RuntimeError(response.error)
+        raise RuntimeError(_sanitize_java_traceback(response.error))

Review Comment:
   Added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Better mixed Java/Python error messages for external transforms. [beam]

Posted by "chamikaramj (via GitHub)" <gi...@apache.org>.
chamikaramj commented on code in PR #31284:
URL: https://github.com/apache/beam/pull/31284#discussion_r1600786019


##########
sdks/python/apache_beam/transforms/external.py:
##########
@@ -750,7 +751,7 @@ def expand(self, pvalueish):
     with ExternalTransform.service(expansion_service) as service:
       response = service.Expand(request)
       if response.error:
-        raise RuntimeError(response.error)
+        raise RuntimeError(_sanitize_java_traceback(response.error))

Review Comment:
   For transform service, we combine the errors from all expansion service container and return them together. Usually one of them is useful while other is a trivial error (for example, URN not available). Seems like this might result in useful Python errors being deleted in that case ?
   
   https://github.com/apache/beam/blob/54db453b032bc3e4827fd8d59aa600cba9dd111d/sdks/java/transform-service/src/main/java/org/apache/beam/sdk/transformservice/ExpansionService.java#L159



##########
sdks/python/apache_beam/transforms/external.py:
##########
@@ -1142,6 +1143,32 @@ def is_docker_available():
         'Docker executables are available in the system.')
 
 
+def _sanitize_java_traceback(s):
+  """Attempts to highlight the root cause in the error string.
+
+  Java tracebacks read bottom to top, while Python tracebacks read top to
+  bottom, resulting in the actual error message getting sandwiched between two
+  walls of text.  This may result in the error being duplicated (as we don't
+  want to remove relevant information) but should be clearer in most cases.
+
+  Best-effort but non-destructive.
+  """
+  traceback_lines = [
+      r'\tat \S+\(\S+\.java:\d+\)',
+      r'\t\.\.\. \d+ more',
+      # A bit more restrictive to avoid accidentally capturing non-java lines.
+      r'Caused by: [a-z]+(\.\S+)?\.[A-Z][A-Za-z0-9_$]+(Error|Exception):[^\n]*'
+  ]
+  without_java_traceback = s + '\n'
+  for p in traceback_lines:
+    without_java_traceback = re.sub(
+        fr'\n{p}$', '', without_java_traceback, flags=re.M)

Review Comment:
   IIUC, this sets every line that matches the pattern within the stack trace to an empty string. Is that correct ?
   
   (probably expand documentation to explain the logic here) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org