Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Upgrade to latest TensorBoard
Browse files Browse the repository at this point in the history
It's now much easier to do custom builds of TensorBoard as the standard plugin
list no longer needs to be exhaustively repeated.
  • Loading branch information
jart committed Oct 6, 2017
1 parent 8ba1f93 commit 5334cdb
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 129 deletions.
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ python:
os:
- linux

branches:
only:
- master
- /^\d+\.\d+(\.\d+)?(-\S*)?$/

env:
- NAME=my_plugin BAZEL=0.5.1 TF=NIGHTLY
- NAME=greeter_plugin BAZEL=0.5.4 TF=NIGHTLY
- NAME=greeter_tensorboard BAZEL=0.5.4 TF=NIGHTLY

cache:
directories:
Expand All @@ -32,18 +38,20 @@ before_install:
;;
NIGHTLY)
if [[ "${TRAVIS_PYTHON_VERSION}" == 2* ]]; then
NIGHTLY_URL='https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-cp27-none-linux_x86_64.whl'
NIGHTLY_URL='https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.head-cp27-none-linux_x86_64.whl'
else
NIGHTLY_URL='https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.1-cp34-cp34m-linux_x86_64.whl'
NIGHTLY_URL='https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.head-cp34-cp34m-linux_x86_64.whl'
fi
pip install "${NIGHTLY_URL}"
pip install -I "${NIGHTLY_URL}"
;;
*)
pip install tensorflow=="${TF}"
;;
esac
- pip install pylint
- pip install futures==3.1.1
- pip install grpcio==1.4.0

script:
- |
Expand Down Expand Up @@ -80,9 +88,9 @@ script:
- |
DIR=$(pwd)
cd bazel-genfiles
find "${my_plugin}" -name \*.py -exec cp {} "${DIR}"/{} \;
find "${NAME}" -name \*.py -exec cp {} "${DIR}"/{} \;
cd "${DIR}"
pylint my_plugin
pylint "${NAME}"
before_cache:
- |
Expand Down
32 changes: 16 additions & 16 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ workspace(name = "io_github_tensorflow_tensorboard_plugin_example")

http_archive(
name = "io_bazel_rules_closure",
sha256 = "e9e2538b1f7f27de73fa2914b7d2cb1ce2ac01d1abe8390cfe51fb2558ef8b27",
strip_prefix = "rules_closure-4c559574447f90751f05155faba4f3344668f666",
sha256 = "110fe68753413777944b473c25eed6368c4a0487cee23a7bac1b13cc49d3e257",
strip_prefix = "rules_closure-4af89ef1db659eb41f110df189b67d4cf14073e1",
urls = [
"http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/4c559574447f90751f05155faba4f3344668f666.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/4c559574447f90751f05155faba4f3344668f666.tar.gz", # 2017-06-21
"http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/4af89ef1db659eb41f110df189b67d4cf14073e1.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/4af89ef1db659eb41f110df189b67d4cf14073e1.tar.gz", # 2017-08-28
],
)

Expand All @@ -35,11 +35,11 @@ closure_repositories()

http_archive(
name = "io_bazel_rules_go",
sha256 = "f7e42a4c1f9f31abff9b2bdee6fe4db18bc373287b7e07a5b844446e561e67e2",
strip_prefix = "rules_go-4c9a52aba0b59511c5646af88d2f93a9c0193647",
sha256 = "8c333df68fb0096221e2127eda2807384e00cc211ee7e7ea4ed08d212e6a69c1",
strip_prefix = "rules_go-0.5.4",
urls = [
"http://mirror.bazel.build/github.com/bazelbuild/rules_go/archive/4c9a52aba0b59511c5646af88d2f93a9c0193647.tar.gz", # 2017-05-05
"https://github.com/bazelbuild/rules_go/archive/4c9a52aba0b59511c5646af88d2f93a9c0193647.tar.gz",
"http://mirror.bazel.build/github.com/bazelbuild/rules_go/archive/0.5.4.tar.gz",
"https://github.com/bazelbuild/rules_go/archive/0.5.4.tar.gz",
],
)

Expand All @@ -57,11 +57,11 @@ go_repositories()

