Esempio n. 1
0
    def testFlag(self):
        loader = core_plugin.CorePluginLoader()
        loader.fix_flags(FakeFlags(inspect=True, logdir='/tmp'))
        loader.fix_flags(FakeFlags(inspect=True, event_file='/tmp/event.out'))
        loader.fix_flags(FakeFlags(inspect=False, logdir='/tmp'))
        loader.fix_flags(FakeFlags(inspect=False, db='sqlite:foo'))
        # User can pass both, although the behavior is not clearly defined.
        loader.fix_flags(
            FakeFlags(inspect=False, logdir='/tmp', db="sqlite:foo"))

        logdir_or_db_req = r'A logdir or db must be specified'
        one_of_event_or_logdir_req = r'Must specify either --logdir.*but not both.$'
        event_or_logdir_req = r'Must specify either --logdir or --event_file.$'

        with six.assertRaisesRegex(self, ValueError, event_or_logdir_req):
            loader.fix_flags(FakeFlags(inspect=True))
        with six.assertRaisesRegex(self, ValueError, event_or_logdir_req):
            loader.fix_flags(FakeFlags(inspect=True, db='sqlite:~/db.sqlite'))
        with six.assertRaisesRegex(self, ValueError,
                                   one_of_event_or_logdir_req):
            loader.fix_flags(
                FakeFlags(inspect=True,
                          logdir='/tmp',
                          event_file='/tmp/event.out'))
        with six.assertRaisesRegex(self, ValueError, logdir_or_db_req):
            loader.fix_flags(FakeFlags(inspect=False))
        with six.assertRaisesRegex(self, ValueError, logdir_or_db_req):
            loader.fix_flags(
                FakeFlags(inspect=False, event_file='/tmp/event.out'))

        flag = FakeFlags(inspect=False, logdir='/tmp', path_prefix='hello/')
        loader.fix_flags(flag)
        self.assertEqual(flag.path_prefix, 'hello')
Esempio n. 2
0
    def testFlag(self):
        loader = core_plugin.CorePluginLoader()
        loader.fix_flags(FakeFlags(version_tb=True))
        loader.fix_flags(FakeFlags(inspect=True, logdir="/tmp"))
        loader.fix_flags(FakeFlags(inspect=True, event_file="/tmp/event.out"))
        loader.fix_flags(FakeFlags(inspect=False, logdir="/tmp"))
        loader.fix_flags(FakeFlags(inspect=False, db="sqlite:foo"))
        # User can pass both, although the behavior is not clearly defined.
        loader.fix_flags(
            FakeFlags(inspect=False, logdir="/tmp", db="sqlite:foo"))

        logdir_or_db_req = r"A logdir or db must be specified"
        one_of_event_or_logdir_req = (
            r"Must specify either --logdir.*but not both.$")
        event_or_logdir_req = r"Must specify either --logdir or --event_file.$"

        with six.assertRaisesRegex(self, ValueError, event_or_logdir_req):
            loader.fix_flags(FakeFlags(inspect=True))
        with six.assertRaisesRegex(self, ValueError, event_or_logdir_req):
            loader.fix_flags(FakeFlags(inspect=True, db="sqlite:~/db.sqlite"))
        with six.assertRaisesRegex(self, ValueError,
                                   one_of_event_or_logdir_req):
            loader.fix_flags(
                FakeFlags(inspect=True,
                          logdir="/tmp",
                          event_file="/tmp/event.out"))
        with six.assertRaisesRegex(self, ValueError, logdir_or_db_req):
            loader.fix_flags(FakeFlags(inspect=False))
        with six.assertRaisesRegex(self, ValueError, logdir_or_db_req):
            loader.fix_flags(
                FakeFlags(inspect=False, event_file="/tmp/event.out"))
Esempio n. 3
0
 def testPlugins_pluginLoader(self):
     loader = core_plugin.CorePluginLoader()
     tb = program.TensorBoard(
         plugins=[loader],
         assets_zip_provider=fake_asset_provider,
     )
     self.assertIs(tb.plugin_loaders[0], loader)
Esempio n. 4
0
 def testPathPrefix_mustStartWithSlash(self):
     loader = core_plugin.CorePluginLoader()
     flag = FakeFlags(inspect=False, logdir="/tmp", path_prefix="noslash")
     with self.assertRaises(base_plugin.FlagsError) as cm:
         loader.fix_flags(flag)
     msg = str(cm.exception)
     self.assertIn("must start with slash", msg)
     self.assertIn(repr("noslash"), msg)
