Skip to content

Commit 85d4b1c

Browse files
author
Jon Wayne Parrott
authored
Move to google-cloud (#544)
1 parent cb805a9 commit 85d4b1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+156
-150
lines changed

appengine/flexible/datastore/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import socket
1919

2020
from flask import Flask, request
21-
from gcloud import datastore
21+
from google.cloud import datastore
2222

2323

2424
app = Flask(__name__)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Flask==0.11.1
2-
gcloud==0.18.3
2+
google-cloud-datastore==0.20.0
33
gunicorn==19.6.0
44
oauth2client==3.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Django==1.10.1
2-
mysqlclient==1.3.7
2+
mysqlclient==1.3.8
33
wheel==0.30.0a0
44
gunicorn==19.6.0
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Flask==0.11.1
22
flask-cors==3.0.2
33
gunicorn==19.6.0
4-
gcloud==0.18.3
54
six==1.10.0
65
pyyaml==3.12
76
requests==2.11.1
8-
google-api-python-client==1.5.3

appengine/flexible/pubsub/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020

2121
from flask import current_app, Flask, render_template, request
22-
from gcloud import pubsub
22+
from google.cloud import pubsub
2323

2424

2525
app = Flask(__name__)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Flask==0.11.1
2-
gcloud==0.18.3
2+
google-cloud-pubsub==0.20.0
33
gunicorn==19.6.0
44
oauth2client==3.0.0

appengine/flexible/storage/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919
from flask import Flask, request
20-
from gcloud import storage
20+
from google.cloud import storage
2121

2222
# [start config]
2323
app = Flask(__name__)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Flask==0.11.1
2-
gcloud==0.18.3
2+
google-cloud-storage==0.20.0
33
gunicorn==19.6.0

bigquery/cloud-client/async_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import time
2828
import uuid
2929

30-
from gcloud import bigquery
30+
from google.cloud import bigquery
3131

3232

3333
def async_query(query):

bigquery/cloud-client/export_data_to_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import time
3030
import uuid
3131

32-
from gcloud import bigquery
32+
from google.cloud import bigquery
3333

3434

3535
def export_data_to_gcs(dataset_name, table_name, destination):

bigquery/cloud-client/load_data_from_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import argparse
2929
import time
30-
from gcloud import bigquery
30+
from google.cloud import bigquery
3131

3232

3333
def load_data_from_file(dataset_name, table_name, source_file_name):

bigquery/cloud-client/load_data_from_gcs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import time
3030
import uuid
3131

32-
from gcloud import bigquery
32+
from google.cloud import bigquery
3333

3434

3535
def load_data_from_gcs(dataset_name, table_name, source):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gcloud==0.18.3
1+
google-cloud-bigquery==0.20.0

bigquery/cloud-client/snippets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import time
2929
import uuid
3030

31-
from gcloud import bigquery
32-
import gcloud.bigquery.job
31+
from google.cloud import bigquery
32+
import google.cloud.bigquery.job
3333

3434

3535
def list_projects():
@@ -145,7 +145,7 @@ def list_rows(dataset_name, table_name, project=None):
145145
break
146146

147147
# Use format to create a simple table.
148-
format_string = '{:<16} ' * len(table.schema)
148+
format_string = '{!s:<16} ' * len(table.schema)
149149

150150
# Print schema field names
151151
field_names = [field.name for field in table.schema]
@@ -177,7 +177,7 @@ def copy_table(dataset_name, table_name, new_table_name, project=None):
177177

178178
# Create the table if it doesn't exist.
179179
job.create_disposition = (
180-
gcloud.bigquery.job.CreateDisposition.CREATE_IF_NEEDED)
180+
google.cloud.bigquery.job.CreateDisposition.CREATE_IF_NEEDED)
181181

182182
# Start the job.
183183
job.begin()

bigquery/cloud-client/snippets_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from gcloud import bigquery
15+
from google.cloud import bigquery
1616
import pytest
1717

1818
import snippets

