(*args, **kwargs)
| 45 | which can otherwise obfuscate user code errors.""" |
| 46 | |
| 47 | def handle_trace(*args, **kwargs): |
| 48 | try: |
| 49 | return fn(*args, **kwargs) |
| 50 | except Exception as e: |
| 51 | # Only log the full internal stack trace to stdout when configured |
| 52 | # via DataContext, or when the Ray Debugger is enabled. |
| 53 | # The full stack trace will always be emitted to the Ray Data log file. |
| 54 | log_to_stdout = DataContext.get_current().log_internal_stack_trace_to_stdout |
| 55 | if _is_ray_debugger_post_mortem_enabled(): |
| 56 | logger.exception("Full stack trace:") |
| 57 | raise e |
| 58 | |
| 59 | is_user_code_exception = isinstance(e, UserCodeException) |
| 60 | if is_user_code_exception: |
| 61 | # Exception has occurred in user code. |
| 62 | if not log_to_stdout and log_once("ray_data_exception_internal_hidden"): |
| 63 | logger.error( |
| 64 | "Exception occurred in user code, with the abbreviated stack " |
| 65 | "trace below. By default, the Ray Data internal stack trace " |
| 66 | "is omitted from stdout, and only written to the Ray Data log " |
| 67 | f"files at `{get_log_directory()}`. To " |
| 68 | "output the full stack trace to stdout, set " |
| 69 | "`DataContext.log_internal_stack_trace_to_stdout` to True." |
| 70 | ) |
| 71 | else: |
| 72 | # Exception has occurred in internal Ray Data / Ray Core code. |
| 73 | logger.error( |
| 74 | "Exception occurred in Ray Data or Ray Core internal code. " |
| 75 | "If you continue to see this error, please open an issue on " |
| 76 | "the Ray project GitHub page with the full stack trace below: " |
| 77 | "https://github.com/ray-project/ray/issues/new/choose" |
| 78 | ) |
| 79 | |
| 80 | should_hide_traceback = is_user_code_exception and not log_to_stdout |
| 81 | logger.exception( |
| 82 | "Full stack trace:", |
| 83 | exc_info=True, |
| 84 | extra={"hide": should_hide_traceback}, |
| 85 | ) |
| 86 | if is_user_code_exception: |
| 87 | raise e.with_traceback(None) |
| 88 | else: |
| 89 | raise e.with_traceback(None) from SystemException() |
| 90 | |
| 91 | return handle_trace |
nothing calls this directly
no test coverage detected
searching dependent graphs…