From 6910136704799976bf4c5500de1d189befb7630c Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 24 Jun 2016 09:38:33 -0700 Subject: [PATCH 01/40] bigtable: Move hello to hello_happybase. [(#383)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/383) --- samples/hello_happybase/README.md | 67 +++++++++++++ samples/hello_happybase/main.py | 119 +++++++++++++++++++++++ samples/hello_happybase/main_test.py | 49 ++++++++++ samples/hello_happybase/requirements.txt | 1 + 4 files changed, 236 insertions(+) create mode 100644 samples/hello_happybase/README.md create mode 100644 samples/hello_happybase/main.py create mode 100644 samples/hello_happybase/main_test.py create mode 100644 samples/hello_happybase/requirements.txt diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md new file mode 100644 index 000000000..6fc0473a3 --- /dev/null +++ b/samples/hello_happybase/README.md @@ -0,0 +1,67 @@ +# Cloud Bigtable Hello World + +This is a simple application that demonstrates using the [Google Cloud Client +Library][gcloud-python] to connect to and interact with Cloud Bigtable. + +[gcloud-python]: https://github.com/GoogleCloudPlatform/gcloud-python + + +## Provision a cluster + +Follow the instructions in the [user documentation](https://cloud.google.com/bigtable/docs/creating-cluster) +to create a Google Cloud Platform project and Cloud Bigtable cluster if necessary. +You'll need to reference your project ID, zone and cluster ID to run the application. + + +## Run the application + +First, set your [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials) + +Install the dependencies with pip. + +``` +$ pip install -r requirements.txt +``` + +Run the application. Replace the command-line parameters with values for your cluster. + +``` +$ python main.py my-project my-cluster us-central1-c +``` + +You will see output resembling the following: + +``` +Create table Hello-Bigtable-1234 +Write some greetings to the table +Scan for all greetings: + greeting0: Hello World! + greeting1: Hello Cloud Bigtable! + greeting2: Hello HappyBase! +Delete table Hello-Bigtable-1234 +``` + +## Understanding the code + +The [application](main.py) uses the [Google Cloud Bigtable HappyBase +package][Bigtable HappyBase], an implementation of the [HappyBase][HappyBase] +library, to make calls to Cloud Bigtable. It demonstrates several basic +concepts of working with Cloud Bigtable via this API: + +[Bigtable HappyBase]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html +[HappyBase]: http://happybase.readthedocs.io/en/latest/index.html + +- Creating a [Connection][HappyBase Connection] to a Cloud Bigtable + [Cluster][Cluster API]. +- Using the [Connection][HappyBase Connection] interface to create, disable and + delete a [Table][HappyBase Table]. +- Using the Connection to get a Table. +- Using the Table to write rows via a [put][HappyBase Table Put] and scan + across multiple rows using [scan][HappyBase Table Scan]. + +[Cluster API]: https://googlecloudplatform.github.io/gcloud-python/stable/bigtable-cluster.html +[HappyBase Connection]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-connection.html +[HappyBase Table]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html +[HappyBase Table Put]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.put +[HappyBase Table Scan]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.scan + diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py new file mode 100644 index 000000000..fc6ff6bb1 --- /dev/null +++ b/samples/hello_happybase/main.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Demonstrates how to connect to Cloud Bigtable and run some basic operations. + +Prerequisites: + +- Create a Cloud Bigtable cluster. + https://cloud.google.com/bigtable/docs/creating-cluster +- Set your Google Application Default Credentials. + https://developers.google.com/identity/protocols/application-default-credentials +- Set the GCLOUD_PROJECT environment variable to your project ID. + https://support.google.com/cloud/answer/6158840 +""" + +import argparse + +from gcloud import bigtable +from gcloud.bigtable import happybase + + +def main(project_id, cluster_id, zone, table_name): + # [START connecting_to_bigtable] + # The client must be created with admin=True because it will create a + # table. + client = bigtable.Client(project=project_id, admin=True) + cluster = client.cluster(zone, cluster_id) + connection = happybase.Connection(cluster=cluster) + # [END connecting_to_bigtable] + + try: + # [START creating_a_table] + print('Creating the {} table.'.format(table_name)) + column_family_name = 'cf1' + connection.create_table( + table_name, + { + column_family_name: dict() # Use default options. + }) + # [END creating_a_table] + + # [START writing_rows] + print('Writing some greetings to the table.') + table = connection.table(table_name) + column_name = '{fam}:greeting'.format(fam=column_family_name) + greetings = [ + 'Hello World!', + 'Hello Cloud Bigtable!', + 'Hello HappyBase!', + ] + for i, value in enumerate(greetings): + # Note: This example uses sequential numeric IDs for simplicity, + # but this can result in poor performance in a production + # application. Since rows are stored in sorted order by key, + # sequential keys can result in poor distribution of operations + # across nodes. + # + # For more information about how to design a Bigtable schema for + # the best performance, see the documentation: + # + # https://cloud.google.com/bigtable/docs/schema-design + row_key = 'greeting{}'.format(i) + table.put(row_key, {column_name: value}) + # [END writing_rows] + + # [START getting_a_row] + print('Getting a single greeting by row key.') + key = 'greeting0' + row = table.row(key) + print('\t{}: {}'.format(key, row[column_name])) + # [END getting_a_row] + + # [START scanning_all_rows] + print('Scanning for all greetings:') + for key, row in table.scan(): + print('\t{}: {}'.format(key, row[column_name])) + # [END scanning_all_rows] + + # [START deleting_a_table] + print('Deleting the {} table.'.format(table_name)) + connection.delete_table(table_name) + # [END deleting_a_table] + finally: + connection.close() + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='A sample application that connects to Cloud' + + ' Bigtable.', + formatter_class=argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument( + 'project_id', + help='Google Cloud Platform project ID that contains the Cloud' + + ' Bigtable cluster.') + parser.add_argument( + 'cluster', help='ID of the Cloud Bigtable cluster to connect to.') + parser.add_argument( + 'zone', help='Zone that contains the Cloud Bigtable cluster.') + parser.add_argument( + '--table', + help='Table to create and destroy.', + default='Hello-Bigtable') + + args = parser.parse_args() + main(args.project_id, args.cluster, args.zone, args.table) diff --git a/samples/hello_happybase/main_test.py b/samples/hello_happybase/main_test.py new file mode 100644 index 000000000..581d10a04 --- /dev/null +++ b/samples/hello_happybase/main_test.py @@ -0,0 +1,49 @@ +# Copyright 2016 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import random +import re +import sys + +from main import main + +import pytest + +TABLE_NAME_FORMAT = 'Hello-Bigtable-{}' +TABLE_NAME_RANGE = 10000 + + +@pytest.mark.skipif( + sys.version_info >= (3, 0), + reason=("grpc doesn't yet support python3 " + 'https://github.com/grpc/grpc/issues/282')) +def test_main(cloud_config, capsys): + table_name = TABLE_NAME_FORMAT.format( + random.randrange(TABLE_NAME_RANGE)) + main( + cloud_config.project, + cloud_config.bigtable_cluster, + cloud_config.bigtable_zone, + table_name) + + out, _ = capsys.readouterr() + assert re.search( + re.compile(r'Creating the Hello-Bigtable-[0-9]+ table\.'), out) + assert re.search(re.compile(r'Writing some greetings to the table\.'), out) + assert re.search(re.compile(r'Getting a single greeting by row key.'), out) + assert re.search(re.compile(r'greeting0: Hello World!'), out) + assert re.search(re.compile(r'Scanning for all greetings'), out) + assert re.search(re.compile(r'greeting1: Hello Cloud Bigtable!'), out) + assert re.search( + re.compile(r'Deleting the Hello-Bigtable-[0-9]+ table\.'), out) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt new file mode 100644 index 000000000..93130c943 --- /dev/null +++ b/samples/hello_happybase/requirements.txt @@ -0,0 +1 @@ +gcloud[grpc]==0.14.0 From 364b942e5dcdd1b2e940450507a4e43799285609 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Fri, 24 Jun 2016 10:27:08 -0700 Subject: [PATCH 02/40] bigtable: add raw gcloud-python hello sample. This sample uses the "raw" [gcloud-python Cloud Bigtable package](https://googlecloudplatform.github.io/gcloud-python/stable/bigtable-usage.html). --- samples/hello_happybase/README.md | 2 +- samples/hello_happybase/main.py | 13 +++++-------- samples/hello_happybase/requirements.txt | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md index 6fc0473a3..910aab6f5 100644 --- a/samples/hello_happybase/README.md +++ b/samples/hello_happybase/README.md @@ -1,4 +1,4 @@ -# Cloud Bigtable Hello World +# Cloud Bigtable Hello World (HappyBase) This is a simple application that demonstrates using the [Google Cloud Client Library][gcloud-python] to connect to and interact with Cloud Bigtable. diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index fc6ff6bb1..8686a1b43 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -22,8 +22,6 @@ https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google Application Default Credentials. https://developers.google.com/identity/protocols/application-default-credentials -- Set the GCLOUD_PROJECT environment variable to your project ID. - https://support.google.com/cloud/answer/6158840 """ import argparse @@ -61,6 +59,7 @@ def main(project_id, cluster_id, zone, table_name): 'Hello Cloud Bigtable!', 'Hello HappyBase!', ] + for i, value in enumerate(greetings): # Note: This example uses sequential numeric IDs for simplicity, # but this can result in poor performance in a production @@ -85,6 +84,7 @@ def main(project_id, cluster_id, zone, table_name): # [START scanning_all_rows] print('Scanning for all greetings:') + for key, row in table.scan(): print('\t{}: {}'.format(key, row[column_name])) # [END scanning_all_rows] @@ -93,19 +93,16 @@ def main(project_id, cluster_id, zone, table_name): print('Deleting the {} table.'.format(table_name)) connection.delete_table(table_name) # [END deleting_a_table] + finally: connection.close() if __name__ == '__main__': parser = argparse.ArgumentParser( - description='A sample application that connects to Cloud' + - ' Bigtable.', + description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument( - 'project_id', - help='Google Cloud Platform project ID that contains the Cloud' + - ' Bigtable cluster.') + parser.add_argument('project_id', help='Your Cloud Platform project ID.') parser.add_argument( 'cluster', help='ID of the Cloud Bigtable cluster to connect to.') parser.add_argument( diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 93130c943..5cb34f73a 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.14.0 +gcloud[grpc]==0.16.0 From 379198d1d430cbd035d7e7a945f813ae052a5f43 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 29 Jun 2016 11:29:56 -0700 Subject: [PATCH 03/40] Update Bigtable samples to v2. Table of Contents generated with: doctoc --title '**Table of Contents**' bigtable Needs to wait for next gcloud-python launch. Tested locally with a previous version of grpcio. --- samples/hello_happybase/README.md | 108 ++++++++++++++++------- samples/hello_happybase/main.py | 12 ++- samples/hello_happybase/main_test.py | 3 +- samples/hello_happybase/requirements.txt | 2 +- 4 files changed, 82 insertions(+), 43 deletions(-) diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md index 910aab6f5..790f2b1b3 100644 --- a/samples/hello_happybase/README.md +++ b/samples/hello_happybase/README.md @@ -1,19 +1,77 @@ -# Cloud Bigtable Hello World (HappyBase) +# Cloud Bigtable Hello World via the HappyBase API This is a simple application that demonstrates using the [Google Cloud Client -Library][gcloud-python] to connect to and interact with Cloud Bigtable. +Library HappyBase package][gcloud-python-happybase], an implementation of the [HappyBase +API][happybase] to connect to and interact with Cloud Bigtable. -[gcloud-python]: https://github.com/GoogleCloudPlatform/gcloud-python + +These samples are used on the following documentation page: +> https://cloud.google.com/bigtable/docs/samples-python-hello-happybase -## Provision a cluster + -Follow the instructions in the [user documentation](https://cloud.google.com/bigtable/docs/creating-cluster) -to create a Google Cloud Platform project and Cloud Bigtable cluster if necessary. -You'll need to reference your project ID, zone and cluster ID to run the application. +[gcloud-python-happybase]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html +[happybase]: http://happybase.readthedocs.io/en/stable/ +[sample-docs]: https://cloud.google.com/bigtable/docs/samples-python-hello-happybase -## Run the application + + +**Table of Contents** + +- [Downloading the sample](#downloading-the-sample) +- [Costs](#costs) +- [Provisioning an instance](#provisioning-an-instance) +- [Running the application](#running-the-application) +- [Cleaning up](#cleaning-up) + + + + +## Downloading the sample + +Download the sample app and navigate into the app directory: + +1. Clone the [Python samples + repository](https://github.com/GoogleCloudPlatform/python-docs-samples), to + your local machine: + + git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git + + Alternatively, you can [download the + sample](https://github.com/GoogleCloudPlatform/python-docs-samples/archive/master.zip) + as a zip file and extract it. + +2. Change to the sample directory. + + cd python-docs-samples/bigtable/hello_happybase + + +## Costs + +This sample uses billable components of Cloud Platform, including: + ++ Google Cloud Bigtable + +Use the [Pricing Calculator][bigtable-pricing] to generate a cost estimate +based on your projected usage. New Cloud Platform users might be eligible for +a [free trial][free-trial]. + +[bigtable-pricing]: https://cloud.google.com/products/calculator/#id=1eb47664-13a2-4be1-9d16-6722902a7572 +[free-trial]: https://cloud.google.com/free-trial + + +## Provisioning an instance + +Follow the instructions in the [user +documentation](https://cloud.google.com/bigtable/docs/creating-instance) to +create a Google Cloud Platform project and Cloud Bigtable instance if necessary. +You'll need to reference your project id and instance id to run the +application. + + +## Running the application First, set your [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials) @@ -23,45 +81,29 @@ Install the dependencies with pip. $ pip install -r requirements.txt ``` -Run the application. Replace the command-line parameters with values for your cluster. +Run the application. Replace the command-line parameters with values for your instance. ``` -$ python main.py my-project my-cluster us-central1-c +$ python main.py my-project my-instance ``` You will see output resembling the following: ``` -Create table Hello-Bigtable-1234 +Create table Hello-Bigtable Write some greetings to the table Scan for all greetings: greeting0: Hello World! greeting1: Hello Cloud Bigtable! greeting2: Hello HappyBase! -Delete table Hello-Bigtable-1234 +Delete table Hello-Bigtable ``` -## Understanding the code - -The [application](main.py) uses the [Google Cloud Bigtable HappyBase -package][Bigtable HappyBase], an implementation of the [HappyBase][HappyBase] -library, to make calls to Cloud Bigtable. It demonstrates several basic -concepts of working with Cloud Bigtable via this API: - -[Bigtable HappyBase]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html -[HappyBase]: http://happybase.readthedocs.io/en/latest/index.html -- Creating a [Connection][HappyBase Connection] to a Cloud Bigtable - [Cluster][Cluster API]. -- Using the [Connection][HappyBase Connection] interface to create, disable and - delete a [Table][HappyBase Table]. -- Using the Connection to get a Table. -- Using the Table to write rows via a [put][HappyBase Table Put] and scan - across multiple rows using [scan][HappyBase Table Scan]. +## Cleaning up -[Cluster API]: https://googlecloudplatform.github.io/gcloud-python/stable/bigtable-cluster.html -[HappyBase Connection]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-connection.html -[HappyBase Table]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html -[HappyBase Table Put]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.put -[HappyBase Table Scan]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-table.html#gcloud.bigtable.happybase.table.Table.scan +To avoid incurring extra charges to your Google Cloud Platform account, remove +the resources created for this sample. +- [Delete the Cloud Bigtable + instance](https://cloud.google.com/bigtable/docs/deleting-instance). diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 8686a1b43..b0e6ef635 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -30,13 +30,13 @@ from gcloud.bigtable import happybase -def main(project_id, cluster_id, zone, table_name): +def main(project_id, instance_id, table_name): # [START connecting_to_bigtable] # The client must be created with admin=True because it will create a # table. client = bigtable.Client(project=project_id, admin=True) - cluster = client.cluster(zone, cluster_id) - connection = happybase.Connection(cluster=cluster) + instance = client.instance(instance_id) + connection = happybase.Connection(instance=instance) # [END connecting_to_bigtable] try: @@ -104,13 +104,11 @@ def main(project_id, cluster_id, zone, table_name): formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('project_id', help='Your Cloud Platform project ID.') parser.add_argument( - 'cluster', help='ID of the Cloud Bigtable cluster to connect to.') - parser.add_argument( - 'zone', help='Zone that contains the Cloud Bigtable cluster.') + 'instance_id', help='ID of the Cloud Bigtable instance to connect to.') parser.add_argument( '--table', help='Table to create and destroy.', default='Hello-Bigtable') args = parser.parse_args() - main(args.project_id, args.cluster, args.zone, args.table) + main(args.project_id, args.instance_id, args.table) diff --git a/samples/hello_happybase/main_test.py b/samples/hello_happybase/main_test.py index 581d10a04..49f77e9f9 100644 --- a/samples/hello_happybase/main_test.py +++ b/samples/hello_happybase/main_test.py @@ -33,8 +33,7 @@ def test_main(cloud_config, capsys): random.randrange(TABLE_NAME_RANGE)) main( cloud_config.project, - cloud_config.bigtable_cluster, - cloud_config.bigtable_zone, + cloud_config.bigtable_instance, table_name) out, _ = capsys.readouterr() diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 5cb34f73a..3bc96b185 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.16.0 +gcloud[grpc]==0.17.0 From 3faf782faf4bd5d797fa27dfc2c3ef3ce6670a3a Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 16 Aug 2016 13:32:42 -0700 Subject: [PATCH 04/40] Auto-update dependencies. [(#456)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/456) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 3bc96b185..ae5e9dbb1 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.17.0 +gcloud[grpc]==0.18.1 From 2a7c3d9da54a5f8e6ea7dc9b8ceed3f5c32af1e5 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Wed, 17 Aug 2016 14:09:41 -0700 Subject: [PATCH 05/40] Remove grpc-python3 hackiness Change-Id: I6bf9a8acb9ba7d067b3095b5857094cbc322ff58 --- samples/hello_happybase/main.py | 6 +++--- samples/hello_happybase/main_test.py | 26 ++++++++------------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index b0e6ef635..519eedc06 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -77,16 +77,16 @@ def main(project_id, instance_id, table_name): # [START getting_a_row] print('Getting a single greeting by row key.') - key = 'greeting0' + key = 'greeting0'.encode('utf-8') row = table.row(key) - print('\t{}: {}'.format(key, row[column_name])) + print('\t{}: {}'.format(key, row[column_name.encode('utf-8')])) # [END getting_a_row] # [START scanning_all_rows] print('Scanning for all greetings:') for key, row in table.scan(): - print('\t{}: {}'.format(key, row[column_name])) + print('\t{}: {}'.format(key, row[column_name.encode('utf-8')])) # [END scanning_all_rows] # [START deleting_a_table] diff --git a/samples/hello_happybase/main_test.py b/samples/hello_happybase/main_test.py index 49f77e9f9..6e58dac4c 100644 --- a/samples/hello_happybase/main_test.py +++ b/samples/hello_happybase/main_test.py @@ -13,21 +13,13 @@ # limitations under the License. import random -import re -import sys from main import main -import pytest - -TABLE_NAME_FORMAT = 'Hello-Bigtable-{}' +TABLE_NAME_FORMAT = 'hello_happybase-system-tests-{}' TABLE_NAME_RANGE = 10000 -@pytest.mark.skipif( - sys.version_info >= (3, 0), - reason=("grpc doesn't yet support python3 " - 'https://github.com/grpc/grpc/issues/282')) def test_main(cloud_config, capsys): table_name = TABLE_NAME_FORMAT.format( random.randrange(TABLE_NAME_RANGE)) @@ -37,12 +29,10 @@ def test_main(cloud_config, capsys): table_name) out, _ = capsys.readouterr() - assert re.search( - re.compile(r'Creating the Hello-Bigtable-[0-9]+ table\.'), out) - assert re.search(re.compile(r'Writing some greetings to the table\.'), out) - assert re.search(re.compile(r'Getting a single greeting by row key.'), out) - assert re.search(re.compile(r'greeting0: Hello World!'), out) - assert re.search(re.compile(r'Scanning for all greetings'), out) - assert re.search(re.compile(r'greeting1: Hello Cloud Bigtable!'), out) - assert re.search( - re.compile(r'Deleting the Hello-Bigtable-[0-9]+ table\.'), out) + assert 'Creating the {} table.'.format(table_name) in out + assert 'Writing some greetings to the table.' in out + assert 'Getting a single greeting by row key.' in out + assert 'Hello World!' in out + assert 'Scanning for all greetings' in out + assert 'Hello Cloud Bigtable!' in out + assert 'Deleting the {} table.'.format(table_name) in out From a4bf3ed9bb50a8d9f576bf92c59ddad6daf053ff Mon Sep 17 00:00:00 2001 From: DPE bot Date: Fri, 23 Sep 2016 09:48:46 -0700 Subject: [PATCH 06/40] Auto-update dependencies. [(#540)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/540) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index ae5e9dbb1..0ea9bf3f5 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.18.1 +gcloud[grpc]==0.18.2 From c6e5e3562333e561c5133500aef90906e8ddeb51 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 26 Sep 2016 11:34:45 -0700 Subject: [PATCH 07/40] Auto-update dependencies. [(#542)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/542) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 0ea9bf3f5..a14adce81 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.18.2 +gcloud[grpc]==0.18.3 From 19f93eca31a654446bd4018cc2238a3e2bfc48b3 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Thu, 29 Sep 2016 20:51:47 -0700 Subject: [PATCH 08/40] Move to google-cloud [(#544)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/544) --- samples/hello_happybase/main.py | 4 ++-- samples/hello_happybase/requirements.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 519eedc06..0668402f8 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -26,8 +26,8 @@ import argparse -from gcloud import bigtable -from gcloud.bigtable import happybase +from google.cloud import bigtable +from google.cloud import happybase def main(project_id, instance_id, table_name): diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index a14adce81..ececa7ae5 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -gcloud[grpc]==0.18.3 +google-cloud-happybase==0.20.0 From cc8fb16594a562768668a9367895687ab71db131 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Wed, 12 Oct 2016 17:21:18 -0700 Subject: [PATCH 09/40] Fix link to bigtable happybase package. [(#576)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/576) It moved to a new repo. --- samples/hello_happybase/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md index 790f2b1b3..d904eb969 100644 --- a/samples/hello_happybase/README.md +++ b/samples/hello_happybase/README.md @@ -11,7 +11,7 @@ These samples are used on the following documentation page: -[gcloud-python-happybase]: https://googlecloudplatform.github.io/gcloud-python/stable/happybase-package.html +[gcloud-python-happybase]: https://github.com/GoogleCloudPlatform/google-cloud-python-happybase [happybase]: http://happybase.readthedocs.io/en/stable/ [sample-docs]: https://cloud.google.com/bigtable/docs/samples-python-hello-happybase From f6ebc973d78bc5ec7213c6d362e94f7348a0a30d Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Mon, 24 Oct 2016 11:03:17 -0700 Subject: [PATCH 10/40] Generate readmes for most service samples [(#599)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/599) --- samples/hello_happybase/README.md | 109 ---------------------- samples/hello_happybase/README.rst | 126 ++++++++++++++++++++++++++ samples/hello_happybase/README.rst.in | 30 ++++++ 3 files changed, 156 insertions(+), 109 deletions(-) delete mode 100644 samples/hello_happybase/README.md create mode 100644 samples/hello_happybase/README.rst create mode 100644 samples/hello_happybase/README.rst.in diff --git a/samples/hello_happybase/README.md b/samples/hello_happybase/README.md deleted file mode 100644 index d904eb969..000000000 --- a/samples/hello_happybase/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# Cloud Bigtable Hello World via the HappyBase API - -This is a simple application that demonstrates using the [Google Cloud Client -Library HappyBase package][gcloud-python-happybase], an implementation of the [HappyBase -API][happybase] to connect to and interact with Cloud Bigtable. - - -These samples are used on the following documentation page: - -> https://cloud.google.com/bigtable/docs/samples-python-hello-happybase - - - -[gcloud-python-happybase]: https://github.com/GoogleCloudPlatform/google-cloud-python-happybase -[happybase]: http://happybase.readthedocs.io/en/stable/ -[sample-docs]: https://cloud.google.com/bigtable/docs/samples-python-hello-happybase - - - - -**Table of Contents** - -- [Downloading the sample](#downloading-the-sample) -- [Costs](#costs) -- [Provisioning an instance](#provisioning-an-instance) -- [Running the application](#running-the-application) -- [Cleaning up](#cleaning-up) - - - - -## Downloading the sample - -Download the sample app and navigate into the app directory: - -1. Clone the [Python samples - repository](https://github.com/GoogleCloudPlatform/python-docs-samples), to - your local machine: - - git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git - - Alternatively, you can [download the - sample](https://github.com/GoogleCloudPlatform/python-docs-samples/archive/master.zip) - as a zip file and extract it. - -2. Change to the sample directory. - - cd python-docs-samples/bigtable/hello_happybase - - -## Costs - -This sample uses billable components of Cloud Platform, including: - -+ Google Cloud Bigtable - -Use the [Pricing Calculator][bigtable-pricing] to generate a cost estimate -based on your projected usage. New Cloud Platform users might be eligible for -a [free trial][free-trial]. - -[bigtable-pricing]: https://cloud.google.com/products/calculator/#id=1eb47664-13a2-4be1-9d16-6722902a7572 -[free-trial]: https://cloud.google.com/free-trial - - -## Provisioning an instance - -Follow the instructions in the [user -documentation](https://cloud.google.com/bigtable/docs/creating-instance) to -create a Google Cloud Platform project and Cloud Bigtable instance if necessary. -You'll need to reference your project id and instance id to run the -application. - - -## Running the application - -First, set your [Google Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials) - -Install the dependencies with pip. - -``` -$ pip install -r requirements.txt -``` - -Run the application. Replace the command-line parameters with values for your instance. - -``` -$ python main.py my-project my-instance -``` - -You will see output resembling the following: - -``` -Create table Hello-Bigtable -Write some greetings to the table -Scan for all greetings: - greeting0: Hello World! - greeting1: Hello Cloud Bigtable! - greeting2: Hello HappyBase! -Delete table Hello-Bigtable -``` - - -## Cleaning up - -To avoid incurring extra charges to your Google Cloud Platform account, remove -the resources created for this sample. - -- [Delete the Cloud Bigtable - instance](https://cloud.google.com/bigtable/docs/deleting-instance). diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst new file mode 100644 index 000000000..56dbbf485 --- /dev/null +++ b/samples/hello_happybase/README.rst @@ -0,0 +1,126 @@ +.. This file is automatically generated. Do not edit this file directly. + +Google Cloud Bigtable Python Samples +=============================================================================== + +This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. + + +This sample demonstrates using the `Google Cloud Client Library HappyBase +package`_, an implementation of the `HappyBase API`_ to connect to and +interact with Cloud Bigtable. + +.. _Google Cloud Client Library HappyBase package: + https://github.com/GoogleCloudPlatform/google-cloud-python-happybase +.. _HappyBase API: http://happybase.readthedocs.io/en/stable/ + + +.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs + +Setup +------------------------------------------------------------------------------- + + +Authentication +++++++++++++++ + +Authentication is typically done through `Application Default Credentials`_, +which means you do not have to change the code to authenticate as long as +your environment has credentials. You have a few options for setting up +authentication: + +#. When running locally, use the `Google Cloud SDK`_ + + .. code-block:: bash + + gcloud beta auth application-default login + + +#. When running on App Engine or Compute Engine, credentials are already + set-up. However, you may need to configure your Compute Engine instance + with `additional scopes`_. + +#. You can create a `Service Account key file`_. This file can be used to + authenticate to Google Cloud Platform services from any environment. To use + the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to + the path to the key file, for example: + + .. code-block:: bash + + export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json + +.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow +.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using +.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount + +Install Dependencies +++++++++++++++++++++ + +#. Install `pip`_ and `virtualenv`_ if you do not already have them. + +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. + + .. code-block:: bash + + $ virtualenv env + $ source env/bin/activate + +#. Install the dependencies needed to run the samples. + + .. code-block:: bash + + $ pip install -r requirements.txt + +.. _pip: https://pip.pypa.io/ +.. _virtualenv: https://virtualenv.pypa.io/ + +Samples +------------------------------------------------------------------------------- + +Basic example ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + +To run this sample: + +.. code-block:: bash + + $ python main.py + + usage: main.py [-h] [--table TABLE] project_id instance_id + + Demonstrates how to connect to Cloud Bigtable and run some basic operations. + Prerequisites: - Create a Cloud Bigtable cluster. + https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google + Application Default Credentials. + https://developers.google.com/identity/protocols/application-default- + credentials + + positional arguments: + project_id Your Cloud Platform project ID. + instance_id ID of the Cloud Bigtable instance to connect to. + + optional arguments: + -h, --help show this help message and exit + --table TABLE Table to create and destroy. (default: Hello-Bigtable) + + + + +The client library +------------------------------------------------------------------------------- + +This sample uses the `Google Cloud Client Library for Python`_. +You can read the documentation for more details on API usage and use GitHub +to `browse the source`_ and `report issues`_. + +.. Google Cloud Client Library for Python: + https://googlecloudplatform.github.io/google-cloud-python/ +.. browse the source: + https://github.com/GoogleCloudPlatform/google-cloud-python +.. report issues: + https://github.com/GoogleCloudPlatform/google-cloud-python/issues + + +.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/hello_happybase/README.rst.in b/samples/hello_happybase/README.rst.in new file mode 100644 index 000000000..4bb363a36 --- /dev/null +++ b/samples/hello_happybase/README.rst.in @@ -0,0 +1,30 @@ +# This file is used to generate README.rst + +product: + name: Google Cloud Bigtable + short_name: Cloud Bigtable + url: https://cloud.google.com/bigtable/docs + description: > + `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's + the same database that powers many core Google services, including Search, + Analytics, Maps, and Gmail. + +description: | + This sample demonstrates using the `Google Cloud Client Library HappyBase + package`_, an implementation of the `HappyBase API`_ to connect to and + interact with Cloud Bigtable. + + .. _Google Cloud Client Library HappyBase package: + https://github.com/GoogleCloudPlatform/google-cloud-python-happybase + .. _HappyBase API: http://happybase.readthedocs.io/en/stable/ + +setup: +- auth +- install_deps + +samples: +- name: Basic example + file: main.py + show_help: true + +cloud_client_library: true From 7244b194a4028936ebd33aebeb79a93ec9238be1 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Wed, 7 Dec 2016 12:27:24 -0800 Subject: [PATCH 11/40] Fix bigtable tests Change-Id: I49b68394ccd5133a64e019e91d1ec0529ffd64b3 --- samples/hello_happybase/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index ececa7ae5..7d5641c37 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1,2 @@ -google-cloud-happybase==0.20.0 +google-cloud-happybase==0.21.0 +google-cloud-core==0.21.0 From e6465bfa813f83a8b0056d268b5c9b6ff35ffbb7 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 13 Dec 2016 09:54:02 -0800 Subject: [PATCH 12/40] Auto-update dependencies. [(#715)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/715) --- samples/hello_happybase/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 7d5641c37..159d79042 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-happybase==0.21.0 -google-cloud-core==0.21.0 +google-cloud-happybase==0.22.0 +google-cloud-core==0.22.1 From bf532d482bd8a6c1d39ba014ada1fd94d625d1c8 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Fri, 3 Feb 2017 09:38:11 -0800 Subject: [PATCH 13/40] Auto-update dependencies. [(#781)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/781) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 159d79042..4009ed798 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ google-cloud-happybase==0.22.0 -google-cloud-core==0.22.1 +google-cloud-core==0.23.0 From 52c4b26583281fdb164897cb1b145f96f100b2d6 Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Tue, 4 Apr 2017 16:08:30 -0700 Subject: [PATCH 14/40] Remove cloud config fixture [(#887)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/887) * Remove cloud config fixture * Fix client secrets * Fix bigtable instance --- samples/hello_happybase/main_test.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/hello_happybase/main_test.py b/samples/hello_happybase/main_test.py index 6e58dac4c..3fc4ad134 100644 --- a/samples/hello_happybase/main_test.py +++ b/samples/hello_happybase/main_test.py @@ -12,20 +12,23 @@ # See the License for the specific language governing permissions and # limitations under the License. +import os import random from main import main +PROJECT = os.environ['GCLOUD_PROJECT'] +BIGTABLE_CLUSTER = os.environ['BIGTABLE_CLUSTER'] TABLE_NAME_FORMAT = 'hello_happybase-system-tests-{}' TABLE_NAME_RANGE = 10000 -def test_main(cloud_config, capsys): +def test_main(capsys): table_name = TABLE_NAME_FORMAT.format( random.randrange(TABLE_NAME_RANGE)) main( - cloud_config.project, - cloud_config.bigtable_instance, + PROJECT, + BIGTABLE_CLUSTER, table_name) out, _ = capsys.readouterr() From 3aa75b1a9ad6bf0f7fad2a8a083e5ed80a0d5165 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 24 Apr 2017 13:12:09 -0700 Subject: [PATCH 15/40] Auto-update dependencies. [(#914)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/914) * Auto-update dependencies. * xfail the error reporting test * Fix lint --- samples/hello_happybase/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 4009ed798..9271b9548 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-happybase==0.22.0 -google-cloud-core==0.23.0 +google-cloud-happybase==0.24.0 +google-cloud-core==0.24.0 From 69513c91e3d964336af74e266855d41e8ed54a3c Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Thu, 27 Apr 2017 09:54:41 -0700 Subject: [PATCH 16/40] Re-generate all readmes --- samples/hello_happybase/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 56dbbf485..6d7c87e6f 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -33,7 +33,7 @@ authentication: .. code-block:: bash - gcloud beta auth application-default login + gcloud auth application-default login #. When running on App Engine or Compute Engine, credentials are already From 8b8ef7719aeb37e7fdbbe161204b3bed55dfaf7c Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 1 May 2017 10:49:29 -0700 Subject: [PATCH 17/40] Auto-update dependencies. [(#922)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/922) * Auto-update dependencies. * Fix pubsub iam samples --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 9271b9548..e2aa8d8e6 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ google-cloud-happybase==0.24.0 -google-cloud-core==0.24.0 +google-cloud-core==0.24.1 From 7f6a7b62c0b0cd5b75b079b8e3c4c9e874ef090a Mon Sep 17 00:00:00 2001 From: Bill Prin Date: Tue, 23 May 2017 17:01:25 -0700 Subject: [PATCH 18/40] Fix README rst links [(#962)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/962) * Fix README rst links * Update all READMEs --- samples/hello_happybase/README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 6d7c87e6f..991e5ec55 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -115,11 +115,11 @@ This sample uses the `Google Cloud Client Library for Python`_. You can read the documentation for more details on API usage and use GitHub to `browse the source`_ and `report issues`_. -.. Google Cloud Client Library for Python: +.. _Google Cloud Client Library for Python: https://googlecloudplatform.github.io/google-cloud-python/ -.. browse the source: +.. _browse the source: https://github.com/GoogleCloudPlatform/google-cloud-python -.. report issues: +.. _report issues: https://github.com/GoogleCloudPlatform/google-cloud-python/issues From b7140e0713ee958d782b6a4f4a660835846dfe7e Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 27 Jun 2017 12:41:15 -0700 Subject: [PATCH 19/40] Auto-update dependencies. [(#1004)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1004) * Auto-update dependencies. * Fix natural language samples * Fix pubsub iam samples * Fix language samples * Fix bigquery samples --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index e2aa8d8e6..dda34551f 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ google-cloud-happybase==0.24.0 -google-cloud-core==0.24.1 +google-cloud-core==0.25.0 From 341cf47028ba9367ef178aee02360f3d9ee18fbf Mon Sep 17 00:00:00 2001 From: DPE bot Date: Thu, 20 Jul 2017 09:54:26 -0700 Subject: [PATCH 20/40] Auto-update dependencies. [(#1028)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1028) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index dda34551f..15243ef7c 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-happybase==0.24.0 +google-cloud-happybase==0.25.0 google-cloud-core==0.25.0 From 5a9cf42d34ef5b0e17328447d7ba8f6d4fad65f5 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 7 Aug 2017 10:04:55 -0700 Subject: [PATCH 21/40] Auto-update dependencies. [(#1055)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1055) * Auto-update dependencies. * Explicitly use latest bigtable client Change-Id: Id71e9e768f020730e4ca9514a0d7ebaa794e7d9e * Revert language update for now Change-Id: I8867f154e9a5aae00d0047c9caf880e5e8f50c53 * Remove pdb. smh Change-Id: I5ff905fadc026eebbcd45512d4e76e003e3b2b43 --- samples/hello_happybase/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 15243ef7c..266d0b360 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,2 +1,3 @@ google-cloud-happybase==0.25.0 -google-cloud-core==0.25.0 +google-cloud-bigtable==0.26.0 +google-cloud-core==0.26.0 From fc19dc81e768caa534cf7e3b16b060c9ba930aa7 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 8 Aug 2017 08:51:01 -0700 Subject: [PATCH 22/40] Auto-update dependencies. [(#1057)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1057) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 266d0b360..e28cd8fff 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-happybase==0.25.0 +google-cloud-happybase==0.26.0 google-cloud-bigtable==0.26.0 google-cloud-core==0.26.0 From 0be2e50ffa2f7ef3f04fe17a96139a792e697c25 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 29 Aug 2017 16:53:02 -0700 Subject: [PATCH 23/40] Auto-update dependencies. [(#1093)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1093) * Auto-update dependencies. * Fix storage notification poll sample Change-Id: I6afbc79d15e050531555e4c8e51066996717a0f3 * Fix spanner samples Change-Id: I40069222c60d57e8f3d3878167591af9130895cb * Drop coverage because it's not useful Change-Id: Iae399a7083d7866c3c7b9162d0de244fbff8b522 * Try again to fix flaky logging test Change-Id: I6225c074701970c17c426677ef1935bb6d7e36b4 --- samples/hello_happybase/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index e28cd8fff..05aee4625 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1,3 @@ google-cloud-happybase==0.26.0 -google-cloud-bigtable==0.26.0 -google-cloud-core==0.26.0 +google-cloud-bigtable==0.27.0 +google-cloud-core==0.27.0 From 64290b31f4cebc2547ce55ed995ee7e3c3ede70c Mon Sep 17 00:00:00 2001 From: DPE bot Date: Wed, 30 Aug 2017 10:15:58 -0700 Subject: [PATCH 24/40] Auto-update dependencies. [(#1094)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1094) * Auto-update dependencies. * Relax assertions in the ocr_nl sample Change-Id: I6d37e5846a8d6dd52429cb30d501f448c52cbba1 * Drop unused logging apiary samples Change-Id: I545718283773cb729a5e0def8a76ebfa40829d51 --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 05aee4625..f0c91e09b 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1,3 @@ google-cloud-happybase==0.26.0 google-cloud-bigtable==0.27.0 -google-cloud-core==0.27.0 +google-cloud-core==0.27.1 From f647622edb26bf68af8854ca2fa460975c52433c Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Mon, 18 Sep 2017 11:04:05 -0700 Subject: [PATCH 25/40] Update all generated readme auth instructions [(#1121)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1121) Change-Id: I03b5eaef8b17ac3dc3c0339fd2c7447bd3e11bd2 --- samples/hello_happybase/README.rst | 32 +++++------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 991e5ec55..d24349569 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -24,34 +24,12 @@ Setup Authentication ++++++++++++++ -Authentication is typically done through `Application Default Credentials`_, -which means you do not have to change the code to authenticate as long as -your environment has credentials. You have a few options for setting up -authentication: +This sample requires you to have authentication setup. Refer to the +`Authentication Getting Started Guide`_ for instructions on setting up +credentials for applications. -#. When running locally, use the `Google Cloud SDK`_ - - .. code-block:: bash - - gcloud auth application-default login - - -#. When running on App Engine or Compute Engine, credentials are already - set-up. However, you may need to configure your Compute Engine instance - with `additional scopes`_. - -#. You can create a `Service Account key file`_. This file can be used to - authenticate to Google Cloud Platform services from any environment. To use - the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to - the path to the key file, for example: - - .. code-block:: bash - - export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json - -.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow -.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using -.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount +.. _Authentication Getting Started Guide: + https://cloud.google.com/docs/authentication/getting-started Install Dependencies ++++++++++++++++++++ From f89e5c2b886dc6629f21cddc74574b09f42fb36d Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Thu, 12 Oct 2017 10:16:11 -0700 Subject: [PATCH 26/40] Added Link to Python Setup Guide [(#1158)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1158) * Update Readme.rst to add Python setup guide As requested in b/64770713. This sample is linked in documentation https://cloud.google.com/bigtable/docs/scaling, and it would make more sense to update the guide here than in the documentation. * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update README.rst * Update install_deps.tmpl.rst * Updated readmegen scripts and re-generated related README files * Fixed the lint error --- samples/hello_happybase/README.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index d24349569..080c84c34 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -34,7 +34,10 @@ credentials for applications. Install Dependencies ++++++++++++++++++++ -#. Install `pip`_ and `virtualenv`_ if you do not already have them. +#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. + + .. _Python Development Environment Setup Guide: + https://cloud.google.com/python/setup #. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. From 3fee3c8bfb896306b62b7ba67ca00b18bc7fa115 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Wed, 1 Nov 2017 12:30:10 -0700 Subject: [PATCH 27/40] Auto-update dependencies. [(#1186)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1186) --- samples/hello_happybase/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index f0c91e09b..b54c0cb88 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1,3 @@ google-cloud-happybase==0.26.0 -google-cloud-bigtable==0.27.0 -google-cloud-core==0.27.1 +google-cloud-bigtable==0.28.0 +google-cloud-core==0.28.0 From 6fa24e9970c665ed33e96becc28a92dc8034111a Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 6 Nov 2017 10:44:14 -0800 Subject: [PATCH 28/40] Auto-update dependencies. [(#1199)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1199) * Auto-update dependencies. * Fix iot lint Change-Id: I6289e093bdb35e38f9e9bfc3fbc3df3660f9a67e --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index b54c0cb88..01671d8f6 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1,3 @@ google-cloud-happybase==0.26.0 -google-cloud-bigtable==0.28.0 +google-cloud-bigtable==0.28.1 google-cloud-core==0.28.0 From e1c3db73f2924e0b976d6f5f7177d49cdac455c2 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Thu, 7 Dec 2017 10:34:29 -0800 Subject: [PATCH 29/40] Added "Open in Cloud Shell" buttons to README files [(#1254)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1254) --- samples/hello_happybase/README.rst | 15 ++++++++++++--- samples/hello_happybase/README.rst.in | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 080c84c34..9c061babd 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -3,6 +3,10 @@ Google Cloud Bigtable Python Samples =============================================================================== +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/README.rst + + This directory contains samples for Google Cloud Bigtable. `Google Cloud Bigtable`_ is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail. @@ -61,6 +65,10 @@ Samples Basic example +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/main.py;bigtable/hello_happybase/README.rst + + To run this sample: @@ -70,18 +78,18 @@ To run this sample: $ python main.py usage: main.py [-h] [--table TABLE] project_id instance_id - + Demonstrates how to connect to Cloud Bigtable and run some basic operations. Prerequisites: - Create a Cloud Bigtable cluster. https://cloud.google.com/bigtable/docs/creating-cluster - Set your Google Application Default Credentials. https://developers.google.com/identity/protocols/application-default- credentials - + positional arguments: project_id Your Cloud Platform project ID. instance_id ID of the Cloud Bigtable instance to connect to. - + optional arguments: -h, --help show this help message and exit --table TABLE Table to create and destroy. (default: Hello-Bigtable) @@ -89,6 +97,7 @@ To run this sample: + The client library ------------------------------------------------------------------------------- diff --git a/samples/hello_happybase/README.rst.in b/samples/hello_happybase/README.rst.in index 4bb363a36..8ef6a956b 100644 --- a/samples/hello_happybase/README.rst.in +++ b/samples/hello_happybase/README.rst.in @@ -28,3 +28,5 @@ samples: show_help: true cloud_client_library: true + +folder: bigtable/hello_happybase \ No newline at end of file From 32e5358bfccf85e62efa508f48c6dc529f40c501 Mon Sep 17 00:00:00 2001 From: DPE bot Date: Mon, 5 Mar 2018 12:28:55 -0800 Subject: [PATCH 30/40] Auto-update dependencies. [(#1377)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1377) * Auto-update dependencies. * Update requirements.txt --- samples/hello_happybase/requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index 01671d8f6..e6e9ed331 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1,3 +1 @@ google-cloud-happybase==0.26.0 -google-cloud-bigtable==0.28.1 -google-cloud-core==0.28.0 From 52193480e30e6e06d80cfc07e286061c8c2c1a10 Mon Sep 17 00:00:00 2001 From: chenyumic Date: Fri, 6 Apr 2018 22:57:36 -0700 Subject: [PATCH 31/40] Regenerate the README files and fix the Open in Cloud Shell link for some samples [(#1441)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1441) --- samples/hello_happybase/README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 9c061babd..99aa9686b 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -19,7 +19,7 @@ interact with Cloud Bigtable. .. _HappyBase API: http://happybase.readthedocs.io/en/stable/ -.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs +.. _Google Cloud Bigtable: https://cloud.google.com/bigtable/docs Setup ------------------------------------------------------------------------------- @@ -66,7 +66,7 @@ Basic example +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/main.py;bigtable/hello_happybase/README.rst + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor=bigtable/hello_happybase/main.py,bigtable/hello_happybase/README.rst From f76a0118178797911685d2e80a10b9aa2ca6bbd4 Mon Sep 17 00:00:00 2001 From: Frank Natividad Date: Thu, 26 Apr 2018 10:26:41 -0700 Subject: [PATCH 32/40] Update READMEs to fix numbering and add git clone [(#1464)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1464) --- samples/hello_happybase/README.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/README.rst b/samples/hello_happybase/README.rst index 99aa9686b..82a376535 100644 --- a/samples/hello_happybase/README.rst +++ b/samples/hello_happybase/README.rst @@ -38,10 +38,16 @@ credentials for applications. Install Dependencies ++++++++++++++++++++ +#. Clone python-docs-samples and change directory to the sample directory you want to use. + + .. code-block:: bash + + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git + #. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. - .. _Python Development Environment Setup Guide: - https://cloud.google.com/python/setup + .. _Python Development Environment Setup Guide: + https://cloud.google.com/python/setup #. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. From f161dd2a72c1d2ccc862d8aab89b53212ca27adb Mon Sep 17 00:00:00 2001 From: sumit-ql <39561577+sumit-ql@users.noreply.github.com> Date: Mon, 29 Oct 2018 20:17:26 +0530 Subject: [PATCH 33/40] updating to latest happy base client version [(#1794)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1794) --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index e6e9ed331..caefee337 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -google-cloud-happybase==0.26.0 +google-cloud-happybase==0.31.0 From 1a7aca233e0813fa96f602efca6d937c15eb91b4 Mon Sep 17 00:00:00 2001 From: DPEBot Date: Wed, 6 Feb 2019 12:06:35 -0800 Subject: [PATCH 34/40] Auto-update dependencies. [(#1980)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1980) * Auto-update dependencies. * Update requirements.txt * Update requirements.txt --- samples/hello_happybase/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index caefee337..a667ebb82 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -google-cloud-happybase==0.31.0 +google-cloud-happybase==0.32.1 From 264aeebfad382e85fd1f5f0c800b6e5a99b8bf05 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Tue, 19 Mar 2019 10:25:55 -0700 Subject: [PATCH 35/40] New library version to address failure. [(#2057)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2057) * New library version to address failure. * Encoded strings for library call * Give changes a bit longer to finish * fix lint error * Update main.py * Paren was missing --- samples/hello_happybase/main.py | 4 +++- samples/hello_happybase/requirements.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 0668402f8..3aea7d4f7 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -72,7 +72,9 @@ def main(project_id, instance_id, table_name): # # https://cloud.google.com/bigtable/docs/schema-design row_key = 'greeting{}'.format(i) - table.put(row_key, {column_name: value}) + table.put( + row_key, {column_name.encode('utf-8'): value.encode('utf-8')} + ) # [END writing_rows] # [START getting_a_row] diff --git a/samples/hello_happybase/requirements.txt b/samples/hello_happybase/requirements.txt index a667ebb82..a144f03e1 100644 --- a/samples/hello_happybase/requirements.txt +++ b/samples/hello_happybase/requirements.txt @@ -1 +1 @@ -google-cloud-happybase==0.32.1 +google-cloud-happybase==0.33.0 From 4dd74a54c15c4263c3a0240e913fd481e42621aa Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Tue, 19 Mar 2019 15:27:05 -0700 Subject: [PATCH 36/40] remove broken test config [(#2054)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2054) From e657b0423ce18040e044d9496348aca9f91b6dd6 Mon Sep 17 00:00:00 2001 From: Billy Jacobson Date: Mon, 22 Apr 2019 13:58:09 -0400 Subject: [PATCH 37/40] Cloud Bigtable Region tag consistency [(#2018)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2018) * Updating the region tags to be consistent across Cloud Bigtable. Need to figure out filtering for happybase or rename * Remove happybase filter * Linting --- samples/hello_happybase/main.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index 3aea7d4f7..e4e684934 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -25,22 +25,23 @@ """ import argparse - +# [START bigtable_hw_imports_happybase] from google.cloud import bigtable from google.cloud import happybase +# [END bigtable_hw_imports_happybase] def main(project_id, instance_id, table_name): - # [START connecting_to_bigtable] + # [START bigtable_hw_connect_happybase] # The client must be created with admin=True because it will create a # table. client = bigtable.Client(project=project_id, admin=True) instance = client.instance(instance_id) connection = happybase.Connection(instance=instance) - # [END connecting_to_bigtable] + # [END bigtable_hw_connect_happybase] try: - # [START creating_a_table] + # [START bigtable_hw_create_table_happybase] print('Creating the {} table.'.format(table_name)) column_family_name = 'cf1' connection.create_table( @@ -48,9 +49,9 @@ def main(project_id, instance_id, table_name): { column_family_name: dict() # Use default options. }) - # [END creating_a_table] + # [END bigtable_hw_create_table_happybase] - # [START writing_rows] + # [START bigtable_hw_write_rows_happybase] print('Writing some greetings to the table.') table = connection.table(table_name) column_name = '{fam}:greeting'.format(fam=column_family_name) @@ -75,26 +76,26 @@ def main(project_id, instance_id, table_name): table.put( row_key, {column_name.encode('utf-8'): value.encode('utf-8')} ) - # [END writing_rows] + # [END bigtable_hw_write_rows_happybase] - # [START getting_a_row] + # [START bigtable_hw_get_by_key_happybase] print('Getting a single greeting by row key.') key = 'greeting0'.encode('utf-8') row = table.row(key) print('\t{}: {}'.format(key, row[column_name.encode('utf-8')])) - # [END getting_a_row] + # [END bigtable_hw_get_by_key_happybase] - # [START scanning_all_rows] + # [START bigtable_hw_scan_all_happybase] print('Scanning for all greetings:') for key, row in table.scan(): print('\t{}: {}'.format(key, row[column_name.encode('utf-8')])) - # [END scanning_all_rows] + # [END bigtable_hw_scan_all_happybase] - # [START deleting_a_table] + # [START bigtable_hw_delete_table_happybase] print('Deleting the {} table.'.format(table_name)) connection.delete_table(table_name) - # [END deleting_a_table] + # [END bigtable_hw_delete_table_happybase] finally: connection.close() From 161662c0841ddbd2a77f5c5da3b477a9a64d3818 Mon Sep 17 00:00:00 2001 From: Billy Jacobson Date: Thu, 9 Jan 2020 16:52:18 -0500 Subject: [PATCH 38/40] Cleanup bigtable python examples [(#2692)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2692) * Cleanup bigtable python: Use new row types for mutations Update bigtable version in requirements Delete table after tests * Change bigtable cluster variable to bigtable instance for consistency Create and delete quickstart table during test * Fixing step size for metric scaler Create unique tables for quickstart tests * Creating fixtures for quickstart tests Fixing hb quickstart test output * Fix quickstart extra delete table Update happybase to use direct row * Use clearer instance names for tests Create unique instances for metric scaler tests * Linting * remove core dep Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> --- samples/hello_happybase/main_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/hello_happybase/main_test.py b/samples/hello_happybase/main_test.py index 3fc4ad134..d1dfc65c2 100644 --- a/samples/hello_happybase/main_test.py +++ b/samples/hello_happybase/main_test.py @@ -18,8 +18,8 @@ from main import main PROJECT = os.environ['GCLOUD_PROJECT'] -BIGTABLE_CLUSTER = os.environ['BIGTABLE_CLUSTER'] -TABLE_NAME_FORMAT = 'hello_happybase-system-tests-{}' +BIGTABLE_INSTANCE = os.environ['BIGTABLE_INSTANCE'] +TABLE_NAME_FORMAT = 'hello-world-hb-test-{}' TABLE_NAME_RANGE = 10000 @@ -28,7 +28,7 @@ def test_main(capsys): random.randrange(TABLE_NAME_RANGE)) main( PROJECT, - BIGTABLE_CLUSTER, + BIGTABLE_INSTANCE, table_name) out, _ = capsys.readouterr() From 582fc537d13c1f12d504c2bc663ae3a5b44466af Mon Sep 17 00:00:00 2001 From: Kurtis Van Gent <31518063+kurtisvg@users.noreply.github.com> Date: Wed, 1 Apr 2020 19:11:50 -0700 Subject: [PATCH 39/40] Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2806) * chore(deps): update dependency requests to v2.23.0 * Simplify noxfile and add version control. * Configure appengine/standard to only test Python 2.7. * Update Kokokro configs to match noxfile. * Add requirements-test to each folder. * Remove Py2 versions from everything execept appengine/standard. * Remove conftest.py. * Remove appengine/standard/conftest.py * Remove 'no-sucess-flaky-report' from pytest.ini. * Add GAE SDK back to appengine/standard tests. * Fix typo. * Roll pytest to python 2 version. * Add a bunch of testing requirements. * Remove typo. * Add appengine lib directory back in. * Add some additional requirements. * Fix issue with flake8 args. * Even more requirements. * Readd appengine conftest.py. * Add a few more requirements. * Even more Appengine requirements. * Add webtest for appengine/standard/mailgun. * Add some additional requirements. * Add workaround for issue with mailjet-rest. * Add responses for appengine/standard/mailjet. Co-authored-by: Renovate Bot --- samples/hello_happybase/requirements-test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 samples/hello_happybase/requirements-test.txt diff --git a/samples/hello_happybase/requirements-test.txt b/samples/hello_happybase/requirements-test.txt new file mode 100644 index 000000000..781d4326c --- /dev/null +++ b/samples/hello_happybase/requirements-test.txt @@ -0,0 +1 @@ +pytest==5.3.2 From eb5049fa90c34c2356fffeea70a36499d0ba2877 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Tue, 12 May 2020 11:51:21 -0700 Subject: [PATCH 40/40] chore: some lint fixes [(#3738)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/3738) --- samples/hello_happybase/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/hello_happybase/main.py b/samples/hello_happybase/main.py index e4e684934..ade4acbf0 100644 --- a/samples/hello_happybase/main.py +++ b/samples/hello_happybase/main.py @@ -25,6 +25,7 @@ """ import argparse + # [START bigtable_hw_imports_happybase] from google.cloud import bigtable from google.cloud import happybase