From 21c080203e8f287e5f17613559ba6792202f588a Mon Sep 17 00:00:00 2001 From: DPE bot Date: Tue, 27 Jun 2017 12:41:15 -0700 Subject: [PATCH] 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/snippets/async_query.py | 17 +++-------------- samples/snippets/query_params.py | 17 ++++------------- samples/snippets/query_params_test.py | 4 ++-- samples/snippets/requirements.txt | 2 +- samples/snippets/resources/data.csv | 2 +- samples/snippets/simple_app.py | 15 +++------------ samples/snippets/sync_query.py | 15 +++------------ samples/snippets/user_credentials.py | 15 +++------------ 8 files changed, 20 insertions(+), 67 deletions(-) diff --git a/samples/snippets/async_query.py b/samples/snippets/async_query.py index f90c8f255..4f7b2330b 100755 --- a/samples/snippets/async_query.py +++ b/samples/snippets/async_query.py @@ -48,20 +48,9 @@ def async_query(query): wait_for_job(query_job) - # Drain the query results by requesting a page at a time. - query_results = query_job.results() - page_token = None - - while True: - rows, total_rows, page_token = query_results.fetch_data( - max_results=10, - page_token=page_token) - - for row in rows: - print(row) - - if not page_token: - break + rows = query_job.results().fetch_data(max_results=10) + for row in rows: + print(row) if __name__ == '__main__': diff --git a/samples/snippets/query_params.py b/samples/snippets/query_params.py index 1025fd26b..192558d91 100644 --- a/samples/snippets/query_params.py +++ b/samples/snippets/query_params.py @@ -43,19 +43,10 @@ def wait_for_job(job): def print_results(query_results): - """Print the query results by requesting a page at a time.""" - page_token = None - - while True: - rows, total_rows, page_token = query_results.fetch_data( - max_results=10, - page_token=page_token) - - for row in rows: - print(row) - - if not page_token: - break + """Print the rows in the query's results.""" + rows = query_results.fetch_data(max_results=10) + for row in rows: + print(row) def query_positional_params(corpus, min_word_count): diff --git a/samples/snippets/query_params_test.py b/samples/snippets/query_params_test.py index 66f4951dd..f4b493137 100644 --- a/samples/snippets/query_params_test.py +++ b/samples/snippets/query_params_test.py @@ -28,7 +28,7 @@ def test_query_named_params(capsys): corpus='romeoandjuliet', min_word_count=100) out, _ = capsys.readouterr() - assert 'love' in out + assert 'the' in out def test_query_positional_params(capsys): @@ -36,7 +36,7 @@ def test_query_positional_params(capsys): corpus='romeoandjuliet', min_word_count=100) out, _ = capsys.readouterr() - assert 'love' in out + assert 'the' in out def test_query_struct_params(capsys): diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 5874270b3..3e0afe76a 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,3 +1,3 @@ -google-cloud-bigquery==0.24.0 +google-cloud-bigquery==0.25.0 google-auth-oauthlib==0.1.0 pytz==2017.2 diff --git a/samples/snippets/resources/data.csv b/samples/snippets/resources/data.csv index 230a96b55..affe39ef8 100644 --- a/samples/snippets/resources/data.csv +++ b/samples/snippets/resources/data.csv @@ -1 +1 @@ -Gandalf, 2000, 140.0, 1 +Gandalf,2000,140.0,1 diff --git a/samples/snippets/simple_app.py b/samples/snippets/simple_app.py index 7180c4fda..31059c9f7 100644 --- a/samples/snippets/simple_app.py +++ b/samples/snippets/simple_app.py @@ -38,19 +38,10 @@ def query_shakespeare(): # [END run_query] # [START print_results] - # Drain the query results by requesting a page at a time. - page_token = None + rows = query_results.fetch_data(max_results=10) - while True: - rows, total_rows, page_token = query_results.fetch_data( - max_results=10, - page_token=page_token) - - for row in rows: - print(row) - - if not page_token: - break + for row in rows: + print(row) # [END print_results] diff --git a/samples/snippets/sync_query.py b/samples/snippets/sync_query.py index 37c8fea8a..1f494f843 100755 --- a/samples/snippets/sync_query.py +++ b/samples/snippets/sync_query.py @@ -39,19 +39,10 @@ def sync_query(query): query_results.run() - # Drain the query results by requesting a page at a time. - page_token = None + rows = query_results.fetch_data(max_results=10) - while True: - rows, total_rows, page_token = query_results.fetch_data( - max_results=10, - page_token=page_token) - - for row in rows: - print(row) - - if not page_token: - break + for row in rows: + print(row) # [END sync_query] diff --git a/samples/snippets/user_credentials.py b/samples/snippets/user_credentials.py index a239b741e..017c87ffd 100644 --- a/samples/snippets/user_credentials.py +++ b/samples/snippets/user_credentials.py @@ -46,20 +46,11 @@ def run_query(credentials, project, query): wait_for_job(query_job) - # Drain the query results by requesting a page at a time. query_results = query_job.results() - page_token = None + rows = query_results.fetch_data(max_results=10) - while True: - rows, total_rows, page_token = query_results.fetch_data( - max_results=10, - page_token=page_token) - - for row in rows: - print(row) - - if not page_token: - break + for row in rows: + print(row) def authenticate_and_query(project, query, launch_browser=True):