Пример #1
0
    def main(self, ignored_argv=('', )):
        """Blocking main function for TensorBoard.

    This method is called by `tensorboard.main.run_main`, which is the
    standard entrypoint for the tensorboard command line program. The
    configure() method must be called first.

    Args:
      ignored_argv: Do not pass. Required for Abseil compatibility.

    Returns:
      Process exit code, i.e. 0 if successful or non-zero on failure. In
      practice, an exception will most likely be raised instead of
      returning non-zero.

    :rtype: int
    """
        if self.flags.inspect:
            logger.info(
                'Not bringing up TensorBoard, but inspecting event files.')
            event_file = os.path.expanduser(self.flags.event_file)
            efi.inspect(self.flags.logdir, event_file, self.flags.tag)
            return 0
        try:
            server = self._make_server()
            sys.stderr.write('TensorBoard %s at %s (Press CTRL+C to quit)\n' %
                             (version.VERSION, server.get_url()))
            sys.stderr.flush()
            server.serve_forever()
            return 0
        except TensorBoardServerException as e:
            logger.error(e.msg)
            sys.stderr.write('ERROR: %s\n' % e.msg)
            sys.stderr.flush()
            return -1
Пример #2
0
def main(unused_argv=None):
  util.setup_logging()
  if FLAGS.inspect:
    tf.logging.info('Not bringing up TensorBoard, but inspecting event files.')
    event_file = os.path.expanduser(FLAGS.event_file)
    efi.inspect(FLAGS.logdir, event_file, FLAGS.tag)
    return 0
  else:
    def ConstructDebuggerPluginWithGrpcPort(context):
      debugger_plugin = debugger_plugin_lib.DebuggerPlugin(context)
      if FLAGS.debugger_data_server_grpc_port is not None:
        debugger_plugin.listen(FLAGS.debugger_data_server_grpc_port)
      return debugger_plugin

    plugins = [
        core_plugin.CorePlugin,
        scalars_plugin.ScalarsPlugin,
        images_plugin.ImagesPlugin,
        audio_plugin.AudioPlugin,
        graphs_plugin.GraphsPlugin,
        distributions_plugin.DistributionsPlugin,
        histograms_plugin.HistogramsPlugin,
        pr_curves_plugin.PrCurvesPlugin,
        projector_plugin.ProjectorPlugin,
        text_plugin.TextPlugin,
        profile_plugin.ProfilePlugin,
        ConstructDebuggerPluginWithGrpcPort,
    ]

    tb = create_tb_app(plugins)
    run_simple_server(tb)
Пример #3
0
def main(unused_argv=None):
    util.setup_logging()
    if FLAGS.inspect:
        tf.logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        event_file = os.path.expanduser(FLAGS.event_file)
        efi.inspect(FLAGS.logdir, event_file, FLAGS.tag)
        return 0
    else:

        def ConstructDebuggerPluginWithGrpcPort(context):
            debugger_plugin = debugger_plugin_lib.DebuggerPlugin(context)
            if FLAGS.debugger_data_server_grpc_port is not None:
                debugger_plugin.listen(FLAGS.debugger_data_server_grpc_port)
            return debugger_plugin

        plugins = [
            core_plugin.CorePlugin,
            scalars_plugin.ScalarsPlugin,
            images_plugin.ImagesPlugin,
            audio_plugin.AudioPlugin,
            graphs_plugin.GraphsPlugin,
            distributions_plugin.DistributionsPlugin,
            histograms_plugin.HistogramsPlugin,
            pr_curves_plugin.PrCurvesPlugin,
            projector_plugin.ProjectorPlugin,
            text_plugin.TextPlugin,
            profile_plugin.ProfilePlugin,
            ConstructDebuggerPluginWithGrpcPort,
        ]

        tb = create_tb_app(plugins)
        run_simple_server(tb)
Пример #4
0
  def main(self, ignored_argv=('',)):
    """Blocking main function for TensorBoard.

    This method is called by `tensorboard.main.run_main`, which is the
    standard entrypoint for the tensorboard command line program. The
    configure() method must be called first.

    Args:
      ignored_argv: Do not pass. Required for Abseil compatibility.

    Returns:
      Process exit code, i.e. 0 if successful or non-zero on failure. In
      practice, an exception will most likely be raised instead of
      returning non-zero.

    :rtype: int
    """
    if self.flags.inspect:
      logger.info('Not bringing up TensorBoard, but inspecting event files.')
      event_file = os.path.expanduser(self.flags.event_file)
      efi.inspect(self.flags.logdir, event_file, self.flags.tag)
      return 0
    try:
      server = self._make_server()
      sys.stderr.write('TensorBoard %s at %s (Press CTRL+C to quit)\n' %
                       (version.VERSION, server.get_url()))
      sys.stderr.flush()
      server.serve_forever()
      return 0
    except TensorBoardServerException as e:
      logger.error(e.msg)
      sys.stderr.write('ERROR: %s\n' % e.msg)
      sys.stderr.flush()
      return -1
