Skip to content

Commit 710ef75

Browse files
authored
fixed protobuf version mismatch error on cloudbuild (#6737)
1 parent cbfe2bb commit 710ef75

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

tfjs-converter/python/.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ max-public-methods=20
412412
max-returns=6
413413

414414
# Maximum number of statements in function / method body
415-
max-statements=50
415+
max-statements=80
416416

417417
# Minimum number of public methods for a class (see R0903).
418418
min-public-methods=2

tfjs-converter/python/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ py_wheel(
4848
license = "Apache 2.0",
4949
python_tag = "py3",
5050
requires = [
51+
"protobuf<3.20,>=3.9.2",
5152
"tensorflow>=2.1.0,<3",
5253
"six>=1.12.0,<2",
5354
"tensorflow-hub>=0.7.0,<0.13",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
protobuf<3.20,>=3.9.2
12
tensorflow>=2.1.0,<3
2-
numpy~=1.19.2
33
six>=1.12.0,<2
44
tensorflow-hub>=0.7.0,<0.13; python_version >= "3"
55
packaging~=20.9

tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def _convert_tf_saved_model(output_dir,
637637
num_outputs = len(output_node_names)
638638
structured_outputs = concrete_func.structured_outputs
639639
if use_structured_outputs_names and structured_outputs is not None:
640-
if type(structured_outputs) is not dict:
640+
if not isinstance(structured_outputs, dict):
641641
raise Exception('Converter only supports dict structured_outputs.')
642642

643643
# As per tensorflow/python/util/nest.py: "If `structure` is or contains a
@@ -649,7 +649,8 @@ def _convert_tf_saved_model(output_dir,
649649
# We don't support anything more complex due to the GraphModel.predict
650650
# function return type in typescript.
651651
test_sequence = list(range(num_outputs))
652-
actual_structure = tf.nest.pack_sequence_as(structured_outputs, test_sequence, True)
652+
actual_structure = tf.nest.pack_sequence_as(
653+
structured_outputs, test_sequence, True)
653654
expected_structure = dict(zip(sorted_keys, test_sequence))
654655
if actual_structure != expected_structure:
655656
raise Exception('Converter only supports structured_outputs of form '
@@ -812,7 +813,7 @@ def convert_tf_saved_model(saved_model_dir,
812813
skip_op_check=skip_op_check,
813814
strip_debug_ops=strip_debug_ops,
814815
use_structured_outputs_names=
815-
use_structured_outputs_names,
816+
use_structured_outputs_names,
816817
weight_shard_size_bytes=weight_shard_size_bytes,
817818
control_flow_v2=control_flow_v2,
818819
experiments=experiments,
@@ -999,7 +1000,7 @@ def convert_tf_hub_module(module_handle, output_dir,
9991000
skip_op_check=skip_op_check,
10001001
strip_debug_ops=strip_debug_ops,
10011002
use_structured_outputs_names=
1002-
use_structured_outputs_names,
1003+
use_structured_outputs_names,
10031004
weight_shard_size_bytes=weight_shard_size_bytes,
10041005
control_flow_v2=control_flow_v2,
10051006
experiments=experiments,
@@ -1044,7 +1045,7 @@ def convert_keras_model_to_graph_model(keras_model,
10441045
skip_op_check=skip_op_check,
10451046
strip_debug_ops=strip_debug_ops,
10461047
use_structured_outputs_names=
1047-
use_structured_outputs_names,
1048+
use_structured_outputs_names,
10481049
weight_shard_size_bytes=weight_shard_size_bytes,
10491050
control_flow_v2=control_flow_v2,
10501051
experiments=experiments,

tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@ def create_input(name):
274274
output3 = tf.keras.layers.Multiply(name='c')([output1, output2])
275275

276276
inputs = {
277-
"input1": input1,
278-
"input3": input3,
279-
"input2": input2
277+
"input1": input1,
278+
"input3": input3,
279+
"input2": input2
280280
}
281281

282282
outputs = {
283-
"a": output1,
284-
"c": output3,
285-
"b": output2
283+
"a": output1,
284+
"c": output3,
285+
"b": output2
286286
}
287287

288288
model = tf.keras.Model(inputs=inputs, outputs=outputs)
@@ -933,7 +933,8 @@ def test_convert_saved_model_structured_outputs_true(self):
933933
self.assertIsNot(signature['inputs'], None)
934934
self.assertIsNot(signature['outputs'], None)
935935

936-
self.assertEqual(["a", "b", "c"], model_json['userDefinedMetadata']['structuredOutputKeys'])
936+
self.assertEqual(["a", "b", "c"],
937+
model_json['userDefinedMetadata']['structuredOutputKeys'])
937938

938939
def test_convert_saved_model_structured_outputs_false(self):
939940
self._create_saved_model_with_structured_outputs()

tfjs-converter/python/tensorflowjs/resource_loader_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def testListingFilesInOpList(self):
2929
files = resource_loader.list_dir('op_list')
3030
self.assertGreater(len(files), 0)
3131
for filename in files:
32-
self.assertTrue(filename.endswith('.json'))
32+
self.assertTrue(filename == 'BUILD' or filename.endswith('.json'))
3333

3434
def testReadingFileInOpList(self):
3535
file_path = path.join('op_list', 'arithmetic.json')

0 commit comments

Comments
 (0)