beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [beam] branch master updated: Label Dataflow jobs with SDK name including Python major / minor version
Date Fri, 08 Feb 2019 02:15:12 GMT
This is an automated email from the ASF dual-hosted git repository.

altay 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 302e7f7  Label Dataflow jobs with SDK name including Python major / minor version
     new af8c400  Merge pull request #7778 from charlesccychen/python-version-tag
302e7f7 is described below

commit 302e7f74810bda0bf03282548e434e17d9bd052b
Author: Charles Chen <ccy@google.com>
AuthorDate: Thu Feb 7 13:19:41 2019 -0800

    Label Dataflow jobs with SDK name including Python major / minor version
---
 .../apache_beam/runners/dataflow/internal/apiclient.py      |  6 +++++-
 .../apache_beam/runners/dataflow/internal/apiclient_test.py | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py
index 8bcfbe1..a1873ea 100644
--- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py
+++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient.py
@@ -154,7 +154,7 @@ class Environment(object):
     self.proto.userAgent.additionalProperties.extend([
         dataflow.Environment.UserAgentValue.AdditionalProperty(
             key='name',
-            value=to_json_value(shared_names.BEAM_SDK_NAME)),
+            value=to_json_value(self._get_python_sdk_name())),
         dataflow.Environment.UserAgentValue.AdditionalProperty(
             key='version', value=to_json_value(beam_version.__version__))])
     # Version information.
@@ -280,6 +280,10 @@ class Environment(object):
           dataflow.Environment.SdkPipelineOptionsValue.AdditionalProperty(
               key='display_data', value=to_json_value(items)))
 
+  def _get_python_sdk_name(self):
+    python_version = '%d.%d' % (sys.version_info[0], sys.version_info[1])
+    return 'Apache Beam Python %s SDK' % python_version
+
 
 class Job(object):
   """Wrapper for a dataflow Job protobuf."""
diff --git a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py
index 6614ab1..ac66fc6 100644
--- a/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py
+++ b/sdks/python/apache_beam/runners/dataflow/internal/apiclient_test.py
@@ -384,6 +384,19 @@ class UtilTest(unittest.TestCase):
     self.assertNotIn(
         "use_multiple_sdk_containers", environment.proto.experiments)
 
+  @mock.patch('apache_beam.runners.dataflow.internal.apiclient.sys')
+  def test_get_python_sdk_name(self, mock_sys):
+    pipeline_options = PipelineOptions(
+        ['--project', 'test_project', '--job_name', 'test_job_name',
+         '--temp_location', 'gs://test-location/temp',
+         '--experiments', 'beam_fn_api',
+         '--experiments', 'use_multiple_sdk_containers'])
+    environment = apiclient.Environment(
+        [], pipeline_options, 1, FAKE_PIPELINE_URL)
+    mock_sys.version_info = [22, 333]
+    self.assertEqual('Apache Beam Python 22.333 SDK',
+                     environment._get_python_sdk_name())
+
 
 if __name__ == '__main__':
   unittest.main()


Mime
View raw message