Skip to content

Commit

Permalink
Migrate uses of struct.to_proto (#6778)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
c-mita authored Mar 12, 2024
1 parent acf1cb9 commit 4d55fda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tensorboard/defs/internal/html.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def _tb_combine_html_impl(ctx):
manifest = ctx.actions.declare_file("%s.pbtxt" % ctx.label.name)
ctx.actions.write(
output = manifest,
content = struct(
content = proto.encode_text(struct(
label = str(ctx.label),
src = manifest_srcs,
).to_proto(),
)),
)
manifests = depset([manifest], transitive = [manifests])

Expand Down
6 changes: 3 additions & 3 deletions tensorboard/defs/web.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _tf_web_library(ctx):
external_asset=[struct(webpath=k, path=v)
for k, v in ctx.attr.external_assets.items()])
params_file = _new_file(ctx, "-params.pbtxt")
ctx.actions.write(output=params_file, content=params.to_proto())
ctx.actions.write(output=params_file, content=proto.encode_text(params))
ctx.actions.write(
is_executable=True,
output=ctx.outputs.executable,
Expand Down Expand Up @@ -150,9 +150,9 @@ def _make_manifest(ctx, src_list):
manifest = _new_file(ctx, "-webfiles.pbtxt")
ctx.actions.write(
output=manifest,
content=struct(
content=proto.encode_text(struct(
label=str(ctx.label),
src=src_list).to_proto())
src=src_list)))
return manifest

def _run_webfiles_validator(ctx, srcs, deps, manifest):
Expand Down

0 comments on commit 4d55fda

Please sign in to comment.