bigquery/cloud-client/stream_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import json
3030
from pprint import pprint
3131

32-
from gcloud import bigquery
32+
from google.cloud import bigquery
3333

3434

3535
def stream_data(dataset_name, table_name, json_data):

bigquery/cloud-client/sync_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import argparse
2727

2828
# [START sync_query]
29-
from gcloud import bigquery
29+
from google.cloud import bigquery
3030

3131

3232
def sync_query(query):

bigquery/dml/insert_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# [START insert_sql]
3434
import argparse
3535

36-
from gcloud import bigquery
36+
from google.cloud import bigquery
3737

3838

3939
def insert_sql(project, default_dataset, sql_path):

bigquery/dml/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
flake8==3.0.4
2-
gcloud==0.18.3
2+
google-cloud-bigquery==0.20.0
33
PyMySQL==0.7.9
44
six==1.10.0
55
SQLAlchemy==1.1.0b3

bigtable/hello/main.py

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -26,79 +26,79 @@
2626

2727
import argparse
2828

29-
from gcloud import bigtable
29+
from google.cloud import bigtable
3030

3131

3232
def main(project_id, instance_id, table_id):
3333
# [START connecting_to_bigtable]
3434
# The client must be created with admin=True because it will create a
3535
# table.
36-
with bigtable.Client(project=project_id, admin=True) as client:
37-
instance = client.instance(instance_id)
38-
# [END connecting_to_bigtable]
39-
40-
# [START creating_a_table]
41-
print('Creating the {} table.'.format(table_id))
42-
table = instance.table(table_id)
43-
table.create()
44-
column_family_id = 'cf1'
45-
cf1 = table.column_family(column_family_id)
46-
cf1.create()
47-
# [END creating_a_table]
48-
49-
# [START writing_rows]
50-
print('Writing some greetings to the table.')
51-
column_id = 'greeting'.encode('utf-8')
52-
greetings = [
53-
'Hello World!',
54-
'Hello Cloud Bigtable!',
55-
'Hello Python!',
56-
]
57-
58-
for i, value in enumerate(greetings):
59-
# Note: This example uses sequential numeric IDs for simplicity,
60-
# but this can result in poor performance in a production
61-
# application. Since rows are stored in sorted order by key,
62-
# sequential keys can result in poor distribution of operations
63-
# across nodes.
64-
#
65-
# For more information about how to design a Bigtable schema for
66-
# the best performance, see the documentation:
67-
#
68-
# https://cloud.google.com/bigtable/docs/schema-design
69-
row_key = 'greeting{}'.format(i)
70-
row = table.row(row_key)
71-
row.set_cell(
72-
column_family_id,
73-
column_id,
74-
value.encode('utf-8'))
75-
row.commit()
76-
# [END writing_rows]
77-
78-
# [START getting_a_row]
79-
print('Getting a single greeting by row key.')
80-
key = 'greeting0'
81-
row = table.read_row(key.encode('utf-8'))
82-
value = row.cells[column_family_id][column_id][0].value
83-
print('\t{}: {}'.format(key, value.decode('utf-8')))
84-
# [END getting_a_row]
85-
86-
# [START scanning_all_rows]
87-
print('Scanning for all greetings:')
88-
partial_rows = table.read_rows()
89-
partial_rows.consume_all()
90-
91-
for row_key, row in partial_rows.rows.items():
92-
key = row_key.decode('utf-8')
93-
cell = row.cells[column_family_id][column_id][0]
94-
value = cell.value.decode('utf-8')
95-
print('\t{}: {}'.format(key, value))
96-
# [END scanning_all_rows]
97-
98-
# [START deleting_a_table]
99-
print('Deleting the {} table.'.format(table_id))
100-
table.delete()
101-
# [END deleting_a_table]
36+
client = bigtable.Client(project=project_id, admin=True)
37+
instance = client.instance(instance_id)
38+
# [END connecting_to_bigtable]
39+
40+
# [START creating_a_table]
41+
print('Creating the {} table.'.format(table_id))
42+
table = instance.table(table_id)
43+
table.create()
44+
column_family_id = 'cf1'
45+
cf1 = table.column_family(column_family_id)
46+
cf1.create()
47+
# [END creating_a_table]
48+
49+
# [START writing_rows]
50+
print('Writing some greetings to the table.')
51+
column_id = 'greeting'.encode('utf-8')
52+
greetings = [
53+
'Hello World!',
54+
'Hello Cloud Bigtable!',
55+
'Hello Python!',
56+
]
57+
58+
for i, value in enumerate(greetings):
59+
# Note: This example uses sequential numeric IDs for simplicity,
60+
# but this can result in poor performance in a production
61+
# application. Since rows are stored in sorted order by key,
62+
# sequential keys can result in poor distribution of operations
63+
# across nodes.
64+
#
65+
# For more information about how to design a Bigtable schema for
66+
# the best performance, see the documentation:
67+
#
68+
# https://cloud.google.com/bigtable/docs/schema-design
69+
row_key = 'greeting{}'.format(i)
70+
row = table.row(row_key)
71+
row.set_cell(
72+
column_family_id,
73+
column_id,
74+
value.encode('utf-8'))
75+
row.commit()
76+
# [END writing_rows]
77+
78+
# [START getting_a_row]
79+
print('Getting a single greeting by row key.')
80+
key = 'greeting0'
81+
row = table.read_row(key.encode('utf-8'))
82+
value = row.cells[column_family_id][column_id][0].value
83+
print('\t{}: {}'.format(key, value.decode('utf-8')))
84+
# [END getting_a_row]
85+
86+
# [START scanning_all_rows]
87+
print('Scanning for all greetings:')
88+
partial_rows = table.read_rows()
89+
partial_rows.consume_all()
90+
91+
for row_key, row in partial_rows.rows.items():
92+
key = row_key.decode('utf-8')
93+
cell = row.cells[column_family_id][column_id][0]
94+
value = cell.value.decode('utf-8')
95+
print('\t{}: {}'.format(key, value))
96+
# [END scanning_all_rows]
97+
98+
# [START deleting_a_table]
99+
print('Deleting the {} table.'.format(table_id))
100+
table.delete()
101+
# [END deleting_a_table]
102102

