Skip to content

Remove legacy providers #6721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ permissions:
env:
# Keep this Bazel version in sync with the `versions.check` directive
# in our WORKSPACE file.
BAZEL_VERSION: '4.2.2'
BAZEL_SHA256SUM: '11dea6c7cfd866ed520af19a6bb1d952f3e9f4ee60ffe84e63c0825d95cb5859'
BAZEL_VERSION: '6.5.0'
BAZEL_SHA256SUM: 'a40ac69263440761199fcb8da47ad4e3f328cbe79ffbf4ecc14e5ba252857307'
BUILDTOOLS_VERSION: '3.0.0'
BUILDIFIER_SHA256SUM: 'e92a6793c7134c5431c58fbc34700664f101e5c9b1c1fcd93b97978e8b7f88db'
BUILDOZER_SHA256SUM: '3d58a0b6972e4535718cdd6c12778170ea7382de7c75bc3728f5719437ffb84d'
Expand Down
22 changes: 12 additions & 10 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ versions.check(
maximum_bazel_version = "6.999.0",
# Keep this version in sync with:
# * The BAZEL environment variable defined in .github/workflows/ci.yml, which is used for CI and nightly builds.
minimum_bazel_version = "4.2.2",
minimum_bazel_version = "6.5.0",
)

http_archive(
name = "io_bazel_rules_webtesting",
sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
urls = [
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
"https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
],
sha256 = "6e104e54c283c94ae3d5c6573cf3233ce478e89e0f541a869057521966a35b8f",
strip_prefix = "rules_webtesting-b6fc79c5a37cd18a5433fd080c9d2cc59548222c",
urls = ["https://github.com/bazelbuild/rules_webtesting/archive/b6fc79c5a37cd18a5433fd080c9d2cc59548222c.tar.gz"],
)

load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
Expand All @@ -55,11 +53,10 @@ py_repositories()

http_archive(
name = "io_bazel_rules_closure",
sha256 = "6a900831c1eb8dbfc9d6879b5820fd614d4ea1db180eb5ff8aedcb75ee747c1f",
strip_prefix = "rules_closure-db4683a2a1836ac8e265804ca5fa31852395185b",
sha256 = "ae060075a7c468eee42e6a08ddbb83f5a6663bdfdbd461261a465f4a3ae8598c",
strip_prefix = "rules_closure-7f3d3351a8cc31fbaa403de7d35578683c17b447",
urls = [
"http://mirror.tensorflow.org/github.com/bazelbuild/rules_closure/archive/db4683a2a1836ac8e265804ca5fa31852395185b.tar.gz",
"https://github.com/bazelbuild/rules_closure/archive/db4683a2a1836ac8e265804ca5fa31852395185b.tar.gz", # 2020-01-15
"https://github.com/bazelbuild/rules_closure/archive/7f3d3351a8cc31fbaa403de7d35578683c17b447.tar.gz", # 2024-03-11
],
)

Expand Down Expand Up @@ -191,6 +188,11 @@ http_archive(
],
)

# WORKAROUND for rules_webtesting not declaring used com_github_gorilla_mux repo:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these lines above where the other load statement from rules_webtesting is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I tried. com_github_gorilla_mux needs setup for Go repositories. It doesn't work even when used after rules_closure.

load("@io_bazel_rules_webtesting//web:go_repositories.bzl", "com_github_gorilla_mux")

com_github_gorilla_mux()

# Please add all new dependencies in workspace.bzl.
load("//third_party:workspace.bzl", "tensorboard_workspace")

Expand Down
45 changes: 23 additions & 22 deletions tensorboard/defs/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ load("@npm//@bazel/concatjs:index.bzl", "karma_web_test_suite", "ts_library")
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
load("@npm//@bazel/typescript:index.bzl", "ts_config")


