You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by xq...@apache.org on 2024/11/27 00:05:49 UTC

(beam) branch master updated: Make the model names unique and fix the tox package deps for tensorflow tests (#33216)

This is an automated email from the ASF dual-hosted git repository.

xqhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a6c9028719 Make the model names unique and fix the tox package deps for tensorflow tests (#33216)
5a6c9028719 is described below

commit 5a6c90287198cc42fedf6d9623c8239d21f6ac74
Author: liferoad <hu...@gmail.com>
AuthorDate: Tue Nov 26 19:05:41 2024 -0500

    Make the model names unique and fix the tox package deps for tensorflow tests (#33216)
    
    * make the model names unique
    
    * fixed lint
    
    * pin keras==3.6.0
    
    * pin keras==2.12.0
    
    * pin tf_keras==2.18.0
    
    * pin tensorflow==2.18.0
    
    * use 1 worker for pytest
    
    * Fixed the tensorflow version
---
 .github/trigger_files/beam_PostCommit_Python_Dependency.json     | 4 ++++
 .../python/apache_beam/ml/inference/tensorflow_inference_test.py | 9 +++++----
 sdks/python/tox.ini                                              | 5 +++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/.github/trigger_files/beam_PostCommit_Python_Dependency.json b/.github/trigger_files/beam_PostCommit_Python_Dependency.json
index e69de29bb2d..a7fc54b3e4b 100644
--- a/.github/trigger_files/beam_PostCommit_Python_Dependency.json
+++ b/.github/trigger_files/beam_PostCommit_Python_Dependency.json
@@ -0,0 +1,4 @@
+{
+    "comment": "Modify this file in a trivial way to cause this test suite to run",
+    "modification": 1
+  }
\ No newline at end of file
diff --git a/sdks/python/apache_beam/ml/inference/tensorflow_inference_test.py b/sdks/python/apache_beam/ml/inference/tensorflow_inference_test.py
index 52123516de1..dc35aa01601 100644
--- a/sdks/python/apache_beam/ml/inference/tensorflow_inference_test.py
+++ b/sdks/python/apache_beam/ml/inference/tensorflow_inference_test.py
@@ -21,6 +21,7 @@ import os
 import shutil
 import tempfile
 import unittest
+import uuid
 from typing import Any
 from typing import Dict
 from typing import Iterable
@@ -127,7 +128,7 @@ class TFRunInferenceTest(unittest.TestCase):
 
   def test_predict_tensor_with_batch_size(self):
     model = _create_mult2_model()
-    model_path = os.path.join(self.tmpdir, 'mult2.keras')
+    model_path = os.path.join(self.tmpdir, f'mult2_{uuid.uuid4()}.keras')
     tf.keras.models.save_model(model, model_path)
     with TestPipeline() as pipeline:
 
@@ -173,7 +174,7 @@ class TFRunInferenceTest(unittest.TestCase):
 
   def test_predict_tensor_with_large_model(self):
     model = _create_mult2_model()
-    model_path = os.path.join(self.tmpdir, 'mult2.keras')
+    model_path = os.path.join(self.tmpdir, f'mult2_{uuid.uuid4()}.keras')
     tf.keras.models.save_model(model, model_path)
     with TestPipeline() as pipeline:
 
@@ -220,7 +221,7 @@ class TFRunInferenceTest(unittest.TestCase):
 
   def test_predict_numpy_with_batch_size(self):
     model = _create_mult2_model()
-    model_path = os.path.join(self.tmpdir, 'mult2_numpy.keras')
+    model_path = os.path.join(self.tmpdir, f'mult2_{uuid.uuid4()}.keras')
     tf.keras.models.save_model(model, model_path)
     with TestPipeline() as pipeline:
 
@@ -263,7 +264,7 @@ class TFRunInferenceTest(unittest.TestCase):
 
   def test_predict_numpy_with_large_model(self):
     model = _create_mult2_model()
-    model_path = os.path.join(self.tmpdir, 'mult2_numpy.keras')
+    model_path = os.path.join(self.tmpdir, f'mult2_{uuid.uuid4()}.keras')
     tf.keras.models.save_model(model, model_path)
     with TestPipeline() as pipeline:
 
diff --git a/sdks/python/tox.ini b/sdks/python/tox.ini
index 85f71e559c1..7a242432589 100644
--- a/sdks/python/tox.ini
+++ b/sdks/python/tox.ini
@@ -410,8 +410,9 @@ deps =
     tensorflow>=2.12rc1,<2.13
     # Help pip resolve conflict with typing-extensions for old version of TF https://github.com/apache/beam/issues/30852
     pydantic<2.7
-    protobuf==4.25.5
-extras = test,gcp,ml_test
+extras = test,gcp
+commands_pre =
+  pip install -U 'protobuf==4.25.5'
 commands =
   # Log tensorflow version for debugging
   /bin/sh -c "pip freeze | grep -E tensorflow"