Пример #5
0
def main(plugins, assets_zip_provider=None):
    """Main function for TensorBoard.

  This function makes some global changes to the Python environment and
  then delegates to other functions in this module.

  Since this function will generally run forever, it should only be
  called if the Python process is only meant to be a TensorBoard
  server.

  Args:
    plugins: A list of constructor functions for TBPlugin subclasses.
    assets_zip_provider: Delegates to TBContext or uses default if None.

  Returns:
    Process exit code, i.e. 0 if successful or non-zero on failure. In
    practice, an exception will most likely be raised instead of
    returning non-zero.

  :type plugins: list[:class:`base_plugin.TBPlugin`]
  :type assets_zip_provider: () -> file
  :rtype: int
  """
    util.setup_logging()

    if FLAGS.inspect:
        tf.logging.info(
            'Not bringing up TensorBoard, but inspecting event files.')
        event_file = os.path.expanduser(FLAGS.event_file)
        efi.inspect(FLAGS.logdir, event_file, FLAGS.tag)
        return 0

    # The default is HTTP/1.0 for some strange reason. If we don't use
    # HTTP/1.1 then a new TCP socket and Python thread is created for
    # each HTTP request. The tradeoff is we must always specify the
    # Content-Length header, or do chunked encoding for streaming.
    serving.WSGIRequestHandler.protocol_version = 'HTTP/1.1'

    tb = create_tb_app(plugins, assets_zip_provider)
    run_simple_server(tb)

    return 0
Пример #6
0
def main(unused_argv=None):
  if FLAGS.inspect:
    tf.logging.info('Not bringing up TensorBoard, but inspecting event files.')
    event_file = os.path.expanduser(FLAGS.event_file)
    efi.inspect(FLAGS.logdir, event_file, FLAGS.tag)
    return 0
  else:
    plugins = [
        core_plugin.CorePlugin,
        scalars_plugin.ScalarsPlugin,
        images_plugin.ImagesPlugin,
        audio_plugin.AudioPlugin,
        graphs_plugin.GraphsPlugin,
        distributions_plugin.DistributionsPlugin,
        histograms_plugin.HistogramsPlugin,
        projector_plugin.ProjectorPlugin,
        text_plugin.TextPlugin,
    ]
    tb = create_tb_app(plugins)
    run_simple_server(tb)
Пример #7
0
 def main(self, ignored_argv=('', )):
     if self.flags.inspect:
         _logger.log_message_info(
             'Not bringing up GRTensorBoard, but inspecting event files.')
         event_file = os.path.expanduser(self.flags.event_file)
         efi.inspect(self.flags.logdir, event_file, self.flags.tag)
         return 0
     try:
         server = self._make_server()
         sys.stderr.write(
             'GRTensorBoard %s at %s (Press CTRL+C to quit)\n' %
             (VERSION, server.get_url()))
         sys.stderr.flush()
         server.serve_forever()
         return 0
     except program.TensorBoardServerException as e:
         _logger.log_message_info("Error: " + e.msg)
         sys.stderr.write('ERROR: %s\n' % e.msg)
         sys.stderr.flush()
         return -1
Пример #8
0
 def _run_serve_subcommand(self, flags):
     # TODO(#2801): Make `--version` a flag on only the base parser, not `serve`.
     if flags.version_tb:
         print(version.VERSION)
         return 0
     if flags.inspect:
         # TODO(@wchargin): Convert `inspect` to a normal subcommand?
         logger.info(
             "Not bringing up TensorBoard, but inspecting event files.")
         event_file = os.path.expanduser(flags.event_file)
         efi.inspect(flags.logdir, event_file, flags.tag)
         return 0
     try:
         server = self._make_server()
         server.print_serving_message()
         self._register_info(server)
         server.serve_forever()
         return 0
     except TensorBoardServerException as e:
         logger.error(e.msg)
         sys.stderr.write("ERROR: %s\n" % e.msg)
         sys.stderr.flush()
         return -1