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 scripts/ up to date with upstream. #14

Merged
merged 6 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Upgrading from gcloud to google-cloud-bigtable.
In the process, also renaming all instances of gcloud.
  • Loading branch information
dhermes committed Sep 29, 2016
commit bc9e924b3fb7145ab2c858997e4c3526f37c0d55
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
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
34 changes: 17 additions & 17 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 Down Expand Up @@ -110,9 +110,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 +134,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 +196,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 @@ -208,8 +208,8 @@ 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
:class:`~google.cloud.bigtable.client.Client` bound to the
:class:`~google.cloud.bigtable.instance.Instance` owned by
this connection.
"""
self._instance._client.start()
Expand All @@ -218,8 +218,8 @@ 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
:class:`~google.cloud.bigtable.client.Client` bound to the
:class:`~google.cloud.bigtable.instance.Instance` owned by
this connection.
"""
self._instance._client.stop()
Expand Down
69 changes: 35 additions & 34 deletions src/google/cloud/happybase/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@

import six

from gcloud._helpers import _datetime_from_microseconds
from gcloud._helpers import _microseconds_from_datetime
from gcloud._helpers import _to_bytes
from gcloud.bigtable.column_family import GCRuleIntersection
from gcloud.bigtable.column_family import MaxAgeGCRule
from gcloud.bigtable.column_family import MaxVersionsGCRule
from gcloud.bigtable.row_filters import CellsColumnLimitFilter
from gcloud.bigtable.row_filters import ColumnQualifierRegexFilter
from gcloud.bigtable.row_filters import FamilyNameRegexFilter
from gcloud.bigtable.row_filters import RowFilterChain
from gcloud.bigtable.row_filters import RowFilterUnion
from gcloud.bigtable.row_filters import RowKeyRegexFilter
from gcloud.bigtable.row_filters import TimestampRange
from gcloud.bigtable.row_filters import TimestampRangeFilter
from gcloud.bigtable.table import Table as _LowLevelTable
from google.cloud._helpers import _datetime_from_microseconds
from google.cloud._helpers import _microseconds_from_datetime
from google.cloud._helpers import _to_bytes
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.row_filters import CellsColumnLimitFilter
from google.cloud.bigtable.row_filters import ColumnQualifierRegexFilter
from google.cloud.bigtable.row_filters import FamilyNameRegexFilter
from google.cloud.bigtable.row_filters import RowFilterChain
from google.cloud.bigtable.row_filters import RowFilterUnion
from google.cloud.bigtable.row_filters import RowKeyRegexFilter
from google.cloud.bigtable.row_filters import TimestampRange
from google.cloud.bigtable.row_filters import TimestampRangeFilter
from google.cloud.bigtable.table import Table as _LowLevelTable

