From 2fc6e1cb06a4c8e95b037e8556a0c3e6682fe2c1 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 28 Aug 2024 20:14:14 +0100 Subject: [PATCH 1/3] Try deflaking test timing --- sdks/python/apache_beam/ml/inference/base_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/ml/inference/base_test.py b/sdks/python/apache_beam/ml/inference/base_test.py index 359a372bc5b0..00f6563d5f18 100644 --- a/sdks/python/apache_beam/ml/inference/base_test.py +++ b/sdks/python/apache_beam/ml/inference/base_test.py @@ -891,8 +891,8 @@ def test_run_inference_timeout_does_garbage_collection(self): with TestPipeline() as pipeline: # Start with bad example which gets timed out. # Then provide plenty of time for GC to happen. - examples = [20] + [1] * 15 - expected_good = [1] * 15 + examples = [20] + [1] * 60 + expected_good = [1] * 60 expected_bad = [20] pcoll = pipeline | 'start' >> beam.Create(examples) main, other = pcoll | base.RunInference( From fc2e1bbfbf38f3d7f9ef074517cd16ed8c36a2ac Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 28 Aug 2024 20:15:39 +0100 Subject: [PATCH 2/3] Add another potential timeout --- sdks/python/apache_beam/ml/inference/base_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdks/python/apache_beam/ml/inference/base_test.py b/sdks/python/apache_beam/ml/inference/base_test.py index 00f6563d5f18..cbe12443b314 100644 --- a/sdks/python/apache_beam/ml/inference/base_test.py +++ b/sdks/python/apache_beam/ml/inference/base_test.py @@ -891,9 +891,9 @@ def test_run_inference_timeout_does_garbage_collection(self): with TestPipeline() as pipeline: # Start with bad example which gets timed out. # Then provide plenty of time for GC to happen. - examples = [20] + [1] * 60 - expected_good = [1] * 60 - expected_bad = [20] + examples = [20] + [1] * 30 + [20] + expected_good = [1] * 30 + expected_bad = [20, 20] pcoll = pipeline | 'start' >> beam.Create(examples) main, other = pcoll | base.RunInference( FakeSlowModelHandler( From cbc792fbc89fb1ffec2c9fefec45d6a812588245 Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Wed, 28 Aug 2024 20:23:51 +0100 Subject: [PATCH 3/3] Simpler technique --- sdks/python/apache_beam/ml/inference/base_test.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sdks/python/apache_beam/ml/inference/base_test.py b/sdks/python/apache_beam/ml/inference/base_test.py index cbe12443b314..767721327842 100644 --- a/sdks/python/apache_beam/ml/inference/base_test.py +++ b/sdks/python/apache_beam/ml/inference/base_test.py @@ -887,13 +887,12 @@ def test_run_inference_timeout_not_hit(self): def test_run_inference_timeout_does_garbage_collection(self): with tempfile.TemporaryDirectory() as tmp_dirname: tmp_path = os.path.join(tmp_dirname, 'tmp_filename') - expected_file_contents = 'Deleted FakeSlowModel' with TestPipeline() as pipeline: # Start with bad example which gets timed out. # Then provide plenty of time for GC to happen. - examples = [20] + [1] * 30 + [20] - expected_good = [1] * 30 - expected_bad = [20, 20] + examples = [20] + [1] * 15 + [20, 20, 20] + expected_good = [1] * 15 + expected_bad = [20, 20, 20, 20] pcoll = pipeline | 'start' >> beam.Create(examples) main, other = pcoll | base.RunInference( FakeSlowModelHandler( @@ -910,7 +909,7 @@ def test_run_inference_timeout_does_garbage_collection(self): with open(tmp_path) as f: s = f.read() - self.assertEqual(s, expected_file_contents) + self.assertNotEqual(s, '') def test_run_inference_impl_inference_args(self): with TestPipeline() as pipeline: