(skip=3)
return '\n'.join(res)
Cleaned-up form of traceback.
Cleaned-up form of traceback.
Cleaned - up form of traceback .
def _short_traceback(skip=3):
  """Cleaned-up form of traceback."""
  counter, res = 0, []
  # Skipping 3 lines by default: the top (useless) and self-call.
  # In python 3, we need to set chain to False (it doesn't exist in python 2).
  lines = traceback.format_exc(chain=False).splitlines()[skip:]  # pylint: disable=unexpected-keyword-arg
  for l in lines:
    if l.startswith('trax.layers.base.LayerError'):
      l = l[len('trax.layers.base.'):]  # Remove the trax.layers.base prefix.
    res.append(_shorten_file_path(l))
    if counter % 2 == 1:
      res.append('')
    counter += 1
    # If we see a LayerError, the traceback has already been processed.
    if l.startswith('LayerError'):
      # Skip 4 back except last as these are internal base-layer calls.
      res = res[:-4] + [res[-1]]
      res += lines[counter:]
      break
  return '\n'.join(res)
def _short_traceback ( skip = 3 ) : counter , res = 0 , [ ] # Skipping 3 lines by default: the top (useless) and self-call. # In python 3, we need to set chain to False (it doesn't exist in python 2). lines = traceback . format_exc ( chain = False ) . splitlines ( ) [ skip : ] # pylint: disable=unexpected-keyword-arg for l in lines : if l . startswith ( 'trax.layers.base.LayerError' ) : l = l [ len ( 'trax.layers.base.' ) : ] # Remove the trax.layers.base prefix. res . append ( _shorten_file_path ( l ) ) if counter % 2 == 1 : res . append ( '' ) counter += 1 # If we see a LayerError, the traceback has already been processed. if l . startswith ( 'LayerError' ) : # Skip 4 back except last as these are internal base-layer calls. res = res [ : - 4 ] + [ res [ - 1 ] ] res += lines [ counter : ] break return '\n' . join ( res )