from google.cloud.happybase.batch import _get_column_pairs
from google.cloud.happybase.batch import _WAL_SENTINEL
Expand Down Expand Up @@ -320,7 +320,7 @@ def scan(self, row_start=None, row_stop=None, row_prefix=None,
used this as an HBase filter string. (See the `Thrift docs`_ for more
details on those filters.) However, Google Cloud Bigtable doesn't
support those filter strings so a
:class:`~gcloud.bigtable.row.RowFilter` should be used instead.
:class:`~google.cloud.bigtable.row.RowFilter` should be used instead.

.. _Thrift docs: http://hbase.apache.org/0.94/book/thrift.html

Expand Down Expand Up @@ -498,7 +498,7 @@ def batch(self, timestamp=None, batch_size=None, transaction=False,
for Cloud Bigtable since it does not have a Write Ahead
Log.

:rtype: :class:`Batch <gcloud.bigtable.happybase.batch.Batch>`
:rtype: :class:`~google.cloud.bigtable.happybase.batch.Batch`
:returns: A batch bound to this table.
"""
return Batch(self, timestamp=timestamp, batch_size=batch_size,
Expand Down Expand Up @@ -631,12 +631,13 @@ def _gc_rule_to_dict(gc_rule):

Only does this if the garbage collection rule is:

* :class:`gcloud.bigtable.column_family.MaxAgeGCRule`
* :class:`gcloud.bigtable.column_family.MaxVersionsGCRule`
* Composite :class:`gcloud.bigtable.column_family.GCRuleIntersection`
* :class:`~google.cloud.bigtable.column_family.MaxAgeGCRule`
* :class:`~google.cloud.bigtable.column_family.MaxVersionsGCRule`
* Composite
:class:`~google.cloud.bigtable.column_family.GCRuleIntersection`
with two rules, one each of type
:class:`gcloud.bigtable.column_family.MaxAgeGCRule` and
:class:`gcloud.bigtable.column_family.MaxVersionsGCRule`
:class:`~google.cloud.bigtable.column_family.MaxAgeGCRule` and
:class:`~google.cloud.bigtable.column_family.MaxVersionsGCRule`

Otherwise, just returns the input without change.

Expand All @@ -646,7 +647,7 @@ def _gc_rule_to_dict(gc_rule):
(if possible).

:rtype: dict or
:class:`gcloud.bigtable.column_family.GarbageCollectionRule`
:class:`~google.cloud.bigtable.column_family.GarbageCollectionRule`
:returns: The converted garbage collection rule.
"""
result = gc_rule
Expand Down Expand Up @@ -693,7 +694,7 @@ def _string_successor(str_val):
Determines shortest string that sorts after the given string when
compared using regular string comparison semantics.

Modeled after implementation in ``gcloud-golang``.
Modeled after implementation in ``google-cloud-go``.

Increments the last byte that is smaller than ``0xFF``, and
drops everything after it. If the string only contains ``0xFF`` bytes,
Expand Down Expand Up @@ -733,7 +734,7 @@ def _convert_to_time_range(timestamp=None):
epoch). Intended to be used as the end of an HBase
time range, which is exclusive.

:rtype: :class:`gcloud.bigtable.row.TimestampRange`,
:rtype: :class:`~google.cloud.bigtable.row.TimestampRange`,
:data:`NoneType <types.NoneType>`
:returns: The timestamp range corresponding to the passed in
``timestamp``.
Expand All @@ -751,7 +752,7 @@ def _cells_to_pairs(cells, include_timestamp=False):
For example::

>>> import datetime
>>> from gcloud.bigtable.row_data import Cell
>>> from google.cloud.bigtable.row_data import Cell
>>> cell1 = Cell(b'val1', datetime.datetime.utcnow())
>>> cell2 = Cell(b'val2', datetime.datetime.utcnow())
>>> _cells_to_pairs([cell1, cell2])
Expand All @@ -760,8 +761,8 @@ def _cells_to_pairs(cells, include_timestamp=False):
[(b'val1', 1456361486255), (b'val2', 1456361491927)]

:type cells: list
:param cells: List of :class:`gcloud.bigtable.row_data.Cell` returned
from a read request.
:param cells: List of :class:`~google.cloud.bigtable.row_data.Cell`
returned from a read request.

:type include_timestamp: bool
:param include_timestamp: Flag to indicate if cell timestamps should be
Expand Down Expand Up @@ -793,7 +794,7 @@ def _partial_row_to_dict(partial_row_data, include_timestamp=False):
For example::

>>> import datetime
>>> from gcloud.bigtable.row_data import Cell, PartialRowData
>>> from google.cloud.bigtable.row_data import Cell, PartialRowData
>>> cell1 = Cell(b'val1', datetime.datetime.utcnow())
>>> cell2 = Cell(b'val2', datetime.datetime.utcnow())
>>> row_data = PartialRowData(b'row-key')
Expand Down Expand Up @@ -845,7 +846,7 @@ def _filter_chain_helper(column=None, versions=None, timestamp=None,
:type filters: list
:param filters: (Optional) List of existing filters to be extended.

:rtype: :class:`RowFilter <gcloud.bigtable.row.RowFilter>`
:rtype: :class:`~google.cloud.bigtable.row.RowFilter`
:returns: The chained filter created, or just a single filter if only
one was needed.
:raises: :class:`ValueError <exceptions.ValueError>` if there are no
Expand Down Expand Up @@ -888,7 +889,7 @@ def _scan_filter_helper(row_start, row_stop, row_prefix, columns,
if legacy_args:
legacy_args = ', '.join(legacy_args)
message = ('The HappyBase legacy arguments %s were used. These '
'arguments are unused by gcloud.' % (legacy_args,))
'arguments are unused by google-cloud.' % (legacy_args,))
_WARN(message)
if kwargs:
raise TypeError('Received unexpected arguments', kwargs.keys())
Expand All @@ -906,7 +907,7 @@ def _scan_filter_helper(row_start, row_stop, row_prefix, columns,
if isinstance(filter_, six.string_types):
raise TypeError('Specifying filters as a string is not supported '
'by Cloud Bigtable. Use a '
'gcloud.bigtable.row.RowFilter instead.')
'google.cloud.bigtable.row.RowFilter instead.')
elif filter_ is not None:
filters.append(filter_)

Expand All @@ -929,7 +930,7 @@ def _columns_filter_helper(columns):
* an entire column family: ``fam`` or ``fam:``
* a single column: ``fam:col``

:rtype: :class:`RowFilter <gcloud.bigtable.row.RowFilter>`
:rtype: :class:`~google.cloud.bigtable.row.RowFilter`
:returns: The union filter created containing all of the matched columns.
:raises: :class:`ValueError <exceptions.ValueError>` if there are no
filters to union.
Expand Down Expand Up @@ -960,7 +961,7 @@ def _row_keys_filter_helper(row_keys):
:type row_keys: list
:param row_keys: Iterable containing row keys (as strings).

:rtype: :class:`RowFilter <gcloud.bigtable.row.RowFilter>`
:rtype: :class:`~google.cloud.bigtable.row.RowFilter`
:returns: The union filter created containing all of the row keys.
:raises: :class:`ValueError <exceptions.ValueError>` if there are no
filters to union.
Expand Down
10 changes: 5 additions & 5 deletions system_tests/happybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

import unittest

from gcloud import _helpers
from gcloud.bigtable import client as client_mod
from gcloud.bigtable.happybase.connection import Connection
from gcloud.environment_vars import TESTS_PROJECT
from google.cloud import _helpers
from google.cloud.bigtable import client as client_mod
from google.cloud.bigtable.happybase.connection import Connection
from google.cloud.environment_vars import TESTS_PROJECT

from retry import RetryResult
from system_test_utils import unique_resource_id
Expand Down Expand Up @@ -66,7 +66,7 @@ class Config(object):
def _operation_wait(operation, max_attempts=5):
"""Wait until an operation has completed.

:type operation: :class:`gcloud.bigtable.instance.Operation`
:type operation: :class:`~google.cloud.bigtable.instance.Operation`
:param operation: Operation that has not finished.

:type max_attempts: int
Expand Down
Loading