Skip to content

Commit 53a8d46

Browse files
authored
Merge branch 'google:master' into test-workflow
2 parents 428c286 + 5ce1eec commit 53a8d46

19 files changed

Lines changed: 175 additions & 143 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![PyPI](https://badge.fury.io/py/struct2tensor.svg)](https://badge.fury.io/py/struct2tensor)
55

66
<!--*
7-
freshness: { owner: 'iindyk' reviewed: '2024-04-22' }
7+
freshness: { owner: 'iindyk' reviewed: '2025-04-02' }
88
*-->
99

1010
## Introduction
@@ -115,6 +115,7 @@ is an integer.
115115

116116
struct2tensor | tensorflow
117117
---------------------------------------------------------------------- | ----------
118+
[0.48.0](https://github.com/google/struct2tensor/releases/tag/v0.48.0) | 2.17.0
118119
[0.47.0](https://github.com/google/struct2tensor/releases/tag/v0.47.0) | 2.16.2
119120
[0.46.0](https://github.com/google/struct2tensor/releases/tag/v0.46.0) | 2.15.0
120121
[0.45.0](https://github.com/google/struct2tensor/releases/tag/v0.45.0) | 2.13.0

RELEASE.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `struct2tensor` release notes
22

3-
# Current Version (not yet released; still in development)
3+
## Current Version (not yet released; still in development)
44

55
## Major Features and Improvements
66

@@ -10,7 +10,27 @@
1010

1111
## Deprecations
1212

13-
# Version 0.47.0
13+
## Version 0.48.0
14+
15+
## Major Features and Improvements
16+
17+
* N/A
18+
19+
## Bug Fixes and Other Changes
20+
21+
* Depends on `protobuf>=4.25.2,<6.0.0` for Python 3.11 and on `protobuf>=4.21.6,<6.0.0` for 3.9 and 3.10.
22+
* Depends on `tensorflow 2.17.1`.
23+
* macOS wheel publishing is temporarily paused due to missing ARM64 support.
24+
25+
## Breaking Changes
26+
27+
* N/A
28+
29+
## Deprecations
30+
31+
* N/A
32+
33+
## Version 0.47.0
1434

1535
## Major Features and Improvements
1636

@@ -30,7 +50,7 @@
3050

3151
* N/A
3252

33-
# Version 0.46.0
53+
## Version 0.46.0
3454

3555
## Major Features and Improvements
3656

@@ -53,7 +73,7 @@
5373

5474
* Deprecated python 3.8 support.
5575

56-
# Version 0.45.0
76+
## Version 0.45.0
5777

5878
## Major Features and Improvements
5979

@@ -73,7 +93,7 @@
7393

7494
* N/A
7595

76-
# Version 0.44.0
96+
## Version 0.44.0
7797

7898
## Major Features and Improvements
7999

@@ -93,7 +113,7 @@
93113

94114
* Deprecated python 3.7 support.
95115

96-
# Version 0.43.0
116+
## Version 0.43.0
97117

98118
## Major Features and Improvements
99119

@@ -111,7 +131,7 @@
111131

112132
* N/A
113133

114-
# Version 0.42.0
134+
## Version 0.42.0
115135

116136
## Major Features and Improvements
117137

@@ -130,7 +150,7 @@
130150

131151
* N/A
132152

133-
# Version 0.41.0
153+
## Version 0.41.0
134154

135155
## Major Features and Improvements
136156

@@ -149,7 +169,7 @@
149169

150170
* N/A
151171

152-
# Version 0.40.0
172+
## Version 0.40.0
153173

154174
## Major Features and Improvements
155175

@@ -170,7 +190,7 @@
170190

171191
* N/A
172192

173-
# Version 0.39.0
193+
## Version 0.39.0
174194

175195
## Major Features and Improvements
176196

@@ -188,7 +208,7 @@
188208

189209
* N/A
190210

191-
# Version 0.38.0
211+
## Version 0.38.0
192212

193213
## Major Features and Improvements
194214

@@ -208,7 +228,7 @@
208228

209229
* N/A
210230

211-
# Version 0.37.0
231+
## Version 0.37.0
212232

213233
## Major Features and Improvements
214234

@@ -226,7 +246,7 @@
226246

227247
* N/A
228248

229-
# Version 0.36.0
249+
## Version 0.36.0
230250

231251
## Major Features and Improvements
232252

@@ -245,7 +265,7 @@
245265

246266
* N/A
247267

248-
# Version 0.35.0
268+
## Version 0.35.0
249269

250270
## Major Features and Improvements
251271

@@ -263,7 +283,7 @@
263283

264284
* Deprecated python 3.6 support.
265285

266-
# Version 0.34.0
286+
## Version 0.34.0
267287

268288
## Major Features and Improvements
269289

examples/prensor_playground.ipynb

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

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ def select_constraint(default, nightly=None, git_master=None):
7979
# TODO(b/263060885): Remove the explicit numpy dependency once TF works
8080
# with numpy>=1.24.
8181
'numpy>=1.22',
82-
'protobuf>=4.25.2,<6;python_version>="3.11"',
83-
'protobuf>=3.20.3,<5;python_version<"3.11"',
84-
'tensorflow>=2.16,<2.17',
82+
'protobuf>=4.25.2,<6.0.0;python_version>="3.11"',
83+
'protobuf>=4.21.6,<6.0.0;python_version<"3.11"',
84+
'tensorflow>=2.17,<2.18',
8585
'tensorflow-metadata'
8686
+ select_constraint(
87-
default='>=1.16.1,<1.17.0',
88-
nightly='>=1.17.0.dev',
87+
default='>=1.17.0,<1.18.0',
88+
nightly='>=1.18.0.dev',
8989
git_master='@git+https://github.com/tensorflow/metadata@master',
9090
),
9191
'pyarrow>=10,<11',

struct2tensor/BUILD

Lines changed: 1 addition & 12 deletions
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")
@@ -37,7 +38,6 @@ s2t_pytype_library(
3738
srcs = [
3839
"__init__.py",
3940
],
40-
srcs_version = "PY3ONLY",
4141
deps = [
4242
":calculate_options",
4343
":expression",
@@ -55,7 +55,6 @@ s2t_pytype_library(
5555
srcs = [
5656
"expression_impl/__init__.py",
5757
],
58-
srcs_version = "PY2AND3",
5958
deps = [
6059
":calculate_options",
6160
":expression",
@@ -84,7 +83,6 @@ s2t_pytype_library(
8483
srcs = [
8584
"path.py",
8685
],
87-
srcs_version = "PY3ONLY",
8886
deps = [
8987
"@com_github_tensorflow_metadata//tensorflow_metadata/proto/v0:py_metadata_v0_proto_py",
9088
"@com_google_protobuf//:protobuf_python",
@@ -100,7 +98,6 @@ s2t_pytype_library(
10098
"prensor_util.py",
10199
"prensor_value.py",
102100
],
103-
srcs_version = "PY3ONLY",
104101
deps = [
105102
":calculate_options",
106103
":path",
@@ -117,7 +114,6 @@ s2t_pytype_library(
117114
srcs = [
118115
"calculate_options.py",
119116
],
120-
srcs_version = "PY3ONLY",
121117
)
122118

123119
# Note: do not separate these, as eventually we want to make sure that they
@@ -146,7 +142,6 @@ s2t_pytype_library(
146142
"expression_impl/size.py",
147143
"expression_impl/slice_expression.py",
148144
],
149-
srcs_version = "PY3ONLY",
150145
deps = [
151146
":calculate_options",
152147
":path",
@@ -163,7 +158,6 @@ s2t_pytype_library(
163158
srcs = [
164159
"expression_impl/map_prensor_to_prensor.py",
165160
],
166-
srcs_version = "PY3ONLY",
167161
deps = [
168162
":expression",
169163
":path",
@@ -176,7 +170,6 @@ s2t_pytype_library(
176170
srcs = [
177171
"expression_impl/placeholder.py",
178172
],
179-
srcs_version = "PY3ONLY",
180173
deps = [
181174
":expression",
182175
":map_prensor_to_prensor",
@@ -190,7 +183,6 @@ s2t_pytype_library(
190183
srcs = [
191184
"expression_impl/parquet.py",
192185
],
193-
srcs_version = "PY3ONLY",
194186
deps = [
195187
":expression",
196188
":map_prensor_to_prensor",
@@ -207,7 +199,6 @@ s2t_pytype_library(
207199
srcs = [
208200
"expression_impl/proto_test_util.py",
209201
],
210-
srcs_version = "PY3ONLY",
211202
deps = [
212203
":expression",
213204
"//struct2tensor/test:test_py_pb2",
@@ -220,7 +211,6 @@ s2t_pytype_library(
220211
srcs = [
221212
"prensor_to_structured_tensor.py",
222213
],
223-
srcs_version = "PY3ONLY",
224214
deps = [
225215
":path",
226216
":prensor",
@@ -232,7 +222,6 @@ s2t_pytype_library(
232222
srcs = [
233223
"structured_tensor_to_prensor.py",
234224
],
235-
srcs_version = "PY3ONLY",
236225
deps = [
237226
":path",
238227
":prensor",

struct2tensor/benchmarks/BUILD

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

15+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
16+
1517
# Placeholder: load py_proto_library
1618
# Placeholder: load py_binary
1719
# Placeholder: load py_library
1820
# Placeholder: load py_test
21+
load("//third_party/protobuf/bazel:proto_library.bzl", "proto_library")
1922
load("//tools/build_defs/proto/cpp:cc_proto_library.bzl", "cc_proto_library")
2023

2124
licenses(["notice"])
@@ -74,15 +77,13 @@ py_test(
7477
# Follow the instructions in the file to properly run the benchmark.
7578
args = ["--test_mode"],
7679
main = "struct2tensor_benchmark.py",
77-
python_version = "PY3",
7880
shard_count = 4,
7981
deps = [":struct2tensor_benchmark_lib"],
8082
)
8183

8284
py_binary(
8385
name = "struct2tensor_benchmark",
8486
srcs = ["struct2tensor_benchmark.py"],
85-
python_version = "PY3",
8687
deps = [
8788
":struct2tensor_benchmark_lib",
8889
],
@@ -95,15 +96,13 @@ py_test(
9596
# Follow the instructions in the file to properly run the benchmark.
9697
args = ["--test_mode"],
9798
main = "ops_benchmark.py",
98-
python_version = "PY3",
9999
# shard_count = 4,
100100
deps = [":struct2tensor_benchmark_lib"],
101101
)
102102

103103
py_binary(
104104
name = "ops_benchmark",
105105
srcs = ["ops_benchmark.py"],
106-
python_version = "PY3",
107106
deps = [
108107
":struct2tensor_benchmark_lib",
109108
],
@@ -112,7 +111,6 @@ py_binary(
112111
py_library(
113112
name = "struct2tensor_benchmark_util",
114113
srcs = ["struct2tensor_benchmark_util.py"],
115-
srcs_version = "PY3ONLY",
116114
deps = [
117115
"//file/colossus/public:cns",
118116
"//third_party/py/cpuinfo",

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/calculate_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,22 @@ def test_calculate_mock(self):
8989
self.assertIs(my_input._calculate_output, result)
9090

9191
def test_calculate_broken_mock_is_repeated(self):
92-
with self.assertRaisesRegexp(
92+
with self.assertRaisesRegex(
9393
ValueError,
9494
"Expression Node0 returned the wrong type: expected: repeated <dtype: "
95-
"'int64'> actual: optional <dtype: 'int64'>."):
95+
"'int64'> actual: optional <dtype: 'int64'>.",
96+
):
9697
single_node = expression_test_util.get_mock_broken_leaf(
9798
True, tf.int64, False, tf.int64, name="Node0")
9899
calculate.calculate_values([single_node])
99100

100101
def test_calculate_broken_mock_dtype(self):
101-
with self.assertRaisesRegexp(
102-
ValueError, "Expression Node0 returned the "
102+
with self.assertRaisesRegex(
103+
ValueError,
104+
"Expression Node0 returned the "
103105
"wrong type: expected: repeated <dtype: "
104-
"'int64'> actual: repeated <dtype: 'int32'>."):
106+
"'int64'> actual: repeated <dtype: 'int32'>.",
107+
):
105108
single_node = expression_test_util.get_mock_broken_leaf(
106109
True, tf.int64, True, tf.int32, name="Node0")
107110
calculate.calculate_values([single_node])

0 commit comments

Comments
 (0)