1+ # Copyright 2023 Google LLC
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+ description : Integrate Google Cloud Datastore Handwritten code
15+ # TODO(Fill in issue number below to add more context)
16+ url : https://github.com/googleapis/gapic-generator-python/issues/123
17+ replacements :
18+ - paths : [
19+ " packages/google-cloud-datastore/docs/conf.py" ,
20+ ]
21+ before : |
22+ exclude_patterns = \[
23+ \ "_build",
24+ after : |
25+ exclude_patterns = [
26+ "datastore_admin_v1/**",
27+ "datastore_v1/**",
28+ "multiprocessing.rst",
29+ "_build",
30+ count : 1
31+ - paths : [
32+ " packages/google-cloud-datastore/setup.py"
33+ ]
34+ before : |
35+ "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0",
36+ \ "grpcio >= 1.33.2, < 2.0.0",
37+ after : |
38+ "google-auth >= 2.14.1, <3.0.0,!=2.24.0,!=2.25.0",
39+ "google-cloud-core >= 1.4.0, <3.0.0",
40+ "grpcio >= 1.38.0, < 2.0.0",
41+ count : 1
42+ - paths : [
43+ " packages/google-cloud-datastore/mypy.ini" ,
44+ ]
45+ before : |-
46+ # Performance: reuse results from previous runs to speed up 'nox'
47+ incremental = True
48+ after : |-
49+ # Performance: reuse results from previous runs to speed up "nox"
50+ incremental = True
51+
52+ [mypy-google.cloud.datastore._app_engine_key_pb2]
53+ ignore_errors = True
54+
55+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2410):
56+ # Remove once this generator bug is fixed
57+ [mypy-google.cloud.datastore_v1.services.datastore.async_client]
58+ ignore_errors = True
59+
60+ # TODO(https://github.com/googleapis/gapic-generator-python/issues/2410):
61+ # Remove once this generator bug is fixed
62+ [mypy-google.cloud.datastore_v1.services.datastore.client]
63+ ignore_errors = True
64+ count : 1
65+ - paths : [
66+ " packages/google-cloud-datastore/mypy.ini" ,
67+ ]
68+ before : |
69+ ignore_missing_imports = False
70+
71+ # TODO\(https://github.com/googleapis/gapic-generator-python/issues/2563\):
72+ # Dependencies that historically lacks py.typed markers
73+ \[mypy-google\.iam\.\*\]
74+ ignore_missing_imports = True
75+ after : |
76+ ignore_missing_imports = True
77+ count : 1
78+ - paths : [
79+ " packages/google-cloud-datastore/docs/index.rst" ,
80+ ]
81+ before : |
82+ \.\. include:: multiprocessing\.rst[\s\S]*?CHANGELOG
83+ after : |
84+ .. note::
85+
86+ Because the Datastore client uses the :mod:`grpcio` library by default
87+ and uses third-party :mod:`requests` library if the GRPC is disabled,
88+ clients are safe to share instances across threads. In multiprocessing
89+ scenarios, the best practice is to create client instances *after*
90+ :class:`multiprocessing.Pool` or :class:`multiprocessing.Process` invokes
91+ :func:`os.fork`.
92+
93+ API Reference
94+ -------------
95+ .. toctree::
96+ :maxdepth: 2
97+
98+ client
99+ entities
100+ keys
101+ queries
102+ aggregations
103+ transactions
104+ batches
105+ helpers
106+ admin_client
107+
108+ Changelog
109+ ---------
110+
111+ For a list of all ``google-cloud-datastore`` releases:
112+
113+ .. toctree::
114+ :maxdepth: 2
115+
116+ CHANGELOG
117+ count : 1
118+ - paths : [
119+ " packages/google-cloud-datastore/google/cloud/datastore/__init__.py" ,
120+ ]
121+ before : |
122+ from google.cloud.datastore import gapic_version as package_version
123+ [\s\S]*?"PlanSummary",\n\)
124+ after : |
125+ """Shortcut methods for getting set up with Google Cloud Datastore.
126+
127+ You'll typically use these to get started with the API:
128+
129+ .. doctest:: constructors
130+
131+ >>> from google.cloud import datastore
132+ >>>
133+ >>> client = datastore.Client()
134+ >>> key = client.key('EntityKind', 1234)
135+ >>> key
136+ <Key('EntityKind', 1234), project=...>
137+ >>> entity = datastore.Entity(key)
138+ >>> entity['question'] = u'Life, universe?' # Explicit unicode for text
139+ >>> entity['answer'] = 42
140+ >>> entity
141+ <Entity('EntityKind', 1234) {'question': 'Life, universe?', 'answer': 42}>
142+ >>> query = client.query(kind='EntityKind')
143+
144+ The main concepts with this API are:
145+
146+ - :class:`~google.cloud.datastore.client.Client`
147+ which represents a project (string), database (string), and namespace
148+ (string) bundled with a connection and has convenience methods for
149+ constructing objects with that project/database/namespace.
150+
151+ - :class:`~google.cloud.datastore.entity.Entity`
152+ which represents a single entity in the datastore
153+ (akin to a row in relational database world).
154+
155+ - :class:`~google.cloud.datastore.key.Key`
156+ which represents a pointer to a particular entity in the datastore
157+ (akin to a unique identifier in relational database world).
158+
159+ - :class:`~google.cloud.datastore.query.Query`
160+ which represents a lookup or search over the rows in the datastore.
161+
162+ - :class:`~google.cloud.datastore.transaction.Transaction`
163+ which represents an all-or-none transaction and enables consistency
164+ when race conditions may occur.
165+ """
166+
167+ from google.cloud.datastore.batch import Batch
168+ from google.cloud.datastore.client import Client
169+ from google.cloud.datastore.entity import Entity
170+ from google.cloud.datastore.key import Key
171+ from google.cloud.datastore.query import Query
172+ from google.cloud.datastore.query_profile import ExplainOptions
173+ from google.cloud.datastore.transaction import Transaction
174+ from google.cloud.datastore.version import __version__
175+
176+ __all__ = [
177+ "__version__",
178+ "Batch",
179+ "Client",
180+ "Entity",
181+ "Key",
182+ "Query",
183+ "ExplainOptions",
184+ "Transaction",
185+ ]
186+ count : 1
187+ - paths : [
188+ " packages/google-cloud-datastore/noxfile.py" ,
189+ ]
190+ before : |
191+ @nox\.session\(python=SYSTEM_TEST_PYTHON_VERSIONS\)
192+ def system\(session\):\s+"""Run the system test suite\."""[\s\S]*?system_test_folder_path,\s*\*session\.posargs,\s*\)
193+ after : |
194+ @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
195+ @nox.parametrize("disable_grpc", [False, True])
196+ def system(session, disable_grpc):
197+ """Run the system test suite."""
198+ constraints_path = str(
199+ CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
200+ )
201+ system_test_path = os.path.join("tests", "system.py")
202+ system_test_folder_path = os.path.join("tests", "system")
203+
204+ # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
205+ if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
206+ session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
207+ # Install pyopenssl for mTLS testing.
208+ if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
209+ session.install("pyopenssl")
210+
211+ system_test_exists = os.path.exists(system_test_path)
212+ system_test_folder_exists = os.path.exists(system_test_folder_path)
213+ # Sanity check: only run tests if found.
214+ if not system_test_exists and not system_test_folder_exists:
215+ session.skip("System tests were not found")
216+
217+ install_systemtest_dependencies(session, "-c", constraints_path)
218+
219+ env = {}
220+ if disable_grpc:
221+ env["GOOGLE_CLOUD_DISABLE_GRPC"] = "True"
222+
223+ # Run py.test against the system tests.
224+ if system_test_exists:
225+ session.run(
226+ "py.test",
227+ "--quiet",
228+ f"--junitxml=system_{session.python}_sponge_log.xml",
229+ system_test_path,
230+ env=env,
231+ *session.posargs,
232+ )
233+ if system_test_folder_exists:
234+ session.run(
235+ "py.test",
236+ "--quiet",
237+ f"--junitxml=system_{session.python}_sponge_log.xml",
238+ system_test_folder_path,
239+ env=env,
240+ *session.posargs,
241+ )
242+ count : 1
0 commit comments