Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bringing system test scripts up to date. #13

Merged
merged 5 commits into from
Sep 29, 2016
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: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pip-log.txt
# Unit test / coverage reports
.coverage
.tox
.cache

# Translations
*.mo
Expand All @@ -38,9 +39,12 @@ pip-log.txt
.project
.pydevproject

# JetBrains
.idea

# Built documentation
docs/_build
docs/_build_rtd
docs/_build_doc2dash

# Virtual environment
env/
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Quick Start
Authentication
--------------

With ``gcloud-python`` we try to make authentication as painless as possible.
Check out the `Authentication section`_ in our documentation to learn more.
You may also find the `authentication document`_ shared by all the ``gcloud-*``
libraries to be helpful.
With ``google-cloud-python`` we try to make authentication as painless as
possible. Check out the `Authentication section`_ in our documentation to
learn more. You may also find the `authentication document`_ shared by all
the ``google-cloud-*`` libraries to be helpful.

.. _Authentication section: http://gcloud-python.readthedocs.org/en/latest/gcloud-auth.html
.. _Authentication section: http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html
.. _authentication document: https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication

Contributing
Expand Down
8 changes: 4 additions & 4 deletions scripts/run_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def get_files_for_linting(allow_limited=True):
this value is not dependable.

To allow faster local ``tox`` runs, the environment variables
``GCLOUD_REMOTE_FOR_LINT`` and ``GCLOUD_BRANCH_FOR_LINT`` can be set to
specify a remote branch to diff against.
``GOOGLE_CLOUD_REMOTE_FOR_LINT`` and ``GOOGLE_CLOUD_BRANCH_FOR_LINT`` can
be set to specify a remote branch to diff against.

:type allow_limited: bool
:param allow_limited: Boolean indicating if a reduced set of files can
Expand All @@ -160,8 +160,8 @@ def get_files_for_linting(allow_limited=True):
diff_base = 'origin/master'
elif os.getenv('TRAVIS') is None:
# Only allow specified remote and branch in local dev.
remote = os.getenv('GCLOUD_REMOTE_FOR_LINT')
branch = os.getenv('GCLOUD_BRANCH_FOR_LINT')
remote = os.getenv('GOOGLE_CLOUD_REMOTE_FOR_LINT')
branch = os.getenv('GOOGLE_CLOUD_BRANCH_FOR_LINT')
if remote is not None and branch is not None:
diff_base = '%s/%s' % (remote, branch)

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1
67 changes: 39 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,59 @@

import os

from setuptools import setup
from setuptools import find_packages
from setuptools import setup


here = os.path.abspath(os.path.dirname(__file__))
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))

with open(os.path.join(PACKAGE_ROOT, 'README.rst')) as file_obj:
README = file_obj.read()

with open(os.path.join(here, 'README.rst')) as f:
README = f.read()
# NOTE: This is duplicated throughout and we should try to
# consolidate.
SETUP_BASE = {
'author': 'Google Cloud Platform',
'author_email': 'jjg+google-cloud-python@google.com',
'scripts': [],
'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python',
'license': 'Apache 2.0',
'platforms': 'Posix; MacOS X; Windows',
'include_package_data': True,
'zip_safe': False,
'classifiers': [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet',
],
}


REQUIREMENTS = [
'gcloud',
'grpcio >= 1.0.0, < 2.0dev',
'google-cloud-bigtable >= 0.20.0',
]

SETUP_BASE.pop('url')

setup(
name='google-cloud-happybase',
version='0.19.0',
description='API Client library for Google Cloud Happybase layer',
author='Google Cloud Platform',
author_email='jjg+gcloud-python@google.com',
description='Client library for Google Cloud Bigtable: HappyBase layer',
long_description=README,
scripts=[],
url='https://github.com/GoogleCloudPlatform/gcloud-python',
license='Apache 2.0',
platforms='Posix; MacOS X; Windows',
url='https://github.com/GoogleCloudPlatform/google-cloud-python-happybase',
namespace_packages=[
'google',
'google.cloud',
],
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['google', 'google.cloud'],
include_package_data=True,
zip_safe=False,
install_requires=REQUIREMENTS,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Topic :: Internet',
]
**SETUP_BASE
)
6 changes: 3 additions & 3 deletions src/google/cloud/happybase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

.. code:: python

from gcloud.bigtable.client import Client
from google.cloud.bigtable.client import Client
client = Client(project=PROJECT_ID, admin=True)
instance = client.instance(instance_id, location_id)
instance.reload()
Expand Down Expand Up @@ -125,9 +125,9 @@

Only ``max_versions`` and ``time_to_live`` are availabe in Cloud Bigtable
(as
:class:`MaxVersionsGCRule <gcloud.bigtable.column_family.MaxVersionsGCRule>`
:class:`~google.cloud.bigtable.column_family.MaxVersionsGCRule`
and
:class:`MaxAgeGCRule <gcloud.bigtable.column_family.MaxAgeGCRule>`).
:class:`~google.cloud.bigtable.column_family.MaxAgeGCRule`).

In addition to using a dictionary for specifying column family options,
we also accept instances of :class:`.GarbageCollectionRule` or subclasses.
Expand Down
8 changes: 4 additions & 4 deletions src/google/cloud/happybase/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import six

from gcloud._helpers import _datetime_from_microseconds
from gcloud.bigtable.row_filters import TimestampRange
from google.cloud._helpers import _datetime_from_microseconds
from google.cloud.bigtable.row_filters import TimestampRange


_WAL_SENTINEL = object()
Expand Down Expand Up @@ -129,7 +129,7 @@ def _get_row(self, row_key):
:type row_key: str
:param row_key: The row key for a row stored in the map.

