Skip to content

Commit

Permalink
Give some helpful info on a suspected serialization error
Browse files Browse the repository at this point in the history
Motivated by some requests in #help and by the fact that diagnosing and
fixing serialization-related errors is currently a rather arcane task.
  • Loading branch information
chris-janidlo committed Dec 7, 2023
1 parent 18ba19b commit bf7b9ec
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion compute_sdk/globus_compute_sdk/errors/error_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import re
import textwrap
import time

Expand Down Expand Up @@ -70,11 +71,31 @@ def __str__(self) -> str:
)


SERDE_TASK_EXECUTION_FAILED_HELP_MESSAGE = """
This appears to be an error with serialization. If it is, using a different
serialization strategy from globus_compute_sdk.serialize might resolve the issue. For
example, to use globus_compute_sdk.serialize.CombinedCode:
from globus_compute_sdk import Client, Executor
from globus_compute_sdk.serialize import CombinedCode
gcc = Client(code_serialization_strategy=CombinedCode())
with Executor('<your-endpoint-id>', client=gcc) as gcx:
# do something with gcx
For more information, see:
https://globus-compute.readthedocs.io/en/latest/sdk.html#specifying-a-serialization-strategy
"""


class TaskExecutionFailed(Exception):
"""
Error result from the remote end, wrapped as an exception object
"""

SERDE_REGEX = re.compile("dill|pickle|serializ", re.IGNORECASE)

def __init__(
self,
remote_data: str,
Expand All @@ -87,4 +108,8 @@ def __init__(
self.completion_t = completion_t or str(time.time())

def __str__(self) -> str:
return "\n" + textwrap.indent(self.remote_data, " ")
stack_trace = textwrap.indent(self.remote_data, " ")
message = "\n" + stack_trace
if re.search(TaskExecutionFailed.SERDE_REGEX, stack_trace):
message += SERDE_TASK_EXECUTION_FAILED_HELP_MESSAGE
return message

0 comments on commit bf7b9ec

Please sign in to comment.