Skip to content

Commit 485e7db

Browse files
committed
feat(datastore): regenerate package with centralized mypy.ini POC
1 parent 779e62a commit 485e7db

4 files changed

Lines changed: 276 additions & 115 deletions

File tree

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
Python Client for Cloud Datastore
2+
=================================
3+
4+
|stable| |pypi| |versions|
5+
6+
`Cloud Datastore`_: Accesses the schemaless NoSQL database to provide fully managed, robust,
7+
scalable storage for your application.
8+
9+
- `Client Library Documentation`_
10+
- `Product Documentation`_
11+
12+
.. |stable| image:: https://img.shields.io/badge/support-stable-gold.svg
13+
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
14+
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-datastore.svg
15+
:target: https://pypi.org/project/google-cloud-datastore/
16+
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-datastore.svg
17+
:target: https://pypi.org/project/google-cloud-datastore/
18+
.. _Cloud Datastore: https://cloud.google.com/datastore
19+
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/datastore/latest/summary_overview
20+
.. _Product Documentation: https://cloud.google.com/datastore
21+
22+
Quick Start
23+
-----------
24+
25+
In order to use this library, you first need to go through the following steps:
26+
27+
1. `Select or create a Cloud Platform project.`_
28+
2. `Enable billing for your project.`_
29+
3. `Enable the Cloud Datastore.`_
30+
4. `Set up Authentication.`_
31+
32+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
33+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
34+
.. _Enable the Cloud Datastore.: https://cloud.google.com/datastore
35+
.. _Set up Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
36+
37+
Installation
38+
~~~~~~~~~~~~
39+
40+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
41+
creates isolated Python environments. These isolated environments can have separate
42+
versions of Python packages, which allows you to isolate one project's dependencies
43+
from the dependencies of other projects.
44+
45+
With `venv`_, it's possible to install this library without needing system
46+
install permissions, and without clashing with the installed system
47+
dependencies.
48+
49+
.. _`venv`: https://docs.python.org/3/library/venv.html
50+
51+
52+
Code samples and snippets
53+
~~~~~~~~~~~~~~~~~~~~~~~~~
54+
55+
Code samples and snippets live in the `samples/`_ folder.
56+
57+
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-datastore/samples
58+
59+
60+
Supported Python Versions
61+
^^^^^^^^^^^^^^^^^^^^^^^^^
62+
Our client libraries are compatible with all current `active`_ and `maintenance`_ versions of
63+
Python.
64+
65+
Python >= 3.10, including 3.14
66+
67+
.. _active: https://devguide.python.org/devcycle/#in-development-main-branch
68+
.. _maintenance: https://devguide.python.org/devcycle/#maintenance-branches
69+
70+
Unsupported Python Versions
71+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
72+
Python <= 3.9
73+
74+
75+
If you are using an `end-of-life`_
76+
version of Python, we recommend that you update as soon as possible to an actively supported version.
77+
78+
.. _end-of-life: https://devguide.python.org/devcycle/#end-of-life-branches
79+
80+
Mac/Linux
81+
^^^^^^^^^
82+
83+
.. code-block:: console
84+
85+
python3 -m venv <your-env>
86+
source <your-env>/bin/activate
87+
pip install google-cloud-datastore
88+
89+
90+
Windows
91+
^^^^^^^
92+
93+
.. code-block:: console
94+
95+
py -m venv <your-env>
96+
.\<your-env>\Scripts\activate
97+
pip install google-cloud-datastore
98+
99+
Next Steps
100+
~~~~~~~~~~
101+
102+
- Read the `Client Library Documentation`_ for Cloud Datastore
103+
to see other available methods on the client.
104+
- Read the `Cloud Datastore Product documentation`_ to learn
105+
more about the product and see How-to Guides.
106+
- View this `README`_ to see the full list of Cloud
107+
APIs that we cover.
108+
109+
.. _Cloud Datastore Product documentation: https://cloud.google.com/datastore
110+
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
111+
112+
Logging
113+
-------
114+
115+
This library uses the standard Python :code:`logging` functionality to log some RPC events that could be of interest for debugging and monitoring purposes.
116+
Note the following:
117+
118+
#. Logs may contain sensitive information. Take care to **restrict access to the logs** if they are saved, whether it be on local storage or on Google Cloud Logging.
119+
#. Google may refine the occurrence, level, and content of various log messages in this library without flagging such changes as breaking. **Do not depend on immutability of the logging events**.
120+
#. By default, the logging events from this library are not handled. You must **explicitly configure log handling** using one of the mechanisms below.
121+
122+
Simple, environment-based configuration
123+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124+
125+
To enable logging for this library without any changes in your code, set the :code:`GOOGLE_SDK_PYTHON_LOGGING_SCOPE` environment variable to a valid Google
126+
logging scope. This configures handling of logging events (at level :code:`logging.DEBUG` or higher) from this library in a default manner, emitting the logged
127+
messages in a structured format. It does not currently allow customizing the logging levels captured nor the handlers, formatters, etc. used for any logging
128+
event.
129+
130+
A logging scope is a period-separated namespace that begins with :code:`google`, identifying the Python module or package to log.
131+
132+
- Valid logging scopes: :code:`google`, :code:`google.cloud.asset.v1`, :code:`google.api`, :code:`google.auth`, etc.
133+
- Invalid logging scopes: :code:`foo`, :code:`123`, etc.
134+
135+
**NOTE**: If the logging scope is invalid, the library does not set up any logging handlers.
136+
137+
Environment-Based Examples
138+
^^^^^^^^^^^^^^^^^^^^^^^^^^
139+
140+
- Enabling the default handler for all Google-based loggers
141+
142+
.. code-block:: console
143+
144+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google
145+
146+
- Enabling the default handler for a specific Google module (for a client library called :code:`library_v1`):
147+
148+
.. code-block:: console
149+
150+
export GOOGLE_SDK_PYTHON_LOGGING_SCOPE=google.cloud.library_v1
151+
152+
153+
Advanced, code-based configuration
154+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155+
156+
You can also configure a valid logging scope using Python's standard `logging` mechanism.
157+
158+
Code-Based Examples
159+
^^^^^^^^^^^^^^^^^^^
160+
161+
- Configuring a handler for all Google-based loggers
162+
163+
.. code-block:: python
164+
165+
import logging
166+
167+
from google.cloud import library_v1
168+
169+
base_logger = logging.getLogger("google")
170+
base_logger.addHandler(logging.StreamHandler())
171+
base_logger.setLevel(logging.DEBUG)
172+
173+
- Configuring a handler for a specific Google module (for a client library called :code:`library_v1`):
174+
175+
.. code-block:: python
176+
177+
import logging
178+
179+
from google.cloud import library_v1
180+
181+
base_logger = logging.getLogger("google.cloud.library_v1")
182+
base_logger.addHandler(logging.StreamHandler())
183+
base_logger.setLevel(logging.DEBUG)
184+
185+
Logging details
186+
~~~~~~~~~~~~~~~
187+
188+
#. Regardless of which of the mechanisms above you use to configure logging for this library, by default logging events are not propagated up to the root
189+
logger from the `google`-level logger. If you need the events to be propagated to the root logger, you must explicitly set
190+
:code:`logging.getLogger("google").propagate = True` in your code.
191+
#. You can mix the different logging configurations above for different Google modules. For example, you may want use a code-based logging configuration for
192+
one library, but decide you need to also set up environment-based logging configuration for another library.
193+
194+
#. If you attempt to use both code-based and environment-based configuration for the same module, the environment-based configuration will be ineffectual
195+
if the code -based configuration gets applied first.
196+
197+
#. The Google-specific logging configurations (default handlers for environment-based configuration; not propagating logging events to the root logger) get
198+
executed the first time *any* client library is instantiated in your application, and only if the affected loggers have not been previously configured.
199+
(This is the reason for 2.i. above.)

packages/google-cloud-datastore/docs/index.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
.. include:: README.rst
22

3-
.. include:: multiprocessing.rst
3+
.. note::
44

5+
Because the Datastore client uses the :mod:`grpcio` library by default
6+
and uses third-party :mod:`requests` library if the GRPC is disabled,
7+
clients are safe to share instances across threads. In multiprocessing
8+
scenarios, the best practice is to create client instances *after*
9+
:class:`multiprocessing.Pool` or :class:`multiprocessing.Process` invokes
10+
:func:`os.fork`.
511

612
API Reference
713
-------------
814
.. toctree::
915
:maxdepth: 2
1016

11-
datastore_admin_v1/services_
12-
datastore_admin_v1/types_
13-
17+
client
18+
entities
19+
keys
20+
queries
21+
aggregations
22+
transactions
23+
batches
24+
helpers
25+
admin_client
1426

1527
Changelog
1628
---------

0 commit comments

Comments
 (0)