:rtype: :class:`Row <gcloud.bigtable.row.Row>`
:rtype: :class:`~google.cloud.bigtable.row.Row`
:returns: The newly created or stored row that will hold mutations.
"""
if row_key not in self._row_map:
Expand Down Expand Up @@ -181,7 +181,7 @@ def _delete_columns(self, columns, row_object):
* an entire column family: ``fam`` or ``fam:``
* a single column: ``fam:col``

:type row_object: :class:`Row <gcloud_bigtable.row.Row>`
:type row_object: :class:`~google.cloud.bigtable.row.Row`
:param row_object: The row which will hold the delete mutations.

:raises: :class:`ValueError <exceptions.ValueError>` if the delete
Expand Down
48 changes: 16 additions & 32 deletions src/google/cloud/happybase/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
try:
from happybase.hbase.ttypes import AlreadyExists
except ImportError:
from gcloud.exceptions import Conflict as AlreadyExists
from google.cloud.exceptions import Conflict as AlreadyExists

from gcloud.bigtable.client import Client
from gcloud.bigtable.column_family import GCRuleIntersection
from gcloud.bigtable.column_family import MaxAgeGCRule
from gcloud.bigtable.column_family import MaxVersionsGCRule
from gcloud.bigtable.table import Table as _LowLevelTable
from google.cloud.bigtable.client import Client
from google.cloud.bigtable.column_family import GCRuleIntersection
from google.cloud.bigtable.column_family import MaxAgeGCRule
from google.cloud.bigtable.column_family import MaxVersionsGCRule
from google.cloud.bigtable.table import Table as _LowLevelTable

from google.cloud.happybase.table import Table

Expand Down Expand Up @@ -75,7 +75,7 @@ def _get_instance(timeout=None):
:type timeout: int
:param timeout: (Optional) The socket timeout in milliseconds.

:rtype: :class:`gcloud.bigtable.instance.Instance`
:rtype: :class:`~google.cloud.bigtable.instance.Instance`
:returns: The unique instance owned by the project inferred from
the environment.
:raises ValueError: if there is a failed location or any number of
Expand All @@ -85,11 +85,7 @@ def _get_instance(timeout=None):
if timeout is not None:
client_kwargs['timeout_seconds'] = timeout / 1000.0
client = Client(**client_kwargs)
try:
client.start()
instances, failed_locations = client.list_instances()
finally:
client.stop()
instances, failed_locations = client.list_instances()

if len(failed_locations) != 0:
raise ValueError('Determining instance via ListInstances encountered '
Expand All @@ -110,9 +106,9 @@ class Connection(object):

If you pass a ``instance``, it will be :meth:`.Instance.copy`-ed before
being stored on the new connection. This also copies the
:class:`Client <gcloud.bigtable.client.Client>` that created the
:class:`Instance <gcloud.bigtable.instance.Instance>` instance and the
:class:`Credentials <oauth2client.client.Credentials>` stored on the
:class:`~google.cloud.bigtable.client.Client` that created the
:class:`~google.cloud.bigtable.instance.Instance` instance and the
:class:`~oauth2client.client.Credentials` stored on the
client.

The arguments ``host``, ``port``, ``compat``, ``transport`` and
Expand All @@ -134,13 +130,13 @@ class Connection(object):
:param table_prefix_separator: (Optional) Separator used with
``table_prefix``. Defaults to ``_``.

:type instance: :class:`Instance <gcloud.bigtable.instance.Instance>`
:type instance: :class:`~google.cloud.bigtable.instance.Instance`
:param instance: (Optional) A Cloud Bigtable instance. The instance also
owns a client for making gRPC requests to the Cloud
Bigtable API. If not passed in, defaults to creating client
with ``admin=True`` and using the ``timeout`` here for the
``timeout_seconds`` argument to the
:class:`Client <gcloud.bigtable.client.Client>`
:class:`~google.cloud.bigtable.client.Client`
constructor. The credentials for the client
will be the implicit ones loaded from the environment.
Then that client is used to retrieve all the instances
Expand Down Expand Up @@ -196,7 +192,7 @@ def _handle_legacy_args(arguments_dict):
if common_args:
all_args = ', '.join(common_args)
message = ('The HappyBase legacy arguments %s were used. These '
'arguments are unused by gcloud.' % (all_args,))
'arguments are unused by google-cloud.' % (all_args,))
_WARN(message)
for arg_name in common_args:
arguments_dict.pop(arg_name)
Expand All @@ -207,26 +203,14 @@ def _handle_legacy_args(arguments_dict):
def open(self):
"""Open the underlying transport to Cloud Bigtable.

This method opens the underlying HTTP/2 gRPC connection using a
:class:`Client <gcloud.bigtable.client.Client>` bound to the
:class:`Instance <gcloud.bigtable.instance.Instance>` owned by
this connection.
This method does nothing and is provided for compatibility.
"""
self._instance._client.start()

def close(self):
"""Close the underlying transport to Cloud Bigtable.

This method closes the underlying HTTP/2 gRPC connection using a
:class:`Client <gcloud.bigtable.client.Client>` bound to the
:class:`Instance <gcloud.bigtable.instance.Instance>` owned by
this connection.
This method does nothing and is provided for compatibility.
"""
self._instance._client.stop()

def __del__(self):
if self._instance is not None:
self.close()

def _table_name(self, name):
"""Construct a table name by optionally adding a table name prefix.
Expand Down
3 changes: 1 addition & 2 deletions src/google/cloud/happybase/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ def connection(self, timeout=None):
with self._lock:
self._thread_connections.current = connection

# This is a no-op for connections that have already been opened
# since they just call Client.start().
# This is a no-op.
connection.open()
yield connection

Expand Down
Loading