Skip to content

Commit dec1f3d

Browse files
committed
Making bigquery subpackage into a proper package.
- Adding README, setup.py, MANIFEST.in, .coveragerc and tox.ini - Adding google-cloud-bigquery as a dependency to the umbrella package - Adding the bigquery subdirectory into the list of packages for verifying the docs - Incorporating the bigquery subdirectory into the umbrella coverage report - Adding the bigquery only tox tests to the Travis config - Adding {toxinidir}/../core as a dependency for the bigquery tox config
1 parent 921d990 commit dec1f3d

File tree

9 files changed

+214
-0
lines changed

9 files changed

+214
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ install:
77
script:
88
- tox -e py27
99
- (cd core && tox -e py27)
10+
- (cd bigquery && tox -e py27)
1011
- tox -e py34
1112
- (cd core && tox -e py34)
13+
- (cd bigquery && tox -e py34)
1214
- tox -e lint
1315
- tox -e cover
1416
- (cd core && tox -e cover)
17+
- (cd bigquery && tox -e cover)
1518
- tox -e system-tests
1619
- tox -e system-tests3
1720
- scripts/update_docs.sh

bigquery/.coveragerc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
fail_under = 100
6+
show_missing = True
7+
exclude_lines =
8+
# Re-enable the standard pragma
9+
pragma: NO COVER
10+
# Ignore debug-only repr
11+
def __repr__

bigquery/MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include README.rst
2+
graft google
3+
graft unit_tests
4+
global-exclude *.pyc

bigquery/README.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Python Client for Google Cloud BigQuery
2+
=======================================
3+
4+
Python idiomatic client for `Google Cloud BigQuery`_
5+
6+
.. _Google Cloud BigQuery: https://cloud.google.com/bigquery/what-is-bigquery
7+
8+
- `Homepage`_
9+
- `API Documentation`_
10+
11+
.. _Homepage: https://googlecloudplatform.github.io/google-cloud-python/
12+
.. _API Documentation: http://googlecloudplatform.github.io/google-cloud-python/
13+
14+
Quick Start
15+
-----------
16+
17+
::
18+
19+
$ pip install --upgrade google-cloud-bigquery
20+
21+
Authentication
22+
--------------
23+
24+
With ``google-cloud-python`` we try to make authentication as painless as
25+
possible. Check out the `Authentication section`_ in our documentation to
26+
learn more. You may also find the `authentication document`_ shared by all
27+
the ``google-cloud-*`` libraries to be helpful.
28+
29+
.. _Authentication section: http://google-cloud-python.readthedocs.io/en/latest/google-cloud-auth.html
30+
.. _authentication document: https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication
31+
32+
Using the API
33+
-------------
34+
35+
Querying massive datasets can be time consuming and expensive without the
36+
right hardware and infrastructure. Google `BigQuery`_ (`BigQuery API docs`_)
37+
solves this problem by enabling super-fast, SQL-like queries against
38+
append-only tables, using the processing power of Google's infrastructure.
39+
40+
.. _BigQuery: https://cloud.google.com/bigquery/what-is-bigquery
41+
.. _BigQuery API docs: https://cloud.google.com/bigquery/docs/reference/v2/
42+
43+
Load data from CSV
44+
~~~~~~~~~~~~~~~~~~
45+
46+
.. code:: python
47+
48+
import csv
49+
50+
from google.cloud import bigquery
51+
from google.cloud.bigquery import SchemaField
52+
53+
client = bigquery.Client()
54+
55+
dataset = client.dataset('dataset_name')
56+
dataset.create() # API request
57+
58+
SCHEMA = [
59+
SchemaField('full_name', 'STRING', mode='required'),
60+
SchemaField('age', 'INTEGER', mode='required'),
61+
]
62+
table = dataset.table('table_name', SCHEMA)
63+
table.create()
64+
65+
with open('csv_file', 'rb') as readable:
66+
table.upload_from_file(
67+
readable, source_format='CSV', skip_leading_rows=1)
68+
69+
Perform a synchronous query
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
.. code:: python
73+
74+
# Perform a synchronous query.
75+
QUERY = (
76+
'SELECT name FROM [bigquery-public-data:usa_names.usa_1910_2013] '
77+
'WHERE state = "TX"')
78+
query = client.run_sync_query('%s LIMIT 100' % QUERY)
79+
query.timeout_ms = TIMEOUT_MS
80+
query.run()
81+
82+
for row in query.rows:
83+
print(row)
84+
85+
86+
See the ``google-cloud-python`` API `BigQuery documentation`_ to learn how
87+
to connect to BigQuery using this Client Library.
88+
89+
.. _BigQuery documentation: https://googlecloudplatform.github.io/google-cloud-python/stable/bigquery-usage.html

