MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _InterpolateFunctionError

Class _InterpolateFunctionError

tensorflow/python/eager/function.py:293–329  ·  view source on GitHub ↗

Context Manager that interpolates the exception from 'top_level_func'.

Source from the content-addressed store, hash-verified

291
292
293class _InterpolateFunctionError(object):
294 """Context Manager that interpolates the exception from 'top_level_func'."""
295
296 def __init__(self, top_level_func):
297 self._func = top_level_func
298
299 def __enter__(self):
300 pass
301
302 def __exit__(self, typ, exc, tb):
303 if not exc or not isinstance(exc, errors.OpError):
304 return False
305 message = compat.as_text(exc.message)
306 _, tags = error_interpolation.parse_message(message)
307 g = None
308 func_stack = []
309 for t in tags:
310 if t.type == "function_node":
311 # TODO(mdan): Tests should cover this.
312 if t.name == compat.as_str(self._func.name):
313 g = self._func.graph
314 elif g:
315 next_func = g._get_function(t.name)
316 if next_func is not None and isinstance(next_func,
317 _EagerDefinedFunction):
318 g = next_func.graph
319 if g:
320 func_stack.append(g.name)
321 else:
322 func_stack.append("<unknown>")
323 if g:
324 message = error_interpolation.interpolate(message, g)
325 message += "\n\nFunction call stack:\n"
326 message += " -> ".join(func_stack)
327 message += "\n"
328 exc._message = message # pylint: disable=protected-access
329 return False
330
331
332def _forward_name(n):

Callers 1

callMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected