diff options
author | Justine Tunney <jart@google.com> | 2017-06-01 19:24:34 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-06-01 19:27:53 -0700 |
commit | b659bc39f27e81b3249f73710671059589c5daa1 (patch) | |
tree | aa935893366da364e8c3e41a2854c8f192e36b16 | |
parent | 0503ce09c74b2249a38bd4a6254b0b5964836ec3 (diff) |
Simplify TensorBoard build
- Remove tensorboard_typescript_genrule
- Remove tensorboard_typescript_bundle
- Introduce ts_web_library Skylark rule which supports seamless
TypeScript compilation.
- Use Closure Compiler in semi-advanced mode to compile JavaScript.
This is done in a way that preserves <script> tag placement, which
causes pages to load faster and avoid FOUC, thereby making it a
better solution than the existing vulcanize.
PiperOrigin-RevId: 157794795
125 files changed, 1824 insertions, 1841 deletions
@@ -2,11 +2,11 @@ workspace(name = "org_tensorflow") http_archive( name = "io_bazel_rules_closure", - sha256 = "4be8a887f6f38f883236e77bb25c2da10d506f2bf1a8e5d785c0f35574c74ca4", - strip_prefix = "rules_closure-aac19edc557aec9b603cd7ffe359401264ceff0d", + sha256 = "edc91f556b762fc5212d1050d00b12e40dd0b0b1c1d5d96886b59e9a30a6cae4", + strip_prefix = "rules_closure-3f07fb6a58870afbb36051bd5d54da4479561cc6", urls = [ - "http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/aac19edc557aec9b603cd7ffe359401264ceff0d.tar.gz", # 2017-05-10 - "https://github.com/bazelbuild/rules_closure/archive/aac19edc557aec9b603cd7ffe359401264ceff0d.tar.gz", + "http://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/3f07fb6a58870afbb36051bd5d54da4479561cc6.tar.gz", # 2017-05-31 + "https://github.com/bazelbuild/rules_closure/archive/3f07fb6a58870afbb36051bd5d54da4479561cc6.tar.gz", ], ) diff --git a/tensorflow/tensorboard/components/BUILD b/tensorflow/tensorboard/components/BUILD index 1cc2b7caf2..6a0052b793 100644 --- a/tensorflow/tensorboard/components/BUILD +++ b/tensorflow/tensorboard/components/BUILD @@ -1,21 +1,18 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") load("//tensorflow/tensorboard:vulcanize.bzl", "tensorboard_html_binary") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tensorboard", srcs = [ "analytics.html", "tensorboard.html", ], path = "/", - deps = [ - "//tensorflow/tensorboard/components/tf_tensorboard", - "@org_polymer_webcomponentsjs", - ], + deps = ["//tensorflow/tensorboard/components/tf_tensorboard"], ) tensorboard_html_binary( diff --git a/tensorflow/tensorboard/components/tensorboard.html b/tensorflow/tensorboard/components/tensorboard.html index 0652902cfa..afaf396614 100644 --- a/tensorflow/tensorboard/components/tensorboard.html +++ b/tensorflow/tensorboard/components/tensorboard.html @@ -19,7 +19,6 @@ limitations under the License. <meta charset="utf-8"> <title>TensorBoard</title> <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAADECAMAAAD3eH5ZAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAD/UExURfFlKfaELvFmKfNyK/67NvWALf68Nv69NvNxK/20NfyyNP22NfN0K/JrKvqhMv2zNf25Nf24Nf23NfeOL/yzNPyvNPJoKviWMPmeMfN1K/WBLfePL/FnKfeML/qlMvR7LPmcMfeLL/aJLvR5LPFoKfJuKvR3LP66NvywNPeNL/V/LfaILv21Nf26NfNzK/NvK/R6LPmaMfyxNPqfMvV+LfurM/iSMPmbMfJvKvmdMfumM/qiMvmZMfytNPJqKvysNPN2K/iYMPNwK/upM/JtKvJsKviVMPaHLvaGLvJpKvR8LPaKLvqkMvuqM/aFLvR4LPuoM/iTMPWDLfiRMPmYMXS0ngkAAALoSURBVHja7drnctpAFIbhFUISSKJ3MKYa0+y4xTW9937/15JkJhlTjhrSrHRmvuf/as6L0YLFCgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBJ6njenqspzgnPrsrGX9Zpi2tCrmnc6+dYNthVY5WpMmxQLWPdMsOuYVwzNj3ei2t3mQwaV43BJPDCS2NbJ5aEeuX/+9qcjQOtfFIkIkrvY2g4MVcmOBsFWbowKO/kNyj62gRpJcDaPBlxLr1B0zdG0C/8LzbJiJrshuvy1gzlA9+rD8mIkuyIJjFE3/dqnYwoSm7IUEPoD/wut8iIguSIDjlFxe/yfXL5vuSI21BTZLLhXoOILMO8Hxwa/L8bI0LfmUdhGowb2ZvT0e57pFNDgB06IlVyjmmIBl2T/nl9Rw6SD9GgSG/Q0uQkaW3XhmovKQ3eFQ4N2Uo9OQ1eFZsNerf7vP+rO4rhmY1Lg3vFVoP8+8BXg1sFnwbnCk4NThW8GuiKBDdkVVtTNFvNelVsNqTbyWnIOM2oeTRoyWvwmpJHg/ucXBrcJuXT4DwrpwZi2vy0VCx8YtXg/D2bU4OfiuQ3eFfE2KD4bfCqiLNB993gXsGlwa2CT4NzBacGIVQ6YsipQdh0xEdODUKjIxrSp88onZ8zbbFLg1DoiFO5BXvDGv2My9/JhUT8JUZTI0yDaNHLBzIbvqTDNYhUiVw/kdjQ1kM2CHFDPjKW+KzyRTF0g/ga9w9y+fANQpxvX8CU+Ny7FUWDeF3Y+g3lROIf4k0UDX9eCyvO531PyYhHga9zvPZJU5b73Y/eXj8Hv9D48n6HaF5LbcjRt8TZTtda5M1DfXnbkX1C0SHCFKzQB5Fe8op4GNGNHavvZESbVwT5r6W1xyuCPBY3Y9YgDqzknH/e3YfNzzuL30l0IebrZ5kKtuDIXt1n868ET6kf3/49tLvrCcZyF8Pu215dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcPIbNrBhOaBXucoAAAAASUVORK5CYII="> -<script src="webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="tf-tensorboard/style.html"> <link rel="import" href="tf-tensorboard/tf-tensorboard.html"> <link rel="import" href="analytics.html"> diff --git a/tensorflow/tensorboard/components/tf_audio_dashboard/BUILD b/tensorflow/tensorboard/components/tf_audio_dashboard/BUILD index 1e599cb710..18009043d2 100644 --- a/tensorflow/tensorboard/components/tf_audio_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_audio_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_audio_dashboard", srcs = [ "tf-audio-dashboard.html", @@ -17,7 +17,7 @@ web_library( "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_paper_icon_button", "@org_polymer_paper_slider", "@org_polymer_paper_spinner", @@ -25,7 +25,7 @@ web_library( ], ) -web_library( +ts_web_library( name = "index", srcs = [ "demo/index.html", @@ -35,11 +35,11 @@ web_library( deps = [ ":tf_audio_dashboard", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "//tensorflow/tensorboard/demo:demo_data", "@org_polymer_iron_component_page", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_audio_dashboard/demo/index.html b/tensorflow/tensorboard/components/tf_audio_dashboard/demo/index.html index 177bc85db0..dc8cd91d43 100644 --- a/tensorflow/tensorboard/components/tf_audio_dashboard/demo/index.html +++ b/tensorflow/tensorboard/components/tf_audio_dashboard/demo/index.html @@ -42,14 +42,16 @@ limitations under the License. <tf-audio-dashboard id="demo" backend="[[backend]]"></tf-audio-dashboard> </template> <script> + import {Backend} from '../tf-backend/backend'; + import {router} from '../tf-backend/router'; + Polymer({ is: "audio-dash-demo", properties: { backend: { type: Object, value: function() { - var router = new TF.Backend.router("/data", true); - return new TF.Backend.Backend(router); + return new Backend(new router("/data", true)); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_audio_dashboard/test/BUILD b/tensorflow/tensorboard/components/tf_audio_dashboard/test/BUILD index 62082ef41c..d40c43986d 100644 --- a/tensorflow/tensorboard/components/tf_audio_dashboard/test/BUILD +++ b/tensorflow/tensorboard/components/tf_audio_dashboard/test/BUILD @@ -3,15 +3,14 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "audioDashboardTests.js", + "audioDashboardTests.ts", "tests.html", ], path = "/tf-audio-dashboard/test", @@ -19,24 +18,10 @@ web_library( "//tensorflow/tensorboard/components/tf_audio_dashboard", "//tensorflow/tensorboard/components/tf_backend", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "//tensorflow/tensorboard/demo:demo_data", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", - ], -) - -tensorboard_typescript_genrule( - name = "ts", - srcs = ["audioDashboardTests.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "@org_definitelytyped//:sinon.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_backend:bundle.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", ], ) diff --git a/tensorflow/tensorboard/components/tf_audio_dashboard/test/audioDashboardTests.ts b/tensorflow/tensorboard/components/tf_audio_dashboard/test/audioDashboardTests.ts index 8cfa97e6b2..2c18a6f179 100644 --- a/tensorflow/tensorboard/components/tf_audio_dashboard/test/audioDashboardTests.ts +++ b/tensorflow/tensorboard/components/tf_audio_dashboard/test/audioDashboardTests.ts @@ -13,6 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +import * as backend_backend from '../../tf-backend/backend'; +import * as backend_router from '../../tf-backend/router'; + // TODO(dandelion): Fix me. declare function fixture(id: string): any; declare function stub(x, y: any): void; @@ -22,8 +25,8 @@ describe('audio dashboard tests', () => { let reloadCount = 0; beforeEach(() => { audioDash = fixture('testElementFixture'); - const router = TF.Backend.router('/data', true); - const backend = new TF.Backend.Backend(router); + const router = backend_router.router('/data', true); + const backend = new backend_backend.Backend(router); audioDash.backend = backend; stub('tf-audio-loader', { reload: () => { reloadCount++; }, diff --git a/tensorflow/tensorboard/components/tf_audio_dashboard/tf-audio-dashboard.html b/tensorflow/tensorboard/components/tf_audio_dashboard/tf-audio-dashboard.html index 0353c51628..7caea7130d 100644 --- a/tensorflow/tensorboard/components/tf_audio_dashboard/tf-audio-dashboard.html +++ b/tensorflow/tensorboard/components/tf_audio_dashboard/tf-audio-dashboard.html @@ -59,18 +59,25 @@ tf-audio-dashboard displays a dashboard that loads audio from a TensorFlow run. </style> </template> <script> - TF.Dashboard.TfAudioDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + + Polymer({ is: "tf-audio-dashboard", factoryImpl: function(backend) { this.backend = backend; }, properties: { - dataType: {value: "audio"}, + dataType: { + type: Object, + value: "audio", + }, }, behaviors: [ - TF.Dashboard.DashboardBehavior("audio"), - TF.Dashboard.ReloadBehavior("tf-audio-loader"), - TF.Backend.BackendBehavior + DashboardBehavior("audio"), + ReloadBehavior("tf-audio-loader"), + BackendBehavior, ], attached: function() { this.async(function() { diff --git a/tensorflow/tensorboard/components/tf_backend/BUILD b/tensorflow/tensorboard/components/tf_backend/BUILD index 1691094a1c..03dd2aba9f 100644 --- a/tensorflow/tensorboard/components/tf_backend/BUILD +++ b/tensorflow/tensorboard/components/tf_backend/BUILD @@ -1,16 +1,19 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_backend", srcs = [ - "bundle.js", + "backend.ts", + "behavior.ts", + "requestManager.ts", + "router.ts", "tf-backend.html", + "urlPathHelpers.ts", ], path = "/tf-backend", visibility = ["//visibility:public"], @@ -18,39 +21,22 @@ web_library( "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", "//tensorflow/tensorboard/components/tf_imports:plottable", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/vz_sorting", - "@org_polymer", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/tf_imports:plottable.d.ts", - "//tensorflow/tensorboard/components/vz_sorting:bundle.d.ts", +tensorboard_webcomponent_library( + name = "legacy", + srcs = [":tf_backend"], + destdir = "tf-backend", + deps = [ + "//tensorflow/tensorboard/components/tf_imports_google:lib", + "//tensorflow/tensorboard/components/vz_sorting:legacy", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.Backend": [ - "requestManager.ts", - "backend.ts", - "behavior.ts", - "urlPathHelpers.ts", - "router.ts", - ]}, - namespace_symbol_aliases = {"TF.Backend": { - "compareTagNames": "VZ.Sorting.compareTagNames", - }}, -) - filegroup( name = "all_files", srcs = glob(["**"]), diff --git a/tensorflow/tensorboard/components/tf_backend/backend.ts b/tensorflow/tensorboard/components/tf_backend/backend.ts index 2db8ddc23d..5d04831102 100644 --- a/tensorflow/tensorboard/components/tf_backend/backend.ts +++ b/tensorflow/tensorboard/components/tf_backend/backend.ts @@ -13,10 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 - -import {compareTagNames} from '../vz_sorting/sorting'; - +import {compareTagNames} from '../vz-sorting/sorting'; import {RequestManager} from './requestManager'; import {Router} from './router'; import {demoify} from './urlPathHelpers'; diff --git a/tensorflow/tensorboard/components/tf_backend/behavior.ts b/tensorflow/tensorboard/components/tf_backend/behavior.ts index 4f6af2f3ba..7ff9df8cf4 100644 --- a/tensorflow/tensorboard/components/tf_backend/behavior.ts +++ b/tensorflow/tensorboard/components/tf_backend/behavior.ts @@ -14,6 +14,7 @@ limitations under the License. ==============================================================================*/ import {getRuns, getTags, TYPES} from './backend'; +/** @polymerBehavior */ export const BackendBehavior = { properties: { /** *** Required properties *** */ diff --git a/tensorflow/tensorboard/components/tf_backend/test/BUILD b/tensorflow/tensorboard/components/tf_backend/test/BUILD index 5cf09f0a9c..908f289963 100644 --- a/tensorflow/tensorboard/components/tf_backend/test/BUILD +++ b/tensorflow/tensorboard/components/tf_backend/test/BUILD @@ -3,51 +3,27 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", "tests.html", + "backendTests.ts", + "behaviorTests.ts", + "requestManagerTests.ts", ] + glob(["data/**"]), path = "/tf-backend/test", deps = [ "//tensorflow/tensorboard/components/tf_backend", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", - ], -) - -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_backend:bundle.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/tf_imports:plottable.d.ts", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", ], ) -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.Backend": [ - "backendTests.ts", - "behaviorTests.ts", - "requestManagerTests.ts", - ]}, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/tf_backend/test/tests.html b/tensorflow/tensorboard/components/tf_backend/test/tests.html index cdc17c2607..58cb89a30b 100644 --- a/tensorflow/tensorboard/components/tf_backend/test/tests.html +++ b/tensorflow/tensorboard/components/tf_backend/test/tests.html @@ -30,6 +30,8 @@ limitations under the License. <test-element id="test"></test-element> </template> </test-fixture> - <script src="bundle.js"></script> + <script src="backendTests.js"></script> + <script src="behaviorTests.js"></script> + <script src="requestManagerTests.js"></script> </body> </html> diff --git a/tensorflow/tensorboard/components/tf_backend/tf-backend.html b/tensorflow/tensorboard/components/tf_backend/tf-backend.html index 5bf2663362..4cfed247a5 100644 --- a/tensorflow/tensorboard/components/tf_backend/tf-backend.html +++ b/tensorflow/tensorboard/components/tf_backend/tf-backend.html @@ -20,4 +20,8 @@ limitations under the License. <link rel="import" href="../tf-imports/d3.html"> <link rel="import" href="../vz-sorting/vz-sorting.html"> -<script src="bundle.js"></script> +<script src="requestManager.js"></script> +<script src="urlPathHelpers.js"></script> +<script src="backend.js"></script> +<script src="behavior.js"></script> +<script src="router.js"></script> diff --git a/tensorflow/tensorboard/components/tf_color_scale/BUILD b/tensorflow/tensorboard/components/tf_color_scale/BUILD index 3ec3d26051..afe98ec5b5 100644 --- a/tensorflow/tensorboard/components/tf_color_scale/BUILD +++ b/tensorflow/tensorboard/components/tf_color_scale/BUILD @@ -1,57 +1,37 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_color_scale", srcs = [ - "bundle.js", + "colorScale.ts", + "palettes.ts", "tf-color-scale.html", ], path = "/tf-color-scale", deps = [ "//tensorflow/tensorboard/components/tf_imports:d3", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/tf-color-scale", deps = [ ":tf_color_scale", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_button", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", - ], -) - -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", ], ) -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF": [ - "palettes.ts", - "colorScale.ts", - ]}, -) - filegroup( name = "all_files", srcs = glob(["**"]), diff --git a/tensorflow/tensorboard/components/tf_color_scale/colorScale.ts b/tensorflow/tensorboard/components/tf_color_scale/colorScale.ts index ff90d46aa2..6916e3bb2d 100644 --- a/tensorflow/tensorboard/components/tf_color_scale/colorScale.ts +++ b/tensorflow/tensorboard/components/tf_color_scale/colorScale.ts @@ -19,9 +19,8 @@ limitations under the License. // ccs.domain(runs); // ccs.getColor("train"); // ccs.getColor("test1"); -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import {palettes} from './palettes' +import {palettes} from './palettes' export class ColorScale { private palette: string[]; @@ -29,8 +28,8 @@ export class ColorScale { /** * Creates a color scale with optional custom palette. - * @param {string[]} [palette=palettes.googleColorBlind] - The color - * palette you want as an Array of hex strings. + * @param {Array<string>} [palette=palettes.googleColorBlind] - The color + * palette you want as an Array of hex strings. */ constructor(palette: string[] = palettes.googleColorBlindAssist) { this.palette = palette; @@ -38,8 +37,8 @@ export class ColorScale { /** * Set the domain of strings. - * @param {string[]} strings - An array of possible strings to use as the - * domain for your scale. + * @param {Array<string>} strings - An array of possible strings to use as the + * domain for your scale. */ public domain(strings: string[]): this { this.identifiers = d3.map(); diff --git a/tensorflow/tensorboard/components/tf_color_scale/test/BUILD b/tensorflow/tensorboard/components/tf_color_scale/test/BUILD index 6071b20886..dab2779dc3 100644 --- a/tensorflow/tensorboard/components/tf_color_scale/test/BUILD +++ b/tensorflow/tensorboard/components/tf_color_scale/test/BUILD @@ -3,43 +3,25 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", + "colorScaleTests.ts", "tests.html", ], path = "/tf-color-scale/test", deps = [ "//tensorflow/tensorboard/components/tf_color_scale", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "//tensorflow/tensorboard/components/tf_color_scale:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF": ["colorScaleTests.ts"]}, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/tf_color_scale/test/tests.html b/tensorflow/tensorboard/components/tf_color_scale/test/tests.html index eccc32cdec..59c802d02b 100644 --- a/tensorflow/tensorboard/components/tf_color_scale/test/tests.html +++ b/tensorflow/tensorboard/components/tf_color_scale/test/tests.html @@ -21,4 +21,4 @@ limitations under the License. <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="../tf-color-scale.html"> <body> -<script src="bundle.js"></script> +<script src="colorScaleTests.js"></script> diff --git a/tensorflow/tensorboard/components/tf_color_scale/tf-color-scale.html b/tensorflow/tensorboard/components/tf_color_scale/tf-color-scale.html index 3dedfaf1a1..a325f0a04c 100644 --- a/tensorflow/tensorboard/components/tf_color_scale/tf-color-scale.html +++ b/tensorflow/tensorboard/components/tf_color_scale/tf-color-scale.html @@ -26,5 +26,6 @@ a set of colors. @element tf-color-scale --> <dom-module id="tf-color-scale"> - <script src="bundle.js"></script> + <script src="palettes.js"></script> + <script src="colorScale.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/BUILD b/tensorflow/tensorboard/components/tf_dashboard_common/BUILD index f9a990e379..b504fe79f9 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/BUILD +++ b/tensorflow/tensorboard/components/tf_dashboard_common/BUILD @@ -1,33 +1,33 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_dashboard_common", srcs = [ + "dashboard-behavior.ts", "dashboard-style.html", + "reload-behavior.ts", "run-color-style.html", "scrollbar-style.html", "tensorboard-color.html", "tf-categorizer.html", - "tf-categorizer-bundle.js", + "tf-categorizer.ts", "tf-chart-scaffold.html", "tf-collapsable-pane.html", "tf-dashboard.html", - "tf-dashboard.js", "tf-dashboard-layout.html", "tf-downloader.html", "tf-multi-checkbox.html", - "tf-multi-checkbox-bundle.js", + "tf-multi-checkbox.ts", "tf-no-data-warning.html", "tf-option-selector.html", "tf-panes-helper.html", "tf-regex-group.html", - "tf-regex-group-bundle.js", + "tf-regex-group.ts", "tf-run-selector.html", "tf-sidebar-helper.html", ], @@ -35,9 +35,9 @@ web_library( deps = [ "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/tf_storage", "//tensorflow/tensorboard/components/vz_sorting", - "@org_polymer", "@org_polymer_iron_ajax", "@org_polymer_iron_collapse", "@org_polymer_iron_icons", @@ -56,7 +56,7 @@ web_library( ], ) -web_library( +ts_web_library( name = "demo", srcs = [ "tf-categorizer-demo.html", @@ -73,91 +73,9 @@ web_library( ], ) -tensorboard_typescript_bundle( - name = "tf_categorizer_bundle", - out = "tf-categorizer-bundle.ts", - namespace_srcs = {"TF.Dashboard.Categorizer": ["tf-categorizer.ts"]}, - namespace_symbol_aliases = {"TF.Dashboard.Categorizer": {"compareTagNames": "VZ.Sorting.compareTagNames"}}, -) - -tensorboard_typescript_genrule( - name = "tf_categorizer_ts", - srcs = ["tf-categorizer-bundle.ts"], - typings = [ - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/vz_sorting:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "tf_regex_group_bundle", - out = "tf-regex-group-bundle.ts", - namespace_srcs = {"TF.Dashboard.RegexGroup": ["tf-regex-group.ts"]}, - namespace_symbol_aliases = {"TF.Dashboard.RegexGroup": {"storage": "TF.URIStorage"}}, -) - -tensorboard_typescript_genrule( - name = "tf_regex_group_ts", - srcs = ["tf-regex-group-bundle.ts"], - typings = [ - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_storage:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "tf_multi_checkbox_bundle", - out = "tf-multi-checkbox-bundle.ts", - namespace_srcs = {"TF.Dashboard.MultiCheckbox": ["tf-multi-checkbox.ts"]}, - namespace_symbol_aliases = {"TF.Dashboard.MultiCheckbox": {"storage": "TF.URIStorage"}}, -) - -tensorboard_typescript_genrule( - name = "tf_multi_checkbox_ts", - srcs = ["tf-multi-checkbox-bundle.ts"], - typings = [ - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_storage:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "tf_dashboard_bundle", - out = "tf-dashboard.ts", - namespace_srcs = { - "TF.Dashboard": [ - "dashboard-behavior.ts", - "reload-behavior.ts", - ], - }, -) - -tensorboard_typescript_genrule( - name = "tf_dashboard_ts", - srcs = ["tf-dashboard.ts"], -) - -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = glob(["*.html"]) + [":legacy_ts"], + srcs = [":tf_dashboard_common"], destdir = "tf-dashboard-common", deps = [ "//tensorflow/tensorboard/components/tf_imports_google:lib", @@ -182,19 +100,8 @@ tensorboard_webcomponent_library( ], ) -tensorboard_ts_library( - name = "legacy_ts", - srcs = [ - "dashboard-behavior.ts", - "reload-behavior.ts", - "tf-categorizer.ts", - ], - deps_mgmt = "off", - runtime = "nodejs", - deps = [ - "//tensorflow/tensorboard/components/vz_sorting:legacy_ts", - "//third_party/javascript/typings/d3_v4:bundle", - "//third_party/javascript/typings/lodash", - "//third_party/javascript/typings/polymer:polymer_without_externs", - ], +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], ) diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/dashboard-behavior.ts b/tensorflow/tensorboard/components/tf_dashboard_common/dashboard-behavior.ts index 3e40da1452..aa063c7422 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/dashboard-behavior.ts +++ b/tensorflow/tensorboard/components/tf_dashboard_common/dashboard-behavior.ts @@ -16,6 +16,8 @@ limitations under the License. /** * A behavior that TensorBoard dashboards must implement. This behavior serves * the purpose of an interface. + * + * @polymerBehavior */ export function DashboardBehavior(dashboardName) { return { diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/reload-behavior.ts b/tensorflow/tensorboard/components/tf_dashboard_common/reload-behavior.ts index 8b5ca120d6..61fe0c0781 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/reload-behavior.ts +++ b/tensorflow/tensorboard/components/tf_dashboard_common/reload-behavior.ts @@ -20,6 +20,8 @@ limitations under the License. * and call a `reload` method on that child. * May later extend it so it has more sophisticated logic, e.g. reloading * only tags that are in view. + * + * @polymerBehavior */ export function ReloadBehavior(tagName) { return { diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/test/BUILD b/tensorflow/tensorboard/components/tf_dashboard_common/test/BUILD index e82c4bd63c..3cad646b96 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/test/BUILD +++ b/tensorflow/tensorboard/components/tf_dashboard_common/test/BUILD @@ -3,44 +3,25 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", "tests.html", + "tf-categorizer-tests.ts", ], path = "/tf-dashboard-common/test", deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "//tensorflow/tensorboard/components/tf_dashboard_common:tf-categorizer-bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.Dashboard": ["tf-categorizer-tests.ts"]}, - namespace_symbol_aliases = {"TF.Dashboard": {"cat": "TF.Dashboard.Categorizer"}}, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/test/tests.html b/tensorflow/tensorboard/components/tf_dashboard_common/test/tests.html index cd33cee474..c9ad14730f 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/test/tests.html +++ b/tensorflow/tensorboard/components/tf_dashboard_common/test/tests.html @@ -21,4 +21,4 @@ limitations under the License. <script src="../../web-component-tester/browser.js"></script> <link rel="import" href="../tf-categorizer.html"> <body> -<script src="bundle.js"></script> +<script src="tf-categorizer-tests.js"></script> diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.html b/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.html index 6388ab5e7d..f09eb03582 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.html +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.html @@ -59,5 +59,5 @@ categories are exclusive. } </style> </template> - <script src="tf-categorizer-bundle.js"></script> + <script src="tf-categorizer.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.ts b/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.ts index ebece84246..0eaf852ff1 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.ts +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-categorizer.ts @@ -13,10 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import * as _ from 'lodash'; - -import {compareTagNames} from '../vz_sorting/sorting'; +import {compareTagNames} from '../vz-sorting/sorting'; /** * This module contains methods that allow sorting tags into 'categories'. diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-dashboard.html b/tensorflow/tensorboard/components/tf_dashboard_common/tf-dashboard.html index 475c2cef3b..9e2f6b9589 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-dashboard.html +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-dashboard.html @@ -22,4 +22,5 @@ limitations under the License. <link rel="import" href="tf-downloader.html"> <link rel="import" href="tf-no-data-warning.html"> -<script src="tf-dashboard.js"></script> +<script src="dashboard-behavior.js"></script> +<script src="reload-behavior.js"></script> diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.html b/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.html index 8a56616f82..fad4642963 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.html +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.html @@ -156,5 +156,5 @@ handle these situations gracefully. } </style> </template> - <script src="tf-multi-checkbox-bundle.js"></script> + <script src="tf-multi-checkbox.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.ts b/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.ts index 44a14a21cf..4b38d82b14 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.ts +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-multi-checkbox.ts @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as _ from 'lodash'; import * as storage from '../tf-storage/storage'; Polymer({ diff --git a/tensorflow/tensorboard/components/tf_dashboard_common/tf-regex-group.html b/tensorflow/tensorboard/components/tf_dashboard_common/tf-regex-group.html index e68b306ee3..c1d3cf06ae 100644 --- a/tensorflow/tensorboard/components/tf_dashboard_common/tf-regex-group.html +++ b/tensorflow/tensorboard/components/tf_dashboard_common/tf-regex-group.html @@ -95,5 +95,5 @@ more regexes). </template> </div> </template> - <script src="tf-regex-group-bundle.js"></script> + <script src="tf-regex-group.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD b/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD index dcd5047bf4..fe089b80b4 100644 --- a/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_distribution_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_distribution_dashboard", srcs = ["tf-distribution-dashboard.html"], path = "/tf-distribution-dashboard", @@ -13,24 +13,24 @@ web_library( "//tensorflow/tensorboard/components/tf_color_scale", "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:lodash", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/vz_distribution_chart", - "@org_polymer", "@org_polymer_iron_collapse", "@org_polymer_paper_icon_button", "@org_polymer_paper_styles", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-distribution-dashboard", deps = [ ":tf_distribution_dashboard", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_distribution_dashboard/index.html b/tensorflow/tensorboard/components/tf_distribution_dashboard/index.html index 5e825f13f5..2c30044648 100644 --- a/tensorflow/tensorboard/components/tf_distribution_dashboard/index.html +++ b/tensorflow/tensorboard/components/tf_distribution_dashboard/index.html @@ -43,14 +43,17 @@ limitations under the License. <tf-distribution-dashboard id="demo" backend="[[backend]]"></tf-distribution-dashboard> </template> <script> + import {Backend} from "../../tf-backend/backend"; + import {router} from "../../tf-backend/router"; + Polymer({ is: "distribution-dash-demo", properties: { backend: { type: Object, value: function() { - var router = new TF.Backend.router("data", true); - return new TF.Backend.Backend(router); + var router = new router("data", true); + return new Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_distribution_dashboard/tf-distribution-dashboard.html b/tensorflow/tensorboard/components/tf_distribution_dashboard/tf-distribution-dashboard.html index 063bd8d099..76de74273f 100644 --- a/tensorflow/tensorboard/components/tf_distribution_dashboard/tf-distribution-dashboard.html +++ b/tensorflow/tensorboard/components/tf_distribution_dashboard/tf-distribution-dashboard.html @@ -101,15 +101,19 @@ contains vz-distribution-charts embedded inside tf-panes-helper's. </template> <script> - TF.Dashboard.TfDistributionDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + + Polymer({ is: "tf-distribution-dashboard", factoryImpl: function(backend) { this.backend = backend; }, behaviors: [ - TF.Dashboard.DashboardBehavior("distributions"), - TF.Dashboard.ReloadBehavior("tf-chart-scaffold"), - TF.Backend.BackendBehavior, + DashboardBehavior("distributions"), + ReloadBehavior("tf-chart-scaffold"), + BackendBehavior, ], properties: { backend: Object, @@ -117,7 +121,10 @@ contains vz-distribution-charts embedded inside tf-panes-helper's. type: String, value: "step" }, - dataType: {value: "compressedHistogram"}, + dataType: { + type: Object, + value: "compressedHistogram", + }, }, }); </script> diff --git a/tensorflow/tensorboard/components/tf_globals/BUILD b/tensorflow/tensorboard/components/tf_globals/BUILD index ca59c2fb93..0ffefd7968 100644 --- a/tensorflow/tensorboard/components/tf_globals/BUILD +++ b/tensorflow/tensorboard/components/tf_globals/BUILD @@ -1,29 +1,23 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_globals", srcs = [ - "bundle.js", + "globals.ts", "tf-globals.html", ], path = "/tf-globals", ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.Globals": ["globals.ts"]}, +tensorboard_webcomponent_library( + name = "legacy", + srcs = [":tf_globals"], + destdir = "tf-globals", ) filegroup( @@ -31,25 +25,3 @@ filegroup( srcs = glob(["**"]), tags = ["notsan"], ) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - -tensorboard_webcomponent_library( - name = "legacy", - srcs = [ - "tf-globals.html", - ":legacy_ts", - ], - destdir = "tf-globals", -) - -tensorboard_ts_library( - name = "legacy_ts", - srcs = ["globals.ts"], - deps_mgmt = "off", - runtime = "nodejs", -) diff --git a/tensorflow/tensorboard/components/tf_globals/globals.ts b/tensorflow/tensorboard/components/tf_globals/globals.ts index 7d4229dccb..fb6bb83b97 100644 --- a/tensorflow/tensorboard/components/tf_globals/globals.ts +++ b/tensorflow/tensorboard/components/tf_globals/globals.ts @@ -13,8 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ - - // The names of TensorBoard tabs. export const TABS = [ 'scalars', 'images', 'audio', 'graphs', 'distributions', 'histograms', diff --git a/tensorflow/tensorboard/components/tf_globals/tf-globals.html b/tensorflow/tensorboard/components/tf_globals/tf-globals.html index b0fd74d4f2..efb8e92e08 100644 --- a/tensorflow/tensorboard/components/tf_globals/tf-globals.html +++ b/tensorflow/tensorboard/components/tf_globals/tf-globals.html @@ -15,5 +15,5 @@ See the License for the specific language governing permissions and limitations under the License. --> -<script src="bundle.js"></script> +<script src="globals.js"></script> diff --git a/tensorflow/tensorboard/components/tf_graph/BUILD b/tensorflow/tensorboard/components/tf_graph/BUILD index 115964a59b..92d2e8a42a 100644 --- a/tensorflow/tensorboard/components/tf_graph/BUILD +++ b/tensorflow/tensorboard/components/tf_graph/BUILD @@ -1,10 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph", srcs = [ "tf-graph.html", @@ -15,7 +16,7 @@ web_library( deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_graph_common", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_iron_flex_layout", "@org_polymer_iron_icons", "@org_polymer_paper_button", @@ -28,26 +29,28 @@ web_library( ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph.html", - "tf-graph-minimap.html", - "tf-graph-scene.html", - ], + srcs = [":tf_graph"], destdir = "tf-graph", deps = [ + "//tensorflow/tensorboard/components/tf_dashboard_common:legacy", "//tensorflow/tensorboard/components/tf_graph_common:legacy", + "//third_party/javascript/polymer/v1/iron-flex-layout:lib", + "//third_party/javascript/polymer/v1/iron-icons:lib", + "//third_party/javascript/polymer/v1/paper-button:lib", + "//third_party/javascript/polymer/v1/paper-dropdown-menu:lib", + "//third_party/javascript/polymer/v1/paper-input:lib", + "//third_party/javascript/polymer/v1/paper-menu:lib", + "//third_party/javascript/polymer/v1/paper-radio-group:lib", + "//third_party/javascript/polymer/v1/paper-toggle-button:lib", + "//third_party/javascript/polymer/v1/paper-tooltip:lib", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph/demo/BUILD b/tensorflow/tensorboard/components/tf_graph/demo/BUILD index 524d0ff767..b578a51798 100644 --- a/tensorflow/tensorboard/components/tf_graph/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph/demo/BUILD @@ -1,11 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph/demo", @@ -13,9 +13,9 @@ web_library( "//tensorflow/tensorboard/components/tf_graph", "//tensorflow/tensorboard/components/tf_graph_common", "//tensorflow/tensorboard/components/tf_graph_loader", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_graph/tf-graph-scene.html b/tensorflow/tensorboard/components/tf_graph/tf-graph-scene.html index 10a65f54d5..ccf8ecc697 100644 --- a/tensorflow/tensorboard/components/tf_graph/tf-graph-scene.html +++ b/tensorflow/tensorboard/components/tf_graph/tf-graph-scene.html @@ -941,7 +941,7 @@ Polymer({ delete this._nodeGroupIndex[n]; }, addEdgeGroup: function(n, selection) { - this._edgeGroupIndex[e] = selection; + this._edgeGroupIndex[n] = selection; }, getEdgeGroup: function(e) { return this._edgeGroupIndex[e]; diff --git a/tensorflow/tensorboard/components/tf_graph_app/BUILD b/tensorflow/tensorboard/components/tf_graph_app/BUILD index 415b20598e..af56889382 100644 --- a/tensorflow/tensorboard/components/tf_graph_app/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_app/BUILD @@ -1,11 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_app", srcs = [ "index.html", @@ -16,34 +16,28 @@ web_library( "//tensorflow/tensorboard/components/tf_graph_board", "//tensorflow/tensorboard/components/tf_graph_controls", "//tensorflow/tensorboard/components/tf_graph_loader", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_component_page", - "@org_polymer_webcomponentsjs", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "index.html", - "tf-graph-app.html", - ], + srcs = [":tf_graph_app"], destdir = "tf-graph-app", deps = [ "//tensorflow/tensorboard/components/tf_graph_board:legacy", "//tensorflow/tensorboard/components/tf_graph_controls:legacy", "//tensorflow/tensorboard/components/tf_graph_loader:legacy", - "//third_party/javascript/polymer/v1/iron-list:lib", - "//third_party/javascript/polymer/v1/paper-radio-group:lib", - "//third_party/javascript/polymer/v1/paper-tooltip:lib", + "//third_party/javascript/polymer/v1/iron-component-page:lib", + "//third_party/javascript/polymer/v1/polymer:lib", + "//third_party/javascript/polymer/v1/webcomponentsjs:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_app/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_app/demo/BUILD index 147cb0947c..0f984664ce 100644 --- a/tensorflow/tensorboard/components/tf_graph_app/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_app/demo/BUILD @@ -1,11 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_app/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph-app/demo", diff --git a/tensorflow/tensorboard/components/tf_graph_board/BUILD b/tensorflow/tensorboard/components/tf_graph_board/BUILD index f1c1ed1fc0..14a6616658 100644 --- a/tensorflow/tensorboard/components/tf_graph_board/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_board/BUILD @@ -1,44 +1,38 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_board", - srcs = [ - "tf-graph-board.html", - ], + srcs = ["tf-graph-board.html"], path = "/tf-graph-board", deps = [ "//tensorflow/tensorboard/components/tf_graph", "//tensorflow/tensorboard/components/tf_graph_common", "//tensorflow/tensorboard/components/tf_graph_info", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_paper_progress", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-board.html", - ], + srcs = [":tf_graph_board"], destdir = "tf-graph-board", deps = [ "//tensorflow/tensorboard/components/tf_graph:legacy", "//tensorflow/tensorboard/components/tf_graph_common:legacy", "//tensorflow/tensorboard/components/tf_graph_info:legacy", + "//third_party/javascript/polymer/v1/paper-progress:lib", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_board/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_board/demo/BUILD index 2d668769e6..4bf52c5a56 100644 --- a/tensorflow/tensorboard/components/tf_graph_board/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_board/demo/BUILD @@ -1,11 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_board/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph-board/demo", @@ -13,9 +13,9 @@ web_library( "//tensorflow/tensorboard/components/tf_graph_board", "//tensorflow/tensorboard/components/tf_graph_common", "//tensorflow/tensorboard/components/tf_graph_loader", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_graph_board/tf-graph-board.html b/tensorflow/tensorboard/components/tf_graph_board/tf-graph-board.html index 0ee694e1e6..79409ce2a0 100644 --- a/tensorflow/tensorboard/components/tf_graph_board/tf-graph-board.html +++ b/tensorflow/tensorboard/components/tf_graph_board/tf-graph-board.html @@ -180,10 +180,9 @@ Polymer({ graph: Object, stats: Object, /** - * @type {value: number, msg: string} - * * A number between 0 and 100 denoting the % of progress * for the progress bar and the displayed message. + * @type {{value: number, msg: string}} */ progress: Object, colorBy: String, diff --git a/tensorflow/tensorboard/components/tf_graph_common/BUILD b/tensorflow/tensorboard/components/tf_graph_common/BUILD index a372ab8279..25e0403aa3 100644 --- a/tensorflow/tensorboard/components/tf_graph_common/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_common/BUILD @@ -1,15 +1,31 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_common", srcs = [ + "annotation.ts", + "colors.ts", + "common.ts", + "contextmenu.ts", + "edge.ts", + "externs.ts", + "graph.ts", + "hierarchy.ts", + "layout.ts", + "minimap.ts", + "node.ts", + "parser.ts", + "proto.ts", + "render.ts", + "scene.ts", + "template.ts", "tf-graph-common.html", - ":ts", + "util.ts", ], path = "/tf-graph-common", deps = [ @@ -17,39 +33,13 @@ web_library( "//tensorflow/tensorboard/components/tf_imports:dagre", "//tensorflow/tensorboard/components/tf_imports:graphlib", "//tensorflow/tensorboard/components/tf_imports:lodash", - "@org_polymer", - ], -) - -tensorboard_typescript_genrule( - name = "ts", - srcs = glob(["*.ts"]), - typings = [ - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-common.html", - ":legacy_ts", - ], + srcs = [":tf_graph_common"], destdir = "tf-graph-common", deps = [ "//tensorflow/tensorboard/components/tf_imports_google:lib", @@ -57,16 +47,8 @@ tensorboard_webcomponent_library( ], ) -tensorboard_ts_library( - name = "legacy_ts", - srcs = glob(["*.ts"]), - deps_mgmt = "off", - runtime = "nodejs", - deps = [ - "//third_party/javascript/node_modules/typescript:es2015.promise", - "//third_party/javascript/typings/d3_v4:bundle", - "//third_party/javascript/typings/lodash", - "//third_party/javascript/typings/polymer:polymer_without_externs", - "//third_party/javascript/typings/webcomponents_js", - ], +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], ) diff --git a/tensorflow/tensorboard/components/tf_graph_controls/BUILD b/tensorflow/tensorboard/components/tf_graph_controls/BUILD index 65cafa9570..7004b7145a 100644 --- a/tensorflow/tensorboard/components/tf_graph_controls/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_controls/BUILD @@ -1,19 +1,18 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_controls", - srcs = [ - "tf-graph-controls.html", - ], + srcs = ["tf-graph-controls.html"], path = "/tf-graph-controls", deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_graph_common", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_paper_button", "@org_polymer_paper_dropdown_menu", "@org_polymer_paper_menu", @@ -23,25 +22,25 @@ web_library( ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-controls.html", - ], + srcs = [":tf_graph_controls"], destdir = "tf-graph-controls", deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common:legacy", "//tensorflow/tensorboard/components/tf_graph_common:legacy", + "//third_party/javascript/polymer/v1/paper-button:lib", + "//third_party/javascript/polymer/v1/paper-dropdown-menu:lib", + "//third_party/javascript/polymer/v1/paper-menu:lib", + "//third_party/javascript/polymer/v1/paper-radio-group:lib", + "//third_party/javascript/polymer/v1/paper-toggle-button:lib", + "//third_party/javascript/polymer/v1/paper-tooltip:lib", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_controls/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_controls/demo/BUILD index c47cb90a03..cd86ac7320 100644 --- a/tensorflow/tensorboard/components/tf_graph_controls/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_controls/demo/BUILD @@ -1,19 +1,19 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_controls/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/tf-graph-controls/demo", deps = [ "//tensorflow/tensorboard/components/tf_graph_controls", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_graph_dashboard/BUILD b/tensorflow/tensorboard/components/tf_graph_dashboard/BUILD index d1866b5d80..20f9d3990b 100644 --- a/tensorflow/tensorboard/components/tf_graph_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_dashboard/BUILD @@ -1,14 +1,13 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_dashboard", - srcs = [ - "tf-graph-dashboard.html", - ], + srcs = ["tf-graph-dashboard.html"], path = "/tf-graph-dashboard", deps = [ "//tensorflow/tensorboard/components/tf_backend", @@ -17,32 +16,29 @@ web_library( "//tensorflow/tensorboard/components/tf_graph_board", "//tensorflow/tensorboard/components/tf_graph_controls", "//tensorflow/tensorboard/components/tf_graph_loader", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/vz_sorting", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-dashboard.html", - ], + srcs = [":tf_graph_dashboard"], destdir = "tf-graph-dashboard", deps = [ + "//tensorflow/tensorboard/components/tf_backend:legacy", "//tensorflow/tensorboard/components/tf_dashboard_common:legacy", "//tensorflow/tensorboard/components/tf_graph:legacy", "//tensorflow/tensorboard/components/tf_graph_board:legacy", "//tensorflow/tensorboard/components/tf_graph_controls:legacy", "//tensorflow/tensorboard/components/tf_graph_loader:legacy", + "//tensorflow/tensorboard/components/vz_sorting:legacy", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_dashboard/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_dashboard/demo/BUILD index 3658f45b15..58cd2854c5 100644 --- a/tensorflow/tensorboard/components/tf_graph_dashboard/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_dashboard/demo/BUILD @@ -1,19 +1,19 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_dashboard/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph-dashboard/demo", deps = [ "//tensorflow/tensorboard/components/tf_graph_dashboard", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_graph_dashboard/demo/index.html b/tensorflow/tensorboard/components/tf_graph_dashboard/demo/index.html index 67756cc129..2035e87898 100644 --- a/tensorflow/tensorboard/components/tf_graph_dashboard/demo/index.html +++ b/tensorflow/tensorboard/components/tf_graph_dashboard/demo/index.html @@ -37,14 +37,17 @@ limitations under the License. <tf-graph-dashboard backend="[[backend]]"></tf-graph-dashboard> </template> <script> + import {Backend} from "../../tf-backend/backend"; + import {router} from "../../tf-backend/router"; + Polymer({ is: "graph-dashboard-demo", properties: { backend: { type: Object, value: function() { - var router = new TF.Backend.router("data", true); - return new TF.Backend.Backend(router); + var router = new router("data", true); + return new Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_graph_dashboard/tf-graph-dashboard.html b/tensorflow/tensorboard/components/tf_graph_dashboard/tf-graph-dashboard.html index 891905e7c4..0ce1e33867 100644 --- a/tensorflow/tensorboard/components/tf_graph_dashboard/tf-graph-dashboard.html +++ b/tensorflow/tensorboard/components/tf_graph_dashboard/tf-graph-dashboard.html @@ -21,6 +21,7 @@ limitations under the License. <link rel="import" href="../tf-graph-controls/tf-graph-controls.html"> <link rel="import" href="../tf-dashboard-common/tf-dashboard.html"> <link rel="import" href="../tf-backend/tf-backend.html"> +<link rel="import" href="../vz-sorting/vz-sorting.html"> <!-- tf-graph-dashboard displays a graph from a TensorFlow run. @@ -103,19 +104,21 @@ out-hierarchy-params="{{_hierarchyParams}}" </dom-module> <script> -"use strict"; +import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; +import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; +import {BackendBehavior} from "../tf-backend/behavior"; +import {compareTagNames} from "../vz-sorting/sorting"; -(function() { -TF.Dashboard.TfGraphDashboard = Polymer({ +Polymer({ is: 'tf-graph-dashboard', factoryImpl: function(backend, debuggerDataEnabled) { this.backend = backend; this.debuggerDataEnabled = debuggerDataEnabled; }, behaviors: [ - TF.Dashboard.DashboardBehavior("graphs"), - TF.Dashboard.ReloadBehavior("tf-graph-dashboard"), - TF.Backend.Behavior, + DashboardBehavior("graphs"), + ReloadBehavior("tf-graph-dashboard"), + BackendBehavior, ], properties: { _datasets: Object, @@ -188,7 +191,7 @@ TF.Dashboard.TfGraphDashboard = Polymer({ this._initialized = true; Promise.all([backend.graphRuns(), backend.runMetadataRuns()]) .then(function(result) { - var runsWithGraph = result[0].sort(VZ.Sorting.compareTagNames); + var runsWithGraph = result[0].sort(compareTagNames); var runToMetadata = result[1]; var datasets = _.map(runsWithGraph, function(runName) { return { @@ -196,7 +199,7 @@ TF.Dashboard.TfGraphDashboard = Polymer({ path: backend.router.graph( runName, tf.graph.LIMIT_ATTR_SIZE, tf.graph.LARGE_ATTRS_KEY), runMetadata: runToMetadata[runName] ? _.map( - runToMetadata[runName].sort(VZ.Sorting.compareTagNames), function(tag) { + runToMetadata[runName].sort(compareTagNames), function(tag) { return { tag: tag, path: backend.router.runMetadata(tag, runName) @@ -296,5 +299,4 @@ TF.Dashboard.TfGraphDashboard = Polymer({ this._requestHealthPills(); }, }); -})(); </script> diff --git a/tensorflow/tensorboard/components/tf_graph_info/BUILD b/tensorflow/tensorboard/components/tf_graph_info/BUILD index 6bab86d538..70b69dda93 100644 --- a/tensorflow/tensorboard/components/tf_graph_info/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_info/BUILD @@ -1,10 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_info", srcs = [ "tf-graph-icon.html", @@ -16,7 +17,7 @@ web_library( deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_graph_common", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_iron_collapse", "@org_polymer_iron_list", "@org_polymer_paper_icon_button", @@ -26,28 +27,25 @@ web_library( ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-icon.html", - "tf-graph-info.html", - "tf-node-info.html", - "tf-node-list-item.html", - ], + srcs = [":tf_graph_info"], destdir = "tf-graph-info", deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common:legacy", "//tensorflow/tensorboard/components/tf_graph_common:legacy", + "//third_party/javascript/polymer/v1/iron-collapse:lib", + "//third_party/javascript/polymer/v1/iron-list:lib", + "//third_party/javascript/polymer/v1/paper-icon-button:lib", + "//third_party/javascript/polymer/v1/paper-item:lib", + "//third_party/javascript/polymer/v1/paper-slider:lib", + "//third_party/javascript/polymer/v1/paper-spinner:lib", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_info/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_info/demo/BUILD index a7d59418fd..39bdd655b5 100644 --- a/tensorflow/tensorboard/components/tf_graph_info/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_info/demo/BUILD @@ -1,11 +1,11 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_info/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph-info/demo", @@ -13,9 +13,9 @@ web_library( "//tensorflow/tensorboard/components/tf_graph_common", "//tensorflow/tensorboard/components/tf_graph_info", "//tensorflow/tensorboard/components/tf_graph_loader", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_graph_info/tf-node-info.html b/tensorflow/tensorboard/components/tf_graph_info/tf-node-info.html index f1455acaee..66a3034b5b 100644 --- a/tensorflow/tensorboard/components/tf_graph_info/tf-node-info.html +++ b/tensorflow/tensorboard/components/tf_graph_info/tf-node-info.html @@ -548,7 +548,7 @@ limitations under the License. */ var unpackMetaedge = function(metaedge) { return _.map(metaedge.baseEdgeList, function(baseEdge) { - name = isPredecessor ? baseEdge.v : baseEdge.w; + var name = isPredecessor ? baseEdge.v : baseEdge.w; return { name: name, node: this._getNode(name, this.graphHierarchy), diff --git a/tensorflow/tensorboard/components/tf_graph_loader/BUILD b/tensorflow/tensorboard/components/tf_graph_loader/BUILD index be85567637..7efac81df0 100644 --- a/tensorflow/tensorboard/components/tf_graph_loader/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_loader/BUILD @@ -1,39 +1,32 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_graph_loader", - srcs = [ - "tf-graph-loader.html", - ], + srcs = ["tf-graph-loader.html"], path = "/tf-graph-loader", deps = [ "//tensorflow/tensorboard/components/tf_graph_common", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-graph-loader.html", - ], + srcs = [":tf_graph_loader"], destdir = "tf-graph-loader", deps = [ "//tensorflow/tensorboard/components/tf_graph_common:legacy", + "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/tf_graph_loader/demo/BUILD b/tensorflow/tensorboard/components/tf_graph_loader/demo/BUILD index b2fc04b2eb..235d23854b 100644 --- a/tensorflow/tensorboard/components/tf_graph_loader/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_graph_loader/demo/BUILD @@ -1,19 +1,19 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 # bazel run //third_party/tensorflow/tensorboard/components/tf_graph_loader/demo -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-graph-loader/demo", deps = [ "//tensorflow/tensorboard/components/tf_graph_loader", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_histogram_dashboard/BUILD b/tensorflow/tensorboard/components/tf_histogram_dashboard/BUILD index 19dd6e0332..0744c661ff 100644 --- a/tensorflow/tensorboard/components/tf_histogram_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_histogram_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_histogram_dashboard", srcs = ["tf-histogram-dashboard.html"], path = "/tf-histogram-dashboard", @@ -13,24 +13,24 @@ web_library( "//tensorflow/tensorboard/components/tf_color_scale", "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:lodash", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/vz_histogram_timeseries", - "@org_polymer", "@org_polymer_iron_collapse", "@org_polymer_paper_icon_button", "@org_polymer_paper_styles", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-histogram-dashboard", deps = [ ":tf_histogram_dashboard", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_histogram_dashboard/index.html b/tensorflow/tensorboard/components/tf_histogram_dashboard/index.html index c8d02f990d..77d62af26f 100644 --- a/tensorflow/tensorboard/components/tf_histogram_dashboard/index.html +++ b/tensorflow/tensorboard/components/tf_histogram_dashboard/index.html @@ -42,14 +42,17 @@ limitations under the License. <tf-histogram-dashboard id="demo" backend="[[backend]]"></tf-histogram-dashboard> </template> <script> + import {Backend} from "../../tf-backend/backend"; + import {router} from "../../tf-backend/router"; + Polymer({ is: "histogram-dash-demo", properties: { backend: { type: Object, value: function() { - var router = new TF.Backend.router("data", true); - return new TF.Backend.Backend(router); + var router = new router("data", true); + return new Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_histogram_dashboard/tf-histogram-dashboard.html b/tensorflow/tensorboard/components/tf_histogram_dashboard/tf-histogram-dashboard.html index d9967961eb..1821ce3b6f 100644 --- a/tensorflow/tensorboard/components/tf_histogram_dashboard/tf-histogram-dashboard.html +++ b/tensorflow/tensorboard/components/tf_histogram_dashboard/tf-histogram-dashboard.html @@ -121,15 +121,19 @@ contains vz-histogram-timeseries embedded inside tf-panes-helper's. </template> <script> - TF.Dashboard.TfHistogramDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + + Polymer({ is: "tf-histogram-dashboard", factoryImpl: function(backend) { this.backend = backend; }, behaviors: [ - TF.Dashboard.DashboardBehavior("histograms"), - TF.Dashboard.ReloadBehavior("tf-chart-scaffold"), - TF.Backend.BackendBehavior, + DashboardBehavior("histograms"), + ReloadBehavior("tf-chart-scaffold"), + BackendBehavior, ], properties: { backend: Object, diff --git a/tensorflow/tensorboard/components/tf_image_dashboard/BUILD b/tensorflow/tensorboard/components/tf_image_dashboard/BUILD index bf3c342a96..fbabf466eb 100644 --- a/tensorflow/tensorboard/components/tf_image_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_image_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_image_dashboard", srcs = [ "tf-image-dashboard.html", @@ -17,7 +17,7 @@ web_library( "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_paper_dialog", "@org_polymer_paper_icon_button", "@org_polymer_paper_slider", @@ -25,15 +25,15 @@ web_library( ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-image-dashboard", deps = [ "//tensorflow/tensorboard/components/tf_image_dashboard", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_image_dashboard/index.html b/tensorflow/tensorboard/components/tf_image_dashboard/index.html index f9ea187952..40cdddc27e 100644 --- a/tensorflow/tensorboard/components/tf_image_dashboard/index.html +++ b/tensorflow/tensorboard/components/tf_image_dashboard/index.html @@ -42,6 +42,9 @@ limitations under the License. </tf-image-dashboard> </template> <script> + import {Backend} from "../../tf-backend/backend"; + import {router} from "../../tf-backend/router"; + Polymer({ is: "image-dash-demo", properties: { @@ -49,8 +52,8 @@ limitations under the License. type: Object, value: function() { var path = "data"; - var router = new TF.Backend.router(path, true); - return new TF.Backend.Backend(router); + var router = new router(path, true); + return new Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_image_dashboard/tf-image-dashboard.html b/tensorflow/tensorboard/components/tf_image_dashboard/tf-image-dashboard.html index 0700a8c0e7..5d46847eb8 100644 --- a/tensorflow/tensorboard/components/tf_image_dashboard/tf-image-dashboard.html +++ b/tensorflow/tensorboard/components/tf_image_dashboard/tf-image-dashboard.html @@ -106,7 +106,11 @@ tf-image-dashboard displays a dashboard that loads images from a TensorFlow run. </style> </template> <script> - TF.Dashboard.TfImageDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + + Polymer({ is: "tf-image-dashboard", factoryImpl: function(backend) { this.backend = backend; @@ -119,9 +123,9 @@ tf-image-dashboard displays a dashboard that loads images from a TensorFlow run. }, }, behaviors: [ - TF.Dashboard.DashboardBehavior("images"), - TF.Dashboard.ReloadBehavior("tf-chart-scaffold"), - TF.Backend.BackendBehavior, + DashboardBehavior("images"), + ReloadBehavior("tf-chart-scaffold"), + BackendBehavior, ], attached: function() { this.async(function() { diff --git a/tensorflow/tensorboard/components/tf_imports/BUILD b/tensorflow/tensorboard/components/tf_imports/BUILD index 4dda6a2b4f..b067a6380b 100644 --- a/tensorflow/tensorboard/components/tf_imports/BUILD +++ b/tensorflow/tensorboard/components/tf_imports/BUILD @@ -1,28 +1,47 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( + name = "webcomponentsjs", + srcs = ["@org_definitelytyped//:webcomponents.js.d.ts"], + path = "/webcomponentsjs", + exports = ["@org_polymer_webcomponentsjs"], +) + +ts_web_library( + name = "polymer", + srcs = ["@org_definitelytyped//:polymer.d.ts"], + path = "/polymer", + exports = ["@org_polymer"], + deps = [":webcomponentsjs"], +) + +ts_web_library( name = "lodash", - srcs = ["lodash.html"], + srcs = [ + "lodash.html", + "@org_definitelytyped//:lodash.d.ts", + ], path = "/tf-imports", deps = ["@com_lodash"], ) -web_library( +ts_web_library( name = "threejs", srcs = [ "threejs.html", + "@org_definitelytyped//:three.d.ts", "@org_threejs//:OrbitControls.js", "@org_threejs//:three.js", ], path = "/tf-imports", ) -web_library( +ts_web_library( name = "numericjs", srcs = [ "numericjs.html", @@ -31,7 +50,7 @@ web_library( path = "/tf-imports", ) -web_library( +ts_web_library( name = "weblas", srcs = [ "weblas.html", @@ -40,21 +59,21 @@ web_library( path = "/tf-imports", ) -web_library( +ts_web_library( name = "graphlib", srcs = [ "graphlib.html", - "@io_github_cpettitt_graphlib//:graphlib.core.js", + "@io_github_cpettitt_graphlib//:graphlib.core.min.js", ], path = "/tf-imports", deps = [":lodash"], ) -web_library( +ts_web_library( name = "dagre", srcs = [ "dagre.html", - "@io_github_cpettitt_dagre//:dagre.core.js", + "@io_github_cpettitt_dagre//:dagre.core.min.js", ], path = "/tf-imports", deps = [ @@ -63,33 +82,60 @@ web_library( ], ) -web_library( +ts_web_library( name = "d3", srcs = [ + "d3.d.ts", "d3.html", - "@org_d3js//:d3.js", + "@org_d3js//:d3.min.js", ], path = "/tf-imports", ) -web_library( +ts_web_library( name = "plottable", - srcs = ["plottable.html"], - path = "/tf-imports", - deps = [ - ":d3", - ":plottable_js_css", + srcs = [ + "plottable.d.ts", + "plottable.html", + "@com_palantir_plottable//:plottable.css", + "@com_palantir_plottable//:plottable.js", ], + path = "/tf-imports", + deps = [":d3"], ) -web_library( - name = "plottable_js_css", - srcs = [ - "@com_palantir_plottable//:package/plottable.css", - "@com_palantir_plottable//:package/plottable.js", +ts_web_library( + name = "web_component_tester", + testonly = 1, + exports = [ + ":chai_typings", + ":mocha_typings", + ":sinon_typings", + "@org_npmjs_registry_web_component_tester", ], - path = "/tf-imports", - strip_prefix = "package", +) + +ts_web_library( + name = "chai_typings", + testonly = 1, + srcs = ["@org_definitelytyped//:chai.d.ts"], + path = "/chai", + visibility = ["//visibility:private"], +) + +ts_web_library( + name = "mocha_typings", + testonly = 1, + srcs = ["@org_definitelytyped//:mocha.d.ts"], + path = "/mocha", + visibility = ["//visibility:private"], +) + +ts_web_library( + name = "sinon_typings", + testonly = 1, + srcs = ["@org_definitelytyped//:sinon.d.ts"], + path = "/sinonjs", visibility = ["//visibility:private"], ) @@ -141,139 +187,139 @@ tensorboard_typescript_bundle( out = "plottable.d.ts", namespace_srcs = { "Plottable": [ - "@com_palantir_plottable//:package/build/src/core/dataset.d.ts", - "@com_palantir_plottable//:package/build/src/core/interfaces.d.ts", - "@com_palantir_plottable//:package/build/src/core/version.d.ts", + "@com_palantir_plottable//:build/src/core/dataset.d.ts", + "@com_palantir_plottable//:build/src/core/interfaces.d.ts", + "@com_palantir_plottable//:build/src/core/version.d.ts", ], "Plottable.Animators": [ - "@com_palantir_plottable//:package/build/src/animators/animator.d.ts", - "@com_palantir_plottable//:package/build/src/animators/easingAnimator.d.ts", - "@com_palantir_plottable//:package/build/src/animators/nullAnimator.d.ts", + "@com_palantir_plottable//:build/src/animators/animator.d.ts", + "@com_palantir_plottable//:build/src/animators/easingAnimator.d.ts", + "@com_palantir_plottable//:build/src/animators/nullAnimator.d.ts", ], "Plottable.Axes": [ - "@com_palantir_plottable//:package/build/src/axes/axis.d.ts", - "@com_palantir_plottable//:package/build/src/axes/categoryAxis.d.ts", - "@com_palantir_plottable//:package/build/src/axes/numericAxis.d.ts", - "@com_palantir_plottable//:package/build/src/axes/timeAxis.d.ts", + "@com_palantir_plottable//:build/src/axes/axis.d.ts", + "@com_palantir_plottable//:build/src/axes/categoryAxis.d.ts", + "@com_palantir_plottable//:build/src/axes/numericAxis.d.ts", + "@com_palantir_plottable//:build/src/axes/timeAxis.d.ts", ], "Plottable.Components": [ - "@com_palantir_plottable//:package/build/src/components/component.d.ts", - "@com_palantir_plottable//:package/build/src/components/componentContainer.d.ts", - "@com_palantir_plottable//:package/build/src/components/dragBoxLayer.d.ts", - "@com_palantir_plottable//:package/build/src/components/dragLineLayer.d.ts", - "@com_palantir_plottable//:package/build/src/components/gridlines.d.ts", - "@com_palantir_plottable//:package/build/src/components/group.d.ts", - "@com_palantir_plottable//:package/build/src/components/guideLineLayer.d.ts", - "@com_palantir_plottable//:package/build/src/components/interpolatedColorLegend.d.ts", - "@com_palantir_plottable//:package/build/src/components/label.d.ts", - "@com_palantir_plottable//:package/build/src/components/legend.d.ts", - "@com_palantir_plottable//:package/build/src/components/plotGroup.d.ts", - "@com_palantir_plottable//:package/build/src/components/selectionBoxLayer.d.ts", - "@com_palantir_plottable//:package/build/src/components/table.d.ts", - "@com_palantir_plottable//:package/build/src/components/xDragBoxLayer.d.ts", - "@com_palantir_plottable//:package/build/src/components/yDragBoxLayer.d.ts", + "@com_palantir_plottable//:build/src/components/component.d.ts", + "@com_palantir_plottable//:build/src/components/componentContainer.d.ts", + "@com_palantir_plottable//:build/src/components/dragBoxLayer.d.ts", + "@com_palantir_plottable//:build/src/components/dragLineLayer.d.ts", + "@com_palantir_plottable//:build/src/components/gridlines.d.ts", + "@com_palantir_plottable//:build/src/components/group.d.ts", + "@com_palantir_plottable//:build/src/components/guideLineLayer.d.ts", + "@com_palantir_plottable//:build/src/components/interpolatedColorLegend.d.ts", + "@com_palantir_plottable//:build/src/components/label.d.ts", + "@com_palantir_plottable//:build/src/components/legend.d.ts", + "@com_palantir_plottable//:build/src/components/plotGroup.d.ts", + "@com_palantir_plottable//:build/src/components/selectionBoxLayer.d.ts", + "@com_palantir_plottable//:build/src/components/table.d.ts", + "@com_palantir_plottable//:build/src/components/xDragBoxLayer.d.ts", + "@com_palantir_plottable//:build/src/components/yDragBoxLayer.d.ts", ], "Plottable.Configs": [ - "@com_palantir_plottable//:package/build/src/core/config.d.ts", + "@com_palantir_plottable//:build/src/core/config.d.ts", ], "Plottable.Formatters": [ - "@com_palantir_plottable//:package/build/src/core/formatters.d.ts", + "@com_palantir_plottable//:build/src/core/formatters.d.ts", ], "Plottable.RenderController": [ - "@com_palantir_plottable//:package/build/src/core/renderController.d.ts", + "@com_palantir_plottable//:build/src/core/renderController.d.ts", ], "Plottable.RenderPolicies": [ - "@com_palantir_plottable//:package/build/src/core/renderPolicy.d.ts", + "@com_palantir_plottable//:build/src/core/renderPolicy.d.ts", ], "Plottable.SymbolFactories": [ - "@com_palantir_plottable//:package/build/src/core/symbolFactories.d.ts", + "@com_palantir_plottable//:build/src/core/symbolFactories.d.ts", ], "Plottable.Dispatchers": [ - "@com_palantir_plottable//:package/build/src/dispatchers/dispatcher.d.ts", - "@com_palantir_plottable//:package/build/src/dispatchers/keyDispatcher.d.ts", - "@com_palantir_plottable//:package/build/src/dispatchers/mouseDispatcher.d.ts", - "@com_palantir_plottable//:package/build/src/dispatchers/touchDispatcher.d.ts", + "@com_palantir_plottable//:build/src/dispatchers/dispatcher.d.ts", + "@com_palantir_plottable//:build/src/dispatchers/keyDispatcher.d.ts", + "@com_palantir_plottable//:build/src/dispatchers/mouseDispatcher.d.ts", + "@com_palantir_plottable//:build/src/dispatchers/touchDispatcher.d.ts", ], "Plottable.Drawers": [ - "@com_palantir_plottable//:package/build/src/drawers/arcDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/arcOutlineDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/areaDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/canvasBuffer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/canvasDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/drawStep.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/drawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/lineDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/rectangleDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/segmentDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/svgDrawer.d.ts", - "@com_palantir_plottable//:package/build/src/drawers/symbolDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/arcDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/arcOutlineDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/areaDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/canvasBuffer.d.ts", + "@com_palantir_plottable//:build/src/drawers/canvasDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/drawStep.d.ts", + "@com_palantir_plottable//:build/src/drawers/drawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/lineDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/rectangleDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/segmentDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/svgDrawer.d.ts", + "@com_palantir_plottable//:build/src/drawers/symbolDrawer.d.ts", ], "Plottable.Interactions": [ - "@com_palantir_plottable//:package/build/src/interactions/clickInteraction.d.ts", - "@com_palantir_plottable//:package/build/src/interactions/dragInteraction.d.ts", - "@com_palantir_plottable//:package/build/src/interactions/interaction.d.ts", - "@com_palantir_plottable//:package/build/src/interactions/keyInteraction.d.ts", - "@com_palantir_plottable//:package/build/src/interactions/panZoomInteraction.d.ts", - "@com_palantir_plottable//:package/build/src/interactions/pointerInteraction.d.ts", + "@com_palantir_plottable//:build/src/interactions/clickInteraction.d.ts", + "@com_palantir_plottable//:build/src/interactions/dragInteraction.d.ts", + "@com_palantir_plottable//:build/src/interactions/interaction.d.ts", + "@com_palantir_plottable//:build/src/interactions/keyInteraction.d.ts", + "@com_palantir_plottable//:build/src/interactions/panZoomInteraction.d.ts", + "@com_palantir_plottable//:build/src/interactions/pointerInteraction.d.ts", ], "Plottable.Plots": [ - "@com_palantir_plottable//:package/build/src/plots/areaPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/barPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/clusteredBarPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/commons.d.ts", - "@com_palantir_plottable//:package/build/src/plots/linePlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/piePlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/plot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/rectanglePlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/scatterPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/segmentPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/stackedAreaPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/stackedBarPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/waterfallPlot.d.ts", - "@com_palantir_plottable//:package/build/src/plots/xyPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/areaPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/barPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/clusteredBarPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/commons.d.ts", + "@com_palantir_plottable//:build/src/plots/linePlot.d.ts", + "@com_palantir_plottable//:build/src/plots/piePlot.d.ts", + "@com_palantir_plottable//:build/src/plots/plot.d.ts", + "@com_palantir_plottable//:build/src/plots/rectanglePlot.d.ts", + "@com_palantir_plottable//:build/src/plots/scatterPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/segmentPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/stackedAreaPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/stackedBarPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/waterfallPlot.d.ts", + "@com_palantir_plottable//:build/src/plots/xyPlot.d.ts", ], "Plottable.Scales": [ - "@com_palantir_plottable//:package/build/src/scales/index.d.ts", - "@com_palantir_plottable//:package/build/src/scales/categoryScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/colorScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/interpolatedColorScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/linearScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/modifiedLogScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/quantitativeScale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/scale.d.ts", - "@com_palantir_plottable//:package/build/src/scales/timeScale.d.ts", + "@com_palantir_plottable//:build/src/scales/index.d.ts", + "@com_palantir_plottable//:build/src/scales/categoryScale.d.ts", + "@com_palantir_plottable//:build/src/scales/colorScale.d.ts", + "@com_palantir_plottable//:build/src/scales/interpolatedColorScale.d.ts", + "@com_palantir_plottable//:build/src/scales/linearScale.d.ts", + "@com_palantir_plottable//:build/src/scales/modifiedLogScale.d.ts", + "@com_palantir_plottable//:build/src/scales/quantitativeScale.d.ts", + "@com_palantir_plottable//:build/src/scales/scale.d.ts", + "@com_palantir_plottable//:build/src/scales/timeScale.d.ts", ], "Plottable.Scales.TickGenerators": [ - "@com_palantir_plottable//:package/build/src/scales/tickGenerators.d.ts", + "@com_palantir_plottable//:build/src/scales/tickGenerators.d.ts", ], "Plottable.Utils": [ - "@com_palantir_plottable//:package/build/src/utils/addD3SelectionMulti.d.ts", - "@com_palantir_plottable//:package/build/src/utils/bucket.d.ts", - "@com_palantir_plottable//:package/build/src/utils/callbackSet.d.ts", - "@com_palantir_plottable//:package/build/src/utils/coerceD3.d.ts", - "@com_palantir_plottable//:package/build/src/utils/entityStore.d.ts", - "@com_palantir_plottable//:package/build/src/utils/makeEnum.d.ts", - "@com_palantir_plottable//:package/build/src/utils/map.d.ts", - "@com_palantir_plottable//:package/build/src/utils/set.d.ts", - "@com_palantir_plottable//:package/build/src/utils/transformAwareTranslator.d.ts", + "@com_palantir_plottable//:build/src/utils/addD3SelectionMulti.d.ts", + "@com_palantir_plottable//:build/src/utils/bucket.d.ts", + "@com_palantir_plottable//:build/src/utils/callbackSet.d.ts", + "@com_palantir_plottable//:build/src/utils/coerceD3.d.ts", + "@com_palantir_plottable//:build/src/utils/entityStore.d.ts", + "@com_palantir_plottable//:build/src/utils/makeEnum.d.ts", + "@com_palantir_plottable//:build/src/utils/map.d.ts", + "@com_palantir_plottable//:build/src/utils/set.d.ts", + "@com_palantir_plottable//:build/src/utils/transformAwareTranslator.d.ts", ], "Plottable.Utils.Array": [ - "@com_palantir_plottable//:package/build/src/utils/arrayUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/arrayUtils.d.ts", ], "Plottable.Utils.Color": [ - "@com_palantir_plottable//:package/build/src/utils/colorUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/colorUtils.d.ts", ], "Plottable.Utils.DOM": [ - "@com_palantir_plottable//:package/build/src/utils/domUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/domUtils.d.ts", ], "Plottable.Utils.Math": [ - "@com_palantir_plottable//:package/build/src/utils/mathUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/mathUtils.d.ts", ], "Plottable.Utils.Stacking": [ - "@com_palantir_plottable//:package/build/src/utils/stackingUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/stackingUtils.d.ts", ], "Plottable.Utils.Window": [ - "@com_palantir_plottable//:package/build/src/utils/windowUtils.d.ts", + "@com_palantir_plottable//:build/src/utils/windowUtils.d.ts", ], }, namespace_symbol_aliases = { diff --git a/tensorflow/tensorboard/components/tf_imports/d3.html b/tensorflow/tensorboard/components/tf_imports/d3.html index 2772db39a8..76ca302709 100644 --- a/tensorflow/tensorboard/components/tf_imports/d3.html +++ b/tensorflow/tensorboard/components/tf_imports/d3.html @@ -47,4 +47,4 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --> -<script src="d3.js"></script> +<script jscomp-nocompile src="d3.min.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/dagre.html b/tensorflow/tensorboard/components/tf_imports/dagre.html index 1e2f6ef9af..cb57b9a5cd 100644 --- a/tensorflow/tensorboard/components/tf_imports/dagre.html +++ b/tensorflow/tensorboard/components/tf_imports/dagre.html @@ -42,4 +42,4 @@ THE SOFTWARE. <link rel="import" href="lodash.html"> <link rel="import" href="graphlib.html"> -<script src="dagre.core.js"></script> +<script jscomp-nocompile src="dagre.core.min.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/graphlib.html b/tensorflow/tensorboard/components/tf_imports/graphlib.html index 783e33be0a..05942123ab 100644 --- a/tensorflow/tensorboard/components/tf_imports/graphlib.html +++ b/tensorflow/tensorboard/components/tf_imports/graphlib.html @@ -17,4 +17,4 @@ limitations under the License. <link rel="import" href="lodash.html"> -<script src="graphlib.core.js"></script> +<script jscomp-nocompile src="graphlib.core.min.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/lodash.html b/tensorflow/tensorboard/components/tf_imports/lodash.html index cbe35f1050..65ff6a4b03 100644 --- a/tensorflow/tensorboard/components/tf_imports/lodash.html +++ b/tensorflow/tensorboard/components/tf_imports/lodash.html @@ -15,4 +15,4 @@ See the License for the specific language governing permissions and limitations under the License. --> -<script src="../lodash/lodash.js"></script> +<script jscomp-nocompile src="../lodash/lodash.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/numericjs.html b/tensorflow/tensorboard/components/tf_imports/numericjs.html index 7559054aab..81fa949168 100644 --- a/tensorflow/tensorboard/components/tf_imports/numericjs.html +++ b/tensorflow/tensorboard/components/tf_imports/numericjs.html @@ -40,4 +40,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> -<script src="numeric.js"></script> +<script jscomp-suppress src="numeric.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/plottable.html b/tensorflow/tensorboard/components/tf_imports/plottable.html index 2c3e10a7c4..77ad544d5a 100644 --- a/tensorflow/tensorboard/components/tf_imports/plottable.html +++ b/tensorflow/tensorboard/components/tf_imports/plottable.html @@ -40,5 +40,5 @@ THE SOFTWARE. --> <link rel="import" href="d3.html"> -<script src="plottable.js"></script> +<script jscomp-suppress src="plottable.js"></script> <link rel="stylesheet" href="plottable.css"> diff --git a/tensorflow/tensorboard/components/tf_imports/threejs.html b/tensorflow/tensorboard/components/tf_imports/threejs.html index d6adad43b0..7f4233b571 100644 --- a/tensorflow/tensorboard/components/tf_imports/threejs.html +++ b/tensorflow/tensorboard/components/tf_imports/threejs.html @@ -39,5 +39,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> -<script src="three.js"></script> -<script src="OrbitControls.js"></script> +<script jscomp-suppress src="three.js"></script> +<script jscomp-suppress src="OrbitControls.js"></script> diff --git a/tensorflow/tensorboard/components/tf_imports/weblas.html b/tensorflow/tensorboard/components/tf_imports/weblas.html index 054d04ea85..c07020598f 100644 --- a/tensorflow/tensorboard/components/tf_imports/weblas.html +++ b/tensorflow/tensorboard/components/tf_imports/weblas.html @@ -39,4 +39,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> -<script src="weblas.js"></script> +<script jscomp-nocompile src="weblas.js"></script> diff --git a/tensorflow/tensorboard/components/tf_option_selector/BUILD b/tensorflow/tensorboard/components/tf_option_selector/BUILD index 6f79ac536a..cd0150529e 100644 --- a/tensorflow/tensorboard/components/tf_option_selector/BUILD +++ b/tensorflow/tensorboard/components/tf_option_selector/BUILD @@ -1,16 +1,16 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_option_selector", srcs = ["tf-option-selector.html"], path = "/tf-option-selector", deps = [ "//tensorflow/tensorboard/components/tf_dashboard_common", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) diff --git a/tensorflow/tensorboard/components/tf_scalar_dashboard/BUILD b/tensorflow/tensorboard/components/tf_scalar_dashboard/BUILD index f2a491a2b2..2de11a231e 100644 --- a/tensorflow/tensorboard/components/tf_scalar_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_scalar_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_scalar_dashboard", srcs = [ "tf-scalar-dashboard.html", @@ -16,8 +16,8 @@ web_library( "//tensorflow/tensorboard/components/tf_color_scale", "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:lodash", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/vz_line_chart", - "@org_polymer", "@org_polymer_iron_collapse", "@org_polymer_paper_checkbox", "@org_polymer_paper_dropdown_menu", diff --git a/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/BUILD b/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/BUILD index 3b135d68af..497767363e 100644 --- a/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/BUILD +++ b/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/BUILD @@ -1,22 +1,22 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/tf-scalar-dashboard/demo", deps = [ "//tensorflow/tensorboard/components/tf_backend", "//tensorflow/tensorboard/components/tf_imports:d3", + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "//tensorflow/tensorboard/components/tf_scalar_dashboard", "//tensorflow/tensorboard/demo:demo_data", - "@org_polymer", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/index.html b/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/index.html index 7429c87b87..10cf83b2e9 100644 --- a/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/index.html +++ b/tensorflow/tensorboard/components/tf_scalar_dashboard/demo/index.html @@ -45,14 +45,17 @@ limitations under the License. <tf-scalar-dashboard id="demo" backend="[[backend]]"></tf-scalar-dashboard> </template> <script> + import {Backend} from "../tf-backend/backend"; + import {router} from "../tf-backend/router"; + Polymer({ is: "scalar-dash-demo", properties: { backend: { type: Object, value: function() { - var router = new TF.Backend.router("/data", true); - return new TF.Backend.Backend(router); + var router = new router("/data", true); + return new Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_scalar_dashboard/tf-scalar-dashboard.html b/tensorflow/tensorboard/components/tf_scalar_dashboard/tf-scalar-dashboard.html index 1066457421..c994f175bd 100644 --- a/tensorflow/tensorboard/components/tf_scalar_dashboard/tf-scalar-dashboard.html +++ b/tensorflow/tensorboard/components/tf_scalar_dashboard/tf-scalar-dashboard.html @@ -190,16 +190,21 @@ contains vz-line-charts embedded inside tf-panes-helper's. </template> <script> - TF.Dashboard.TfScalarDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + import * as storage from "../tf-storage/storage"; + + Polymer({ is: "tf-scalar-dashboard", factoryImpl: function(backend, router) { this.backend = backend; this.router = router; }, behaviors: [ - TF.Dashboard.DashboardBehavior("scalars"), - TF.Dashboard.ReloadBehavior("tf-chart-scaffold"), - TF.Backend.BackendBehavior, + DashboardBehavior("scalars"), + ReloadBehavior("tf-chart-scaffold"), + BackendBehavior, ], properties: { backend: Object, @@ -215,14 +220,13 @@ contains vz-line-charts embedded inside tf-panes-helper's. _showDownloadLinks: { type: Boolean, notify: true, - value: TF.URIStorage.getBooleanInitializer('_showDownloadLinks', - false, true), + value: storage.getBooleanInitializer('_showDownloadLinks', false, true), observer: '_showDownloadLinksObserver' }, _smoothingWeight: { type: Number, notify: true, - value: TF.URIStorage.getNumberInitializer('_smoothingWeight', 0.6), + value: storage.getNumberInitializer('_smoothingWeight', 0.6), observer: '_smoothingWeightObserver' }, _smoothingEnabled: { @@ -231,7 +235,7 @@ contains vz-line-charts embedded inside tf-panes-helper's. }, _ignoreYOutliers: { type: Boolean, - value: TF.URIStorage.getBooleanInitializer('_ignoreYOutliers', true, true), + value: storage.getBooleanInitializer('_ignoreYOutliers', true, true), observer: '_ignoreYOutliersObserver', }, _xType: { @@ -247,11 +251,11 @@ contains vz-line-charts embedded inside tf-panes-helper's. _getScalarUrl: function() { return this.router.pluginRunTagRoute('scalars', '/scalars'); }, - _showDownloadLinksObserver: TF.URIStorage.getBooleanObserver( + _showDownloadLinksObserver: storage.getBooleanObserver( '_showDownloadLinks', /*default=*/ false, /*useLocalStorage=*/ true), - _smoothingWeightObserver: TF.URIStorage.getNumberObserver( + _smoothingWeightObserver: storage.getNumberObserver( '_smoothingWeight', 0.6), - _ignoreYOutliersObserver: TF.URIStorage.getBooleanObserver( + _ignoreYOutliersObserver: storage.getBooleanObserver( '_ignoreYOutliers', /*default=*/ true, /*useLocalStorage=*/true), _computeSmoothingEnabled: function(_smoothingWeight) { return _smoothingWeight > 0; diff --git a/tensorflow/tensorboard/components/tf_storage/BUILD b/tensorflow/tensorboard/components/tf_storage/BUILD index 04322131b8..1acabf8cf6 100644 --- a/tensorflow/tensorboard/components/tf_storage/BUILD +++ b/tensorflow/tensorboard/components/tf_storage/BUILD @@ -1,15 +1,14 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_storage", srcs = [ - "bundle.js", + "storage.ts", "tf-storage.html", ], path = "/tf-storage", @@ -19,50 +18,9 @@ web_library( ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_globals:bundle.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.URIStorage": [ - "storage.ts", - ]}, - namespace_symbol_aliases = {"TF.URIStorage": { - "TABS": "TF.Globals.TABS", - "getFakeHash": "TF.Globals.getFakeHash", - "setFakeHash": "TF.Globals.setFakeHash", - "setUseHash": "TF.Globals.setUseHash", - "useHash": "TF.Globals.useHash", - }}, -) - -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "tf-storage.html", - ":legacy_ts", - ], + srcs = [":tf_storage"], destdir = "tf-storage", deps = [ "//tensorflow/tensorboard/components/tf_globals:legacy", @@ -71,13 +29,8 @@ tensorboard_webcomponent_library( ], ) -tensorboard_ts_library( - name = "legacy_ts", - srcs = ["storage.ts"], - deps_mgmt = "off", - runtime = "nodejs", - deps = [ - "//tensorflow/tensorboard/components/tf_globals:legacy_ts", - "//third_party/javascript/typings/lodash", - ], +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], ) diff --git a/tensorflow/tensorboard/components/tf_storage/storage.ts b/tensorflow/tensorboard/components/tf_storage/storage.ts index bb183d1d59..573df1cb2b 100644 --- a/tensorflow/tensorboard/components/tf_storage/storage.ts +++ b/tensorflow/tensorboard/components/tf_storage/storage.ts @@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as _ from 'lodash'; -import {getFakeHash, setFakeHash, TABS, useHash} from '../tf_globals/globals'; + +import {getFakeHash, setFakeHash, TABS, useHash} from '../tf-globals/globals'; /* tslint:disable:no-namespace variable-name */ diff --git a/tensorflow/tensorboard/components/tf_storage/test/BUILD b/tensorflow/tensorboard/components/tf_storage/test/BUILD index 255f7298b3..6d8c944184 100644 --- a/tensorflow/tensorboard/components/tf_storage/test/BUILD +++ b/tensorflow/tensorboard/components/tf_storage/test/BUILD @@ -3,45 +3,25 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", + "storageTests.ts", "tests.html", ], path = "/tf-storage/test", deps = [ + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "//tensorflow/tensorboard/components/tf_storage", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "//tensorflow/tensorboard/components/tf_globals:bundle.d.ts", - "//tensorflow/tensorboard/components/tf_storage:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"TF.URIStorage": ["storageTests.ts"]}, - namespace_symbol_aliases = {"TF.URIStorage": {"TABS": "TF.Globals.TABS"}}, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/tf_storage/test/tests.html b/tensorflow/tensorboard/components/tf_storage/test/tests.html index e0553c7d3c..4668b119d2 100644 --- a/tensorflow/tensorboard/components/tf_storage/test/tests.html +++ b/tensorflow/tensorboard/components/tf_storage/test/tests.html @@ -22,4 +22,4 @@ limitations under the License. <link rel="import" href="../../polymer/polymer.html"> <link rel="import" href="../tf-storage.html"> <body> -<script src="bundle.js"></script> +<script src="storageTests.js"></script> diff --git a/tensorflow/tensorboard/components/tf_storage/tf-storage.html b/tensorflow/tensorboard/components/tf_storage/tf-storage.html index 91b8976519..ff3f7b0ad4 100644 --- a/tensorflow/tensorboard/components/tf_storage/tf-storage.html +++ b/tensorflow/tensorboard/components/tf_storage/tf-storage.html @@ -18,4 +18,4 @@ limitations under the License. <link rel="import" href="../tf-globals/tf-globals.html"> <link rel="import" href="../tf-imports/lodash.html"> -<script src="bundle.js"></script> +<script src="storage.js"></script> diff --git a/tensorflow/tensorboard/components/tf_tensorboard/BUILD b/tensorflow/tensorboard/components/tf_tensorboard/BUILD index b649bb53f2..72f9a0852a 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/BUILD +++ b/tensorflow/tensorboard/components/tf_tensorboard/BUILD @@ -1,16 +1,16 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") +load("//tensorflow/tensorboard:vulcanize.bzl", "tensorboard_html_binary") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_tensorboard", srcs = [ + "autoReloadBehavior.ts", "style.html", "tf-tensorboard.html", - ":ts", ], path = "/tf-tensorboard", visibility = ["//visibility:public"], @@ -23,11 +23,11 @@ web_library( "//tensorflow/tensorboard/components/tf_graph_dashboard", "//tensorflow/tensorboard/components/tf_histogram_dashboard", "//tensorflow/tensorboard/components/tf_image_dashboard", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/tf_scalar_dashboard", "//tensorflow/tensorboard/components/tf_storage", "//tensorflow/tensorboard/components/tf_text_dashboard", "//tensorflow/tensorboard/components/vz_projector", - "@org_polymer", "@org_polymer_font_roboto", "@org_polymer_iron_icons", "@org_polymer_paper_button", @@ -40,20 +40,22 @@ web_library( ], ) -web_library( +ts_web_library( name = "demo", srcs = ["demo.html"], path = "/tf-tensorboard", deps = [ ":tf_tensorboard", "//tensorflow/tensorboard/demo:demo_data", - "@org_polymer_webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["autoReloadBehavior.ts"], +tensorboard_html_binary( + name = "devserver", + testonly = 1, + input_path = "/tf-tensorboard/demo.html", + output_path = "/index.html", + deps = [":demo"], ) filegroup( diff --git a/tensorflow/tensorboard/components/tf_tensorboard/autoReloadBehavior.ts b/tensorflow/tensorboard/components/tf_tensorboard/autoReloadBehavior.ts index 1f6b4cf641..54df16f5b5 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/autoReloadBehavior.ts +++ b/tensorflow/tensorboard/components/tf_tensorboard/autoReloadBehavior.ts @@ -12,49 +12,51 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -module TF.TensorBoard { - export var AUTORELOAD_LOCALSTORAGE_KEY = 'TF.TensorBoard.autoReloadEnabled'; - var getAutoReloadFromLocalStorage: () => boolean = () => { - var val = window.localStorage.getItem(AUTORELOAD_LOCALSTORAGE_KEY); - return val === 'true' || val == null; // defaults to true - }; +export var AUTORELOAD_LOCALSTORAGE_KEY = 'TF.TensorBoard.autoReloadEnabled'; - export var AutoReloadBehavior = { - properties: { - autoReloadEnabled: { - type: Boolean, - observer: '_autoReloadObserver', - value: getAutoReloadFromLocalStorage, - }, - _autoReloadId: { - type: Number, - }, - autoReloadIntervalSecs: { - type: Number, - value: 30, - }, +var getAutoReloadFromLocalStorage: () => boolean = () => { + var val = window.localStorage.getItem(AUTORELOAD_LOCALSTORAGE_KEY); + return val === 'true' || val == null; // defaults to true +}; + +/** + * @polymerBehavior + */ +export var AutoReloadBehavior = { + properties: { + autoReloadEnabled: { + type: Boolean, + observer: '_autoReloadObserver', + value: getAutoReloadFromLocalStorage, }, - detached: function() { - window.clearTimeout(this._autoReloadId); + _autoReloadId: { + type: Number, }, - _autoReloadObserver: function(autoReload) { - window.localStorage.setItem(AUTORELOAD_LOCALSTORAGE_KEY, autoReload); - if (autoReload) { - var _this = this; - this._autoReloadId = window.setTimeout( - this._doAutoReload.bind(this), this.autoReloadIntervalSecs * 1000); - } else { - window.clearTimeout(this._autoReloadId); - } + autoReloadIntervalSecs: { + type: Number, + value: 30, }, - _doAutoReload: function() { - if (this.reload == null) { - throw new Error('AutoReloadBehavior requires a reload method'); - } - this.reload(); + }, + detached: function() { + window.clearTimeout(this._autoReloadId); + }, + _autoReloadObserver: function(autoReload) { + window.localStorage.setItem(AUTORELOAD_LOCALSTORAGE_KEY, autoReload); + if (autoReload) { + var _this = this; this._autoReloadId = window.setTimeout( this._doAutoReload.bind(this), this.autoReloadIntervalSecs * 1000); + } else { + window.clearTimeout(this._autoReloadId); + } + }, + _doAutoReload: function() { + if (this.reload == null) { + throw new Error('AutoReloadBehavior requires a reload method'); } - }; -} + this.reload(); + this._autoReloadId = window.setTimeout( + this._doAutoReload.bind(this), this.autoReloadIntervalSecs * 1000); + } +}; diff --git a/tensorflow/tensorboard/components/tf_tensorboard/demo.html b/tensorflow/tensorboard/components/tf_tensorboard/demo.html index c8a9238aef..f691f6211b 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/demo.html +++ b/tensorflow/tensorboard/components/tf_tensorboard/demo.html @@ -18,7 +18,6 @@ limitations under the License. <meta charset="utf-8"> <title>TensorBoard Demo</title> -<script src="../webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="style.html"> <link rel="import" href="tf-tensorboard.html"> <body> diff --git a/tensorflow/tensorboard/components/tf_tensorboard/test/autoReloadTests.ts b/tensorflow/tensorboard/components/tf_tensorboard/test/autoReloadTests.ts index 0f049d40ab..b68fd8c943 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/test/autoReloadTests.ts +++ b/tensorflow/tensorboard/components/tf_tensorboard/test/autoReloadTests.ts @@ -12,19 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +import {AUTORELOAD_LOCALSTORAGE_KEY, AutoReloadBehavior} from '../autoReloadBehavior'; + declare function fixture(id: string): void; + window.HTMLImports.whenReady(() => { Polymer({ is: 'autoreload-test-element', - behaviors: [TF.TensorBoard.AutoReloadBehavior], + behaviors: [AutoReloadBehavior], }); describe('autoReload-behavior', function() { - var testElement; - var ls = window.localStorage; - var key = TF.TensorBoard.AUTORELOAD_LOCALSTORAGE_KEY; - var clock; - var callCount: number; + let testElement; + const ls = window.localStorage; + const key = AUTORELOAD_LOCALSTORAGE_KEY; + let clock; + let callCount: number; beforeEach(function() { ls.setItem(key, 'false'); // start it turned off so we can mutate fns diff --git a/tensorflow/tensorboard/components/tf_tensorboard/test/e2eTests.ts b/tensorflow/tensorboard/components/tf_tensorboard/test/e2eTests.ts index 2308298ced..a00027963b 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/test/e2eTests.ts +++ b/tensorflow/tensorboard/components/tf_tensorboard/test/e2eTests.ts @@ -13,13 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +import {TABS} from '../../tf-globals/globals'; + describe('end-to-end test', () => { window.HTMLImports.whenReady(() => { let tb = d3.select('tf-tensorboard'); var tabs = (<any>tb.node()).$.tabs; function testTab(tabIndex: number) { - it(`selecting ${TF.Globals.TABS[tabIndex]} tab`, done => { + it(`selecting ${TABS[tabIndex]} tab`, done => { // Every dashboard emits a rendered event when it is done rendering. tb.on('rendered', () => done()); tabs.set('selected', tabIndex); @@ -32,7 +34,7 @@ describe('end-to-end test', () => { // have failed. Re-selecting the default tab and listening for // "rendered" event won't work since the content is not re-stamped. let selected = +tabs.get('selected'); - for (let i = 0; i < TF.Globals.TABS.length; i++) { + for (let i = 0; i < TABS.length; i++) { if (i !== selected) { testTab(i); } diff --git a/tensorflow/tensorboard/components/tf_tensorboard/test/fastTabSwitch.ts b/tensorflow/tensorboard/components/tf_tensorboard/test/fastTabSwitch.ts index 4dd62a0c38..905ed4ee4a 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/test/fastTabSwitch.ts +++ b/tensorflow/tensorboard/components/tf_tensorboard/test/fastTabSwitch.ts @@ -13,9 +13,12 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +import {TABS} from '../../tf-globals/globals'; + describe('fast tab switch', () => { window.HTMLImports.whenReady(() => { let tb = d3.select('tf-tensorboard'); + // tslint:disable-next-line:no-any be quiet tsc var tabs = (<any>tb.node()).$.tabs; // This test will select the events tab. Once the events tab @@ -23,9 +26,9 @@ describe('fast tab switch', () => { // the images tab wihout waiting for the graph tab to finish // rendering. Finally, it finishes when the images tab // has rendered and no errors were thrown. - let eventsTabIndex = TF.Globals.TABS.indexOf('events'); - let imagesTabIndex = TF.Globals.TABS.indexOf('images'); - let graphTabIndex = TF.Globals.TABS.indexOf('graphs'); + const eventsTabIndex = TABS.indexOf('events'); + const imagesTabIndex = TABS.indexOf('images'); + const graphTabIndex = TABS.indexOf('graphs'); // Listen for when the events tab rendered. tb.on('rendered', () => { diff --git a/tensorflow/tensorboard/components/tf_tensorboard/test/tensorboardTests.ts b/tensorflow/tensorboard/components/tf_tensorboard/test/tensorboardTests.ts index 3c7fe2c9e7..33e11e3094 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/test/tensorboardTests.ts +++ b/tensorflow/tensorboard/components/tf_tensorboard/test/tensorboardTests.ts @@ -12,6 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ + +import * as backend_router from '../../tf-backend/router'; +import {TABS} from '../../tf-globals/globals'; + describe('tf-tensorboard tests', () => { window.HTMLImports.whenReady(() => { let tensorboard: any; @@ -25,16 +29,16 @@ describe('tf-tensorboard tests', () => { setTimeout(function() { let tabs = tensorboard.$.tabs.getElementsByTagName('paper-tab'); let tabMode = Array.prototype.map.call(tabs, (x) => x.dataMode); - chai.assert.deepEqual(tabMode, TF.Globals.TABS, 'mode is correct'); + chai.assert.deepEqual(tabMode, TABS, 'mode is correct'); let tabText = Array.prototype.map.call(tabs, (x) => x.innerText.toLowerCase()); - chai.assert.deepEqual(tabText, TF.Globals.TABS, 'text is correct'); + chai.assert.deepEqual(tabText, TABS, 'text is correct'); done(); }); }); it('respects router manually provided', function() { - let router = TF.Backend.router('data', true); + const router = backend_router.router('data', true); tensorboard.router = router; tensorboard.demoDir = null; chai.assert.equal(tensorboard._backend.router, router); @@ -46,7 +50,7 @@ describe('tf-tensorboard tests', () => { }); describe('reloading the selected dashboard', function() { - TF.Globals.TABS.forEach((name, tabIndex) => { + TABS.forEach((name, tabIndex) => { // These tabs do not support reload mode. if (name === 'graphs' || name === 'projections') { return; @@ -70,7 +74,7 @@ describe('tf-tensorboard tests', () => { }); it('reload is disabled for graph dashboard', function(done) { - let idx = TF.Globals.TABS.indexOf('graphs'); + const idx = TABS.indexOf('graphs'); chai.assert.notEqual(idx, -1, 'graphs was found'); tensorboard.$.tabs.set('selected', idx); setTimeout( diff --git a/tensorflow/tensorboard/components/tf_tensorboard/tf-tensorboard.html b/tensorflow/tensorboard/components/tf_tensorboard/tf-tensorboard.html index ac3132fada..00a30686f6 100644 --- a/tensorflow/tensorboard/components/tf_tensorboard/tf-tensorboard.html +++ b/tensorflow/tensorboard/components/tf_tensorboard/tf-tensorboard.html @@ -44,7 +44,6 @@ tf-tensorboard is the frontend entry point for TensorBoard. It implements a toolbar (via paper-header-panel and paper-toolbar) that allows the user to toggle between various dashboards. --> -<script src="autoReloadBehavior.js"></script> <dom-module id="tf-tensorboard"> <template> <paper-dialog with-backdrop id="settings"> @@ -210,17 +209,22 @@ allows the user to toggle between various dashboards. </style> </template> + <script src="autoReloadBehavior.js"></script> <script> - "use strict"; + import {AutoReloadBehavior} from "./autoReloadBehavior"; + import {Backend} from "../tf-backend/backend"; + import {TABS, setUseHash} from "../tf-globals/globals"; + import {getString, setString, TAB} from "../tf-storage/storage"; + import * as backend_router from "../tf-backend/router"; Polymer({ is: "tf-tensorboard", - behaviors: [TF.TensorBoard.AutoReloadBehavior], + behaviors: [AutoReloadBehavior], properties: { router: { type: Object, value: function() { - return TF.Backend.router(); + return backend_router.router(); }, }, _backend: { @@ -245,7 +249,7 @@ allows the user to toggle between various dashboards. tabs: { type: Array, readOnly: true, - value: TF.Globals.TABS, + value: TABS, }, // If this is set to a string, TensorBoard will switch to "demo mode" // and attempt to load serialized json data from that directory. You can @@ -271,15 +275,15 @@ allows the user to toggle between various dashboards. }, _getModeFromIndex: function(modeIndex) { var mode = this.tabs[modeIndex]; - TF.URIStorage.setString(TF.URIStorage.TAB, mode); + setString(TAB, mode); return mode; }, _makeBackend: function(router, demoDir) { // use the demoDir if it is set, otherwise use the provided router if (demoDir != null) { - router = TF.Backend.router(demoDir, true); + router = backend_router.router(demoDir, true); } - return new TF.Backend.Backend(router); + return new Backend(router); }, _isReloadDisabled: function(mode) { return !this._debuggerDataEnabled && this._modeIsGraphs(mode); @@ -316,7 +320,7 @@ allows the user to toggle between various dashboards. return dashboard; }, ready: function() { - TF.Globals.setUseHash(this.useHash); + setUseHash(this.useHash); this._getModeFromHash(); window.addEventListener('hashchange', function() { @@ -324,7 +328,7 @@ allows the user to toggle between various dashboards. }.bind(this)); }, _getModeFromHash: function() { - var tabName = TF.URIStorage.getString(TF.URIStorage.TAB); + var tabName = getString(TAB); var modeIndex = this.tabs.indexOf(tabName); if (modeIndex == -1 && this.modeIndex == null) { // Select the first tab as default. @@ -348,5 +352,4 @@ allows the user to toggle between various dashboards. }, }); </script> - <script src="autoReloadBehavior.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/tf_text_dashboard/BUILD b/tensorflow/tensorboard/components/tf_text_dashboard/BUILD index a1a9777828..b6dfdbefb4 100644 --- a/tensorflow/tensorboard/components/tf_text_dashboard/BUILD +++ b/tensorflow/tensorboard/components/tf_text_dashboard/BUILD @@ -1,10 +1,10 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "tf_text_dashboard", srcs = [ "tf-text-dashboard.html", @@ -17,7 +17,7 @@ web_library( "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", "@org_polymer_paper_dialog", "@org_polymer_paper_icon_button", "@org_polymer_paper_material", @@ -26,15 +26,15 @@ web_library( ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"] + glob(["data/**"]), path = "/tf-text-dashboard", deps = [ ":tf_text_dashboard", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) diff --git a/tensorflow/tensorboard/components/tf_text_dashboard/index.html b/tensorflow/tensorboard/components/tf_text_dashboard/index.html index 77d19b948c..d01f4777ed 100644 --- a/tensorflow/tensorboard/components/tf_text_dashboard/index.html +++ b/tensorflow/tensorboard/components/tf_text_dashboard/index.html @@ -44,6 +44,9 @@ limitations under the License. </tf-text-dashboard> </template> <script> + import * as backend_backend from '../tf-backend/backend'; + import * as backend_router from '../tf-backend/router'; + Polymer({ is: "text-dash-demo", properties: { @@ -51,8 +54,8 @@ limitations under the License. type: Object, value: function() { var path = "data"; - var router = new TF.Backend.router(path, true); - return new TF.Backend.Backend(router); + var router = new backend_backend.router(path, true); + return new backend_backend.Backend(router); }, }, }, diff --git a/tensorflow/tensorboard/components/tf_text_dashboard/tf-text-dashboard.html b/tensorflow/tensorboard/components/tf_text_dashboard/tf-text-dashboard.html index 4c0b34055d..9b4fd3239c 100644 --- a/tensorflow/tensorboard/components/tf_text_dashboard/tf-text-dashboard.html +++ b/tensorflow/tensorboard/components/tf_text_dashboard/tf-text-dashboard.html @@ -82,7 +82,11 @@ tf-text-dashboard displays a dashboard that loads texts from a TensorFlow run. </style> </template> <script> - TF.Dashboard.TfTextDashboard = Polymer({ + import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; + import {ReloadBehavior} from "../tf-dashboard-common/reload-behavior"; + import {BackendBehavior} from "../tf-backend/behavior"; + + Polymer({ is: "tf-text-dashboard", factoryImpl: function(backend) { this.backend = backend; @@ -95,9 +99,9 @@ tf-text-dashboard displays a dashboard that loads texts from a TensorFlow run. }, }, behaviors: [ - TF.Dashboard.DashboardBehavior("text"), - TF.Dashboard.ReloadBehavior("tf-chart-scaffold"), - TF.Backend.BackendBehavior, + DashboardBehavior("text"), + ReloadBehavior("tf-chart-scaffold"), + BackendBehavior, ], attached: function() { this.async(function() { diff --git a/tensorflow/tensorboard/components/vz_distribution_chart/BUILD b/tensorflow/tensorboard/components/vz_distribution_chart/BUILD index b886fba3df..d0b8ee7749 100644 --- a/tensorflow/tensorboard/components/vz_distribution_chart/BUILD +++ b/tensorflow/tensorboard/components/vz_distribution_chart/BUILD @@ -1,64 +1,37 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "vz_distribution_chart", srcs = [ - "bundle.js", "vz-distribution-chart.html", + "vz-distribution-chart.ts", ], path = "/vz-distribution-chart", visibility = ["//visibility:public"], deps = [ "//tensorflow/tensorboard/components/tf_imports:lodash", "//tensorflow/tensorboard/components/tf_imports:plottable", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/vz_line_chart", - "@org_polymer", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/vz-distribution-chart", deps = [ ":vz_distribution_chart", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", - ], -) - -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/tf_imports:plottable.d.ts", - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/vz_line_chart:bundle.d.ts", ], ) -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"VZ": [ - "vz-distribution-chart.ts", - ]}, - namespace_symbol_aliases = {"VZ": { - "Dataset": "Plottable.Dataset", - "ChartHelpers": "VZ.ChartHelpers", - }}, -) - filegroup( name = "all_files", srcs = glob(["**"]), diff --git a/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.html b/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.html index 3c517bd164..1f1fdda919 100644 --- a/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.html +++ b/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.html @@ -41,5 +41,5 @@ limitations under the License. </style> </template> - <script src="bundle.js"></script> + <script src="vz-distribution-chart.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.ts b/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.ts index 17e3597824..f3911d301d 100644 --- a/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.ts +++ b/tensorflow/tensorboard/components/vz_distribution_chart/vz-distribution-chart.ts @@ -12,13 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -/* tslint:disable:no-namespace variable-name */ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import * as _ from 'lodash' -import * as Plottable from 'Plottable/plottable'; // from //third_party/javascript/plottable -import {Dataset} from 'Plottable/plottable'; -import * as ChartHelpers from '../vz_line_chart/vz-chart-helpers'; +import * as ChartHelpers from '../vz-line-chart/vz-chart-helpers'; export class DistributionChart { private run2datasets: {[run: string]: Plottable.Dataset}; diff --git a/tensorflow/tensorboard/components/vz_histogram_timeseries/BUILD b/tensorflow/tensorboard/components/vz_histogram_timeseries/BUILD index 005090b8e0..6f21df0c86 100644 --- a/tensorflow/tensorboard/components/vz_histogram_timeseries/BUILD +++ b/tensorflow/tensorboard/components/vz_histogram_timeseries/BUILD @@ -1,49 +1,36 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "vz_histogram_timeseries", srcs = ["vz-histogram-timeseries.html"], path = "/vz-histogram-timeseries", deps = [ "//tensorflow/tensorboard/components/tf_imports:d3", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/vz-histogram-timeseries", deps = [ ":vz_histogram_timeseries", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_button", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "index.html", - "vz-histogram-timeseries.html", - ], + srcs = [":vz_histogram_timeseries"], visibility = ["//learning/vis/vz_elements/catalog:__pkg__"], destdir = "vz-histogram-timeseries", deps = [ @@ -51,3 +38,9 @@ tensorboard_webcomponent_library( "//third_party/javascript/polymer/v1/polymer:lib", ], ) + +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], +) diff --git a/tensorflow/tensorboard/components/vz_line_chart/BUILD b/tensorflow/tensorboard/components/vz_line_chart/BUILD index c641587158..7d8d0d6074 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/BUILD +++ b/tensorflow/tensorboard/components/vz_line_chart/BUILD @@ -1,16 +1,17 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "vz_line_chart", srcs = [ - "bundle.js", + "dragZoomInteraction.ts", + "vz-chart-helpers.ts", "vz-line-chart.html", + "vz-line-chart.ts", ], path = "/vz-line-chart", visibility = ["//visibility:public"], @@ -18,11 +19,11 @@ web_library( "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:lodash", "//tensorflow/tensorboard/components/tf_imports:plottable", - "@org_polymer", + "//tensorflow/tensorboard/components/tf_imports:polymer", ], ) -web_library( +ts_web_library( name = "demo", srcs = ["index.html"], path = "/vz-line-chart", @@ -30,60 +31,12 @@ web_library( ":vz_line_chart", "@org_polymer_iron_demo_helpers", "@org_polymer_paper_styles", - "@org_polymer_webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:lodash.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/tf_imports:plottable.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = { - "VZ.ChartHelpers": [ - "vz-chart-helpers.ts", - ], - "VZ": [ - "vz-line-chart.ts", - "dragZoomInteraction.ts", - ], - }, - namespace_symbol_aliases = { - "VZ.ChartHelpers": { - "Dataset": "Plottable.Dataset", - }, - }, -) - -filegroup( - name = "all_files", - srcs = glob(["**"]), - tags = ["notsan"], -) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - tensorboard_webcomponent_library( name = "legacy", - srcs = [ - "index.html", - "vz-line-chart.html", - ":legacy_ts", - ], + srcs = [":vz_line_chart"], visibility = ["//learning/vis/vz_elements/catalog:__pkg__"], destdir = "vz-line-chart", deps = [ @@ -93,24 +46,8 @@ tensorboard_webcomponent_library( ], ) -tensorboard_ts_library( - name = "legacy_ts", - srcs = [ - "dragZoomInteraction.ts", - "vz-chart-helpers.ts", - "vz-line-chart.ts", - ], - deps_mgmt = "off", - runtime = "nodejs", - deps = [ - "//third_party/javascript/node_modules/typescript:es2015.promise", - "//third_party/javascript/plottable:bundle", - "//third_party/javascript/typings/chai", - "//third_party/javascript/typings/d3_v4:bundle", - "//third_party/javascript/typings/lodash", - "//third_party/javascript/typings/mocha", - "//third_party/javascript/typings/polymer:polymer_without_externs", - "//third_party/javascript/typings/sinon", - "//third_party/javascript/typings/webcomponents_js", - ], +filegroup( + name = "all_files", + srcs = glob(["**"]), + tags = ["notsan"], ) diff --git a/tensorflow/tensorboard/components/vz_line_chart/dragZoomInteraction.ts b/tensorflow/tensorboard/components/vz_line_chart/dragZoomInteraction.ts index 2c1f4989c4..c7f1f30e76 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/dragZoomInteraction.ts +++ b/tensorflow/tensorboard/components/vz_line_chart/dragZoomInteraction.ts @@ -13,11 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ - -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import * as Plottable from 'Plottable/plottable'; // from //third_party/javascript/plottable - - export class DragZoomLayer extends Plottable.Components.SelectionBoxLayer { private _dragInteraction: Plottable.Interactions.Drag; private _doubleClickInteraction: Plottable.Interactions.Click; diff --git a/tensorflow/tensorboard/components/vz_line_chart/index.html b/tensorflow/tensorboard/components/vz_line_chart/index.html index fb571a5183..856ab7d1ef 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/index.html +++ b/tensorflow/tensorboard/components/vz_line_chart/index.html @@ -21,7 +21,6 @@ limitations under the License. <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>vz-line-chart demo</title> - <script src="../webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="vz-line-chart.html"> <link rel="import" href="../iron-demo-helpers/demo-snippet.html"> <link rel="import" href="../paper-styles/typography.html"> diff --git a/tensorflow/tensorboard/components/vz_line_chart/vz-chart-helpers.ts b/tensorflow/tensorboard/components/vz_line_chart/vz-chart-helpers.ts index cd8f137617..fa89e06ada 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/vz-chart-helpers.ts +++ b/tensorflow/tensorboard/components/vz_line_chart/vz-chart-helpers.ts @@ -12,12 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -/* tslint:disable:no-namespace variable-name */ - - -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import * as Plottable from 'Plottable/plottable'; // from //third_party/javascript/plottable -import {Dataset} from 'Plottable/plottable'; export interface Datum { wall_time: Date; @@ -123,6 +117,7 @@ export function computeDomain(values: number[], ignoreOutliers: boolean) { } export function accessorize(key: string): Plottable.IAccessor<number> { + // tslint:disable-next-line:no-any be quiet tsc return (d: any, index: number, dataset: Plottable.Dataset) => d[key]; } @@ -157,19 +152,21 @@ export function wallX(): XComponents { accessor: (d: Datum) => d.wall_time, }; } -export let relativeAccessor = (d: any, index: number, dataset: Dataset) => { - // We may be rendering the final-point datum for scatterplot. - // If so, we will have already provided the 'relative' property - if (d.relative != null) { - return d.relative; - } - let data = dataset.data(); - // I can't imagine how this function would be called when the data is - // empty (after all, it iterates over the data), but lets guard just - // to be safe. - let first = data.length > 0 ? +data[0].wall_time : 0; - return (+d.wall_time - first) / (60 * 60 * 1000); // ms to hours -}; +export let relativeAccessor = + // tslint:disable-next-line:no-any be quiet tsc + (d: any, index: number, dataset: Plottable.Dataset) => { + // We may be rendering the final-point datum for scatterplot. + // If so, we will have already provided the 'relative' property + if (d.relative != null) { + return d.relative; + } + let data = dataset.data(); + // I can't imagine how this function would be called when the data is + // empty (after all, it iterates over the data), but lets guard just + // to be safe. + let first = data.length > 0 ? +data[0].wall_time : 0; + return (+d.wall_time - first) / (60 * 60 * 1000); // ms to hours + }; export let relativeFormatter = (n: number) => { // we will always show 2 units of precision, e.g days and hours, or diff --git a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html index 85e24ae4be..38e0d7cb8d 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html +++ b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.html @@ -125,5 +125,7 @@ such as different X scales (linear and temporal), tooltips and smoothing. </style> </template> - <script src="bundle.js"></script> + <script src="vz-chart-helpers.js"></script> + <script src="dragZoomInteraction.js"></script> + <script src="vz-line-chart.js"></script> </dom-module> diff --git a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts index d50a7834f5..5da6190ea2 100644 --- a/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts +++ b/tensorflow/tensorboard/components/vz_line_chart/vz-line-chart.ts @@ -14,10 +14,6 @@ limitations under the License. ==============================================================================*/ /* tslint:disable:no-namespace variable-name */ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 -import * as _ from 'lodash' -import * as Plottable from 'Plottable/plottable'; // from //third_party/javascript/plottable - import {DragZoomLayer} from './dragZoomInteraction' import * as ChartHelpers from './vz-chart-helpers' @@ -142,7 +138,7 @@ Polymer({ * Sets the series that the chart displays. Series with other names will * not be displayed. * - * @param {String[]} names Array with the names of the series to + * @param {Array<String>} names Array with the names of the series to * display. */ setVisibleSeries: function(names) { @@ -157,8 +153,8 @@ Polymer({ * Sets the data of one of the series. Note that to display this series * its name must be in the setVisibleSeries() array. * - * @param {String} name Name of the series. - * @param {VZ.ChartHelpers.ScalarDatum[]} data Data of the series. This is + * @param {string} name Name of the series. + * @param {Array<ChartHelpers.ScalarDatum>} data Data of the series. This is * an array of objects with at least the following properties: * - step: (Number) - index of the datum. * - wall_time: (Date) - Date object with the datum's time. diff --git a/tensorflow/tensorboard/components/vz_projector/BUILD b/tensorflow/tensorboard/components/vz_projector/BUILD index c1adeabbf5..6d22554efa 100644 --- a/tensorflow/tensorboard/components/vz_projector/BUILD +++ b/tensorflow/tensorboard/components/vz_projector/BUILD @@ -1,38 +1,69 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "vz_projector", srcs = [ + "analyticsLogger.ts", "bundle.html", - "bundle.js", + "data.ts", + "data-provider.ts", + "data-provider-demo.ts", + "data-provider-proto.ts", + "data-provider-server.ts", + "external.d.ts", + "knn.ts", + "label.ts", + "logging.ts", + "projectorEventContext.ts", + "projectorScatterPlotAdapter.ts", + "renderContext.ts", + "scatterPlot.ts", + "scatterPlotRectangleSelector.ts", + "scatterPlotVisualizer.ts", + "scatterPlotVisualizer3DLabels.ts", + "scatterPlotVisualizerCanvasLabels.ts", + "scatterPlotVisualizerPolylines.ts", + "scatterPlotVisualizerSprites.ts", "styles.html", + "util.ts", + "vector.ts", "vz-projector.html", + "vz-projector.ts", "vz-projector-app.html", "vz-projector-bookmark-panel.html", + "vz-projector-bookmark-panel.ts", "vz-projector-colab.html", "vz-projector-dashboard.html", "vz-projector-data-panel.html", + "vz-projector-data-panel.ts", "vz-projector-input.html", + "vz-projector-input.ts", "vz-projector-inspector-panel.html", + "vz-projector-inspector-panel.ts", "vz-projector-legend.html", + "vz-projector-legend.ts", "vz-projector-metadata-card.html", + "vz-projector-metadata-card.ts", "vz-projector-projections-panel.html", + "vz-projector-projections-panel.ts", + "vz-projector-util.ts", ], path = "/vz-projector", visibility = ["//visibility:public"], deps = [ + ":bh_tsne", + ":heap", + ":sptree", "//tensorflow/tensorboard/components/tf_dashboard_common", "//tensorflow/tensorboard/components/tf_imports:d3", "//tensorflow/tensorboard/components/tf_imports:numericjs", + "//tensorflow/tensorboard/components/tf_imports:polymer", "//tensorflow/tensorboard/components/tf_imports:threejs", "//tensorflow/tensorboard/components/tf_imports:weblas", - "@org_polymer", "@org_polymer_iron_collapse", "@org_polymer_iron_icons", "@org_polymer_paper_button", @@ -53,298 +84,23 @@ web_library( ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "external.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:three.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - ], +ts_web_library( + name = "heap", + srcs = ["heap.ts"], + path = "/vz-projector", +) + +ts_web_library( + name = "sptree", + srcs = ["sptree.ts"], + path = "/vz-projector", ) -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = { - "VZ.Projector.Heap": ["heap.ts"], - "VZ.Projector.Label": ["label.ts"], - "VZ.Projector.SPTree": ["sptree.ts"], - "VZ.Projector.BhTsne": ["bh_tsne.ts"], - "VZ.Projector.Logging": ["logging.ts"], - "VZ.Projector.RenderContext": ["renderContext.ts"], - "VZ.Projector.ScatterPlotRectangleSelector": ["scatterPlotRectangleSelector.ts"], - "VZ.Projector.AnalyticsLogger": ["analyticsLogger.ts"], - "VZ.Projector.Util": ["util.ts"], - "VZ.Projector.Vector": ["vector.ts"], - "VZ.Projector.Knn": ["knn.ts"], - "VZ.Projector.Data": ["data.ts"], - "VZ.Projector.DataProvider": ["data-provider.ts"], - "VZ.Projector.DataProviderDemo": ["data-provider-demo.ts"], - "VZ.Projector.DataProviderProto": ["data-provider-proto.ts"], - "VZ.Projector.DataProviderServer": ["data-provider-server.ts"], - "VZ.Projector.ProjectorEventContext": ["projectorEventContext.ts"], - "VZ.Projector.ScatterPlot": ["scatterPlot.ts"], - "VZ.Projector.ScatterPlotVisualizer3DLabels": ["scatterPlotVisualizer3DLabels.ts"], - "VZ.Projector.ScatterPlotVisualizerCanvasLabels": ["scatterPlotVisualizerCanvasLabels.ts"], - "VZ.Projector.ScatterPlotVisualizerPolylines": ["scatterPlotVisualizerPolylines.ts"], - "VZ.Projector.ScatterPlotVisualizerSprites": ["scatterPlotVisualizerSprites.ts"], - "VZ.Projector.ScatterPlotVisualizer": ["scatterPlotVisualizer.ts"], - "VZ.Projector.ProjectorScatterPlotAdapter": ["projectorScatterPlotAdapter.ts"], - "VZ.Projector.ProjectorUtil": ["vz-projector-util.ts"], - "VZ.Projector.ProjectorBookmarkPanel": ["vz-projector-bookmark-panel.ts"], - "VZ.Projector.ProjectorDataPanel": ["vz-projector-data-panel.ts"], - "VZ.Projector.ProjectorInput": ["vz-projector-input.ts"], - "VZ.Projector.ProjectorInspectorPanel": ["vz-projector-inspector-panel.ts"], - "VZ.Projector.ProjectorLegend": ["vz-projector-legend.ts"], - "VZ.Projector.ProjectorMetadataCard": ["vz-projector-metadata-card.ts"], - "VZ.Projector.ProjectorProjectionsPanel": ["vz-projector-projections-panel.ts"], - "VZ.Projector": ["vz-projector.ts"], - }, - namespace_symbol_aliases = { - "VZ.Projector.AnalyticsLogger": { - "ProjectionType": "VZ.Projector.Data.ProjectionType", - }, - "VZ.Projector.BhTsne": { - "SPNode": "VZ.Projector.SPTree.SPNode", - "SPTree": "VZ.Projector.SPTree.SPTree", - }, - "VZ.Projector.DataProviderDemo": { - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "DataSet": "VZ.Projector.Data.DataSet", - "EmbeddingInfo": "VZ.Projector.DataProvider.EmbeddingInfo", - "ProjectorConfig": "VZ.Projector.DataProvider.ProjectorConfig", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "TENSORS_MSG_ID": "VZ.Projector.DataProvider.TENSORS_MSG_ID", - "dataProvider": "VZ.Projector.DataProvider", - "logging": "VZ.Projector.Logging", - }, - "VZ.Projector.DataProviderProto": { - "DataPoint": "VZ.Projector.Data.DataPoint", - "DataProto": "VZ.Projector.Data.DataProto", - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "DataSet": "VZ.Projector.Data.DataSet", - "PointMetadata": "VZ.Projector.Data.PointMetadata", - "ProjectorConfig": "VZ.Projector.DataProvider.ProjectorConfig", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "analyzeMetadata": "VZ.Projector.DataProvider.analyzeMetadata", - }, - "VZ.Projector.DataProviderServer": { - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "DataSet": "VZ.Projector.Data.DataSet", - "EmbeddingInfo": "VZ.Projector.DataProvider.EmbeddingInfo", - "ProjectorConfig": "VZ.Projector.DataProvider.ProjectorConfig", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "dataProvider": "VZ.Projector.DataProvider", - "logging": "VZ.Projector.Logging", - }, - "VZ.Projector.DataProvider": { - "ColumnStats": "VZ.Projector.Data.ColumnStats", - "DataPoint": "VZ.Projector.Data.DataPoint", - "DataSet": "VZ.Projector.Data.DataSet", - "PointMetadata": "VZ.Projector.Data.PointMetadata", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "logging": "VZ.Projector.Logging", - "runAsyncTask": "VZ.Projector.Util.runAsyncTask", - }, - "VZ.Projector.Data": { - "SpriteMetadata": "VZ.Projector.DataProvider.SpriteMetadata", - "TSNE": "VZ.Projector.BhTsne.TSNE", - "knn": "VZ.Projector.Knn", - "logging": "VZ.Projector.Logging", - "scatterPlot": "VZ.Projector.ScatterPlot", - "util": "VZ.Projector.Util", - "vector": "VZ.Projector.Vector", - }, - "VZ.Projector.Knn": { - "KMin": "VZ.Projector.Heap.KMin", - "Vector": "VZ.Projector.Vector.Vector", - "logging": "VZ.Projector.Logging", - "runAsyncTask": "VZ.Projector.Util.runAsyncTask", - "vector": "VZ.Projector.Vector", - }, - "VZ.Projector.ProjectorEventContext": { - "DistanceFunction": "VZ.Projector.Data.DistanceFunction", - "NearestEntry": "VZ.Projector.Knn.NearestEntry", - "Projection": "VZ.Projector.Data.Projection", - }, - "VZ.Projector.ProjectorScatterPlotAdapter": { - "DataSet": "VZ.Projector.Data.DataSet", - "DistanceFunction": "VZ.Projector.Data.DistanceFunction", - "LabelRenderParams": "VZ.Projector.RenderContext.LabelRenderParams", - "NearestEntry": "VZ.Projector.Knn.NearestEntry", - "Projection": "VZ.Projector.Data.Projection", - "ProjectionComponents3D": "VZ.Projector.Data.ProjectionComponents3D", - "ProjectorEventContext": "VZ.Projector.ProjectorEventContext.ProjectorEventContext", - "ScatterPlot": "VZ.Projector.ScatterPlot.ScatterPlot", - "ScatterPlotVisualizer3DLabels": "VZ.Projector.ScatterPlotVisualizer3DLabels.ScatterPlotVisualizer3DLabels", - "ScatterPlotVisualizerCanvasLabels": "VZ.Projector.ScatterPlotVisualizerCanvasLabels.ScatterPlotVisualizerCanvasLabels", - "ScatterPlotVisualizerPolylines": "VZ.Projector.ScatterPlotVisualizerPolylines.ScatterPlotVisualizerPolylines", - "ScatterPlotVisualizerSprites": "VZ.Projector.ScatterPlotVisualizerSprites.ScatterPlotVisualizerSprites", - "State": "VZ.Projector.Data.State", - "vector": "VZ.Projector.Vector", - }, - "VZ.Projector.ScatterPlot": { - "BoundingBox": "VZ.Projector.ScatterPlotRectangleSelector.BoundingBox", - "CameraType": "VZ.Projector.RenderContext.CameraType", - "LabelRenderParams": "VZ.Projector.RenderContext.LabelRenderParams", - "Point2D": "VZ.Projector.Vector.Point2D", - "Point3D": "VZ.Projector.Vector.Point3D", - "ProjectorEventContext": "VZ.Projector.ProjectorEventContext.ProjectorEventContext", - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - "ScatterPlotRectangleSelector": "VZ.Projector.ScatterPlotRectangleSelector.ScatterPlotRectangleSelector", - "ScatterPlotVisualizer": "VZ.Projector.ScatterPlotVisualizer.ScatterPlotVisualizer", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ScatterPlotVisualizer3DLabels": { - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - "ScatterPlotVisualizer": "VZ.Projector.ScatterPlotVisualizer.ScatterPlotVisualizer", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ScatterPlotVisualizerCanvasLabels": { - "BoundingBox": "VZ.Projector.Label.BoundingBox", - "CameraType": "VZ.Projector.RenderContext.CameraType", - "CollisionGrid": "VZ.Projector.Label.CollisionGrid", - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - "ScatterPlotVisualizer": "VZ.Projector.ScatterPlotVisualizer.ScatterPlotVisualizer", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ScatterPlotVisualizerPolylines": { - "DataSet": "VZ.Projector.Data.DataSet", - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - "ScatterPlotVisualizer": "VZ.Projector.ScatterPlotVisualizer.ScatterPlotVisualizer", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ScatterPlotVisualizerSprites": { - "CameraType": "VZ.Projector.RenderContext.CameraType", - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - "ScatterPlotVisualizer": "VZ.Projector.ScatterPlotVisualizer.ScatterPlotVisualizer", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ScatterPlotVisualizer": { - "RenderContext": "VZ.Projector.RenderContext.RenderContext", - }, - "VZ.Projector.Util": { - "DataPoint": "VZ.Projector.Data.DataPoint", - "Point2D": "VZ.Projector.Vector.Point2D", - "logging": "VZ.Projector.Logging", - }, - "VZ.Projector.Vector": { - "assert": "VZ.Projector.Util.assert", - }, - "VZ.Projector.ProjectorBookmarkPanel": { - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "EmbeddingInfo": "VZ.Projector.DataProvider.EmbeddingInfo", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - "Projector": "VZ.Projector.Projector", - "ProjectorEventContext": "VZ.Projector.ProjectorEventContext.ProjectorEventContext", - "State": "VZ.Projector.Data.State", - "logging": "VZ.Projector.Logging", - }, - "VZ.Projector.ProjectorDataPanel": { - "ColorLegendRenderInfo": "VZ.Projector.ProjectorLegend.ColorLegendRenderInfo", - "ColorLegendThreshold": "VZ.Projector.ProjectorLegend.ColorLegendThreshold", - "ColorOption": "VZ.Projector.Data.ColorOption", - "ColumnStats": "VZ.Projector.Data.ColumnStats", - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "EmbeddingInfo": "VZ.Projector.DataProvider.EmbeddingInfo", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - "Projector": "VZ.Projector.Projector", - "ProjectorConfig": "VZ.Projector.DataProvider.ProjectorConfig", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "parseRawMetadata": "VZ.Projector.DataProvider.parseRawMetadata", - "parseRawTensors": "VZ.Projector.DataProvider.parseRawTensors", - "util": "VZ.Projector.Util", - }, - "VZ.Projector.ProjectorInput": { - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - }, - "VZ.Projector.ProjectorInspectorPanel": { - "DistanceFunction": "VZ.Projector.Data.DistanceFunction", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - "Projector": "VZ.Projector.Projector", - "ProjectorEventContext": "VZ.Projector.ProjectorEventContext.ProjectorEventContext", - "ProjectorInput": "VZ.Projector.ProjectorInput.ProjectorInput", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "adapter": "VZ.Projector.ProjectorScatterPlotAdapter", - "knn": "VZ.Projector.Knn", - "util": "VZ.Projector.Util", - "vector": "VZ.Projector.Vector", - }, - "VZ.Projector.ProjectorLegend": { - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - }, - "VZ.Projector.ProjectorMetadataCard": { - "PointMetadata": "VZ.Projector.Data.PointMetadata", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - }, - "VZ.Projector.ProjectorProjectionsPanel": { - "DataSet": "VZ.Projector.Data.DataSet", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - "Projection": "VZ.Projector.Data.Projection", - "ProjectionType": "VZ.Projector.Data.ProjectionType", - "Projector": "VZ.Projector.Projector", - "ProjectorInput": "VZ.Projector.ProjectorInput.ProjectorInput", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "Vector": "VZ.Projector.Vector.Vector", - "data": "VZ.Projector.Data", - "util": "VZ.Projector.Util", - "vector": "VZ.Projector.Vector", - }, - "VZ.Projector": { - "AnalyticsLogger": "VZ.Projector.AnalyticsLogger.AnalyticsLogger", - "BookmarkPanel": "VZ.Projector.ProjectorBookmarkPanel.BookmarkPanel", - "ColorOption": "VZ.Projector.Data.ColorOption", - "ColumnStats": "VZ.Projector.Data.ColumnStats", - "DataPanel": "VZ.Projector.ProjectorDataPanel.DataPanel", - "DataPoint": "VZ.Projector.Data.DataPoint", - "DataProto": "VZ.Projector.Data.DataProto", - "DataProvider": "VZ.Projector.DataProvider.DataProvider", - "DataSet": "VZ.Projector.Data.DataSet", - "DemoDataProvider": "VZ.Projector.DataProviderDemo.DemoDataProvider", - "DistanceFunction": "VZ.Projector.Data.DistanceFunction", - "DistanceMetricChangedListener": "VZ.Projector.ProjectorEventContext.DistanceMetricChangedListener", - "EmbeddingInfo": "VZ.Projector.DataProvider.EmbeddingInfo", - "HoverListener": "VZ.Projector.ProjectorEventContext.HoverListener", - "InspectorPanel": "VZ.Projector.ProjectorInspectorPanel.InspectorPanel", - "MetadataCard": "VZ.Projector.ProjectorMetadataCard.MetadataCard", - "MouseMode": "VZ.Projector.ScatterPlot.MouseMode", - "PointMetadata": "VZ.Projector.Data.PointMetadata", - "PolymerElement": "VZ.Projector.ProjectorUtil.PolymerElement", - "PolymerHTMLElement": "VZ.Projector.ProjectorUtil.PolymerHTMLElement", - "Projection": "VZ.Projector.Data.Projection", - "ProjectionChangedListener": "VZ.Projector.ProjectorEventContext.ProjectionChangedListener", - "ProjectionsPanel": "VZ.Projector.ProjectorProjectionsPanel.ProjectionsPanel", - "ProjectorEventContext": "VZ.Projector.ProjectorEventContext.ProjectorEventContext", - "ProjectorScatterPlotAdapter": "VZ.Projector.ProjectorScatterPlotAdapter.ProjectorScatterPlotAdapter", - "ProtoDataProvider": "VZ.Projector.DataProviderProto.ProtoDataProvider", - "SelectionChangedListener": "VZ.Projector.ProjectorEventContext.SelectionChangedListener", - "ServerDataProvider": "VZ.Projector.DataProviderServer.ServerDataProvider", - "ServingMode": "VZ.Projector.DataProvider.ServingMode", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "data": "VZ.Projector.Data", - "knn": "VZ.Projector.Knn", - "logging": "VZ.Projector.Logging", - "stateGetAccessorDimensions": "VZ.Projector.Data.stateGetAccessorDimensions", - "util": "VZ.Projector.Util", - }, - }, +ts_web_library( + name = "bh_tsne", + srcs = ["bh_tsne.ts"], + path = "/vz-projector", + deps = [":sptree"], ) filegroup( @@ -352,97 +108,3 @@ filegroup( srcs = glob(["**"]), tags = ["notsan"], ) - -#### Legacy for other consumers -load( - "//tensorflow/tensorboard:defs.bzl", - "tensorboard_webcomponent_library", - "tensorboard_ts_library", - "tensorboard_ts_declaration", -) - -# Standalone embedding projector demos should depend on this target. We -# exclude the HTML file for the dashboard itself. Demos do not need that -# HTML file. This was introduced because standalone demos as of today -# have an additional Closure pass that uses a compilation configuration -# stricter than that of TensorBoard. - -_PROJECTOR_LIB_TS_LIB_DEPS = [ - ":ts_lib", - ":tsne_ts_lib", -] - -_PROJECTOR_DESTDIR = "vz-projector" - -_PROJECTOR_LIB_DEPS = [ - "//third_party/javascript/polymer/v1/iron-collapse:lib", - "//third_party/javascript/polymer/v1/iron-icons:lib", - "//third_party/javascript/polymer/v1/paper-button:lib", - "//third_party/javascript/polymer/v1/paper-checkbox:lib", - "//third_party/javascript/polymer/v1/paper-dialog:lib", - "//third_party/javascript/polymer/v1/paper-dialog-scrollable:lib", - "//third_party/javascript/polymer/v1/paper-dropdown-menu:lib", - "//third_party/javascript/polymer/v1/paper-icon-button:lib", - "//third_party/javascript/polymer/v1/paper-input:lib", - "//third_party/javascript/polymer/v1/paper-item:lib", - "//third_party/javascript/polymer/v1/paper-listbox:lib", - "//third_party/javascript/polymer/v1/paper-slider:lib", - "//third_party/javascript/polymer/v1/paper-spinner:lib", - "//third_party/javascript/polymer/v1/paper-toast:lib", - "//third_party/javascript/polymer/v1/paper-toggle-button:lib", - "//third_party/javascript/polymer/v1/paper-tooltip:lib", - "//third_party/javascript/polymer/v1/polymer:lib", -] - -tensorboard_ts_library( - name = "tsne_ts_lib", - srcs = [ - "bh_tsne.ts", - "sptree.ts", - ], -) - -tensorboard_ts_declaration( - name = "external", - srcs = ["external.d.ts"], -) - -tensorboard_ts_library( - name = "ts_lib", - srcs = glob( - ["*.ts"], - exclude = [ - "*.d.ts", - "*_test.ts", - "bh_tsne.ts", - "sptree.ts", - ], - ), - runtime_deps = [ - "//third_party/javascript/d3/v4:d3", - "//third_party/javascript/numericjs", - "//third_party/javascript/threejs/r77:threejs", - "//third_party/javascript/threejs/r77/examples/js/controls:orbitcontrols", - "//third_party/javascript/weblas", - ], - deps = [ - ":external", - ":tsne_ts_lib", - "//third_party/javascript/node_modules/typescript:es2015.promise", - "//third_party/javascript/typings/d3_v4:bundle", - "//third_party/javascript/typings/polymer:polymer_without_externs", - "//third_party/javascript/typings/threejs:three", - "//third_party/javascript/typings/webcomponents_js", - ], -) - -tensorboard_webcomponent_library( - name = "lib", - srcs = glob( - ["*.html"], - exclude = ["vz-projector-dashboard.html"], - ), - ts_lib_deps = _PROJECTOR_LIB_TS_LIB_DEPS, - destdir = _PROJECTOR_DESTDIR, - deps = _PROJECTOR_LIB_DEPS, -) diff --git a/tensorflow/tensorboard/components/vz_projector/bundle.html b/tensorflow/tensorboard/components/vz_projector/bundle.html index 2837fed870..de87763673 100644 --- a/tensorflow/tensorboard/components/vz_projector/bundle.html +++ b/tensorflow/tensorboard/components/vz_projector/bundle.html @@ -21,4 +21,36 @@ limitations under the License. <link rel="import" href="../tf-imports/threejs.html"> <link rel="import" href="../tf-imports/weblas.html"> -<script src="bundle.js"></script> +<script src="heap.js"></script> +<script src="label.js"></script> +<script src="sptree.js"></script> +<script src="bh_tsne.js"></script> +<script src="logging.js"></script> +<script src="renderContext.js"></script> +<script src="scatterPlotRectangleSelector.js"></script> +<script src="analyticsLogger.js"></script> +<script src="util.js"></script> +<script src="vector.js"></script> +<script src="knn.js"></script> +<script src="data.js"></script> +<script src="data-provider.js"></script> +<script src="data-provider-demo.js"></script> +<script src="data-provider-proto.js"></script> +<script src="data-provider-server.js"></script> +<script src="projectorEventContext.js"></script> +<script src="scatterPlot.js"></script> +<script src="scatterPlotVisualizer3DLabels.js"></script> +<script src="scatterPlotVisualizerCanvasLabels.js"></script> +<script src="scatterPlotVisualizerPolylines.js"></script> +<script src="scatterPlotVisualizerSprites.js"></script> +<script src="scatterPlotVisualizer.js"></script> +<script src="projectorScatterPlotAdapter.js"></script> +<script src="vz-projector-util.js"></script> +<script src="vz-projector-bookmark-panel.js"></script> +<script src="vz-projector-data-panel.js"></script> +<script src="vz-projector-input.js"></script> +<script src="vz-projector-inspector-panel.js"></script> +<script src="vz-projector-legend.js"></script> +<script src="vz-projector-metadata-card.js"></script> +<script src="vz-projector-projections-panel.js"></script> +<script src="vz-projector.js"></script> diff --git a/tensorflow/tensorboard/components/vz_projector/projectorScatterPlotAdapter.ts b/tensorflow/tensorboard/components/vz_projector/projectorScatterPlotAdapter.ts index 9d6df953d6..c0da952659 100644 --- a/tensorflow/tensorboard/components/vz_projector/projectorScatterPlotAdapter.ts +++ b/tensorflow/tensorboard/components/vz_projector/projectorScatterPlotAdapter.ts @@ -13,8 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 - import {DataSet, DistanceFunction, Projection, ProjectionComponents3D, State} from './data'; import {NearestEntry} from './knn'; import {ProjectorEventContext} from './projectorEventContext'; diff --git a/tensorflow/tensorboard/components/vz_projector/scatterPlotVisualizerCanvasLabels.ts b/tensorflow/tensorboard/components/vz_projector/scatterPlotVisualizerCanvasLabels.ts index ece4d84ef2..2f3146d213 100644 --- a/tensorflow/tensorboard/components/vz_projector/scatterPlotVisualizerCanvasLabels.ts +++ b/tensorflow/tensorboard/components/vz_projector/scatterPlotVisualizerCanvasLabels.ts @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 import {BoundingBox, CollisionGrid} from './label'; import {CameraType, RenderContext} from './renderContext'; import {ScatterPlotVisualizer} from './scatterPlotVisualizer'; diff --git a/tensorflow/tensorboard/components/vz_projector/test/BUILD b/tensorflow/tensorboard/components/vz_projector/test/BUILD index 7629272c35..a73c50dcd6 100644 --- a/tensorflow/tensorboard/components/vz_projector/test/BUILD +++ b/tensorflow/tensorboard/components/vz_projector/test/BUILD @@ -3,76 +3,31 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", + "assert.ts", + "data-provider_test.ts", + "data_test.ts", + "sptree_test.ts", "tests.html", + "util_test.ts", + # "scatterPlotRectangleSelector_test.ts", + # "vz-projector-projections-panel_test.ts", ], path = "/vz-projector/test", deps = [ + "//tensorflow/tensorboard/components/tf_imports:polymer", + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", + "//tensorflow/tensorboard/components/tf_imports:webcomponentsjs", "//tensorflow/tensorboard/components/vz_projector", - "@org_npmjs_registry_web_component_tester", - "@org_polymer", - "@org_polymer_webcomponentsjs", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:chai.d.ts", - "@org_definitelytyped//:mocha.d.ts", - "@org_definitelytyped//:polymer.d.ts", - "@org_definitelytyped//:three.d.ts", - "@org_definitelytyped//:webcomponents.js.d.ts", - "//tensorflow/tensorboard/components/tf_imports:d3.d.ts", - "//tensorflow/tensorboard/components/tf_imports:plottable.d.ts", - "//tensorflow/tensorboard/components/vz_projector:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = { - "VZ.Projector.Test": [ - "assert.ts", - "sptree_test.ts", - "data_test.ts", - "data-provider_test.ts", - "util_test.ts", - - # TODO(smilkov): Migrate these away from jasmine. - # "scatterPlotRectangleSelector_test.ts", - # "vz-projector-projections-panel_test.ts", - ], - }, - namespace_symbol_aliases = { - "VZ.Projector.Test": { - "BoundingBox": "VZ.Projector.ScatterPlotRectangleSelector.BoundingBox", - "DataPoint": "VZ.Projector.Data.DataPoint", - "DataSet": "VZ.Projector.Data.DataSet", - "ProjectionsPanel": "VZ.Projector.ProjectorProjectionsPanel.ProjectionsPanel", - "SPTree": "VZ.Projector.SPTree.SPTree", - "ScatterPlotRectangleSelector": "VZ.Projector.ScatterPlotRectangleSelector.ScatterPlotRectangleSelector", - "SpriteAndMetadataInfo": "VZ.Projector.Data.SpriteAndMetadataInfo", - "State": "VZ.Projector.Data.State", - "State": "VZ.Projector.Data.State", - "data_provider": "VZ.Projector.DataProvider", - "stateGetAccessorDimensions": "VZ.Projector.Data.stateGetAccessorDimensions", - "util": "VZ.Projector.Util", - }, - }, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/vz_projector/test/tests.html b/tensorflow/tensorboard/components/vz_projector/test/tests.html index dd43079bde..a6843d0d6b 100644 --- a/tensorflow/tensorboard/components/vz_projector/test/tests.html +++ b/tensorflow/tensorboard/components/vz_projector/test/tests.html @@ -21,4 +21,11 @@ limitations under the License. <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="../bundle.html"> <body> -<script src="bundle.js"></script> +<script src="assert.js"></script> +<script src="sptree_test.js"></script> +<script src="data_test.js"></script> +<script src="data-provider_test.js"></script> +<script src="util_test.js"></script> +<!-- TODO(smilkov): Migrate these away from jasmine. --> +<!-- <script src="scatterPlotRectangleSelector_test.js"></script> + <script src="vz-projector-projections-panel_test.js"></script> --> diff --git a/tensorflow/tensorboard/components/vz_projector/vector.ts b/tensorflow/tensorboard/components/vz_projector/vector.ts index 0de78ad85d..cab3048313 100644 --- a/tensorflow/tensorboard/components/vz_projector/vector.ts +++ b/tensorflow/tensorboard/components/vz_projector/vector.ts @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 import {assert} from './util'; /** diff --git a/tensorflow/tensorboard/components/vz_projector/vz-projector-dashboard.html b/tensorflow/tensorboard/components/vz_projector/vz-projector-dashboard.html index 55c15da5ed..8223c503ec 100644 --- a/tensorflow/tensorboard/components/vz_projector/vz-projector-dashboard.html +++ b/tensorflow/tensorboard/components/vz_projector/vz-projector-dashboard.html @@ -37,10 +37,9 @@ limitations under the License. </template> </template> <script> -"use strict"; +import {DashboardBehavior} from "../tf-dashboard-common/dashboard-behavior"; -(function() { -TF.Dashboard.VzProjectorDashboard = Polymer({ +Polymer({ is: 'vz-projector-dashboard', factoryImpl: function(routePrefix) { this.routePrefix = routePrefix; @@ -52,7 +51,7 @@ TF.Dashboard.VzProjectorDashboard = Polymer({ _initialized: Boolean, }, behaviors: [ - TF.Dashboard.DashboardBehavior("embeddings"), + DashboardBehavior("embeddings"), ], reload: function() { // Do not reload the embedding projector. Reloading could take a long time. @@ -76,6 +75,5 @@ TF.Dashboard.VzProjectorDashboard = Polymer({ xhr.send(); }, }); -})(); </script> </dom-module> diff --git a/tensorflow/tensorboard/components/vz_projector/vz-projector-data-panel.ts b/tensorflow/tensorboard/components/vz_projector/vz-projector-data-panel.ts index a6847ed3c8..a9b6f6c5a0 100644 --- a/tensorflow/tensorboard/components/vz_projector/vz-projector-data-panel.ts +++ b/tensorflow/tensorboard/components/vz_projector/vz-projector-data-panel.ts @@ -13,7 +13,6 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import * as d3 from 'd3'; // from //third_party/javascript/typings/d3_v4 import {ColorOption, ColumnStats, SpriteAndMetadataInfo} from './data'; import {DataProvider, EmbeddingInfo, parseRawMetadata, parseRawTensors, ProjectorConfig} from './data-provider'; import * as util from './util'; diff --git a/tensorflow/tensorboard/components/vz_sorting/BUILD b/tensorflow/tensorboard/components/vz_sorting/BUILD index 96e270ce21..fc309ce4a5 100644 --- a/tensorflow/tensorboard/components/vz_sorting/BUILD +++ b/tensorflow/tensorboard/components/vz_sorting/BUILD @@ -1,30 +1,24 @@ package(default_visibility = ["//tensorflow:internal"]) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "vz_sorting", srcs = [ - "bundle.js", + "sorting.ts", "vz-sorting.html", ], path = "/vz-sorting", visibility = ["//visibility:public"], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"VZ.Sorting": ["sorting.ts"]}, +tensorboard_webcomponent_library( + name = "legacy", + srcs = [":vz_sorting"], + destdir = "vz-sorting", ) filegroup( @@ -32,25 +26,3 @@ filegroup( srcs = glob(["**"]), tags = ["notsan"], ) - -################################################################################ -# MARKED FOR DELETION - -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library") - -tensorboard_webcomponent_library( - name = "legacy", - srcs = [ - "vz-sorting.html", - ":legacy_ts", - ], - destdir = "vz-sorting", -) - -tensorboard_ts_library( - name = "legacy_ts", - srcs = ["sorting.ts"], - deps_mgmt = "off", - runtime = "nodejs", -) diff --git a/tensorflow/tensorboard/components/vz_sorting/test/BUILD b/tensorflow/tensorboard/components/vz_sorting/test/BUILD index 07913e3cbd..23e575945b 100644 --- a/tensorflow/tensorboard/components/vz_sorting/test/BUILD +++ b/tensorflow/tensorboard/components/vz_sorting/test/BUILD @@ -3,41 +3,23 @@ package( default_visibility = ["//tensorflow:internal"], ) -load("@io_bazel_rules_closure//closure:defs.bzl", "web_library") -load("//tensorflow/tensorboard:hacks.bzl", "tensorboard_typescript_bundle") -load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule") +load("//tensorflow/tensorboard:web.bzl", "ts_web_library") licenses(["notice"]) # Apache 2.0 -web_library( +ts_web_library( name = "test", srcs = [ - "bundle.js", + "sortingTests.ts", "tests.html", ], path = "/vz-sorting/test", deps = [ + "//tensorflow/tensorboard/components/tf_imports:web_component_tester", "//tensorflow/tensorboard/components/vz_sorting", - "@org_npmjs_registry_web_component_tester", ], ) -tensorboard_typescript_genrule( - name = "ts", - srcs = ["bundle.ts"], - typings = [ - "@org_definitelytyped//:mocha.d.ts", - "@org_definitelytyped//:chai.d.ts", - "//tensorflow/tensorboard/components/vz_sorting:bundle.d.ts", - ], -) - -tensorboard_typescript_bundle( - name = "bundle", - out = "bundle.ts", - namespace_srcs = {"VZ.Sorting": ["sortingTests.ts"]}, -) - filegroup( name = "all_files", testonly = 0, diff --git a/tensorflow/tensorboard/components/vz_sorting/test/tests.html b/tensorflow/tensorboard/components/vz_sorting/test/tests.html index d1b4a1db31..c408690603 100644 --- a/tensorflow/tensorboard/components/vz_sorting/test/tests.html +++ b/tensorflow/tensorboard/components/vz_sorting/test/tests.html @@ -18,6 +18,6 @@ limitations under the License. <meta charset="utf-8"> <script src="../../web-component-tester/browser.js"></script> +<link rel="import" href="../vz-sorting.html"> <body> -<script src="../bundle.js"></script> -<script src="bundle.js"></script> +<script src="sortingTests.js"></script> diff --git a/tensorflow/tensorboard/components/vz_sorting/vz-sorting.html b/tensorflow/tensorboard/components/vz_sorting/vz-sorting.html index 9f925951cb..5ff6f31158 100644 --- a/tensorflow/tensorboard/components/vz_sorting/vz-sorting.html +++ b/tensorflow/tensorboard/components/vz_sorting/vz-sorting.html @@ -15,4 +15,4 @@ See the License for the specific language governing permissions and limitations under the License. --> -<script src="bundle.js"></script> +<script src="sorting.js"></script> diff --git a/tensorflow/tensorboard/defs.bzl b/tensorflow/tensorboard/defs.bzl index 827a74b173..b3712a8156 100644 --- a/tensorflow/tensorboard/defs.bzl +++ b/tensorflow/tensorboard/defs.bzl @@ -12,83 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -_DEFAULT_TYPINGS = [ - "@com_microsoft_typescript//:lib.es6.d.ts", -] - -def tensorboard_typescript_genrule(name, srcs, typings=[], **kwargs): - """Filegroup of compiled TypeScript sources. - - This is a very unsophisticated TypeScript rule where the user is responsible - for passing all typings and sources via srcs. It's meant as a stopgap because - TypeScript rules currently don't exist for Bazel. The definition of this rule - will need to evolve as more ts_library rules are migrated. - """ - for src in srcs: - if (src.startswith("/") or - src.endswith(".d.ts") or - not src.endswith(".ts")): - fail("srcs must be typescript sources in same package") - typings_out = [src[:-3] + ".d.ts" for src in srcs] - inputs = _DEFAULT_TYPINGS + typings + srcs - # These inputs are meant to work around a sandbox bug in Bazel. If we list - # @com_microsoft_typescript//:tsc.sh under tools, then its - # data attribute won't be considered when --genrule_strategy=sandboxed. See - # https://github.com/bazelbuild/bazel/issues/1147 and its linked issues. - data = [ - "@org_nodejs", - "@com_microsoft_typescript", - ] - native.genrule( - name = name, - srcs = inputs + data, - outs = [src[:-3] + ".js" for src in srcs] + typings_out, - cmd = "$(location @com_microsoft_typescript//:tsc.sh)" + - " --inlineSourceMap" + - " --inlineSources" + - # Do not follow triple slash references within typings. - " --noResolve" + - " --declaration" + - " --module es6" + - " --outDir $(@D) " + - " ".join(["$(locations %s)" % i for i in inputs]), - tools = ["@com_microsoft_typescript//:tsc.sh"], - **kwargs - ) - native.filegroup( - name = name + "_typings", - srcs = typings_out, - **kwargs - ) - -def tensorboard_karma_web_test_suite(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - -def tensorboard_ts_config(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - -def tensorboard_ts_declaration(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - -def tensorboard_ts_development_sources(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - -def tensorboard_ts_devserver(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - -def tensorboard_ts_library(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass - def tensorboard_webcomponent_library(**kwargs): """Rules referencing this will be deleted from the codebase soon.""" pass - -def tensorboard_wct_test_suite(**kwargs): - """Rules referencing this will be deleted from the codebase soon.""" - pass diff --git a/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/BUILD b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/BUILD index 447dff55a3..f2ea14503a 100644 --- a/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/BUILD +++ b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/BUILD @@ -5,6 +5,11 @@ licenses(["notice"]) # Apache 2.0 java_binary( name = "Vulcanize", srcs = ["Vulcanize.java"], + jvm_flags = [ + "-Xss20m", # JSCompiler needs big stacks for recursive parsing + "-XX:+UseParallelGC", # Best GC when app isn't latency sensitive + "-Djava.util.logging.SimpleFormatter.format='%1$$tY-%1$$tm-%1$$td %1$$tH:%1$$tM:%1$$tS.%1$$tL %4$$-6s %5$$s%6$$s%n'", # Less log spam + ], visibility = ["//visibility:public"], deps = [ "@com_google_guava", @@ -29,6 +34,21 @@ java_binary( ], ) +# These JS files are always taken into consideration by the Closure Compiler +# when vulcanizing, per vulcanize.bzl. +filegroup( + name = "jslibs", + srcs = [ + # Ordering probably matters + "@com_google_javascript_closure_compiler_externs", + "@com_google_javascript_closure_compiler_externs_polymer", + "externs.js", + "@com_google_javascript_closure_library//:closure/goog/base.js", + "@com_google_javascript_closure_library//:closure/goog/deps.js", + ], + visibility = ["//visibility:public"], +) + filegroup( name = "all_files", srcs = glob(["**"]), diff --git a/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/Vulcanize.java b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/Vulcanize.java index e572415856..8ef0f31d1e 100644 --- a/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/Vulcanize.java +++ b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/Vulcanize.java @@ -15,23 +15,33 @@ package org.tensorflow.tensorboard.vulcanize; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verifyNotNull; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.CharMatcher; import com.google.common.base.Joiner; +import com.google.common.base.Optional; +import com.google.common.base.Splitter; +import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.javascript.jscomp.BasicErrorManager; +import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import com.google.javascript.jscomp.CheckLevel; +import com.google.javascript.jscomp.CompilationLevel; import com.google.javascript.jscomp.Compiler; import com.google.javascript.jscomp.CompilerOptions; -import com.google.javascript.jscomp.CompilerOptions.LanguageMode; -import com.google.javascript.jscomp.CompilerOptions.Reach; +import com.google.javascript.jscomp.DiagnosticGroup; +import com.google.javascript.jscomp.DiagnosticGroups; +import com.google.javascript.jscomp.DiagnosticType; import com.google.javascript.jscomp.JSError; import com.google.javascript.jscomp.PropertyRenamingPolicy; +import com.google.javascript.jscomp.Result; import com.google.javascript.jscomp.SourceFile; -import com.google.javascript.jscomp.VariableRenamingPolicy; +import com.google.javascript.jscomp.WarningsGuard; import com.google.protobuf.TextFormat; import io.bazel.rules.closure.Webpath; import io.bazel.rules.closure.webfiles.BuildInfo.Webfiles; @@ -44,12 +54,17 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.jsoup.Jsoup; +import org.jsoup.nodes.Attribute; import org.jsoup.nodes.Comment; import org.jsoup.nodes.DataNode; import org.jsoup.nodes.Document; @@ -63,21 +78,45 @@ import org.jsoup.parser.Tag; /** Simple one-off solution for TensorBoard vulcanization. */ public final class Vulcanize { + private static final Pattern IGNORE_PATHS_PATTERN = + Pattern.compile("/(?:polymer|marked-element)/.*"); + + private static final ImmutableSet<String> EXTRA_JSDOC_TAGS = + ImmutableSet.of("attribute", "hero", "group", "required"); + + private static final Pattern WEBPATH_PATTERN = Pattern.compile("//~~WEBPATH~~([^\n]+)"); + private static final Parser parser = Parser.htmlParser(); private static final Map<Webpath, Path> webfiles = new HashMap<>(); private static final Set<Webpath> alreadyInlined = new HashSet<>(); private static final Set<String> legalese = new HashSet<>(); private static final List<String> licenses = new ArrayList<>(); private static final List<Webpath> stack = new ArrayList<>(); + private static final List<SourceFile> sourcesFromJsLibraries = new ArrayList<>(); + private static final Map<Webpath, String> sourcesFromScriptTags = new LinkedHashMap<>(); + private static final Map<Webpath, Node> sourceTags = new LinkedHashMap<>(); + private static final Multimap<Webpath, String> suppressions = HashMultimap.create(); + private static CompilationLevel compilationLevel; private static Webpath outputPath; + private static Node firstCompiledScript; private static Node licenseComment; - private static boolean nominify; + private static int insideDemoSnippet; + private static boolean testOnly; public static void main(String[] args) throws IOException { - Webpath inputPath = Webpath.get(args[0]); - outputPath = Webpath.get(args[1]); - Path output = Paths.get(args[2]); - for (int i = 3; i < args.length; i++) { + compilationLevel = CompilationLevel.fromString(args[0]); + testOnly = args[1].equals("true"); + Webpath inputPath = Webpath.get(args[2]); + outputPath = Webpath.get(args[3]); + Path output = Paths.get(args[4]); + for (int i = 5; i < args.length; i++) { + if (args[i].endsWith(".js")) { + sourcesFromJsLibraries.add(SourceFile.fromFile(args[i])); + continue; + } + if (!args[i].endsWith(".pbtxt")) { + continue; + } Webfiles manifest = loadWebfilesPbtxt(Paths.get(args[i])); for (WebfilesSource src : manifest.getSrcList()) { webfiles.put(Webpath.get(src.getWebpath()), Paths.get(src.getPath())); @@ -86,6 +125,7 @@ public final class Vulcanize { stack.add(inputPath); Document document = parse(Files.readAllBytes(webfiles.get(inputPath))); transform(document); + compile(); if (licenseComment != null) { licenseComment.attr("comment", String.format("\n%s\n", Joiner.on("\n\n").join(licenses))); } @@ -134,72 +174,30 @@ public final class Vulcanize { } private static Node enterNode(Node node) throws IOException { - Node newNode = node; + if (node.nodeName().equals("demo-snippet")) { + insideDemoSnippet++; + } + if (insideDemoSnippet > 0) { + return node; + } if (node instanceof Element) { if (node.nodeName().equals("link") && node.attr("rel").equals("import")) { // Inline HTML. - Webpath href = me().lookup(Webpath.get(node.attr("href"))); - if (alreadyInlined.add(href)) { - newNode = - parse(Files.readAllBytes(checkNotNull(webfiles.get(href), "%s in %s", href, me()))); - stack.add(href); - node.replaceWith(newNode); - } else { - newNode = new TextNode("", node.baseUri()); - node.replaceWith(newNode); - } - } else if (node.nodeName().equals("script")) { - nominify = node.hasAttr("nominify"); - node.removeAttr("nominify"); - Webpath src; - String script; - if (node.attr("src").isEmpty()) { - // Minify JavaScript. - StringBuilder sb = new StringBuilder(); - for (Node child : node.childNodes()) { - if (child instanceof DataNode) { - sb.append(((DataNode) child).getWholeData()); - } - } - src = me(); - script = sb.toString(); - } else { - // Inline JavaScript. - src = me().lookup(Webpath.get(node.attr("src"))); - Path other = webfiles.get(src); - if (other != null) { - script = new String(Files.readAllBytes(other), UTF_8); - node.removeAttr("src"); - } else { - src = me(); - script = ""; - } - } - script = minify(src, script); - newNode = - new Element(Tag.valueOf("script"), node.baseUri(), node.attributes()) - .appendChild(new DataNode(script, node.baseUri())); - node.replaceWith(newNode); + node = visitHtmlImport(node); + } else if (node.nodeName().equals("script") + && !shouldIgnoreUri(node.attr("src")) + && !node.hasAttr("jscomp-ignore")) { + node = visitScript(node); } else if (node.nodeName().equals("link") && node.attr("rel").equals("stylesheet") - && !node.attr("href").isEmpty()) { - // Inline CSS. - Webpath href = me().lookup(Webpath.get(node.attr("href"))); - Path other = webfiles.get(href); - if (other != null) { - newNode = - new Element(Tag.valueOf("style"), node.baseUri(), node.attributes()) - .appendChild( - new DataNode(new String(Files.readAllBytes(other), UTF_8), node.baseUri())); - newNode.removeAttr("rel"); - newNode.removeAttr("href"); - node.replaceWith(newNode); - } + && !node.attr("href").isEmpty() + && !shouldIgnoreUri(node.attr("href"))) { + node = visitStylesheet(node); } - rootifyAttribute(newNode, "href"); - rootifyAttribute(newNode, "src"); - rootifyAttribute(newNode, "action"); - rootifyAttribute(newNode, "assetpath"); + rootifyAttribute(node, "href"); + rootifyAttribute(node, "src"); + rootifyAttribute(node, "action"); + rootifyAttribute(node, "assetpath"); } else if (node instanceof Comment) { String text = ((Comment) node).getData(); if (text.contains("@license")) { @@ -207,53 +205,230 @@ public final class Vulcanize { if (licenseComment == null) { licenseComment = node; } else { - newNode = new TextNode("", node.baseUri()); - node.replaceWith(newNode); + node = replaceNode(node, new TextNode("", node.baseUri())); } } else { - newNode = new TextNode("", node.baseUri()); - node.replaceWith(newNode); + node = replaceNode(node, new TextNode("", node.baseUri())); } } + return node; + } + + private static Node leaveNode(Node node) { + if (node instanceof Document) { + stack.remove(stack.size() - 1); + } else if (node.nodeName().equals("demo-snippet")) { + insideDemoSnippet--; + } + return node; + } + + private static Node visitHtmlImport(Node node) throws IOException { + Webpath href = me().lookup(Webpath.get(node.attr("href"))); + if (alreadyInlined.add(href)) { + stack.add(href); + Document subdocument = parse(Files.readAllBytes(getWebfile(href))); + for (Attribute attr : node.attributes()) { + subdocument.attr(attr.getKey(), attr.getValue()); + } + return replaceNode(node, subdocument); + } else { + return replaceNode(node, new TextNode("", node.baseUri())); + } + } + + private static Node visitScript(Node node) throws IOException { + Webpath path; + String script; + if (node.attr("src").isEmpty()) { + path = makeSyntheticName(".js"); + script = getInlineScriptFromNode(node); + } else { + path = me().lookup(Webpath.get(node.attr("src"))); + script = new String(Files.readAllBytes(getWebfile(path)), UTF_8); + } + if (node.attr("src").endsWith(".min.js") + || getAttrTransitive(node, "jscomp-nocompile").isPresent()) { + Node newScript = + new Element(Tag.valueOf("script"), node.baseUri(), node.attributes()) + .appendChild(new DataNode(script, node.baseUri())) + .removeAttr("src") + .removeAttr("jscomp-nocompile"); + if (firstCompiledScript != null) { + firstCompiledScript.before(newScript); + return replaceNode(node, new TextNode("", node.baseUri())); + } else { + return replaceNode(node, newScript); + } + } else { + if (firstCompiledScript == null) { + firstCompiledScript = node; + } + sourcesFromScriptTags.put(path, script); + sourceTags.put(path, node); + Optional<String> suppress = getAttrTransitive(node, "jscomp-suppress"); + if (suppress.isPresent()) { + if (suppress.get().isEmpty()) { + suppressions.put(path, "*"); + } else { + suppressions.putAll(path, Splitter.on(' ').split(suppress.get())); + } + } + return node; + } + } + + private static Node visitStylesheet(Node node) throws IOException { + Webpath href = me().lookup(Webpath.get(node.attr("href"))); + return replaceNode( + node, + new Element(Tag.valueOf("style"), node.baseUri(), node.attributes()) + .appendChild( + new DataNode( + new String(Files.readAllBytes(getWebfile(href)), UTF_8), node.baseUri())) + .removeAttr("rel") + .removeAttr("href")); + } + + private static Optional<String> getAttrTransitive(Node node, String attr) { + while (node != null) { + if (node.hasAttr(attr)) { + return Optional.of(node.attr(attr)); + } + node = node.parent(); + } + return Optional.absent(); + } + + private static Node replaceNode(Node oldNode, Node newNode) { + oldNode.replaceWith(newNode); return newNode; } - private static String minify(Webpath src, String script) { - if (nominify) { - return script; + private static Path getWebfile(Webpath path) { + return verifyNotNull(webfiles.get(path), "Bad ref: %s -> %s", me(), path); + } + + private static void compile() { + if (sourcesFromScriptTags.isEmpty()) { + return; } - Compiler compiler = new Compiler(new JsPrintlessErrorManager()); + CompilerOptions options = new CompilerOptions(); - options.skipAllCompilerPasses(); // too lazy to get externs - options.setLanguageIn(LanguageMode.ECMASCRIPT_2016); - options.setLanguageOut(LanguageMode.ECMASCRIPT5); + compilationLevel.setOptionsForCompilationLevel(options); + + // Nice options. + options.setColorizeErrorOutput(true); options.setContinueAfterErrors(true); - options.setManageClosureDependencies(false); - options.setRenamingPolicy(VariableRenamingPolicy.LOCAL, PropertyRenamingPolicy.OFF); - options.setShadowVariables(true); - options.setInlineVariables(Reach.LOCAL_ONLY); - options.setFlowSensitiveInlineVariables(true); - options.setInlineFunctions(Reach.LOCAL_ONLY); - options.setAssumeClosuresOnlyCaptureReferences(false); + options.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT_2016); + options.setLanguageOut(CompilerOptions.LanguageMode.ECMASCRIPT5); + options.setGenerateExports(true); + options.setStrictModeInput(false); + options.setExtraAnnotationNames(EXTRA_JSDOC_TAGS); + + // So we can chop JS binary back up into the original script tags. + options.setPrintInputDelimiter(true); + options.setInputDelimiter("//~~WEBPATH~~%name%"); + + // Optimizations that are too advanced for us right now. + options.setPropertyRenaming(PropertyRenamingPolicy.OFF); options.setCheckGlobalThisLevel(CheckLevel.OFF); - options.setFoldConstants(true); - options.setCoalesceVariableNames(true); - options.setDeadAssignmentElimination(true); - options.setCollapseVariableDeclarations(true); - options.setConvertToDottedProperties(true); - options.setLabelRenaming(true); - options.setRemoveDeadCode(true); - options.setOptimizeArgumentsArray(true); - options.setRemoveUnusedVariables(Reach.LOCAL_ONLY); - options.setCollapseObjectLiterals(true); - options.setProtectHiddenSideEffects(true); - //options.setPrettyPrint(true); + options.setRemoveUnusedPrototypeProperties(false); + options.setRemoveUnusedPrototypePropertiesInExterns(false); + options.setRemoveUnusedClassProperties(false); + + // Closure pass. + options.setClosurePass(true); + options.setManageClosureDependencies(true); + options.getDependencyOptions().setDependencyPruning(true); + options.getDependencyOptions().setDependencySorting(false); + options.getDependencyOptions().setMoocherDropping(false); + + // Polymer pass. + options.setPolymerVersion(1); + + // Debug flags. + if (testOnly) { + options.setPrettyPrint(true); + options.setGeneratePseudoNames(true); + options.setExportTestFunctions(true); + } + + // Don't print warnings from <script jscomp-suppress="group1 group2" ...> tags. + ImmutableMultimap<DiagnosticType, String> diagnosticGroups = initDiagnosticGroups(); + options.addWarningsGuard( + new WarningsGuard() { + @Override + public CheckLevel level(JSError error) { + if (IGNORE_PATHS_PATTERN.matcher(error.sourceName).matches()) { + return CheckLevel.OFF; + } + if (error.sourceName.startsWith("/tf-graph") + && error.getType().key.equals("JSC_VAR_MULTIPLY_DECLARED_ERROR")) { + return CheckLevel.OFF; // TODO(jart): Remove when tf-graph is ES6 modules. + } + if (error.getType().key.equals("JSC_POLYMER_UNQUALIFIED_BEHAVIOR") + || error.getType().key.equals("JSC_POLYMER_UNANNOTATED_BEHAVIOR")) { + return CheckLevel.OFF; // TODO(jart): What is wrong with this thing? + } + Collection<String> codes = suppressions.get(Webpath.get(error.sourceName)); + if (codes.contains("*") || codes.contains(error.getType().key)) { + return CheckLevel.OFF; + } + for (String group : diagnosticGroups.get(error.getType())) { + if (codes.contains(group)) { + return CheckLevel.OFF; + } + } + return null; + } + }); + + // Get reverse topological script tags and their web paths, which js_library stuff first. + List<SourceFile> sauce = Lists.newArrayList(sourcesFromJsLibraries); + for (Map.Entry<Webpath, String> source : sourcesFromScriptTags.entrySet()) { + sauce.add(SourceFile.fromCode(source.getKey().toString(), source.getValue())); + } + + // Compile everything into a single script. + Compiler compiler = new Compiler(); compiler.disableThreads(); - compiler.compile( - ImmutableList.<SourceFile>of(), - ImmutableList.of(SourceFile.fromCode(src.toString(), script)), - options); - return compiler.toSource(); + Result result = compiler.compile(ImmutableList.<SourceFile>of(), sauce, options); + if (!result.success) { + System.exit(1); + } + String jsBlob = compiler.toSource(); + + // Split apart the JS blob and put it back in the original <script> locations. + Matcher matcher = WEBPATH_PATTERN.matcher(jsBlob); + Webpath path = null; + String pureJsDeps = ""; + int start = -1; + while (matcher.find()) { + if (!sourceTags.containsKey(Webpath.get(matcher.group(1)))) { + continue; // Skip over js_library dependencies, which must group at beginning of args. + } + if (path != null) { + swapScript(path, pureJsDeps + jsBlob.substring(start, matcher.start())); + pureJsDeps = ""; + } else { + pureJsDeps = jsBlob.substring(0, matcher.start()); + } + path = Webpath.get(matcher.group(1)); + start = matcher.start(); + } + swapScript(path, pureJsDeps + jsBlob.substring(start)); + if (!sourceTags.isEmpty()) { + throw new RuntimeException("Couldn't pull out: " + ImmutableSet.copyOf(sourceTags.keySet())); + } + } + + private static void swapScript(Webpath path, String script) { + Node tag = sourceTags.get(path); + tag.replaceWith( + new Element(Tag.valueOf("script"), tag.baseUri()) + .appendChild(new DataNode(script, tag.baseUri()))); + sourceTags.remove(path); } private static void handleLicense(String text) { @@ -262,17 +437,20 @@ public final class Vulcanize { } } - private static Node leaveNode(Node node) { - if (node instanceof Document) { - stack.remove(stack.size() - 1); - } - return node; - } - private static Webpath me() { return Iterables.getLast(stack); } + private static Webpath makeSyntheticName(String extension) { + String me = me().toString(); + Webpath result = Webpath.get(me + extension); + int n = 2; + while (sourcesFromScriptTags.containsKey(result)) { + result = Webpath.get(String.format("%s-%d%s", me, n++, extension)); + } + return result; + } + private static void rootifyAttribute(Node node, String attribute) { String value = node.attr(attribute); if (value.isEmpty()) { @@ -284,6 +462,16 @@ public final class Vulcanize { } } + private static String getInlineScriptFromNode(Node node) { + StringBuilder sb = new StringBuilder(); + for (Node child : node.childNodes()) { + if (child instanceof DataNode) { + sb.append(((DataNode) child).getWholeData()); + } + } + return sb.toString(); + } + private static Document parse(byte[] bytes) { return parse(new ByteArrayInputStream(bytes)); } @@ -301,17 +489,31 @@ public final class Vulcanize { } private static Webfiles loadWebfilesPbtxt(Path path) throws IOException { + verify(path.toString().endsWith(".pbtxt"), "Not a pbtxt file: %s", path); Webfiles.Builder build = Webfiles.newBuilder(); TextFormat.getParser().merge(new String(Files.readAllBytes(path), UTF_8), build); return build.build(); } - private static final class JsPrintlessErrorManager extends BasicErrorManager { - - @Override - public void println(CheckLevel level, JSError error) {} + private static boolean shouldIgnoreUri(String uri) { + return uri.startsWith("#") + || uri.endsWith("/") + || uri.contains("//") + || uri.startsWith("data:") + || uri.startsWith("javascript:") + // The following are intended to filter out URLs with Polymer variables. + || (uri.contains("[[") && uri.contains("]]")) + || (uri.contains("{{") && uri.contains("}}")); + } - @Override - public void printSummary() {} + private static ImmutableMultimap<DiagnosticType, String> initDiagnosticGroups() { + DiagnosticGroups groups = new DiagnosticGroups(); + Multimap<DiagnosticType, String> builder = HashMultimap.create(); + for (Map.Entry<String, DiagnosticGroup> group : groups.getRegisteredGroups().entrySet()) { + for (DiagnosticType type : group.getValue().getTypes()) { + builder.put(type, group.getKey()); + } + } + return ImmutableMultimap.copyOf(builder); } } diff --git a/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/externs.js b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/externs.js new file mode 100644 index 0000000000..2e56562c1c --- /dev/null +++ b/tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize/externs.js @@ -0,0 +1,48 @@ +// Copyright 2017 The TensorFlow Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Miscellaneous JSCompiler externs needed for TensorBoard. + * @externs + */ + +/** @type {!Object} */ var _; +/** @type {!Object} */ var d3; +/** @type {!Object} */ var dagre; +/** @type {!Object} */ var weblas; +/** @type {!Object} */ var graphlib; +/** @type {!Object} */ var Plottable; +/** @type {!Object} */ var GroupEffect; +/** @type {!Function|undefined} */ var ga; +/** @type {!Function|undefined} */ var KeyframeEffect; + +/** + * Some weird webcomponents-lite.js thing. + * @type {!Function|undefined} + */ +var wrap; + +/** + * Some weird webcomponents-lite.js thing. + * @type {!Function|undefined} + */ +window.wrap; + +var HTMLImports; + +/** + * @param {function()} callback + * @param {!HTMLDocument=} opt_doc + */ +HTMLImports.whenReady = function(callback, opt_doc) {}; diff --git a/tensorflow/tensorboard/scripts/BUILD b/tensorflow/tensorboard/scripts/BUILD index fa0d5709ee..3960977465 100644 --- a/tensorflow/tensorboard/scripts/BUILD +++ b/tensorflow/tensorboard/scripts/BUILD @@ -18,6 +18,13 @@ py_binary( ], ) +py_binary( + name = "execrooter", + srcs = ["execrooter.py"], + srcs_version = "PY2AND3", + visibility = ["//visibility:public"], +) + filegroup( name = "all_files", srcs = glob(["*"]), diff --git a/tensorflow/tensorboard/scripts/execrooter.py b/tensorflow/tensorboard/scripts/execrooter.py new file mode 100644 index 0000000000..65569b9151 --- /dev/null +++ b/tensorflow/tensorboard/scripts/execrooter.py @@ -0,0 +1,85 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Utility for running programs in a symlinked execroot.""" + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + +import json +import os +import shutil +import subprocess +import sys +import tempfile + + +def run(inputs, program, outputs): + """Creates temp symlink tree, runs program, and copies back outputs. + + Args: + inputs: List of fake paths to real paths, which are used for symlink tree. + program: List containing real path of program and its arguments. The + execroot directory will be appended as the last argument. + outputs: List of fake outputted paths to copy back to real paths. + Returns: + 0 if succeeded or nonzero if failed. + """ + root = tempfile.mkdtemp() + try: + cwd = os.getcwd() + for fake, real in inputs: + parent = os.path.join(root, os.path.dirname(fake)) + if not os.path.exists(parent): + os.makedirs(parent) + os.symlink(os.path.join(cwd, real), os.path.join(root, fake)) + if subprocess.call(program + [root]) != 0: + return 1 + for fake, real in outputs: + shutil.copyfile(os.path.join(root, fake), real) + return 0 + finally: + shutil.rmtree(root) + + +def main(args): + """Invokes run function using a JSON file config. + + Args: + args: CLI args, which can be a JSON file containing an object whose + attributes are the parameters to the run function. If multiple JSON + files are passed, their contents are concatenated. + Returns: + 0 if succeeded or nonzero if failed. + Raises: + Exception: If input data is missing. + """ + if not args: + raise Exception('Please specify at least one JSON config path') + inputs = [] + program = [] + outputs = [] + for arg in args: + with open(arg) as fd: + config = json.load(fd) + inputs.extend(config.get('inputs', [])) + program.extend(config.get('program', [])) + outputs.extend(config.get('outputs', [])) + if not program: + raise Exception('Please specify a program') + return run(inputs, program, outputs) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/tensorflow/tensorboard/vulcanize.bzl b/tensorflow/tensorboard/vulcanize.bzl index 4c1b6eb2d0..e444bbe9df 100644 --- a/tensorflow/tensorboard/vulcanize.bzl +++ b/tensorflow/tensorboard/vulcanize.bzl @@ -13,27 +13,36 @@ # limitations under the License. load("@io_bazel_rules_closure//closure/private:defs.bzl", "unfurl", "long_path") +load("//tensorflow/tensorboard:web.bzl", "web_aspect") def _tensorboard_html_binary(ctx): deps = unfurl(ctx.attr.deps, provider="webfiles") manifests = set() files = set() + jslibs = set(ctx.files._jslibs) webpaths = set() for dep in deps: manifests += dep.webfiles.manifests webpaths += dep.webfiles.webpaths files += dep.data_runfiles.files + if hasattr(dep.webfiles, "jslibs"): + jslibs += dep.webfiles.jslibs + if hasattr(dep, "closure_js_library"): + jslibs += getattr(dep.closure_js_library, "srcs", []) webpaths += [ctx.attr.output_path] # vulcanize ctx.action( - inputs=list(manifests + files), + inputs=list(manifests | files | jslibs), outputs=[ctx.outputs.html], executable=ctx.executable._Vulcanize, - arguments=([ctx.attr.input_path, + arguments=([ctx.attr.compilation_level, + "true" if ctx.attr.testonly else "false", + ctx.attr.input_path, ctx.attr.output_path, ctx.outputs.html.path] + - [m.path for m in manifests]), + [f.path for f in jslibs] + + [f.path for f in manifests]), progress_message="Vulcanizing %s" % ctx.attr.input_path) # webfiles manifest @@ -88,11 +97,16 @@ tensorboard_html_binary = rule( implementation=_tensorboard_html_binary, executable=True, attrs={ + "compilation_level": attr.string(default="ADVANCED"), "input_path": attr.string(mandatory=True), "output_path": attr.string(mandatory=True), "data": attr.label_list(cfg="data", allow_files=True), - "deps": attr.label_list(providers=["webfiles"], mandatory=True), + "deps": attr.label_list( + aspects=[web_aspect], providers=["webfiles"], mandatory=True), "external_assets": attr.string_dict(default={"/_/runfiles": "."}), + "_jslibs": attr.label( + default=Label("//tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize:jslibs"), + allow_files=True), "_Vulcanize": attr.label( default=Label("//tensorflow/tensorboard/java/org/tensorflow/tensorboard/vulcanize:Vulcanize"), executable=True, diff --git a/tensorflow/tensorboard/web.bzl b/tensorflow/tensorboard/web.bzl new file mode 100644 index 0000000000..0b2ed66a57 --- /dev/null +++ b/tensorflow/tensorboard/web.bzl @@ -0,0 +1,398 @@ +# Copyright 2017 The TensorFlow Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Same as web_library but supports TypeScript.""" + +load("@io_bazel_rules_closure//closure/private:defs.bzl", + "collect_runfiles", + "convert_path_to_es6_module_name", + "create_argfile", + "difference", + "long_path", + "unfurl") + +def _ts_web_library(ctx): + if not ctx.attr.srcs: + if ctx.attr.deps: + fail("deps can not be set when srcs is not") + if not ctx.attr.exports: + fail("exports must be set if srcs is not") + if ctx.attr.path: + if not ctx.attr.path.startswith("/"): + fail("webpath must start with /") + if ctx.attr.path != "/" and ctx.attr.path.endswith("/"): + fail("webpath must not end with / unless it is /") + if "//" in ctx.attr.path: + fail("webpath must not have //") + elif ctx.attr.srcs: + fail("path must be set when srcs is set") + if "*" in ctx.attr.suppress and len(ctx.attr.suppress) != 1: + fail("when \"*\" is suppressed no other items should be present") + + # process what came before + deps = unfurl(ctx.attr.deps, provider="webfiles") + webpaths = depset() + manifests = depset(order="topological") + jslibs = depset(order="postorder") + ts_typings = depset(ctx.files._es6dts) + ts_typings_paths = depset() + ts_typings_execroots = depset() + for dep in deps: + webpaths += dep.webfiles.webpaths + manifests += dep.webfiles.manifests + if hasattr(dep.webfiles, "ts_typings"): + ts_typings += dep.webfiles.ts_typings + if hasattr(dep.webfiles, "ts_typings_paths"): + ts_typings_paths += dep.webfiles.ts_typings_paths + if hasattr(dep.webfiles, "ts_typings_execroots"): + ts_typings_execroots += dep.webfiles.ts_typings_execroots + if hasattr(dep.webfiles, "jslibs"): + jslibs += dep.webfiles.jslibs + if hasattr(dep, "closure_js_library"): + jslibs += getattr(dep.closure_js_library, "srcs", []) + + # process what comes now + manifest_srcs = [] + new_webpaths = [] + ts_inputs = depset() + ts_outputs = [] + ts_files = ["lib.es6.d.ts"] + list(ts_typings_paths) + new_typings = [] + new_typings_paths = [] + new_typings_execroot = struct(inputs=[]) + execroot = struct( + inputs=[("lib.es6.d.ts", ctx.files._es6dts[0].path)], + outputs=[], + program=[ctx.executable._tsc.path, "-p"]) + web_srcs = [] + path = ctx.attr.path + strip = _get_strip(ctx) + for src in ctx.files.srcs: + suffix = _get_path_relative_to_package(src) + if strip: + if not suffix.startswith(strip): + fail("Relative src path not start with '%s': %s" % (strip, suffix)) + suffix = suffix[len(strip):] + webpath = "%s/%s" % ("" if path == "/" else path, suffix) + _add_webpath(ctx, src, webpath, webpaths, new_webpaths, manifest_srcs) + if suffix.endswith(".d.ts"): + web_srcs.append(src) + entry = (webpath[1:], src.path) + new_typings.append(src) + new_typings_paths.append(entry[0]) + new_typings_execroot.inputs.append(entry) + ts_inputs += [src] + ts_files.append(entry[0]) + execroot.inputs.append(entry) + elif suffix.endswith(".ts"): + noext = suffix[:-3] + js = ctx.new_file(ctx.bin_dir, "%s.js" % noext) + dts = ctx.new_file(ctx.bin_dir, "%s.d.ts" % noext) + webpath_js = webpath[:-3] + ".js" + webpath_dts = webpath[:-3] + ".d.ts" + _add_webpath(ctx, js, webpath_js, webpaths, new_webpaths, manifest_srcs) + _add_webpath(ctx, dts, webpath_dts, webpaths, new_webpaths, manifest_srcs) + ts_inputs += [src] + ts_outputs.append(js) + ts_outputs.append(dts) + web_srcs.append(dts) + web_srcs.append(js) + ts_files.append(webpath[1:]) + execroot.inputs.append((webpath[1:], src.path)) + execroot.outputs.append((webpath_js[1:], js.path)) + execroot.outputs.append((webpath_dts[1:], dts.path)) + new_typings.append(dts) + new_typings_paths.append(webpath_dts[1:]) + new_typings_execroot.inputs.append((webpath_dts[1:], dts.path)) + else: + web_srcs.append(src) + + # create webfiles manifest + manifest = ctx.new_file(ctx.configuration.bin_dir, + "%s.pbtxt" % ctx.label.name) + ctx.file_action( + output=manifest, + content=struct( + label=str(ctx.label), + src=manifest_srcs).to_proto()) + manifests += [manifest] + webpaths += new_webpaths + + # compile typescript + workspace = "" + if ctx.label.workspace_root: + workspace = "/" + ctx.label.workspace_root + if execroot.outputs: + ts_config = ctx.new_file(ctx.bin_dir, "%s-tsc.json" % ctx.label.name) + execroot.inputs.append(("tsconfig.json", ts_config.path)) + ctx.file_action( + output=ts_config, + content=struct( + compilerOptions=struct( + baseUrl=".", + declaration=True, + inlineSourceMap=True, + inlineSources=True, + module="es6", + moduleResolution="node", + noResolve=True, + target="es5", + ), + files=list(ts_files), + ).to_json()) + er_config = ctx.new_file(ctx.bin_dir, + "%s-tsc-execroot.json" % ctx.label.name) + ctx.file_action(output=er_config, content=execroot.to_json()) + ts_inputs += collect_runfiles([ctx.attr._tsc]) + ts_inputs += ctx.files._tsc + ts_inputs += ts_typings + ts_inputs += ts_typings_execroots + ts_inputs += [ts_config, er_config] + ctx.action( + inputs=list(ts_inputs), + outputs=ts_outputs, + executable=ctx.executable._execrooter, + arguments=[er_config.path] + [f.path for f in ts_typings_execroots], + progress_message="Compiling %d TypeScript files" % len(ts_files)) + + # perform strict dependency checking + inputs = [manifest] + direct_manifests = depset([manifest]) + args = ["WebfilesValidator", + "--dummy", ctx.outputs.dummy.path, + "--target", manifest.path] + for category in ctx.attr.suppress: + args.append("--suppress") + args.append(category) + inputs.extend(web_srcs) + for dep in deps: + inputs.append(dep.webfiles.dummy) + for f in dep.files: + inputs.append(f) + direct_manifests += [dep.webfiles.manifest] + inputs.append(dep.webfiles.manifest) + args.append("--direct_dep") + args.append(dep.webfiles.manifest.path) + for man in difference(manifests, direct_manifests): + inputs.append(man) + args.append("--transitive_dep") + args.append(man.path) + argfile = create_argfile(ctx, args) + inputs.append(argfile) + ctx.action( + inputs=inputs, + outputs=[ctx.outputs.dummy], + executable=ctx.executable._ClosureWorker, + arguments=["@@" + argfile.path], + mnemonic="Closure", + execution_requirements={"supports-workers": "1"}, + progress_message="Checking webfiles in %s" % ctx.label) + web_srcs.append(ctx.outputs.dummy) + + # define development web server that only applies to this transitive closure + params = struct( + label=str(ctx.label), + bind="[::]:6006", + manifest=[long_path(ctx, man) for man in manifests], + external_asset=[struct(webpath=k, path=v) + for k, v in ctx.attr.external_assets.items()]) + params_file = ctx.new_file(ctx.bin_dir, "%s_params.pbtxt" % ctx.label.name) + ctx.file_action(output=params_file, content=params.to_proto()) + ctx.file_action( + executable=True, + output=ctx.outputs.executable, + content="#!/bin/sh\nexec %s %s" % ( + ctx.executable._WebfilesServer.short_path, + long_path(ctx, params_file))) + + if new_typings: + er_config = ctx.new_file(ctx.bin_dir, + "%s-typings-execroot.json" % ctx.label.name) + ctx.file_action(output=er_config, content=new_typings_execroot.to_json()) + ts_typings += new_typings + ts_typings_paths += new_typings_paths + ts_typings_execroots += [er_config] + else: + ts_typings = depset() + ts_typings_paths = depset() + ts_typings_execroots = depset() + + # export data to parent rules + return struct( + files=depset(web_srcs), + exports=unfurl(ctx.attr.exports), + webfiles=struct( + manifest=manifest, + manifests=manifests, + webpaths=webpaths, + dummy=ctx.outputs.dummy, + jslibs=jslibs, + ts_typings=ts_typings, + ts_typings_paths=ts_typings_paths, + ts_typings_execroots=ts_typings_execroots), + runfiles=ctx.runfiles( + files=ctx.files.srcs + ctx.files.data + ts_outputs + [ + manifest, + params_file, + ctx.outputs.executable, + ctx.outputs.dummy], + transitive_files=(collect_runfiles([ctx.attr._WebfilesServer]) | + collect_runfiles(deps) | + collect_runfiles(ctx.attr.data)))) + +def _web_aspect_impl(target, ctx): + if ctx.rule.kind in ("js_library", "pinto_library"): + return _web_aspect_js_library(target, ctx, [], depset()) + if hasattr(target, "js"): + return _web_aspect_js_library( + target, + ctx, + target.files, + target.js.full_tc(True)) + return struct() + +def _web_aspect_js_library(target, ctx, extra_srcs, extra_transitive): + deps = unfurl((ctx.rule.attr.deps + + getattr(ctx.rule.attr, 'sticky_deps', [])), + provider="webfiles") + # process what came before + webpaths = depset() + manifests = depset(order="topological") + jslibs = depset(order="postorder") + for dep in deps: + webpaths += dep.webfiles.webpaths + manifests += dep.webfiles.manifests + if hasattr(dep.webfiles, "jslibs"): + jslibs += dep.webfiles.jslibs + # process what comes now + srcs = ctx.rule.files.srcs + extra_srcs + jslibs += [src for src in srcs if src.path.endswith(".js")] + manifest_srcs = [] + new_webpaths = [] + web_srcs = [] + for src in srcs: + webpath = "/" + long_path(ctx, src) + _add_webpath(ctx, src, webpath, webpaths, new_webpaths, manifest_srcs) + web_srcs.append(src) + # create webfiles manifest + manifest = ctx.new_file(ctx.configuration.bin_dir, + "%s-webfiles.pbtxt" % ctx.label.name) + ctx.file_action( + output=manifest, + content=struct( + label=str(ctx.label), + src=manifest_srcs).to_proto()) + manifests += [manifest] + webpaths += new_webpaths + return struct( + exports=[] if srcs else deps, + webfiles=struct( + manifest=manifest, + manifests=manifests, + webpaths=webpaths, + dummy=manifest, + jslibs=jslibs), + closure_legacy_js_runfiles=(depset(srcs + ctx.rule.files.data) | + extra_transitive | + collect_runfiles(deps) | + collect_runfiles(ctx.rule.files.data))) + +def _add_webpath(ctx, src, webpath, webpaths, new_webpaths, manifest_srcs): + if webpath in new_webpaths: + _fail(ctx, "multiple srcs within %s define the webpath %s " % ( + ctx.label, webpath)) + if webpath in webpaths: + _fail(ctx, "webpath %s was defined by %s when already defined by deps" % ( + webpath, ctx.label)) + new_webpaths.append(webpath) + manifest_srcs.append(struct( + path=src.path, + longpath=long_path(ctx, src), + webpath=webpath)) + +def _fail(ctx, message): + if ctx.attr.suppress == ["*"]: + print(message) + else: + fail(message) + +def _get_path_relative_to_package(artifact): + """Returns file path relative to the package that declared it.""" + path = artifact.path + for prefix in (artifact.root.path, + artifact.owner.workspace_root if artifact.owner else '', + artifact.owner.package if artifact.owner else ''): + if prefix: + prefix = prefix + "/" + if not path.startswith(prefix): + fail("Path %s doesn't start with %s" % (path, prefix)) + path = path[len(prefix):] + return path + +def _get_strip(ctx): + strip = ctx.attr.strip_prefix + if strip: + if strip.startswith("/"): + _fail(ctx, "strip_prefix should not end with /") + strip = strip[1:] + if strip.endswith("/"): + _fail(ctx, "strip_prefix should not end with /") + else: + strip += "/" + return strip + +web_aspect = aspect( + implementation=_web_aspect_impl, + attr_aspects=["deps"]) + +ts_web_library = rule( + implementation=_ts_web_library, + executable=True, + attrs={ + "path": attr.string(), + "srcs": attr.label_list(allow_files=True), + "deps": attr.label_list(aspects=[web_aspect], providers=["webfiles"]), + "exports": attr.label_list(), + "data": attr.label_list(cfg="data", allow_files=True), + "suppress": attr.string_list(), + "strip_prefix": attr.string(), + "external_assets": attr.string_dict(default={"/_/runfiles": "."}), + "_execrooter": attr.label( + default=Label( + "//tensorflow/tensorboard/scripts:execrooter"), + executable=True, + cfg="host"), + "_tsc": attr.label( + default=Label( + "@com_microsoft_typescript//:tsc"), + allow_files=True, + executable=True, + cfg="host"), + "_es6dts": attr.label( + default=Label( + "@com_microsoft_typescript//:lib.es6.d.ts"), + allow_files=True), + "_ClosureWorker": attr.label( + default=Label("@io_bazel_rules_closure//java/io/bazel/rules/closure:ClosureWorker"), + executable=True, + cfg="host"), + "_WebfilesServer": attr.label( + default=Label( + "@io_bazel_rules_closure//java/io/bazel/rules/closure/webfiles/server:WebfilesServer"), + executable=True, + cfg="host"), + }, + outputs={ + "dummy": "%{name}.ignoreme", + }) diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index c44b966451..cfd55a4f85 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -96,7 +96,6 @@ filegroup( "//third_party/hadoop:LICENSE.txt", "@boringssl//:LICENSE", "@com_googlesource_code_re2//:LICENSE", - "@com_microsoft_typescript//:LICENSE.txt", "@curl//:COPYING", "@eigen_archive//:COPYING.MPL2", "@farmhash_archive//:COPYING", @@ -112,7 +111,6 @@ filegroup( "@nanopb_git//:LICENSE.txt", "@org_html5lib//:LICENSE", "@org_mozilla_bleach//:LICENSE", - "@org_nodejs//:LICENSE", "@org_pocoo_werkzeug//:LICENSE", "@org_pythonhosted_markdown//:LICENSE.md", "@png_archive//:LICENSE", diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index d1326ff08f..c529f4d78c 100644 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -744,6 +744,29 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ############################################################################## # TensorBoard JavaScript Production Dependencies + filegroup_external( + name = "com_google_javascript_closure_compiler_externs", + licenses = ["notice"], # Apache 2.0 + sha256_urls_extract = { + "0ee7b88ed2955b622eaa038bece283e28d0fb5abebfbb80871fc3d0353f0000b": [ + "http://mirror.bazel.build/github.com/google/closure-compiler/archive/v20170423.tar.gz", + "https://github.com/google/closure-compiler/archive/v20170423.tar.gz", + ], + }, + strip_prefix = {"v20170423.tar.gz": "closure-compiler-20170423/externs"}, + ) + + filegroup_external( + name = "com_google_javascript_closure_compiler_externs_polymer", + licenses = ["notice"], # Apache 2.0 + sha256_urls = { + "23baad9a200a717a821c6df504c84d3a893d7ea9102b14876eb80097e3b94292": [ + "http://mirror.bazel.build/raw.githubusercontent.com/google/closure-compiler/0e8dc5597a295ee259e3fecd98d6535dc621232f/contrib/externs/polymer-1.0.js", + "https://raw.githubusercontent.com/google/closure-compiler/0e8dc5597a295ee259e3fecd98d6535dc621232f/contrib/externs/polymer-1.0.js", + ], + }, + ) + web_library_external( name = "com_lodash", licenses = ["notice"], # MIT @@ -754,7 +777,10 @@ def tf_workspace(path_prefix="", tf_repo_name=""): ], strip_prefix = "lodash-3.10.1", path = "/lodash", - srcs = ["lodash.js"], + srcs = [ + "lodash.js", + "lodash.min.js", + ], ) filegroup_external( @@ -786,6 +812,7 @@ def tf_workspace(path_prefix="", tf_repo_name=""): "https://registry.npmjs.org/plottable/-/plottable-3.1.0.tgz", ], }, + strip_prefix = {"plottable-3.1.0.tgz": "package"}, ) filegroup_external( @@ -797,9 +824,9 @@ def tf_workspace(path_prefix="", tf_repo_name=""): "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/dagre/v0.7.4/LICENSE", "https://raw.githubusercontent.com/cpettitt/dagre/v0.7.4/LICENSE", ], - "7323829ddd77924a69e2b1235ded3eac30acd990da0f037e0fbd3c8e9035b50d": [ - "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/dagre/v0.7.4/dist/dagre.core.js", - "https://raw.githubusercontent.com/cpettitt/dagre/v0.7.4/dist/dagre.core.js", + "6132f5c009a3a72ebced7263ae5d4da48dc513f314a645876293bb658d3631d2": [ + "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/dagre/v0.7.4/dist/dagre.core.min.js", + "https://raw.githubusercontent.com/cpettitt/dagre/v0.7.4/dist/dagre.core.min.js", ], }, ) @@ -812,9 +839,9 @@ def tf_workspace(path_prefix="", tf_repo_name=""): "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/LICENSE", "https://raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/LICENSE", ], - "772045d412b1513b549be991c2e1846c38019429d43974efcae943fbe83489bf": [ - "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/dist/graphlib.core.js", - "https://raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/dist/graphlib.core.js", + "af1db00d36f9a68a6a1981d65997448baa0463a1f5d8bf1f54ff67bcc2e76498": [ + "http://mirror.bazel.build/raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/dist/graphlib.core.min.js", + "https://raw.githubusercontent.com/cpettitt/graphlib/v1.0.7/dist/graphlib.core.min.js", ], }, ) @@ -845,14 +872,6 @@ def tf_workspace(path_prefix="", tf_repo_name=""): "https://github.com/d3/d3/releases/download/v4.8.0/d3.zip", ], }, - # TODO(jart): Use srcs=["d3.js"] instead of this once supported. - generated_rule_name = "all_files", - extra_build_file_content = "\n".join([ - "filegroup(", - " name = \"org_d3js\",", - " srcs = [\"d3.js\"],", - ")", - ]), ) filegroup_external( @@ -1795,12 +1814,12 @@ def tf_workspace(path_prefix="", tf_repo_name=""): web_library_external( name = "org_polymer_neon_animation", licenses = ["notice"], # BSD-3-Clause - sha256 = "8800c314a76b2da190a2b203259c1091f6d38e0057ed37c2a3d0b734980fa9a5", + sha256 = "a104bb02db956e0e34d3eefcd07f3f6919d137af27d8139879a227ecfdc7d8a4", urls = [ - "http://mirror.bazel.build/github.com/PolymerElements/neon-animation/archive/v1.2.2.tar.gz", - "https://github.com/PolymerElements/neon-animation/archive/v1.2.2.tar.gz", + "http://mirror.bazel.build/github.com/PolymerElements/neon-animation/archive/v1.2.5.tar.gz", + "https://github.com/PolymerElements/neon-animation/archive/v1.2.5.tar.gz", ], - strip_prefix = "neon-animation-1.2.2", + strip_prefix = "neon-animation-1.2.5", path = "/neon-animation", srcs = [ "animations/cascaded-animation.html", @@ -2502,12 +2521,12 @@ def tf_workspace(path_prefix="", tf_repo_name=""): web_library_external( name = "org_polymer_web_animations_js", licenses = ["notice"], # BSD-3-Clause - sha256 = "f8bd760cbdeba131f6790bd5abe170bcbf7b1755ff58ed16d0b82fa8a7f34a7f", + sha256 = "84273610f15d5061a320b1dd0f4c3233d0bdf874798a60837b7de7110e086d7e", urls = [ - "http://mirror.bazel.build/github.com/web-animations/web-animations-js/archive/2.2.1.tar.gz", - "https://github.com/web-animations/web-animations-js/archive/2.2.1.tar.gz", + "http://mirror.bazel.build/github.com/web-animations/web-animations-js/archive/2.2.5.tar.gz", + "https://github.com/web-animations/web-animations-js/archive/2.2.5.tar.gz", ], - strip_prefix = "web-animations-js-2.2.1", + strip_prefix = "web-animations-js-2.2.5", path = "/web-animations-js", srcs = ["web-animations-next-lite.min.js"], ) |