Skip to content

Commit 4686c07

Browse files
authored
Change some exceptions to put human readable text in __str__ not __repr__ (#3741)
# Description See #2025 for more context. # Changed Behaviour Rendering of exceptions made with `__repr__` will change to a more machine readable format. Generally Python itself reports exceptions using `__str__`, but DFK task failure history (which goes into the monitoring database) is rendered with `__repr__`. This is probably better behaviour for that history field, which is quasi-machine-readable. ## Type of change - Update to human readable text: Documentation/error messages/comments - Code maintenance/cleanup
1 parent a1c7e30 commit 4686c07

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

parsl/app/errors.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def __init__(self, reason: str, outputs: List[File]) -> None:
7070
self.reason = reason
7171
self.outputs = outputs
7272

73-
def __repr__(self) -> str:
74-
return "Missing Outputs: {0}, Reason:{1}".format(self.outputs, self.reason)
73+
def __str__(self) -> str:
74+
return "Missing Outputs: {0}, Reason: {1}".format(self.outputs, self.reason)
7575

7676

7777
class BadStdStreamFile(ParslError):
@@ -85,11 +85,8 @@ def __init__(self, reason: str) -> None:
8585
super().__init__(reason)
8686
self._reason = reason
8787

88-
def __repr__(self) -> str:
89-
return "Bad Stream File: {}".format(self._reason)
90-
9188
def __str__(self) -> str:
92-
return self.__repr__()
89+
return "Bad Stream File: {}".format(self._reason)
9390

9491

9592
class RemoteExceptionWrapper:

parsl/dataflow/errors.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ class BadCheckpoint(DataFlowException):
2525
def __init__(self, reason: str) -> None:
2626
self.reason = reason
2727

28-
def __repr__(self) -> str:
29-
return self.reason
30-
3128
def __str__(self) -> str:
32-
return self.__repr__()
29+
return self.reason
3330

3431

3532
class DependencyError(DataFlowException):

parsl/executors/high_throughput/errors.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,8 @@ def __init__(self, worker_id, hostname):
3838
self.worker_id = worker_id
3939
self.hostname = hostname
4040

41-
def __repr__(self):
42-
return "Task failure due to loss of worker {} on host {}".format(self.worker_id, self.hostname)
43-
4441
def __str__(self):
45-
return self.__repr__()
42+
return "Task failure due to loss of worker {} on host {}".format(self.worker_id, self.hostname)
4643

4744

4845
class CommandClientTimeoutError(Exception):

0 commit comments

Comments
 (0)