Skip to content

Commit a5ee596

Browse files
vkarampuditfx-copybaraczgdp1807
authored
Changes thats need to be included for 0.48.1 patch release (#52)
* Struct2Tensor 0.48.0 Release PiperOrigin-RevId: 743712449 * Build documentation with `mkdocs` (#38) * Add minimum viable mkdocs configuration * Add examples section * Add links to api docs and overviews * Get api docs up and running * Add `__all__` to `__init__.py` files to include correct classes This is just a first step to including the correct items in the api docs * Exclude test modules from docs * Use correct module * Add docs deployment workflow * Include all correct modules/classes/functions * Fix button rendering * Fix formatting, including admonitions * Fix broken link * Use README.md as homepage for docs * Fix links * Remove debug triggers from docs deployment workflow * Remove deprecated api docs * Fix triggers * Move docs requirements to common location * Only trigger on pushes to master * Remove unnecessary newline characters * Move docs location to default `docs` directory * only internal visibility change, no external change PiperOrigin-RevId: 755419474 * Automated Code Change PiperOrigin-RevId: 796979132 * Automated Code Change PiperOrigin-RevId: 803375108 * no-op PiperOrigin-RevId: 809038483 * Added pytype None checks to calculate.py PiperOrigin-RevId: 845226580 * Replace unicode escaped characters in ipynb files PiperOrigin-RevId: 856192266 * Fixes that needs to be available in the main branch in order to cherry-pick into Release branch (#49) * Update WORKSPACE * Update workspace.bzl * Migrate to Protobuf 4.23.4: custom Bazel rule for Python proto generation Protobuf 4.x removed py_proto_library and changed proto_library behavior. This commit: - Creates _py_proto_library_rule: a custom Bazel rule that accepts ProtoInfo or PyInfo, runs protoc to generate Python _pb2.py files, and provides PyInfo for Python deps - Replaces deprecated py_proto_library calls with custom rule implementation - Configures protoc proto_path to include workspace dirs and external dependencies - Adds local any.proto copies to bypass sandbox limitations in proto imports - Applies compatibility patches to TensorFlow and TensorFlow Metadata dependencies - Updates all s2t_proto_library_py calls to work with new implementation Fixes: Protobuf 4.23.4 compatibility for struct2tensor build system * Add compatibility patches for older Abseil and Protobuf 4.x This patch extends tensorflow.patch with changes to support: 1. Abseil backward compatibility: - Add absl_base_prefetch.h compatibility shim for older Abseil versions that lack absl/base/prefetch.h - Update prefetch includes across TensorFlow/TSL to use the shim - Add inline implementation of NullTerminatedMessage for older Abseil versions without StatusMessageAsCStr 2. Protobuf 4.x support: - Refactor cc_proto_library to use native proto_library and cc_proto_library rules instead of custom proto_gen - Implement custom _tsl_py_proto_library_rule to replace the built-in py_proto_library removed in Protobuf 4.x - Update proto library generation to depend on generated cc_proto_library targets 3. Build cleanup: - Remove unused absl/strings:string_view dependency - Update BUILD files to reflect new dependency structure These changes enable building struct2tensor with older Abseil versions while supporting Protobuf 4.x, improving compatibility across different dependency versions. * chore: upgrade Protobuf dependency from 4.23.4 to 4.25.6 * Move TFMD patch to tfmd.patch; Protobuf 4.x compatibility Remove vendored google/protobuf/any.proto and obsolete third_party/README.md * fix: Use native prefix for Bazel rules in macros Prefix cc_binary and cc_library with native. in struct2tensor.bzl * Update Dockerfile * Fix struct2tensor integration in TensorFlow Serving Docker build Apply rules_cc patch before adding struct2tensor local repository to ensure proper Bazel configuration. * Update RELEASE.md to sync with main branch * Update version.py --------- Co-authored-by: Gagandeep Singh <gdp.1807@gmail.com> * docs(release): Update RELEASE.md and version for 0.48.0 * Update Dockerfile to build with serving version 2.17.1 * Build and stage dynamic op libraries before wheel creation (#51) Add explicit build and copy steps for dynamic op libraries (.so files) in build_common.sh. This ensures all six dynamic library targets are built and copied to struct2tensor/ops/ before the wheel is packaged. Previously, the stamp_wheel step in build_manylinux.sh would fail with patchelf errors ("No such file or directory") because the .so files were expected in struct2tensor/ops/ but were not being copied from bazel-bin. This fix: - Explicitly builds each dynamic library target - Copies the built .so files from bazel-bin to the staging directory - Runs before bazel run :build_pip_package to ensure files are present Fixes the missing _decode_proto_map_op.so, _decode_proto_sparse_op.so and related dynamic library warnings during wheel packaging. * Enable OSS Bazel builds by fixing dependencies and proto paths (#50) - Add py_proto_library macro for OSS compatibility - Replace gunit_main with googletest gtest_main - Comment out Google-internal dependencies and missing test files - Fix proto import to use workspace-relative path - Remove invalid third_party load statements Fixes build errors when running `bazel build //...` in OSS environment. Co-authored-by: Madhur Karampudi <142544288+vkarampudi@users.noreply.github.com> --------- Co-authored-by: struct2tensor-team <tensorflow-extended-nonhuman@googlegroups.com> Co-authored-by: Gagandeep Singh <gdp.1807@gmail.com>
1 parent 99b0d12 commit a5ee596

23 files changed

Lines changed: 1143 additions & 194 deletions

File tree

RELEASE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616

1717
## Deprecations
1818

19-
* N/A
20-
19+
* N/A

WORKSPACE

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ tf_configure(name = "local_config_tf")
4141
# 3. Request the new archive to be mirrored on mirror.bazel.build for more
4242
# reliable downloads.
4343

44-
_TENSORFLOW_GIT_COMMIT = "5bc9d26649cca274750ad3625bd93422617eed4b" # tf 2.16.1
45-
_TENSORFLOW_ARCHIVE_SHA256 = "fe592915c85d1a89c20f3dd89db0772ee22a0fbda78e39aa46a778d638a96abc"
44+
_TENSORFLOW_GIT_COMMIT = "3c92ac03cab816044f7b18a86eb86aa01a294d95" # tf 2.17.1
45+
_TENSORFLOW_ARCHIVE_SHA256 = "317dd95c4830a408b14f3e802698eb68d70d81c7c7cfcd3d28b0ba023fe84a68"
4646

4747
http_archive(
4848
name = "org_tensorflow",
@@ -51,6 +51,8 @@ http_archive(
5151
"https://github.com/tensorflow/tensorflow/archive/%s.tar.gz" % _TENSORFLOW_GIT_COMMIT,
5252
],
5353
strip_prefix = "tensorflow-%s" % _TENSORFLOW_GIT_COMMIT,
54+
patches = ["//third_party:tensorflow.patch"],
55+
patch_args = ["-p1"],
5456
)
5557

5658
load("//third_party:python_configure.bzl", "local_python_configure")
@@ -62,6 +64,21 @@ local_python_configure(name = "local_execution_config_python")
6264
load("//struct2tensor:workspace.bzl", "struct2tensor_workspace")
6365
struct2tensor_workspace()
6466

67+
# ===== Protobuf 4.25.6 dependency =====
68+
# Must be declared BEFORE TensorFlow's workspaces to override the version they pull
69+
http_archive(
70+
name = "com_google_protobuf",
71+
sha256 = "4e6727bc5d23177edefa3ad86fd2f5a92cd324151636212fd1f7f13aef3fd2b7",
72+
strip_prefix = "protobuf-4.25.6",
73+
urls = [
74+
"https://github.com/protocolbuffers/protobuf/archive/v4.25.6.tar.gz",
75+
],
76+
)
77+
78+
# Load Protobuf dependencies
79+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
80+
protobuf_deps()
81+
6582
# Initialize TensorFlow's external dependencies.
6683
load("@org_tensorflow//tensorflow:workspace3.bzl", "tf_workspace3")
6784
tf_workspace3()

build_common.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ function install_tensorflow() {
6262
"${PYTHON_BIN_PATH}" -c 'import tensorflow as tf; print(tf.version.VERSION)'
6363
}
6464

65+
function build_dynamic_libraries() {
66+
# Explicitly build the dynamic library targets that are needed for the wheel.
67+
# These are required by the stamp_wheel function.
68+
bazel build //struct2tensor/ops:_decode_proto_map_op.so || exit 1;
69+
bazel build //struct2tensor/ops:_decode_proto_sparse_op.so || exit 1;
70+
bazel build //struct2tensor/ops:_run_length_before_op.so || exit 1;
71+
bazel build //struct2tensor/ops:_equi_join_any_indices_op.so || exit 1;
72+
bazel build //struct2tensor/ops:_equi_join_indices_op.so || exit 1;
73+
bazel build //struct2tensor/ops:_parquet_dataset_op.so || exit 1;
74+
75+
RUNFILES_DIR=$(pwd)
76+
cp -f bazel-bin/struct2tensor/ops/*.so ${RUNFILES_DIR}/struct2tensor/ops/
77+
78+
}
79+
6580
set -x
6681

6782
for i in "$@"; do
@@ -116,6 +131,8 @@ if [[ ("${TF_VERSION}" == "NIGHTLY_TF") || ("${TF_VERSION}" == "NIGHTLY_TF_2") ]
116131

117132
fi
118133

134+
build_dynamic_libraries
135+
119136
# :build_pip_package builds and links struct2tensor ops against a TF
120137
# installation and packages the result dynamic libraries.
121138
bazel run -c opt \

examples/prensor_playground.ipynb

Lines changed: 80 additions & 80 deletions
Large diffs are not rendered by default.

struct2tensor/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# Prensors provide a way to parse protocol buffers and other structured data in tensorflow
1616
# simply and efficiently.
1717

18+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1819
# Placeholder: load py_test
1920

2021
load("//struct2tensor:struct2tensor.bzl", "s2t_pytype_library")
@@ -83,7 +84,7 @@ s2t_pytype_library(
8384
"path.py",
8485
],
8586
deps = [
86-
"@com_github_tensorflow_metadata//tensorflow_metadata/proto/v0:py_metadata_v0_proto_py",
87+
"@com_github_tensorflow_metadata//tensorflow_metadata/proto/v0:metadata_v0_proto_py_pb2",
8788
"@com_google_protobuf//:protobuf_python",
8889
],
8990
)

struct2tensor/benchmarks/BUILD

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Placeholder: load py_proto_library
16-
# Placeholder: load py_binary
17-
# Placeholder: load py_library
18-
# Placeholder: load py_test
19-
load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library")
20-
load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", "cc_proto_library")
15+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
16+
load("//struct2tensor:struct2tensor.bzl", "py_proto_library")
2117

2218
licenses(["notice"])
2319

@@ -33,26 +29,28 @@ py_proto_library(
3329
deps = [":benchmark_proto"],
3430
)
3531

32+
# Use native cc_proto_library instead of custom macro since we already have proto_library defined
3633
cc_proto_library(
3734
name = "benchmark_cc_proto",
3835
deps = [":benchmark_proto"],
3936
)
4037

41-
cc_test(
42-
name = "serialization_benchmark",
43-
srcs = ["serialization_benchmark.cc"],
44-
deps = [
45-
":benchmark_cc_proto",
46-
"//testing/base/public:gunit",
47-
"@com_google_absl//absl/flags:flag",
48-
"@com_google_absl//absl/flags:parse",
49-
"@com_google_absl//absl/random",
50-
"@com_google_absl//absl/random:distributions",
51-
"@com_google_protobuf//:protobuf",
52-
"@org_tensorflow//tensorflow/core:feature_util",
53-
"@org_tensorflow//tensorflow/core:protos_all_cc",
54-
],
55-
)
38+
# Google-internal benchmark - commented out for OSS
39+
# cc_test(
40+
# name = "serialization_benchmark",
41+
# srcs = ["serialization_benchmark.cc"],
42+
# deps = [
43+
# ":benchmark_cc_proto",
44+
# "//testing/base/public:gunit",
45+
# "@com_google_absl//absl/flags:flag",
46+
# "@com_google_absl//absl/flags:parse",
47+
# "@com_google_absl//absl/random",
48+
# "@com_google_absl//absl/random:distributions",
49+
# "@com_google_protobuf//:protobuf",
50+
# "@org_tensorflow//tensorflow/core:feature_util",
51+
# "@org_tensorflow//tensorflow/core:protos_all_cc",
52+
# ],
53+
# )
5654

5755
py_library(
5856
name = "struct2tensor_benchmark_lib",
@@ -61,10 +59,11 @@ py_library(
6159
":benchmark_proto_py_pb2",
6260
":struct2tensor_benchmark_util",
6361
"//struct2tensor",
64-
"//testing/pybase",
65-
"//testing/pybase:parameterized",
66-
"//third_party/py/cpuinfo",
67-
"//third_party/py/psutil",
62+
# Google-internal dependencies - not available in OSS
63+
# "//testing/pybase",
64+
# "//testing/pybase:parameterized",
65+
# "//third_party/py/cpuinfo",
66+
# "//third_party/py/psutil",
6867
],
6968
)
7069

@@ -110,9 +109,10 @@ py_library(
110109
name = "struct2tensor_benchmark_util",
111110
srcs = ["struct2tensor_benchmark_util.py"],
112111
deps = [
113-
"//file/colossus/public:cns",
114-
"//third_party/py/cpuinfo",
115-
"//third_party/py/psutil",
112+
# Google-internal dependencies - not available in OSS
113+
# "//file/colossus/public:cns",
114+
# "//third_party/py/cpuinfo",
115+
# "//third_party/py/psutil",
116116
"@absl_py//absl/flags",
117117
"@absl_py//absl/testing:parameterized",
118118
],

struct2tensor/calculate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def __str__(self) -> str:
259259

260260
def _create_value_error(self) -> ValueError:
261261
"""Creates a ValueError, assuming there should be one for this node."""
262+
assert self.value is not None
262263
return ValueError("Expression {} returned the wrong type:"
263264
" expected: {}"
264265
" actual: {}.".format(
@@ -353,8 +354,14 @@ def calculate_values(
353354
options: calculate_options.Options,
354355
feed_dict: Optional[Dict[expression.Expression, prensor.Prensor]] = None
355356
) -> None:
357+
"""Calculates the values of the expressions in the graph."""
356358
for node in self.ordered_node_list:
357-
source_values = [self._node[id(x)].value for x in node.sources]
359+
source_values = [
360+
self._node[id(x)].value
361+
for x in node.sources
362+
if self._node[id(x)] is not None
363+
and self._node[id(x)].value is not None
364+
]
358365
side_info = feed_dict[node.expression] if feed_dict and (
359366
node.expression in feed_dict) else None
360367
node.calculate(source_values, options, side_info=side_info)

struct2tensor/kernels/BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# CPU kernels for struct2tensors.
1616

17+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1718
load("//struct2tensor:struct2tensor.bzl", "s2t_dynamic_library")
1819

1920
package(
@@ -68,7 +69,6 @@ s2t_dynamic_library(
6869
"@com_google_absl//absl/base:endian",
6970
"@com_google_absl//absl/container:flat_hash_map",
7071
"@com_google_absl//absl/container:inlined_vector",
71-
"@com_google_absl//absl/container:inlined_vector_internal",
7272
"@com_google_absl//absl/memory",
7373
"@com_google_absl//absl/strings",
7474
"@com_google_absl//absl/types:span",
@@ -104,7 +104,6 @@ s2t_dynamic_library(
104104
"@com_google_absl//absl/base:endian",
105105
"@com_google_absl//absl/container:flat_hash_map",
106106
"@com_google_absl//absl/container:inlined_vector",
107-
"@com_google_absl//absl/container:inlined_vector_internal",
108107
"@com_google_absl//absl/strings",
109108
"@com_google_absl//absl/types:span",
110109
],

struct2tensor/kernels/parquet/BUILD

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#
1515
# Parquet Dataset Kernel Implementation.
1616

17+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
18+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1719
load("//struct2tensor:struct2tensor.bzl", "s2t_dynamic_library")
1820

1921
package(
@@ -60,6 +62,7 @@ cc_library(
6062
deps = [
6163
":parent_indices_builder_lib",
6264
":parquet_reader_util_lib",
65+
"@com_google_absl//absl/status",
6366
"@com_google_absl//absl/strings",
6467
"@arrow//:arrow",
6568
"//struct2tensor/kernels:vector_to_tensor",
@@ -96,38 +99,40 @@ cc_library(
9699
],
97100
)
98101

99-
cc_test(
100-
name = "parent_indices_builder_test",
101-
srcs = ["parent_indices_builder_test.cc"],
102-
deps = [
103-
":parent_indices_builder_lib",
104-
"//testing/base/public:gunit_main",
105-
"@org_tensorflow//tensorflow/core:lib",
106-
"@org_tensorflow//tensorflow/core:test",
107-
],
108-
)
102+
# Test file parent_indices_builder_test.cc does not exist, commenting out
103+
# cc_test(
104+
# name = "parent_indices_builder_test",
105+
# srcs = ["parent_indices_builder_test.cc"],
106+
# deps = [
107+
# ":parent_indices_builder_lib",
108+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
109+
# "@org_tensorflow//tensorflow/core:lib",
110+
# "@org_tensorflow//tensorflow/core:test",
111+
# ],
112+
# )
109113

110-
cc_test(
111-
name = "parquet_reader_test",
112-
srcs = ["parquet_reader_test.cc"],
113-
data = [
114-
"//struct2tensor/testdata/parquet_testdata",
115-
],
116-
deps = [
117-
":parquet_reader_lib",
118-
"//testing/base/public:gunit_main",
119-
"@org_tensorflow//tensorflow/core:framework",
120-
],
121-
)
122-
123-
cc_test(
124-
name = "parquet_reader_util_test",
125-
srcs = ["parquet_reader_util_test.cc"],
126-
data = [
127-
"//struct2tensor/testdata/parquet_testdata",
128-
],
129-
deps = [
130-
":parquet_reader_util_lib",
131-
"//testing/base/public:gunit_main",
132-
],
133-
)
114+
# Test file parquet_reader_test.cc does not exist, commenting out
115+
# cc_test(
116+
# name = "parquet_reader_test",
117+
# srcs = ["parquet_reader_test.cc"],
118+
# data = [
119+
# "//struct2tensor/testdata/parquet_testdata",
120+
# ],
121+
# deps = [
122+
# ":parquet_reader_lib",
123+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
124+
# "@org_tensorflow//tensorflow/core:framework",
125+
# ],
126+
# )
127+
# Test file parquet_reader_util_test.cc does not exist, commenting out
128+
# cc_test(
129+
# name = "parquet_reader_util_test",
130+
# srcs = ["parquet_reader_util_test.cc"],
131+
# data = [
132+
# "//struct2tensor/testdata/parquet_testdata",
133+
# ],
134+
# deps = [
135+
# ":parquet_reader_util_lib",
136+
# "@com_google_googletest//:gtest_main", # Replaces Google-internal //testing/base/public:gunit_main
137+
# ],
138+
# )

struct2tensor/kernels/parquet/parquet_reader.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616

1717
#include <memory>
1818

19+
#include "absl/status/status.h"
1920
#include "absl/strings/str_cat.h"
2021
#include "struct2tensor/kernels/parquet/parquet_reader_util.h"
2122
#include "struct2tensor/kernels/vector_to_tensor.h"
@@ -440,7 +441,7 @@ tensorflow::Status ParquetReader::ReadOneColumnTemplated(
440441
column_index, def_levels, rep_levels, &cumulative_values);
441442

442443
++(*messages_read);
443-
if (tensorflow::errors::IsOutOfRange(s)) {
444+
if (absl::IsOutOfRange(s)) {
444445
break;
445446
}
446447
TF_RETURN_IF_ERROR(s);

0 commit comments

Comments
 (0)