Exemplo n.º 1
0
def ensure_tf_logging_patched():
    try:
        from tensorboard.util import tb_logging
    except ImportError:
        pass
    else:
        logger = tb_logging.get_logger()
        logger.info = logger.debug = lambda *_arg, **_kw: None
Exemplo n.º 2
0
def ensure_tf_logging_patched():
    try:
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", Warning)
            from tensorboard.util import tb_logging
    except ImportError:
        pass
    else:
        logger = tb_logging.get_logger()
        logger.info = logger.debug = lambda *_arg, **_kw: None
Exemplo n.º 3
0
 def test_get_all_ignores_bad_files(self):
   with open(os.path.join(self.info_dir, "pid-1234.info"), "w") as outfile:
     outfile.write("good luck parsing this\n")
   with open(os.path.join(self.info_dir, "pid-5678.info"), "w") as outfile:
     outfile.write('{"valid_json":"yes","valid_tbinfo":"no"}\n')
   with open(os.path.join(self.info_dir, "pid-9012.info"), "w") as outfile:
     outfile.write('if a tbinfo has st_mode==0, does it make a sound?\n')
   os.chmod(os.path.join(self.info_dir, "pid-9012.info"), 0o000)
   with mock.patch.object(tb_logging.get_logger(), "warning") as fn:
     self.assertEqual(manager.get_all(), [])
   self.assertEqual(fn.call_count, 2)  # 2 invalid, 1 unreadable (silent)
Exemplo n.º 4
0
def get_all():
  """Return TensorBoardInfo values for running TensorBoard processes.

  This function may not provide a perfect snapshot of the set of running
  processes. Its result set may be incomplete if the user has cleaned
  their /tmp/ directory while TensorBoard processes are running. It may
  contain extraneous entries if TensorBoard processes exited uncleanly
  (e.g., with SIGKILL or SIGQUIT).

  Entries in the info directory that do not represent valid
  `TensorBoardInfo` values will be silently ignored.

  Returns:
    A fresh list of `TensorBoardInfo` objects.
  """
  info_dir = _get_info_dir()
  results = []
  for filename in os.listdir(info_dir):
    filepath = os.path.join(info_dir, filename)
    try:
      with open(filepath) as infile:
        contents = infile.read()
    except IOError as e:
      if e.errno == errno.EACCES:
        # May have been written by this module in a process whose
        # `umask` includes some bits of 0o444.
        continue
      else:
        raise
    try:
      info = _info_from_string(contents)
    except ValueError:
      # Ignore unrecognized files, logging at debug only.
      tb_logging.get_logger().debug(
          "invalid info file: %r",
          filepath,
          exc_info=True,
      )
    else:
      results.append(info)
  return results
Exemplo n.º 5
0
def _ensure_tb_logging_patched():
    """Patch tb logging to supress noisy info and debug logs.

    TB has become very chatty and we want to control our logs. We
    disable outright info and debug logs here.
    """
    try:
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", Warning)
            from tensorboard.util import tb_logging
    except ImportError:
        pass
    else:
        logger = tb_logging.get_logger()
        if logger.info != _null_logger:
            logger.info = logger.debug = _null_logger
Exemplo n.º 6
0
# Minimum length of a logdir polling cycle in seconds. Shorter cycles will
# sleep to avoid spinning over the logdir, which isn't great for disks and can
# be expensive for network file systems.
_MIN_LOGDIR_POLL_INTERVAL_SECS = 5

# Age in seconds of last write after which an event file is considered inactive.
# TODO(@nfelt): consolidate with TensorBoard --reload_multifile default logic.
_EVENT_FILE_INACTIVE_SECS = 4000

# Maximum length of a base-128 varint as used to encode a 64-bit value
# (without the "msb of last byte is bit 63" optimization, to be
# compatible with protobuf and golang varints).
_MAX_VARINT64_LENGTH_BYTES = 10

logger = tb_logging.get_logger()


class TensorBoardUploader(object):
    """Uploads a TensorBoard logdir to TensorBoard.dev."""
    def __init__(
        self,
        writer_client,
        logdir,
        allowed_plugins,
        upload_limits,
        logdir_poll_rate_limiter=None,
        rpc_rate_limiter=None,
        tensor_rpc_rate_limiter=None,
        blob_rpc_rate_limiter=None,
        name=None,
Exemplo n.º 7
0
def _setup_tensorboard_logging():
    from tensorboard.util import tb_logging

    tb_logging.get_logger().info = lambda *_args, **_kw: None
Exemplo n.º 8
0
def silence_info_logging():
    from tensorboard.util import tb_logging

    logger = tb_logging.get_logger()
    logger.info = lambda *_args, **_kw: None
    logger.debug = lambda *_args, **_kw: None