def tensorboard_webcomponent_library(**kwargs):
"""Rules referencing this will be deleted from the codebase soon."""
pass
Expand Down Expand Up @@ -72,8 +71,8 @@ def tf_js_binary(
# the global level and tends to overwrite `window` functions. "iife" is
# just a thin wrapper around "esm" (it adds 11 bytes) and doesn't
# suffer from the same overwriting problem.
format="iife",
minify= False if dev_mode_only else True,
format = "iife",
minify = False if dev_mode_only else True,
args = {
# Must specify that 'mjs' extensions are preferred, since that is
# the extension that is used for es2015/esm code generated by
Expand All @@ -91,7 +90,6 @@ def tf_js_binary(
**kwargs
)


def tf_ng_prod_js_binary(
name,
compile,
Expand All @@ -114,7 +112,7 @@ def tf_ng_prod_js_binary(
https://esbuild.github.io/api/ for more details.
"""

app_bundle_name = '%s_app_bundle' % name
app_bundle_name = "%s_app_bundle" % name
app_bundle(
name = app_bundle_name,
**kwargs
Expand All @@ -124,8 +122,8 @@ def tf_ng_prod_js_binary(
# through a terser pass to be the output of this rule.
copy_file(
name = name,
src = '%s.min.js' % app_bundle_name,
out = '%s.js' % name,
src = "%s.min.js" % app_bundle_name,
out = "%s.js" % name,
)

def tf_ts_config(**kwargs):
Expand All @@ -148,22 +146,24 @@ def tf_ts_library(srcs = [], strict_checks = True, **kwargs):
kwargs.setdefault("deps", []).extend(["@npm//tslib", "//tensorboard/defs:strict_types"])

new_srcs = []

# Find test.ts and testbed.ts files and rename to test.spec.ts to be
# compatible with spec_bundle() tooling.
for s in srcs:
if s.endswith("_test.ts") or s.endswith("-test.ts") or s.endswith("_testbed.ts"):
# Make a copy of the file with name .spec.ts and switch to that as
# the src file.
new_src = s[0:s.rindex('.ts')] + ".spec.ts"
copy_file(
name = new_src + '_spec_copy',
src = s,
out = new_src,
allow_symlink = True)
new_srcs.append(new_src)
else:
# Not a test file. Nothing to do here.
new_srcs.append(s)
if s.endswith("_test.ts") or s.endswith("-test.ts") or s.endswith("_testbed.ts"):
# Make a copy of the file with name .spec.ts and switch to that as
# the src file.
new_src = s[0:s.rindex(".ts")] + ".spec.ts"
copy_file(
name = new_src + "_spec_copy",
src = s,
out = new_src,
allow_symlink = True,
)
new_srcs.append(new_src)
else:
# Not a test file. Nothing to do here.
new_srcs.append(s)

ts_library(
srcs = new_srcs,
Expand All @@ -176,7 +176,8 @@ def tf_ts_library(srcs = [], strict_checks = True, **kwargs):
prodmode_target = "es2020",
devmode_target = "es2020",
devmode_module = "esnext",
**kwargs)
**kwargs
)

def tf_ng_web_test_suite(name, deps = [], **kwargs):
"""TensorBoard wrapper for the rule for a Karma web test suite.
Expand Down Expand Up @@ -231,7 +232,7 @@ def tf_ng_web_test_suite(name, deps = [], **kwargs):
# karma_web_test_suite() will rebundle it along with the test framework
# in a CommonJS bundle.
deps = [
"%s_bundle" % name,
"%s_bundle" % name,
],
)

Expand Down
121 changes: 61 additions & 60 deletions tensorboard/defs/hacks.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,66 @@
# TODO(@jart): Merge this file into defs.bzl once that file is sync unified.

def tensorboard_typescript_bundle(
name,
out,
namespace_srcs,
namespace_symbol_aliases={},
namespace_symbol_aliases_public={},
):
"""Rolls TypeScript ES6 modules into one vanilla source file without imports.
name,
out,
namespace_srcs,
namespace_symbol_aliases = {},
namespace_symbol_aliases_public = {}):
"""Rolls TypeScript ES6 modules into one vanilla source file without imports.

This is a genrule wrapper that concatenates TypeScripts sources inside
namespace blocks while removing ^import lines. Because the sources themselves
are not parsed, the structure of the modules must be passed to this macro as
a Skylark data structure.
This is a genrule wrapper that concatenates TypeScripts sources inside
namespace blocks while removing ^import lines. Because the sources themselves
are not parsed, the structure of the modules must be passed to this macro as
a Skylark data structure.

Args:
name: Name of this build rule target.
out: Path of outputted TypeScript source file.
namespace_srcs: Multimap of namespace strings to build file targets. The
ordering of the dictionary and nested lists does not matter when
generating a typings file, but *does* matter when generating a source
file.
namespace_symbol_aliases: Map of namespace strings where each value is a
map of symbol names to fully qualified symbol names.
namespace_symbol_aliases_public: Same as namespace_symbol_aliases but the
symbol will be visible to other namespaces.
"""
cmd = ["(", "echo // GENERATED BY TENSORBOARD_TYPESCRIPT_BUNDLE"]
inputs_depsets = []
for namespace, srcs in namespace_srcs.items():
cmd.append("echo")
if out[-5:] == ".d.ts":
cmd.append("echo 'declare namespace %s {'" % namespace)
elif out[-3:] == ".ts":
cmd.append("echo 'module %s {'" % namespace)
else:
fail("'out' must end with .ts or .d.ts: " + out)
for symbol, canon in namespace_symbol_aliases.get(namespace, {}).items():
cmd.append("echo 'import %s = %s;'" % (symbol, canon))
for symbol, canon in namespace_symbol_aliases_public.get(namespace,
{}).items():
cmd.append("echo 'export import %s = %s;'" % (symbol, canon))
inputs_depsets.append(depset(srcs))
for src in srcs:
cmd.append("for f in $(locations %s); do" % src)
cmd.append(" echo")
cmd.append(" echo /////////////////////////////////////////////////////")
cmd.append(" echo // " + namespace)
cmd.append(" echo // $$f")
cmd.append(" echo /////////////////////////////////////////////////////")
cmd.append(" echo")
cmd.append(" sed 's!^import !// import !' $$f \\")
cmd.append(" | sed 's!^export declare !export !' \\")
cmd.append(" | sed '/^export .* from /d' \\")
cmd.append(" | sed '/^export {.*};$$/d'")
cmd.append("done")
cmd.append("echo '}'")
cmd.append(") >$@")
native.genrule(
name = name,
srcs = depset(transitive=inputs_depsets).to_list(),
outs = [out],
cmd = "\n".join(cmd),
)
Args:
name: Name of this build rule target.
out: Path of outputted TypeScript source file.
namespace_srcs: Multimap of namespace strings to build file targets. The
ordering of the dictionary and nested lists does not matter when
generating a typings file, but *does* matter when generating a source
file.
namespace_symbol_aliases: Map of namespace strings where each value is a
map of symbol names to fully qualified symbol names.
namespace_symbol_aliases_public: Same as namespace_symbol_aliases but the
symbol will be visible to other namespaces.
"""
cmd = ["(", "echo // GENERATED BY TENSORBOARD_TYPESCRIPT_BUNDLE"]
inputs_depsets = []
for namespace, srcs in namespace_srcs.items():
cmd.append("echo")
if out[-5:] == ".d.ts":
cmd.append("echo 'declare namespace %s {'" % namespace)
elif out[-3:] == ".ts":
cmd.append("echo 'module %s {'" % namespace)
else:
fail("'out' must end with .ts or .d.ts: " + out)
for symbol, canon in namespace_symbol_aliases.get(namespace, {}).items():
cmd.append("echo 'import %s = %s;'" % (symbol, canon))
for symbol, canon in namespace_symbol_aliases_public.get(
namespace,
{},
).items():
cmd.append("echo 'export import %s = %s;'" % (symbol, canon))
inputs_depsets.append(depset(srcs))
for src in srcs:
cmd.append("for f in $(locations %s); do" % src)
cmd.append(" echo")
cmd.append(" echo /////////////////////////////////////////////////////")
cmd.append(" echo // " + namespace)
cmd.append(" echo // $$f")
cmd.append(" echo /////////////////////////////////////////////////////")
cmd.append(" echo")
cmd.append(" sed 's!^import !// import !' $$f \\")
cmd.append(" | sed 's!^export declare !export !' \\")
cmd.append(" | sed '/^export .* from /d' \\")
cmd.append(" | sed '/^export {.*};$$/d'")
cmd.append("done")
cmd.append("echo '}'")
cmd.append(") >$@")
native.genrule(
name = name,
srcs = depset(transitive = inputs_depsets).to_list(),
outs = [out],
cmd = "\n".join(cmd),
)
51 changes: 20 additions & 31 deletions tensorboard/defs/internal/html.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Rule for building the HTML binary."""

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_aspect")
load("@io_bazel_rules_closure//closure/private:defs.bzl", "collect_js", "long_path", "unfurl") # buildifier: disable=bzl-visibility
load("@io_bazel_rules_closure//closure/private:defs.bzl", "WebFilesInfo", "collect_runfiles", "extract_providers", "long_path", "unfurl") # buildifier: disable=bzl-visibility

def _tb_combine_html_impl(ctx):
"""Compiles HTMLs into one HTML.
Expand All @@ -25,18 +25,12 @@ def _tb_combine_html_impl(ctx):
JavaScript file when `js_path` is specified.
"""

deps = unfurl(ctx.attr.deps, provider = "webfiles")
manifests = depset(order = "postorder")
files = depset()
webpaths = depset()
for dep in deps:
manifests = depset(transitive = [manifests, dep.webfiles.manifests])
webpaths = depset(transitive = [webpaths, dep.webfiles.webpaths])
files = depset(transitive = [files, dep.data_runfiles.files])
deps = extract_providers(ctx.attr.deps, provider = WebFilesInfo)
deps = unfurl(deps)
manifests = depset(order = "postorder", transitive = [dep.manifests for dep in deps])
webpaths = depset(transitive = [dep.webpaths for dep in deps])
files = depset(transitive = [dep[DefaultInfo].data_runfiles.files for dep in ctx.attr.deps])
webpaths = depset([ctx.attr.output_path], transitive = [webpaths])
closure_js_library = collect_js(
unfurl(ctx.attr.deps, provider = "closure_js_library"),
)

# vulcanize
ctx.actions.run(
Expand Down Expand Up @@ -84,30 +78,25 @@ def _tb_combine_html_impl(ctx):
)
manifests = depset([manifest], transitive = [manifests])

transitive_runfiles = depset()
for dep in deps:
transitive_runfiles = depset(transitive = [
transitive_runfiles,
dep.data_runfiles.files,
])

return struct(
files = depset([ctx.outputs.html, ctx.outputs.js]),
webfiles = struct(
return [
DefaultInfo(
files = depset([ctx.outputs.html, ctx.outputs.js]),
runfiles = collect_runfiles(
ctx,
files = ctx.files.data + [
manifest,
ctx.outputs.html,
ctx.outputs.js,
],
),
),
WebFilesInfo(
manifest = manifest,
manifests = manifests,
webpaths = webpaths,
dummy = ctx.outputs.html,
),
runfiles = ctx.runfiles(
files = ctx.files.data + [
manifest,
ctx.outputs.html,
ctx.outputs.js,
],
transitive_files = transitive_runfiles,
),
)
]

tb_combine_html = rule(
implementation = _tb_combine_html_impl,
Expand Down
Loading