From 8a7bc71dee1e3f9f17c29e5e558870a6bc5f4880 Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Mon, 25 Jul 2016 18:22:08 -0700 Subject: [PATCH 1/2] Fix SDK name and version sent to the Cloud Dataflow service --- sdks/python/apache_beam/internal/apiclient.py | 6 +++--- sdks/python/apache_beam/utils/dependency.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sdks/python/apache_beam/internal/apiclient.py b/sdks/python/apache_beam/internal/apiclient.py index 363b8e152e1c..137a40b5be37 100644 --- a/sdks/python/apache_beam/internal/apiclient.py +++ b/sdks/python/apache_beam/internal/apiclient.py @@ -29,7 +29,6 @@ from apitools.base.py import exceptions from apache_beam import utils -from apache_beam import version from apache_beam.internal import pickler from apache_beam.internal.auth import get_service_credentials from apache_beam.internal.json_value import to_json_value @@ -39,6 +38,7 @@ from apache_beam.utils import names from apache_beam.utils import retry from apache_beam.utils.dependency import get_required_container_version +from apache_beam.utils.dependency import get_sdk_name_and_version from apache_beam.utils.names import PropertyNames from apache_beam.utils.options import GoogleCloudOptions from apache_beam.utils.options import StandardOptions @@ -191,12 +191,12 @@ def __init__(self, packages, options, environment_version): self.proto.userAgent = dataflow.Environment.UserAgentValue() self.local = 'localhost' in self.google_cloud_options.dataflow_endpoint - version_string = version.__version__ + sdk_name, version_string = get_sdk_name_and_version() self.proto.userAgent.additionalProperties.extend([ dataflow.Environment.UserAgentValue.AdditionalProperty( key='name', - value=to_json_value('Google Cloud Dataflow SDK for Python')), + value=to_json_value(sdk_name)), dataflow.Environment.UserAgentValue.AdditionalProperty( key='version', value=to_json_value(version_string))]) # Version information. diff --git a/sdks/python/apache_beam/utils/dependency.py b/sdks/python/apache_beam/utils/dependency.py index b809cf2eae7b..d8e00366e60e 100644 --- a/sdks/python/apache_beam/utils/dependency.py +++ b/sdks/python/apache_beam/utils/dependency.py @@ -59,6 +59,7 @@ from apache_beam import utils +from apache_beam import version as beam_version from apache_beam.internal import pickler from apache_beam.utils import names from apache_beam.utils import processes @@ -437,6 +438,16 @@ def get_required_container_version(): return 'beamhead' +def get_sdk_name_and_version(): + """Returns the name and version of the SDK reported to Cloud Dataflow.""" + # TODO(ccy): Make this check cleaner. + container_version = get_required_container_version() + if container_version == 'beamhead': + return ('Apache Beam SDK for Python', beam_version.__version__) + else: + return ('Google Cloud Dataflow SDK for Python', container_version) + + def _download_pypi_sdk_package(temp_dir): """Downloads SDK package from PyPI and returns path to local path.""" # TODO(silviuc): Handle apache-beam versions when we have official releases. From 76f3864b61ad9e2ac9a2e81e7a0d5993db5fde6c Mon Sep 17 00:00:00 2001 From: Charles Chen Date: Mon, 25 Jul 2016 18:36:45 -0700 Subject: [PATCH 2/2] Update docstring. --- sdks/python/apache_beam/utils/dependency.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/utils/dependency.py b/sdks/python/apache_beam/utils/dependency.py index d8e00366e60e..7d1ae4194c68 100644 --- a/sdks/python/apache_beam/utils/dependency.py +++ b/sdks/python/apache_beam/utils/dependency.py @@ -1,3 +1,4 @@ + # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -439,7 +440,7 @@ def get_required_container_version(): def get_sdk_name_and_version(): - """Returns the name and version of the SDK reported to Cloud Dataflow.""" + """Returns name and version of SDK reported to Google Cloud Dataflow.""" # TODO(ccy): Make this check cleaner. container_version = get_required_container_version() if container_version == 'beamhead':