Skip to content

Commit

Permalink
Release 0.8.0 (#236)
Browse files Browse the repository at this point in the history
* Release 0.8.0

* Update changelog.
* Add Python 3.7 to supported versions in the package.
* Fix docstrings in new Context class to match pandas-style.
* Document new context class in authentication and API docs.

* Add issue number for `credentials` parameter change.
  • Loading branch information
tswast committed Nov 12, 2018
1 parent 40480ea commit 398e75e
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 33 deletions.
4 changes: 4 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ API Reference
Context

.. autofunction:: read_gbq

.. autofunction:: to_gbq

.. autodata:: context

.. autoclass:: Context
:members:
14 changes: 11 additions & 3 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Changelog

.. _changelog-0.8.0:

0.8.0 / unreleased
--------------------
0.8.0 / 2018-11-12
------------------

Breaking changes
~~~~~~~~~~~~~~~~
Expand All @@ -16,12 +16,20 @@ Breaking changes
or
:func:`google.oauth2.service_account.Credentials.from_service_account_file`.
See the :doc:`authentication how-to guide <howto/authentication>` for
examples. (:issue:`161`, :issue:`TODO`)
examples. (:issue:`161`, :issue:`231`)

Enhancements
~~~~~~~~~~~~

- Allow newlines in data passed to ``to_gbq``. (:issue:`180`)
- Add :attr:`pandas_gbq.context.dialect` to allow overriding the default SQL
syntax dialect. (:issue:`195`, :issue:`235`)
- Support Python 3.7. (:issue:`197`, :issue:`232`)

Internal changes
~~~~~~~~~~~~~~~~

- Migrate tests to CircleCI. (:issue:`228`, :issue:`232`)

.. _changelog-0.7.0:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ run gbq integration tests on a forked repository:
- ``GBQ_PROJECT_ID`` with the value being the ID of your BigQuery project.

- ``SERVICE_ACCOUNT_KEY`` with the value being the base64-encoded
*contents* of the JSON key that you downloaded for your service account.
*contents* of the JSON key that you downloaded for your service account.

Keep the contents of these variables confidential. These variables contain
sensitive data and you do not want their contents being exposed in build
Expand Down
12 changes: 8 additions & 4 deletions docs/source/howto/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ more information on service accounts.
Default Authentication Methods
------------------------------

If the ``private_key`` parameter is ``None``, pandas-gbq tries the following
authentication methods:
If the ``credentials`` parameter (or the deprecated ``private_key``
parameter) is ``None``, pandas-gbq tries the following authentication
methods:

1. Application Default Credentials via the :func:`google.auth.default`
1. In-memory, cached credentials at ``pandas_gbq.context.credentials``. See
:attr:`pandas_gbq.Context.credentials` for details.

2. Application Default Credentials via the :func:`google.auth.default`
function.

.. note::
Expand All @@ -74,7 +78,7 @@ authentication methods:
Compute Engine is that the VM does not have sufficient scopes to query
BigQuery.

2. User account credentials.
3. User account credentials.

pandas-gbq loads cached credentials from a hidden user folder on the
operating system. Override the location of the cached user credentials
Expand Down
77 changes: 52 additions & 25 deletions pandas_gbq/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,34 @@ def __init__(self):

@property
def credentials(self):
"""google.auth.credentials.Credentials: Credentials to use for Google
APIs.
Note:
These credentials are automatically cached in memory by calls to
:func:`pandas_gbq.read_gbq` and :func:`pandas_gbq.to_gbq`. To
manually set the credentials, construct an
:class:`google.auth.credentials.Credentials` object and set it as
the context credentials as demonstrated in the example below. See
`auth docs`_ for more information on obtaining credentials.
Example:
Manually setting the context credentials:
>>> import pandas_gbq
>>> from google.oauth2 import service_account
>>> credentials = (service_account
... .Credentials.from_service_account_file(
... '/path/to/key.json'))
>>> pandas_gbq.context.credentials = credentials
"""
Credentials to use for Google APIs.
These credentials are automatically cached in memory by calls to
:func:`pandas_gbq.read_gbq` and :func:`pandas_gbq.to_gbq`. To
manually set the credentials, construct an
:class:`google.auth.credentials.Credentials` object and set it as
the context credentials as demonstrated in the example below. See
`auth docs`_ for more information on obtaining credentials.
.. _auth docs: http://google-auth.readthedocs.io
/en/latest/user-guide.html#obtaining-credentials
Returns
-------
google.auth.credentials.Credentials
Examples
--------
Manually setting the context credentials:
>>> import pandas_gbq
>>> from google.oauth2 import service_account
>>> credentials = service_account.Credentials.from_service_account_file(
... '/path/to/key.json',
... )
>>> pandas_gbq.context.credentials = credentials
"""
return self._credentials

Expand All @@ -205,12 +212,19 @@ def credentials(self, value):

@property
def project(self):
"""str: Default project to use for calls to Google APIs.
"""Default project to use for calls to Google APIs.
Example:
Manually setting the context project:
>>> import pandas_gbq
>>> pandas_gbq.context.project = 'my-project'
Returns
-------
str
Examples
--------
Manually setting the context project:
>>> import pandas_gbq
>>> pandas_gbq.context.project = 'my-project'
"""
return self._project

Expand All @@ -220,7 +234,8 @@ def project(self, value):

@property
def dialect(self):
"""str: Default dialect to use in :func:`pandas_gbq.read_gbq`.
"""
Default dialect to use in :func:`pandas_gbq.read_gbq`.
Allowed values for the BigQuery SQL syntax dialect:
Expand All @@ -233,6 +248,18 @@ def dialect(self):
compliant with the SQL 2011 standard. For more information
see `BigQuery Standard SQL Reference
<https://cloud.google.com/bigquery/docs/reference/standard-sql/>`__.
Returns
-------
str
Examples
--------
Setting the default syntax to standard:
>>> import pandas_gbq
>>> pandas_gbq.context.dialect = 'standard'
"""
return self._dialect

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def readme():
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Scientific/Engineering",
],
keywords="data",
Expand Down

0 comments on commit 398e75e

Please sign in to comment.