From 73c8e91e67a35e6a3dc6273e67625aac5b57537e Mon Sep 17 00:00:00 2001 From: Charles Mita Date: Thu, 7 Mar 2024 11:35:25 +0100 Subject: [PATCH] Migrate uses of struct.to_proto 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. --- tensorboard/defs/internal/html.bzl | 4 ++-- tensorboard/defs/web.bzl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tensorboard/defs/internal/html.bzl b/tensorboard/defs/internal/html.bzl index bb442dba65..48d3dcbe80 100644 --- a/tensorboard/defs/internal/html.bzl +++ b/tensorboard/defs/internal/html.bzl @@ -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]) diff --git a/tensorboard/defs/web.bzl b/tensorboard/defs/web.bzl index 88819a716e..04579085e3 100644 --- a/tensorboard/defs/web.bzl +++ b/tensorboard/defs/web.bzl @@ -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, @@ -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):