/
exceptions.py
170 lines (118 loc) · 4.3 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# First Party
from smdebug.core.modes import ModeKeys as modes
class SMDebugError(Exception):
pass
class SMDebugCustomerError(SMDebugError):
pass
class SMDebugTypeError(SMDebugError, TypeError):
pass
class SMDebugRuntimeError(SMDebugError, RuntimeError):
pass
class SMDebugNotImplementedError(SMDebugError, NotImplementedError):
pass
class SMDebugValueError(SMDebugError, ValueError):
pass
class InvalidCollectionConfiguration(SMDebugError):
def __init__(self, c_name):
self.c_name = c_name
def __str__(self):
return f"Collection {self.c_name} has not been configured. \
Please fill in tensor_name or include_regex"
class StepNotYetAvailable(SMDebugError):
def __init__(self, step, mode):
self.step = step
self.mode = mode
def __str__(self):
return "Step {} of mode {} not yet available".format(self.step, self.mode.name)
class MissingCollectionFiles(SMDebugError):
def __init__(self):
pass
def __str__(self):
return "Training job has ended. All the collection files could not be loaded"
class IndexReaderException(SMDebugError):
def __init__(self, message):
self.message = message
def __str__(self):
return self.message
class StepUnavailable(SMDebugError):
def __init__(self, step, mode):
self.step = step
self.mode = mode
def __str__(self):
return "Step {} of mode {} is not available as it was not saved".format(
self.step, self.mode.name
)
class TensorUnavailableForStep(SMDebugError):
def __init__(self, tname, step, mode=modes.GLOBAL, has_reductions=False):
self.step = step
self.mode = mode
self.tname = tname
self.has_reductions = has_reductions
def __str__(self):
msg = (
"Value for tensor {} is not available for step {} "
"with mode {} as it was not saved."
"".format(self.tname, self.step, self.mode.name)
)
if self.has_reductions:
msg += (
"This tensor has reductions saved for this step. "
"You might want to query for the reductions."
)
return msg
class ShapeUnavailableForStep(SMDebugError):
def __init__(self, tname, step, mode=modes.GLOBAL):
self.step = step
self.mode = mode
self.tname = tname
def __str__(self):
msg = (
"Shape for tensor {} is not available for step {} "
"with mode {} as it was not saved."
"".format(self.tname, self.step, self.mode.name)
)
return msg
class TensorUnavailable(SMDebugError):
def __init__(self, tname):
self.tname = tname
def __str__(self):
return "Tensor {} was not saved.".format(self.tname)
class InvalidWorker(SMDebugError):
def __init__(self, worker):
self.worker = worker
def __str__(self):
return "Invalid Worker: {}".format(self.worker)
class NoMoreProfilerData(SMDebugError):
def __init__(self, timestamp):
self.timestamp = timestamp
self.msg = "Looking for timestamp {} and reached " "end of training.".format(timestamp)
def __str__(self):
return self.msg
class NoMoreData(SMDebugError):
def __init__(self, step, mode, last_step):
self.step = step
self.mode = mode
self.last_step = last_step
self.msg = (
"Looking for step {} of mode {} and reached "
"end of training. Max step available is {}".format(
self.step, self.mode.name, self.last_step
)
)
def __str__(self):
return self.msg
class RuleEvaluationConditionMet(SMDebugError):
def __init__(self, rule_name, step, end_of_rule=False):
self.rule_name = rule_name
self.step = step
self.end_of_rule = end_of_rule
def __str__(self):
return "Evaluation of the rule {} at step {} resulted in the condition being met".format(
self.rule_name, self.step
)
class InsufficientInformationForRuleInvocation(SMDebugError):
def __init__(self, rule_name, message):
self.rule_name = rule_name
self.message = message
def __str__(self):
return "Insufficient information to invoke rule {}: {}".format(self.rule_name, self.message)