From b659bc39f27e81b3249f73710671059589c5daa1 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Thu, 1 Jun 2017 19:24:34 -0700 Subject: 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 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. + + + 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. - + + + + + 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} [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} 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. - + 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 --> - + + 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. - + 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. } - + 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. - + + 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. } - + 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). - + 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. 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. --> - + 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. + 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. - + 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. - + 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. --> - + 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. --> - + 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. --> - + 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. --> - - + + 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. --> - + 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. + 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. - + 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. TensorBoard Demo - 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 = (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 = (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. --> - + - 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. + 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. vz-line-chart demo - 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 { + // 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. - + + + 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} 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} 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. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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. - + + + + + + + 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. 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. + - - + 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. --> - + 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 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 webfiles = new HashMap<>(); private static final Set alreadyInlined = new HashSet<>(); private static final Set legalese = new HashSet<>(); private static final List licenses = new ArrayList<>(); private static final List stack = new ArrayList<>(); + private static final List sourcesFromJsLibraries = new ArrayList<>(); + private static final Map sourcesFromScriptTags = new LinkedHashMap<>(); + private static final Map sourceTags = new LinkedHashMap<>(); + private static final Multimap 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 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 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