103103

104104
if __name__ == '__main__':

bigtable/hello/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gcloud[grpc]==0.18.3
1+
google-cloud-bigtable==0.20.0

bigtable/hello_happybase/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
import argparse
2828

29-
from gcloud import bigtable
30-
from gcloud.bigtable import happybase
29+
from google.cloud import bigtable
30+
from google.cloud import happybase
3131

3232

3333
def main(project_id, instance_id, table_name):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gcloud[grpc]==0.18.3
1+
google-cloud-happybase==0.20.0

blog/introduction_to_data_models_in_cloud_datastore/blog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import argparse
1515
import datetime
1616

17-
from gcloud import datastore
17+
from google.cloud import datastore
1818

1919

2020
def path_to_key(datastore, path):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gcloud==0.18.3
1+
google-cloud-datastore==0.20.0

blog/introduction_to_data_models_in_cloud_datastore/wiki.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import argparse
1515
import datetime
1616

17-
from gcloud import datastore
17+
from google.cloud import datastore
1818

1919

2020
def path_to_key(datastore, path):
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Django==1.10.1
2-
mysqlclient==1.3.7
2+
mysqlclient==1.3.8
33
wheel==0.30.0a0
44
gunicorn==19.6.0

dataproc/create_cluster_and_submit_job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919
from apiclient import discovery
20-
from gcloud import storage
20+
from google.cloud import storage
2121
from oauth2client.client import GoogleCredentials
2222

2323
# Currently only the "global" region is supported

dataproc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
google-api-python-client==1.5.3
2-
gcloud==0.18.3
2+
google-cloud==0.20.0

datastore/api/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
gcloud==0.18.3
1+
google-cloud-datastore==0.20.0

0 commit comments

Comments
 (0)