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
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
#

"""For internal use only; no backwards-compatibility guarantees."""

from __future__ import absolute_import
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/internal/gcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
#

"""For internal use only; no backwards-compatibility guarantees."""

from __future__ import absolute_import
6 changes: 4 additions & 2 deletions sdks/python/apache_beam/internal/gcp/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@

"""Dataflow credentials and authentication."""

from __future__ import absolute_import

import datetime
import json
import logging
import os

from future.moves.urllib.request import Request
from future.moves.urllib.request import urlopen
from oauth2client.client import GoogleCredentials
from oauth2client.client import OAuth2Credentials

from apache_beam.utils import retry
from six.moves.urllib.request import Request
from six.moves.urllib.request import urlopen

# When we are running in GCE, we can authenticate with VM credentials.
is_running_in_gce = False
Expand Down
19 changes: 13 additions & 6 deletions sdks/python/apache_beam/internal/gcp/json_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

"""JSON conversion utility functions."""

from __future__ import absolute_import

from apache_beam.options.value_provider import ValueProvider

# Protect against environments where apitools library is not available.
# pylint: disable=wrong-import-order, wrong-import-position
try:
Expand All @@ -25,9 +29,12 @@
extra_types = None
# pylint: enable=wrong-import-order, wrong-import-position

import six

from apache_beam.options.value_provider import ValueProvider
try: # Python 2
unicode # pylint: disable=unicode-builtin
long # pylint: disable=long-builtin
except NameError: # Python 3
unicode = str
long = int

_MAXINT64 = (1 << 63) - 1
_MININT64 = - (1 << 63)
Expand All @@ -49,7 +56,7 @@ def get_typed_value_descriptor(obj):
~exceptions.TypeError: if the Python object has a type that is not
supported.
"""
if isinstance(obj, six.string_types):
if isinstance(obj, (str, unicode)):
type_name = 'Text'
elif isinstance(obj, bool):
type_name = 'Boolean'
Expand Down Expand Up @@ -101,11 +108,11 @@ def to_json_value(obj, with_type=False):
return extra_types.JsonValue(object_value=json_object)
elif with_type:
return to_json_value(get_typed_value_descriptor(obj), with_type=False)
elif isinstance(obj, six.string_types):
elif isinstance(obj, (str, unicode)):
return extra_types.JsonValue(string_value=obj)
elif isinstance(obj, bool):
return extra_types.JsonValue(boolean_value=obj)
elif isinstance(obj, six.integer_types):
elif isinstance(obj, (int, long)):
if _MININT64 <= obj <= _MAXINT64:
return extra_types.JsonValue(integer_value=obj)
else:
Expand Down
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/internal/gcp/json_value_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

"""Unit tests for the json_value module."""

from __future__ import absolute_import

import unittest

from apache_beam.internal.gcp.json_value import from_json_value
Expand Down
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/internal/module_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

"""Module used to define functions and classes used by the coder unit tests."""

from __future__ import absolute_import

import re
from builtins import object


class TopClass(object):
Expand Down
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/internal/pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
the coders.*PickleCoder classes should be used instead.
"""

from __future__ import absolute_import

import base64
import logging
import sys
Expand Down
2 changes: 2 additions & 0 deletions sdks/python/apache_beam/internal/pickler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

"""Unit tests for the pickler module."""

from __future__ import absolute_import

import unittest

from apache_beam.internal import module_test
Expand Down
6 changes: 6 additions & 0 deletions sdks/python/apache_beam/internal/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
For internal use only. No backwards compatibility guarantees.
"""

from __future__ import absolute_import

import logging
import threading
import weakref
from builtins import object
from multiprocessing.pool import ThreadPool


Expand Down Expand Up @@ -51,6 +54,9 @@ def __eq__(self, other):
"""
return isinstance(other, ArgumentPlaceholder)

def __hash__(self):
return hash(type(self))


def remove_objects_from_args(args, kwargs, pvalue_classes):
"""For internal use only; no backwards-compatibility guarantees.
Expand Down
1 change: 1 addition & 0 deletions sdks/python/apache_beam/internal/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

"""Unit tests for the util module."""
from __future__ import absolute_import

import unittest

Expand Down
1 change: 1 addition & 0 deletions sdks/python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ deps =
flake8==3.5.0
modules =
apache_beam/coders
apache_beam/internal
apache_beam/metrics
commands =
python --version
Expand Down