http_archive(
name = "io_bazel_rules_webtesting",
sha256 = "bb278df2afe88ed01490e4b25e2c048d453a518cb77d4795f6232a10fbae6c1f",
strip_prefix = "rules_webtesting-dc0530015f201c2707085deba93ad210e89e6d18",
sha256 = "4a34918cdb57b7c0976c1d6a9a7af1d657266b239c9c1066c87d6f9a4058bc7d",
strip_prefix = "rules_webtesting-a9f624ac542d2be75f6f0bdd255f108f2795924a",
urls = [
"http://mirror.bazel.build/github.com/bazelbuild/rules_webtesting/archive/dc0530015f201c2707085deba93ad210e89e6d18.tar.gz", # 2017-05-10
"https://github.com/bazelbuild/rules_webtesting/archive/dc0530015f201c2707085deba93ad210e89e6d18.tar.gz",
"http://mirror.bazel.build/github.com/bazelbuild/rules_webtesting/archive/a9f624ac542d2be75f6f0bdd255f108f2795924a.tar.gz", # 2017-09-11
"https://github.com/bazelbuild/rules_webtesting/archive/a9f624ac542d2be75f6f0bdd255f108f2795924a.tar.gz",
],
)

Expand Down Expand Up @@ -90,11 +90,11 @@ web_test_repositories(

http_archive(
name = "org_tensorflow_tensorboard",
sha256 = "60fe0b58bee52b0cc639b9947b2d1887dd5aafb99feb0baa243ce734f2f65815",
strip_prefix = "tensorboard-3080944fe5828762e7fd43f8f412f3de326eeaa1",
sha256 = "4f57a58463885ffcff5ac66e192c180a42526ef8dd822376518c15e23a65e918",
strip_prefix = "tensorboard-c2a83736477f53cac88d4bc45f55b6f22d3ceb62",
urls = [
"http://mirror.bazel.build/github.com/tensorflow/tensorboard/archive/3080944fe5828762e7fd43f8f412f3de326eeaa1.tar.gz",
"https://github.com/tensorflow/tensorboard/archive/3080944fe5828762e7fd43f8f412f3de326eeaa1.tar.gz", # 2017-08-22
"http://mirror.bazel.build/github.com/tensorflow/tensorboard/archive/c2a83736477f53cac88d4bc45f55b6f22d3ceb62.tar.gz",
"https://github.com/tensorflow/tensorboard/archive/c2a83736477f53cac88d4bc45f55b6f22d3ceb62.tar.gz", # 2017-10-05
],
)

Expand Down
16 changes: 10 additions & 6 deletions greeter_plugin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ py_binary(
name = "greeter_demo",
srcs = ["greeter_demo.py"],
srcs_version = "PY2AND3",
deps = [":greeter_summary"]
deps = [":greeter_summary"],
)

py_library(
Expand All @@ -46,20 +46,24 @@ py_library(

ts_web_library(
name = "greeter_dashboard",
srcs = ["greeter-dashboard.html", "greeter-card.html"],
srcs = [
"greeter-card.html",
"greeter-dashboard.html",
],
path = "/greeter-plugin",
deps = [
"@org_polymer_iron_icon//:org_polymer_iron_icon",
"@org_polymer_paper_icon_button//:org_polymer_paper_icon_button",
"@org_polymer_paper_input//:org_polymer_paper_input",
"@org_tensorflow_tensorboard//tensorboard/components/tf_backend",
"@org_tensorflow_tensorboard//tensorboard/components/tf_dashboard_common",
"@org_tensorflow_tensorboard//tensorboard/components/tf_color_scale",
"@org_tensorflow_tensorboard//tensorboard/components/tf_card_heading",
"@org_tensorflow_tensorboard//tensorboard/components/tf_paginated_view",
"@org_tensorflow_tensorboard//tensorboard/components/tf_categorization_utils",
"@org_tensorflow_tensorboard//tensorboard/components/tf_imports:polymer",
"@org_tensorflow_tensorboard//tensorboard/components/tf_color_scale",
"@org_tensorflow_tensorboard//tensorboard/components/tf_dashboard_common",
"@org_tensorflow_tensorboard//tensorboard/components/tf_imports:lodash",
"@org_tensorflow_tensorboard//tensorboard/components/tf_imports:polymer",
"@org_tensorflow_tensorboard//tensorboard/components/tf_paginated_view",
"@org_tensorflow_tensorboard//tensorboard/components/tf_runs_selector",
"@org_tensorflow_tensorboard//tensorboard/components/tf_tensorboard:registry",
],
)
11 changes: 10 additions & 1 deletion greeter_plugin/greeter-dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<link rel="import" href="../tf-dashboard-common/dashboard-style.html">
<link rel="import" href="../tf-dashboard-common/tf-dashboard-layout.html">
<link rel="import" href="../tf-runs-selector/tf-runs-selector.html">
<link rel="import" href="../tf-tensorboard/registry.html">
<link rel="import" href="greeter-card.html">

<!--
Expand Down Expand Up @@ -106,6 +107,8 @@ <h3>No greeter data was found.</h3>
import {getTags} from '../tf-backend/backend.js';
import {getRouter} from '../tf-backend/router.js';
import {categorizeRunTagCombinations} from '../tf-categorization-utils/categorizationUtils.js';
import {registerDashboard} from '../tf-tensorboard/registry.js';

Polymer({
is: "greeter-dashboard",
properties: {
Expand Down Expand Up @@ -155,5 +158,11 @@ <h3>No greeter data was found.</h3>
return categorizeRunTagCombinations(runToTag, selectedRuns, tagFilter);
},
});

registerDashboard({
plugin: 'greeter',
elementName: 'greeter-dashboard',
});

</script>
</dom-module>
</dom-module>
24 changes: 3 additions & 21 deletions greeter_tensorboard/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@ py_binary(
deps = [
"//greeter_plugin",
"@org_pocoo_werkzeug",
"@org_tensorflow_tensorboard//tensorboard",
"@org_tensorflow_tensorboard//tensorboard:util",
"@org_tensorflow_tensorboard//tensorboard/plugins/audio:audio_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/core:core_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/distribution:distributions_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/graph:graphs_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/histogram:histograms_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/image:images_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/profile:profile_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/projector:projector_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/scalar:scalars_plugin",
"@org_tensorflow_tensorboard//tensorboard/plugins/text:text_plugin",
"@org_tensorflow_tensorboard//tensorboard:default",
"@org_tensorflow_tensorboard//tensorboard:program",
],
)

Expand All @@ -36,15 +26,7 @@ ts_web_library(
"//greeter_plugin:greeter_dashboard",
"@org_tensorflow_tensorboard//tensorboard/components/tf_imports:webcomponentsjs",
"@org_tensorflow_tensorboard//tensorboard/components/tf_tensorboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/audio/tf_audio_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/distribution/tf_distribution_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/graph/tf_graph_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/histogram/tf_histogram_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/image/tf_image_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/profile/tf_profile_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/projector/vz_projector",
"@org_tensorflow_tensorboard//tensorboard/plugins/scalar/tf_scalar_dashboard",
"@org_tensorflow_tensorboard//tensorboard/plugins/text/tf_text_dashboard",
"@org_tensorflow_tensorboard//tensorboard/components/tf_tensorboard:default_plugins",
],
)

Expand Down
47 changes: 18 additions & 29 deletions greeter_tensorboard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,27 @@
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="tf-tensorboard/style.html">

<!-- Import dynamically loaded web components. -->
<link rel="import" href="greeter-plugin/greeter-dashboard.html">
<link rel="import" href="tf-audio-dashboard/tf-audio-dashboard.html">
<link rel="import" href="tf-distribution-dashboard/tf-distribution-dashboard.html">
<link rel="import" href="tf-graph-dashboard/tf-graph-dashboard.html">
<link rel="import" href="tf-histogram-dashboard/tf-histogram-dashboard.html">
<link rel="import" href="tf-image-dashboard/tf-image-dashboard.html">
<link rel="import" href="tf-profile-dashboard/tf-profile-dashboard.html">
<link rel="import" href="tf-scalar-dashboard/tf-scalar-dashboard.html">
<link rel="import" href="tf-text-dashboard/tf-text-dashboard.html">
<link rel="import" href="vz-projector/vz-projector-dashboard.html">

<!-- Tell tf-tensorboard what plugins exist. -->
<script>
const TENSORBOARD_PLUGINS = {
// This object provides the linkage from backend plugins to their
// corresponding dashboards. The key is the `plugin_name` from the
// backend, and the value is the name of the Polymer component on
// the frontend.
'greeter': 'greeter-dashboard',
'scalars': 'tf-scalar-dashboard',
'images': 'tf-image-dashboard',
'audio': 'tf-audio-dashboard',
'graphs': 'tf-graph-dashboard',
'distributions': 'tf-distribution-dashboard',
'histograms': 'tf-histogram-dashboard',
'projector': 'vz-projector-dashboard',
'text': 'tf-text-dashboard',
'profile': 'tf-profile-dashboard',
};
// It's required that Google Analytics be defined, or be faked an the
// following manner (which is the default behavior in the TensorBoard
// open source release.)
window['ga'] = function() {};
</script>

<!--
Load dashboards into UI for all first-party TensorBoard plugins.
Each dashboard calls the registerDashboard() function to tell
<tf-tensorboard> that it exists, so it can be loaded dynamically via
document.createElement().
Ordering matters. The order in which these lines appear determines the
ordering of tabs in TensorBoard's GUI.
-->
<link rel="import" href="greeter-plugin/greeter-dashboard.html">
<link rel="import" href="tf-tensorboard/default-plugins.html">

<!-- Now we load the TensorBoard UI. -->
<link rel="import" href="tf-tensorboard/tf-tensorboard.html">
<body>
<tf-tensorboard use-hash title="My Greeter TensorBoard"></tf-tensorboard>
55 changes: 5 additions & 50 deletions greeter_tensorboard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,61 +16,16 @@
from __future__ import division
from __future__ import print_function

import logging
import os

from tensorboard import util
from tensorboard import main as tb_main
from tensorboard.plugins.audio import audio_plugin
from tensorboard.plugins.core import core_plugin
from tensorboard.plugins.distribution import distributions_plugin
from tensorboard.plugins.graph import graphs_plugin
from tensorboard.plugins.histogram import histograms_plugin
from tensorboard.plugins.image import images_plugin
from tensorboard.plugins.profile import profile_plugin
from tensorboard.plugins.projector import projector_plugin
from tensorboard.plugins.scalar import scalars_plugin
from tensorboard.plugins.text import text_plugin
from tensorboard import default
from tensorboard import program
import tensorflow as tf

from greeter_plugin import greeter_plugin


def get_assets_zip_provider():
path = os.path.join(tf.resource_loader.get_data_files_path(), 'assets.zip')
return lambda: open(path, 'rb')


def main(unused_argv=None):
util.setup_logging()
tb_app = tb_main.create_tb_app(
assets_zip_provider=get_assets_zip_provider(),
# We use the standard TensorBoard plugins, plus our Greeter Plugin
plugins=[
core_plugin.CorePlugin,
greeter_plugin.GreeterPlugin,
scalars_plugin.ScalarsPlugin,
images_plugin.ImagesPlugin,
audio_plugin.AudioPlugin,
graphs_plugin.GraphsPlugin,
distributions_plugin.DistributionsPlugin,
histograms_plugin.HistogramsPlugin,
projector_plugin.ProjectorPlugin,
text_plugin.TextPlugin,
profile_plugin.ProfilePlugin,
])
server, url = tb_main.make_simple_server(tb_app)
logger = logging.getLogger('tensorflow' + util.LogHandler.EPHEMERAL)
logger.setLevel(logging.INFO)

tensorboard_name = 'Greeter TensorBoard 0.1.0'

logger.info('%s at %s (CTRL+C to quit) ', tensorboard_name, url)
try:
server.serve_forever()
finally:
logger.info('')


if __name__ == '__main__':
tf.app.run()
plugins = default.get_plugins() + [greeter_plugin.GreeterPlugin]
assets = os.path.join(tf.resource_loader.get_data_files_path(), 'assets.zip')
program.main(plugins, lambda: open(assets, 'rb'))

0 comments on commit 5334cdb

Please sign in to comment.