Skip to content

Commit ebf25a4

Browse files
authored
chore(migration): Migrate code from googleapis/python-datastore into packages/google-cloud-datastore (googleapis#15592)
See googleapis#11015. This PR should be merged with a merge-commit, not a squash-commit, in order to preserve the git history.
2 parents 083606a + 4508a39 commit ebf25a4

File tree

171 files changed

+63072
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+63072
-2
lines changed
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
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
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "datastore",
3+
"name_pretty": "Google Cloud Datastore API",
4+
"product_documentation": "https://cloud.google.com/datastore",
5+
"client_documentation": "https://cloud.google.com/python/docs/reference/datastore/latest",
6+
"issue_tracker": "https://issuetracker.google.com/savedsearches/559768",
7+
"release_level": "stable",
8+
"language": "python",
9+
"library_type": "GAPIC_COMBO",
10+
"repo": "googleapis/google-cloud-python",
11+
"distribution_name": "google-cloud-datastore",
12+
"api_id": "datastore.googleapis.com",
13+
"default_version": "v1",
14+
"codeowner_team": "@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners",
15+
"api_shortname": "datastore",
16+
"api_description": "is a fully managed, schemaless database for\nstoring non-relational data. Cloud Datastore automatically scales with\nyour users and supports ACID transactions, high availability of reads and\nwrites, strong consistency for reads and ancestor queries, and eventual\nconsistency for all other queries."
17+
}

.librarian/state.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,67 @@ libraries:
13691369
remove_regex:
13701370
- packages/google-cloud-dataproc-metastore/
13711371
tag_format: '{id}-v{version}'
1372+
- id: google-cloud-datastore
1373+
version: 2.23.0
1374+
last_generated_commit: ce8678a96c8e1fc0d870d80fcf062e5be2b12877
1375+
apis:
1376+
- path: google/datastore/admin/v1
1377+
service_config: datastore_v1.yaml
1378+
- path: google/datastore/v1
1379+
service_config: datastore_v1.yaml
1380+
source_roots:
1381+
- packages/google-cloud-datastore
1382+
preserve_regex:
1383+
- packages/google-cloud-datastore/CHANGELOG.md
1384+
- docs/CHANGELOG.md
1385+
remove_regex:
1386+
- ^packages/google-cloud-datastore/.coveragerc
1387+
- ^packages/google-cloud-datastore/.flake8
1388+
- ^packages/google-cloud-datastore/.repo-metadata.json
1389+
- ^packages/google-cloud-datastore/LICENSE
1390+
- ^packages/google-cloud-datastore/MANIFEST.in
1391+
- ^packages/google-cloud-datastore/README.rst
1392+
- ^packages/google-cloud-datastore/mypy.ini
1393+
- ^packages/google-cloud-datastore/noxfile.py
1394+
- ^packages/google-cloud-datastore/setup.py
1395+
- ^packages/google-cloud-datastore/docs/conf.py
1396+
- ^packages/google-cloud-datastore/docs/index.rst
1397+
- ^packages/google-cloud-datastore/docs/summary_overview.md
1398+
- ^packages/google-cloud-datastore/docs/README.rst
1399+
- ^packages/google-cloud-datastore/docs/_static/custom.css
1400+
- ^packages/google-cloud-datastore/docs/datastore_admin_v1/datastore_admin.rst
1401+
- ^packages/google-cloud-datastore/docs/datastore_admin_v1/services_.rst
1402+
- ^packages/google-cloud-datastore/docs/datastore_admin_v1/types_.rst
1403+
- ^packages/google-cloud-datastore/docs/datastore_v1/datastore.rst
1404+
- ^packages/google-cloud-datastore/docs/datastore_v1/services_.rst
1405+
- ^packages/google-cloud-datastore/docs/datastore_v1/types_.rst
1406+
- ^packages/google-cloud-datastore/docs/multiprocessing.rst
1407+
- ^packages/google-cloud-datastore/docs/_templates/datastore_admin.rst
1408+
- ^packages/google-cloud-datastore/docs/_templates/layout.html
1409+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/__init__.py
1410+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/gapic_metadata.json
1411+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/gapic_version.py
1412+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/py.typed
1413+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/services
1414+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin_v1/types
1415+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/__init__.py
1416+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/gapic_metadata.json
1417+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/gapic_version.py
1418+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/py.typed
1419+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/services
1420+
- ^packages/google-cloud-datastore/google/cloud/datastore_v1/types
1421+
- ^packages/google-cloud-datastore/google/cloud/datastore/__init__.py
1422+
- ^packages/google-cloud-datastore/google/cloud/datastore/gapic_version.py
1423+
- ^packages/google-cloud-datastore/google/cloud/datastore/py.typed
1424+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin/__init__.py
1425+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin/gapic_version.py
1426+
- ^packages/google-cloud-datastore/google/cloud/datastore_admin/py.typed
1427+
- ^packages/google-cloud-datastore/testing
1428+
- ^packages/google-cloud-datastore/tests/__init__.py
1429+
- ^packages/google-cloud-datastore/tests/unit/__init__.py
1430+
- ^packages/google-cloud-datastore/tests/unit/gapic
1431+
- ^packages/google-cloud-datastore/samples/generated_samples
1432+
tag_format: '{id}-v{version}'
13721433
- id: google-cloud-datastream
13731434
version: 1.17.0
13741435
last_generated_commit: 3322511885371d2b2253f209ccc3aa60d4100cfd

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ Libraries
331331
-
332332
-
333333
- `Client Library Issues <https://github.com/googleapis/google-cloud-python/issues>`_
334-
* - `Datastore <https://github.com/googleapis/python-datastore>`_
334+
* - `Datastore <https://github.com/googleapis/google-cloud-python/tree/main/packages/python-datastore>`_
335335
- stable
336336
- |PyPI-google-cloud-datastore|
337337
- `API Issues <https://issuetracker.google.com/savedsearches/559768>`_
338338
- `File an API Issue <https://issuetracker.google.com/issues/new?component=187197>`_
339-
- `Client Library Issues <https://github.com/googleapis/python-datastore/issues>`_
339+
- `Client Library Issues <https://github.com/googleapis/google-cloud-python/issues>`_
340340
* - `Datastream <https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-datastream>`_
341341
- stable
342342
- |PyPI-google-cloud-datastream|
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
show_missing = True
6+
omit =
7+
google/cloud/datastore/__init__.py
8+
google/cloud/datastore/gapic_version.py
9+
exclude_lines =
10+
# Re-enable the standard pragma
11+
pragma: NO COVER
12+
# Ignore debug-only repr
13+
def __repr__
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
[flake8]
17+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333):
18+
# Resolve flake8 lint issues
19+
ignore = E203, E231, E266, E501, W503
20+
exclude =
21+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333):
22+
# Ensure that generated code passes flake8 lint
23+
**/gapic/**
24+
**/services/**
25+
**/types/**
26+
# Exclude Protobuf gencode
27+
*_pb2.py
28+
29+
# Standard linting exemptions.
30+
**/.nox/**
31+
__pycache__,
32+
.git,
33+
*.pyc,
34+
conf.py

0 commit comments

Comments
 (0)