Esempio n. 5
0
  def testConfigure(self):
    # Many useful flags are defined under the core plugin.
    tb = program.TensorBoard(plugins=[core_plugin.CorePluginLoader()])
    tb.configure(logdir='foo')
    self.assertStartsWith(tb.flags.logdir, 'foo')

    with six.assertRaisesRegex(self, ValueError, 'Unknown TensorBoard flag'):
      tb.configure(foo='bar')
Esempio n. 6
0
 def testPathPrefix_stripsTrailingSlashes(self):
     loader = core_plugin.CorePluginLoader()
     for path_prefix in ("/hello", "/hello/", "/hello//", "/hello///"):
         flag = FakeFlags(inspect=False,
                          logdir="/tmp",
                          path_prefix=path_prefix)
         loader.fix_flags(flag)
         self.assertEqual(
             flag.path_prefix,
             "/hello",
             "got %r (input %r)" % (flag.path_prefix, path_prefix),
         )
 def testPathPrefix_stripsTrailingSlashes(self):
     loader = core_plugin.CorePluginLoader()
     for path_prefix in ('/hello', '/hello/', '/hello//', '/hello///'):
         flag = FakeFlags(inspect=False,
                          logdir='/tmp',
                          path_prefix=path_prefix)
         loader.fix_flags(flag)
         self.assertEqual(
             flag.path_prefix,
             '/hello',
             'got %r (input %r)' % (flag.path_prefix, path_prefix),
         )
Esempio n. 8
0
 def testPlugins_pluginLoader(self):
     loader = core_plugin.CorePluginLoader()
     tb = program.TensorBoard(plugins=[loader])
     self.assertIs(tb.plugin_loaders[0], loader)
Esempio n. 9
0
from tensorboard.plugins.hparams import hparams_plugin_loader
from tensorboard.plugins.image import images_plugin
from tensorboard.plugins.interactive_inference import (
    interactive_inference_plugin_loader)
from tensorboard.plugins.pr_curve import pr_curves_plugin
from tensorboard.plugins.profile import profile_plugin_loader
from tensorboard.plugins.scalar import scalars_plugin
from tensorboard.plugins.text import text_plugin
from tensorboard.plugins.mesh import mesh_plugin

logger = logging.getLogger(__name__)

# Ordering matters. The order in which these lines appear determines the
# ordering of tabs in TensorBoard's GUI.
_PLUGINS = [
    core_plugin.CorePluginLoader(),
    scalars_plugin.ScalarsPlugin,
    custom_scalars_plugin.CustomScalarsPlugin,
    images_plugin.ImagesPlugin,
    audio_plugin.AudioPlugin,
    debugger_plugin_loader.DebuggerPluginLoader(),
    graphs_plugin.GraphsPlugin,
    distributions_plugin.DistributionsPlugin,
    histograms_plugin.HistogramsPlugin,
    bar_plugin.BarsPlugin,
    text_plugin.TextPlugin,
    pr_curves_plugin.PrCurvesPlugin,
    profile_plugin_loader.ProfilePluginLoader(),
    beholder_plugin_loader.BeholderPluginLoader(),
    interactive_inference_plugin_loader.InteractiveInferencePluginLoader(),
    hparams_plugin_loader.HParamsPluginLoader(),
Esempio n. 10
0
def start_tensorboard(logdir):
    tb = tb_program.TensorBoard(plugins=[core_plugin.CorePluginLoader()])
    port = int(os.getenv('TB_PORT', 6006))
    tb.configure(logdir=logdir, port=port)
    tb.launch()
    logging.info("Starting TensorBoard with --logdir=%s" % logdir)
Esempio n. 11
0
    """Angular Text Plugin marked as experimental."""

    pass


class ExperimentalNpmiPlugin(npmi_plugin.NpmiPlugin,
                             experimental_plugin.ExperimentalPlugin):
    """Angular nPMI Plugin marked as experimental."""

    pass


# Ordering matters. The order in which these lines appear determines the
# ordering of tabs in TensorBoard's GUI.
_PLUGINS = [
    core_plugin.CorePluginLoader(include_debug_info=True),
    scalars_plugin.ScalarsPlugin,
    custom_scalars_plugin.CustomScalarsPlugin,
    images_plugin.ImagesPlugin,
    audio_plugin.AudioPlugin,
    debugger_v2_plugin.DebuggerV2Plugin,
    graphs_plugin.GraphsPlugin,
    distributions_plugin.DistributionsPlugin,
    histograms_plugin.HistogramsPlugin,
    text_plugin.TextPlugin,
    pr_curves_plugin.PrCurvesPlugin,
    profile_redirect_plugin.ProfileRedirectPluginLoader,
    hparams_plugin.HParamsPlugin,
    mesh_plugin.MeshPlugin,
    metrics_plugin.MetricsPlugin,
    ExperimentalTextV2Plugin,