Skip to content

Commit 4d55fda

Browse files
authored
Migrate uses of struct.to_proto (#6778)
The "to_proto" method on Starlark structs is deprecated and shouldn't be used. Instead, the proto module's "encode_text" function should be used. (https://bazel.build/rules/lib/toplevel/proto) It, along with "to_json", can be disabled in Bazel using the flag --incompatible_struct_has_no_methods The underlying implementation is the same, so there should be no observable changes in final outputs.
1 parent acf1cb9 commit 4d55fda

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tensorboard/defs/internal/html.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ def _tb_combine_html_impl(ctx):
7777
manifest = ctx.actions.declare_file("%s.pbtxt" % ctx.label.name)
7878
ctx.actions.write(
7979
output = manifest,
80-
content = struct(
80+
content = proto.encode_text(struct(
8181
label = str(ctx.label),
8282
src = manifest_srcs,
83-
).to_proto(),
83+
)),
8484
)
8585
manifests = depset([manifest], transitive = [manifests])
8686

tensorboard/defs/web.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _tf_web_library(ctx):
104104
external_asset=[struct(webpath=k, path=v)
105105
for k, v in ctx.attr.external_assets.items()])
106106
params_file = _new_file(ctx, "-params.pbtxt")
107-
ctx.actions.write(output=params_file, content=params.to_proto())
107+
ctx.actions.write(output=params_file, content=proto.encode_text(params))
108108
ctx.actions.write(
109109
is_executable=True,
110110
output=ctx.outputs.executable,
@@ -150,9 +150,9 @@ def _make_manifest(ctx, src_list):
150150
manifest = _new_file(ctx, "-webfiles.pbtxt")
151151
ctx.actions.write(
152152
output=manifest,
153-
content=struct(
153+
content=proto.encode_text(struct(
154154
label=str(ctx.label),
155-
src=src_list).to_proto())
155+
src=src_list)))
156156
return manifest
157157

158158
def _run_webfiles_validator(ctx, srcs, deps, manifest):

0 commit comments

Comments
 (0)