Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdks/python/apache_beam/internal/apiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions sdks/python/apache_beam/utils/dependency.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -59,6 +60,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
Expand Down Expand Up @@ -437,6 +439,16 @@ def get_required_container_version():
return 'beamhead'


def get_sdk_name_and_version():
"""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':
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.
Expand Down