From 36438699dfe9a17b76d3c8e3d57fa002ae2a3a4b Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Mon, 15 Oct 2018 15:28:22 -0700 Subject: [PATCH 1/4] Making bigtable tests run successfully --- bigtable/hello/main.py | 6 +++--- bigtable/tableadmin/tableadmin.py | 22 ++++++++++++++++++++-- bigtable/tableadmin/tableadmin_test.py | 1 + 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/bigtable/hello/main.py b/bigtable/hello/main.py index 8bf927d9dc3..95c78e24fb5 100644 --- a/bigtable/hello/main.py +++ b/bigtable/hello/main.py @@ -59,7 +59,7 @@ def main(project_id, instance_id, table_id): print('Writing some greetings to the table.') greetings = ['Hello World!', 'Hello Cloud Bigtable!', 'Hello Python!'] rows = [] - column = 'greeting' + column = 'greeting'.encode() 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 @@ -71,7 +71,7 @@ def main(project_id, instance_id, table_id): # the best performance, see the documentation: # # https://cloud.google.com/bigtable/docs/schema-design - row_key = 'greeting{}'.format(i) + row_key = 'greeting{}'.format(i).encode() row = table.row(row_key) row.set_cell(column_family_id, column, @@ -83,7 +83,7 @@ def main(project_id, instance_id, table_id): # [START getting_a_row] print('Getting a single greeting by row key.') - key = 'greeting0' + key = 'greeting0'.encode() # Only retrieve the most recent version of the cell. row_filter = row_filters.CellsColumnLimitFilter(1) diff --git a/bigtable/tableadmin/tableadmin.py b/bigtable/tableadmin/tableadmin.py index 6bad0bebae8..29551a7f390 100644 --- a/bigtable/tableadmin/tableadmin.py +++ b/bigtable/tableadmin/tableadmin.py @@ -37,8 +37,8 @@ from google.cloud.bigtable import column_family -def run_table_operations(project_id, instance_id, table_id): - ''' Create a Bigtable table and perform basic table operations +def create_table(project_id, instance_id, table_id): + ''' Create a Bigtable table :type project_id: str :param project_id: Project id of the client. @@ -64,6 +64,24 @@ def run_table_operations(project_id, instance_id, table_id): table.create() print('Created table {}.'.format(table_id)) + return client, instance, table + + +def run_table_operations(project_id, instance_id, table_id): + ''' Create a Bigtable table and perform basic operations on it + + :type project_id: str + :param project_id: Project id of the client. + + :type instance_id: str + :param instance_id: Instance of the client. + + :type table_id: str + :param table_id: Table id to create table. + ''' + + client, instance, table = create_table(project_id, instance_id, table_id) + # [START bigtable_list_tables] tables = instance.list_tables() print('Listing tables in current project...') diff --git a/bigtable/tableadmin/tableadmin_test.py b/bigtable/tableadmin/tableadmin_test.py index df384a18b80..9477152ae41 100755 --- a/bigtable/tableadmin/tableadmin_test.py +++ b/bigtable/tableadmin/tableadmin_test.py @@ -53,6 +53,7 @@ def test_run_table_operations(capsys): def test_delete_table(capsys): table_name = TABLE_NAME_FORMAT.format( random.randrange(TABLE_NAME_RANGE)) + create_table(PROJECT, BIGTABLE_CLUSTER, table_name) delete_table(PROJECT, BIGTABLE_CLUSTER, table_name) out, _ = capsys.readouterr() From fb5d8b0359e6e260817907e9843fb7dfefe2e756 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Mon, 15 Oct 2018 15:38:01 -0700 Subject: [PATCH 2/4] Fixed missing import --- bigtable/tableadmin/tableadmin_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bigtable/tableadmin/tableadmin_test.py b/bigtable/tableadmin/tableadmin_test.py index 9477152ae41..c5852ed77f2 100755 --- a/bigtable/tableadmin/tableadmin_test.py +++ b/bigtable/tableadmin/tableadmin_test.py @@ -16,6 +16,7 @@ import os import random +from tableadmin import create_table from tableadmin import delete_table from tableadmin import run_table_operations From e4ec075e687f548e07cfd7e7691c6dcdb9527133 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Mon, 15 Oct 2018 16:13:05 -0700 Subject: [PATCH 3/4] Renamed noxfile for new environment --- nox.py => noxfile.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename nox.py => noxfile.py (100%) diff --git a/nox.py b/noxfile.py similarity index 100% rename from nox.py rename to noxfile.py From 60512e1958a8f9561dc18ee2ed545d43a1b88940 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Mon, 15 Oct 2018 16:17:02 -0700 Subject: [PATCH 4/4] Moving the nox name back --- noxfile.py => nox.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename noxfile.py => nox.py (100%) diff --git a/noxfile.py b/nox.py similarity index 100% rename from noxfile.py rename to nox.py