bigquery/setup.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Copyright 2016 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
17+
from setuptools import find_packages
18+
from setuptools import setup
19+
20+
21+
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
22+
23+
with open(os.path.join(PACKAGE_ROOT, 'README.rst')) as file_obj:
24+
README = file_obj.read()
25+
26+
# NOTE: This is duplicated throughout and we should try to
27+
# consolidate.
28+
SETUP_BASE = {
29+
'author': 'Google Cloud Platform',
30+
'author_email': '[email protected]',
31+
'scripts': [],
32+
'url': 'https://github.com/GoogleCloudPlatform/google-cloud-python',
33+
'license': 'Apache 2.0',
34+
'platforms': 'Posix; MacOS X; Windows',
35+
'include_package_data': True,
36+
'zip_safe': False,
37+
'classifiers': [
38+
'Development Status :: 4 - Beta',
39+
'Intended Audience :: Developers',
40+
'License :: OSI Approved :: Apache Software License',
41+
'Operating System :: OS Independent',
42+
'Programming Language :: Python :: 2',
43+
'Programming Language :: Python :: 2.7',
44+
'Programming Language :: Python :: 3',
45+
'Programming Language :: Python :: 3.4',
46+
'Programming Language :: Python :: 3.5',
47+
'Topic :: Internet',
48+
],
49+
}
50+
51+
52+
REQUIREMENTS = [
53+
'google-cloud-core',
54+
]
55+
56+
setup(
57+
name='google-cloud-bigquery',
58+
version='0.20.0dev',
59+
description='Python Client for Google BigQuery',
60+
long_description=README,
61+
namespace_packages=[
62+
'google',
63+
'google.cloud',
64+
],
65+
packages=find_packages(),
66+
install_requires=REQUIREMENTS,
67+
**SETUP_BASE
68+
)

bigquery/tox.ini

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tox]
2+
envlist =
3+
py27,py34,py35,cover
4+
5+
[testing]
6+
deps =
7+
{toxinidir}/../core
8+
pytest
9+
covercmd =
10+
py.test --quiet \
11+
--cov=google.cloud.bigquery \
12+
--cov=unit_tests \
13+
--cov-config {toxinidir}/.coveragerc \
14+
unit_tests
15+
16+
[testenv]
17+
commands =
18+
py.test --quiet {posargs} unit_tests
19+
deps =
20+
{[testing]deps}
21+
22+
[testenv:cover]
23+
basepython =
24+
python2.7
25+
commands =
26+
{[testing]covercmd}
27+
deps =
28+
{[testenv]deps}
29+
coverage
30+
pytest-cov

scripts/verify_included_modules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
])
6060
PACKAGES = (
6161
'',
62+
'bigquery',
6263
'core',
6364
)
6465

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151

5252
REQUIREMENTS = [
53+
'google-cloud-bigquery',
5354
'google-cloud-core',
5455
]
5556

tox.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ envlist =
55
[testing]
66
deps =
77
{toxinidir}/core
8+
{toxinidir}/bigquery
89
pytest
910
covercmd =
1011
py.test --quiet \
@@ -18,6 +19,12 @@ covercmd =
1819
--cov-append \
1920
--cov-config {toxinidir}/.coveragerc \
2021
core/unit_tests
22+
py.test --quiet \
23+
--cov=google.cloud \
24+
--cov=unit_tests \
25+
--cov-append \
26+
--cov-config {toxinidir}/.coveragerc \
27+
bigquery/unit_tests
2128
coverage report --show-missing --fail-under=100
2229

2330
[testenv]

0 commit comments

Comments
 (0)