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

bhulette 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 9af555d  [BEAM-12490] Fixed test_harness_monitoring_infos_and_metadata 
precommit error (#15033)
9af555d is described below

commit 9af555d9ccdb0d7a378dbea456cdeefe2e781d6d
Author: roger-mike <[email protected]>
AuthorDate: Fri Jun 18 11:03:32 2021 -0500

    [BEAM-12490] Fixed test_harness_monitoring_infos_and_metadata precommit 
error (#15033)
---
 sdks/python/apache_beam/io/gcp/gcsio.py      |  4 ++--
 sdks/python/apache_beam/io/gcp/gcsio_test.py | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/sdks/python/apache_beam/io/gcp/gcsio.py 
b/sdks/python/apache_beam/io/gcp/gcsio.py
index 344fa4c..b9fb15f 100644
--- a/sdks/python/apache_beam/io/gcp/gcsio.py
+++ b/sdks/python/apache_beam/io/gcp/gcsio.py
@@ -591,7 +591,7 @@ class GcsDownloader(Downloader):
         monitoring_infos.METHOD_LABEL: 'Objects.get',
         monitoring_infos.RESOURCE_LABEL: resource,
         monitoring_infos.GCS_BUCKET_LABEL: self._bucket,
-        monitoring_infos.GCS_PROJECT_ID_LABEL: project_number
+        monitoring_infos.GCS_PROJECT_ID_LABEL: str(project_number)
     }
     service_call_metric = ServiceCallMetric(
         request_count_urn=monitoring_infos.API_REQUEST_COUNT_URN,
@@ -697,7 +697,7 @@ class GcsUploader(Uploader):
         monitoring_infos.METHOD_LABEL: 'Objects.insert',
         monitoring_infos.RESOURCE_LABEL: resource,
         monitoring_infos.GCS_BUCKET_LABEL: self._bucket,
-        monitoring_infos.GCS_PROJECT_ID_LABEL: project_number
+        monitoring_infos.GCS_PROJECT_ID_LABEL: str(project_number)
     }
     service_call_metric = ServiceCallMetric(
         request_count_urn=monitoring_infos.API_REQUEST_COUNT_URN,
diff --git a/sdks/python/apache_beam/io/gcp/gcsio_test.py 
b/sdks/python/apache_beam/io/gcp/gcsio_test.py
index 3df9355..06a98b1 100644
--- a/sdks/python/apache_beam/io/gcp/gcsio_test.py
+++ b/sdks/python/apache_beam/io/gcp/gcsio_test.py
@@ -769,6 +769,9 @@ class TestGCSIO(unittest.TestCase):
     self.assertEqual(test_msg.encode('ascii'), output_buffer.getvalue())
 
   def test_downloader_monitoring_info(self):
+    # Clear the process wide metric container.
+    MetricsEnvironment.process_wide_container().reset()
+
     file_name = 'gs://gcsio-metrics-test/dummy_mode_file'
     file_size = 5 * 1024 * 1024 + 100
     random_file = self._insert_random_file(self.client, file_name, file_size)
@@ -780,7 +783,7 @@ class TestGCSIO(unittest.TestCase):
         monitoring_infos.METHOD_LABEL: 'Objects.get',
         monitoring_infos.RESOURCE_LABEL: resource,
         monitoring_infos.GCS_BUCKET_LABEL: random_file.bucket,
-        monitoring_infos.GCS_PROJECT_ID_LABEL: DEFAULT_PROJECT_NUMBER,
+        monitoring_infos.GCS_PROJECT_ID_LABEL: str(DEFAULT_PROJECT_NUMBER),
         monitoring_infos.STATUS_LABEL: 'ok'
     }
 
@@ -792,6 +795,9 @@ class TestGCSIO(unittest.TestCase):
     self.assertEqual(metric_value, 2)
 
   def test_uploader_monitoring_info(self):
+    # Clear the process wide metric container.
+    MetricsEnvironment.process_wide_container().reset()
+
     file_name = 'gs://gcsio-metrics-test/dummy_mode_file'
     file_size = 5 * 1024 * 1024 + 100
     random_file = self._insert_random_file(self.client, file_name, file_size)
@@ -803,7 +809,7 @@ class TestGCSIO(unittest.TestCase):
         monitoring_infos.METHOD_LABEL: 'Objects.insert',
         monitoring_infos.RESOURCE_LABEL: resource,
         monitoring_infos.GCS_BUCKET_LABEL: random_file.bucket,
-        monitoring_infos.GCS_PROJECT_ID_LABEL: DEFAULT_PROJECT_NUMBER,
+        monitoring_infos.GCS_PROJECT_ID_LABEL: str(DEFAULT_PROJECT_NUMBER),
         monitoring_infos.STATUS_LABEL: 'ok'
     }
 

Reply via email to