google-cloud-ndb 2.4.2__tar.gz → 2.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {google_cloud_ndb-2.4.2/google_cloud_ndb.egg-info → google_cloud_ndb-2.5.1}/PKG-INFO +8 -9
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/README.md +2 -2
- google_cloud_ndb-2.5.1/google/cloud/ndb/__init__.py +244 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_cache.py +12 -15
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_datastore_api.py +12 -10
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_datastore_query.py +20 -11
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_datastore_types.py +4 -4
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_eventloop.py +10 -7
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_gql.py +22 -12
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_legacy_entity_pb.py +2 -3
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_legacy_protocol_buffer.py +3 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_options.py +7 -3
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_remote.py +3 -2
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_retry.py +6 -6
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_transaction.py +6 -8
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/blobstore.py +1 -5
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/client.py +4 -7
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/context.py +16 -7
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/django_middleware.py +0 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/exceptions.py +0 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/global_cache.py +7 -6
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/key.py +11 -17
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/metadata.py +1 -3
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/model.py +186 -109
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/msgprop.py +0 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/polymodel.py +2 -3
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/query.py +45 -28
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/stats.py +0 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/tasklets.py +3 -3
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/utils.py +0 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/version.py +1 -1
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1/google_cloud_ndb.egg-info}/PKG-INFO +8 -9
- google_cloud_ndb-2.5.1/google_cloud_ndb.egg-info/requires.txt +6 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/setup.py +9 -10
- google_cloud_ndb-2.4.2/google/cloud/ndb/__init__.py +0 -239
- google_cloud_ndb-2.4.2/google_cloud_ndb.egg-info/requires.txt +0 -6
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/AUTHORS +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/LICENSE +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google/cloud/ndb/_batch.py +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google_cloud_ndb.egg-info/SOURCES.txt +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google_cloud_ndb.egg-info/dependency_links.txt +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google_cloud_ndb.egg-info/not-zip-safe +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/google_cloud_ndb.egg-info/top_level.txt +0 -0
- {google_cloud_ndb-2.4.2 → google_cloud_ndb-2.5.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: google-cloud-ndb
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.1
|
|
4
4
|
Summary: NDB library for Google Cloud Datastore
|
|
5
5
|
Home-page: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-ndb
|
|
6
6
|
Author: Google LLC
|
|
@@ -14,7 +14,6 @@ Classifier: Intended Audience :: Developers
|
|
|
14
14
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
19
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
@@ -22,15 +21,15 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.14
|
|
23
22
|
Classifier: Operating System :: OS Independent
|
|
24
23
|
Classifier: Topic :: Internet
|
|
25
|
-
Requires-Python: >=3.
|
|
24
|
+
Requires-Python: >=3.10
|
|
26
25
|
Description-Content-Type: text/markdown
|
|
27
26
|
License-File: LICENSE
|
|
28
27
|
License-File: AUTHORS
|
|
29
|
-
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.
|
|
30
|
-
Requires-Dist: google-cloud-datastore
|
|
31
|
-
Requires-Dist: protobuf<8.0.0,>=
|
|
28
|
+
Requires-Dist: google-api-core[grpc]<3.0.0,>=2.28.0
|
|
29
|
+
Requires-Dist: google-cloud-datastore<3.0.0,>=2.21.0
|
|
30
|
+
Requires-Dist: protobuf<8.0.0,>=6.33.5
|
|
32
31
|
Requires-Dist: pymemcache<5.0.0,>=2.1.0
|
|
33
|
-
Requires-Dist: pytz>=
|
|
32
|
+
Requires-Dist: pytz>=2022.1
|
|
34
33
|
Requires-Dist: redis<8.0.0,>=3.0.0
|
|
35
34
|
Dynamic: author
|
|
36
35
|
Dynamic: author-email
|
|
@@ -78,14 +77,14 @@ GA
|
|
|
78
77
|
|
|
79
78
|
Our client libraries are compatible with all current [active][3] and [maintenance][4] versions of Python.
|
|
80
79
|
|
|
81
|
-
Python >= 3.
|
|
80
|
+
Python >= 3.10
|
|
82
81
|
|
|
83
82
|
[3]: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
84
83
|
[4]: https://devguide.python.org/devcycle/#maintenance-branches
|
|
85
84
|
|
|
86
85
|
### Unsupported Python Versions
|
|
87
86
|
|
|
88
|
-
Python <= 3.
|
|
87
|
+
Python <= 3.9
|
|
89
88
|
|
|
90
89
|
If you are using an [end-of-life][5]
|
|
91
90
|
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
@@ -30,14 +30,14 @@ GA
|
|
|
30
30
|
|
|
31
31
|
Our client libraries are compatible with all current [active][3] and [maintenance][4] versions of Python.
|
|
32
32
|
|
|
33
|
-
Python >= 3.
|
|
33
|
+
Python >= 3.10
|
|
34
34
|
|
|
35
35
|
[3]: https://devguide.python.org/devcycle/#in-development-main-branch
|
|
36
36
|
[4]: https://devguide.python.org/devcycle/#maintenance-branches
|
|
37
37
|
|
|
38
38
|
### Unsupported Python Versions
|
|
39
39
|
|
|
40
|
-
Python <= 3.
|
|
40
|
+
Python <= 3.9
|
|
41
41
|
|
|
42
42
|
If you are using an [end-of-life][5]
|
|
43
43
|
version of Python, we recommend that you update as soon as possible to an actively supported version.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# Copyright 2018 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
|
+
# https://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
|
+
"""``ndb`` is a library for Google Cloud Firestore in Datastore Mode and Google Cloud Datastore.
|
|
16
|
+
|
|
17
|
+
It was originally included in the Google App Engine runtime as a "new"
|
|
18
|
+
version of the ``db`` API (hence ``ndb``).
|
|
19
|
+
|
|
20
|
+
.. autodata:: __version__
|
|
21
|
+
.. autodata:: __all__
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from google.cloud.ndb import version
|
|
25
|
+
|
|
26
|
+
__version__: str = version.__version__
|
|
27
|
+
|
|
28
|
+
from google.cloud.ndb._datastore_api import EVENTUAL, EVENTUAL_CONSISTENCY, STRONG
|
|
29
|
+
from google.cloud.ndb._datastore_query import Cursor, QueryIterator
|
|
30
|
+
from google.cloud.ndb._transaction import (
|
|
31
|
+
in_transaction,
|
|
32
|
+
non_transactional,
|
|
33
|
+
transaction,
|
|
34
|
+
transaction_async,
|
|
35
|
+
transactional,
|
|
36
|
+
transactional_async,
|
|
37
|
+
transactional_tasklet,
|
|
38
|
+
)
|
|
39
|
+
from google.cloud.ndb.client import Client
|
|
40
|
+
from google.cloud.ndb.context import (
|
|
41
|
+
AutoBatcher,
|
|
42
|
+
Context,
|
|
43
|
+
ContextOptions,
|
|
44
|
+
TransactionOptions,
|
|
45
|
+
get_context,
|
|
46
|
+
get_toplevel_context,
|
|
47
|
+
)
|
|
48
|
+
from google.cloud.ndb.global_cache import GlobalCache, MemcacheCache, RedisCache
|
|
49
|
+
from google.cloud.ndb.key import Key
|
|
50
|
+
from google.cloud.ndb.model import (
|
|
51
|
+
BadProjectionError,
|
|
52
|
+
BlobKey,
|
|
53
|
+
BlobKeyProperty,
|
|
54
|
+
BlobProperty,
|
|
55
|
+
BooleanProperty,
|
|
56
|
+
ComputedProperty,
|
|
57
|
+
ComputedPropertyError,
|
|
58
|
+
DateProperty,
|
|
59
|
+
DateTimeProperty,
|
|
60
|
+
Expando,
|
|
61
|
+
FloatProperty,
|
|
62
|
+
GenericProperty,
|
|
63
|
+
GeoPt,
|
|
64
|
+
GeoPtProperty,
|
|
65
|
+
Index,
|
|
66
|
+
IndexProperty,
|
|
67
|
+
IndexState,
|
|
68
|
+
IntegerProperty,
|
|
69
|
+
InvalidPropertyError,
|
|
70
|
+
JsonProperty,
|
|
71
|
+
KeyProperty,
|
|
72
|
+
KindError,
|
|
73
|
+
LocalStructuredProperty,
|
|
74
|
+
MetaModel,
|
|
75
|
+
Model,
|
|
76
|
+
ModelAdapter,
|
|
77
|
+
ModelAttribute,
|
|
78
|
+
ModelKey,
|
|
79
|
+
PickleProperty,
|
|
80
|
+
Property,
|
|
81
|
+
ReadonlyPropertyError,
|
|
82
|
+
Rollback,
|
|
83
|
+
StringProperty,
|
|
84
|
+
StructuredProperty,
|
|
85
|
+
TextProperty,
|
|
86
|
+
TimeProperty,
|
|
87
|
+
UnprojectedPropertyError,
|
|
88
|
+
User,
|
|
89
|
+
UserNotFoundError,
|
|
90
|
+
UserProperty,
|
|
91
|
+
delete_multi,
|
|
92
|
+
delete_multi_async,
|
|
93
|
+
get_indexes,
|
|
94
|
+
get_indexes_async,
|
|
95
|
+
get_multi,
|
|
96
|
+
get_multi_async,
|
|
97
|
+
make_connection,
|
|
98
|
+
put_multi,
|
|
99
|
+
put_multi_async,
|
|
100
|
+
)
|
|
101
|
+
from google.cloud.ndb.polymodel import PolyModel
|
|
102
|
+
from google.cloud.ndb.query import (
|
|
103
|
+
AND,
|
|
104
|
+
OR,
|
|
105
|
+
ConjunctionNode,
|
|
106
|
+
DisjunctionNode,
|
|
107
|
+
FalseNode,
|
|
108
|
+
FilterNode,
|
|
109
|
+
Node,
|
|
110
|
+
Parameter,
|
|
111
|
+
ParameterizedFunction,
|
|
112
|
+
ParameterizedThing,
|
|
113
|
+
ParameterNode,
|
|
114
|
+
PostFilterNode,
|
|
115
|
+
Query,
|
|
116
|
+
QueryOptions,
|
|
117
|
+
RepeatedStructuredPropertyPredicate,
|
|
118
|
+
gql,
|
|
119
|
+
)
|
|
120
|
+
from google.cloud.ndb.tasklets import (
|
|
121
|
+
Future,
|
|
122
|
+
QueueFuture,
|
|
123
|
+
ReducingFuture,
|
|
124
|
+
Return,
|
|
125
|
+
SerialQueueFuture,
|
|
126
|
+
add_flow_exception,
|
|
127
|
+
make_context,
|
|
128
|
+
make_default_context,
|
|
129
|
+
set_context,
|
|
130
|
+
sleep,
|
|
131
|
+
synctasklet,
|
|
132
|
+
tasklet,
|
|
133
|
+
toplevel,
|
|
134
|
+
wait_all,
|
|
135
|
+
wait_any,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
__all__ = [
|
|
139
|
+
"__version__",
|
|
140
|
+
"AutoBatcher",
|
|
141
|
+
"Client",
|
|
142
|
+
"Context",
|
|
143
|
+
"ContextOptions",
|
|
144
|
+
"EVENTUAL",
|
|
145
|
+
"EVENTUAL_CONSISTENCY",
|
|
146
|
+
"STRONG",
|
|
147
|
+
"TransactionOptions",
|
|
148
|
+
"Key",
|
|
149
|
+
"BlobKey",
|
|
150
|
+
"BlobKeyProperty",
|
|
151
|
+
"BlobProperty",
|
|
152
|
+
"BooleanProperty",
|
|
153
|
+
"ComputedProperty",
|
|
154
|
+
"ComputedPropertyError",
|
|
155
|
+
"DateProperty",
|
|
156
|
+
"DateTimeProperty",
|
|
157
|
+
"delete_multi",
|
|
158
|
+
"delete_multi_async",
|
|
159
|
+
"Expando",
|
|
160
|
+
"FloatProperty",
|
|
161
|
+
"GenericProperty",
|
|
162
|
+
"GeoPt",
|
|
163
|
+
"GeoPtProperty",
|
|
164
|
+
"get_indexes",
|
|
165
|
+
"get_indexes_async",
|
|
166
|
+
"get_multi",
|
|
167
|
+
"get_multi_async",
|
|
168
|
+
"GlobalCache",
|
|
169
|
+
"in_transaction",
|
|
170
|
+
"Index",
|
|
171
|
+
"IndexProperty",
|
|
172
|
+
"IndexState",
|
|
173
|
+
"IntegerProperty",
|
|
174
|
+
"InvalidPropertyError",
|
|
175
|
+
"BadProjectionError",
|
|
176
|
+
"JsonProperty",
|
|
177
|
+
"KeyProperty",
|
|
178
|
+
"KindError",
|
|
179
|
+
"LocalStructuredProperty",
|
|
180
|
+
"make_connection",
|
|
181
|
+
"MemcacheCache",
|
|
182
|
+
"MetaModel",
|
|
183
|
+
"Model",
|
|
184
|
+
"ModelAdapter",
|
|
185
|
+
"ModelAttribute",
|
|
186
|
+
"ModelKey",
|
|
187
|
+
"non_transactional",
|
|
188
|
+
"PickleProperty",
|
|
189
|
+
"PolyModel",
|
|
190
|
+
"Property",
|
|
191
|
+
"put_multi",
|
|
192
|
+
"put_multi_async",
|
|
193
|
+
"ReadonlyPropertyError",
|
|
194
|
+
"RedisCache",
|
|
195
|
+
"Rollback",
|
|
196
|
+
"StringProperty",
|
|
197
|
+
"StructuredProperty",
|
|
198
|
+
"TextProperty",
|
|
199
|
+
"TimeProperty",
|
|
200
|
+
"transaction",
|
|
201
|
+
"transaction_async",
|
|
202
|
+
"transactional",
|
|
203
|
+
"transactional_async",
|
|
204
|
+
"transactional_tasklet",
|
|
205
|
+
"UnprojectedPropertyError",
|
|
206
|
+
"User",
|
|
207
|
+
"UserNotFoundError",
|
|
208
|
+
"UserProperty",
|
|
209
|
+
"ConjunctionNode",
|
|
210
|
+
"AND",
|
|
211
|
+
"Cursor",
|
|
212
|
+
"DisjunctionNode",
|
|
213
|
+
"OR",
|
|
214
|
+
"FalseNode",
|
|
215
|
+
"FilterNode",
|
|
216
|
+
"gql",
|
|
217
|
+
"Node",
|
|
218
|
+
"Parameter",
|
|
219
|
+
"ParameterizedFunction",
|
|
220
|
+
"ParameterizedThing",
|
|
221
|
+
"ParameterNode",
|
|
222
|
+
"PostFilterNode",
|
|
223
|
+
"Query",
|
|
224
|
+
"QueryIterator",
|
|
225
|
+
"QueryOptions",
|
|
226
|
+
"RepeatedStructuredPropertyPredicate",
|
|
227
|
+
"add_flow_exception",
|
|
228
|
+
"Future",
|
|
229
|
+
"get_context",
|
|
230
|
+
"get_toplevel_context",
|
|
231
|
+
"make_context",
|
|
232
|
+
"make_default_context",
|
|
233
|
+
"QueueFuture",
|
|
234
|
+
"ReducingFuture",
|
|
235
|
+
"Return",
|
|
236
|
+
"SerialQueueFuture",
|
|
237
|
+
"set_context",
|
|
238
|
+
"sleep",
|
|
239
|
+
"synctasklet",
|
|
240
|
+
"tasklet",
|
|
241
|
+
"toplevel",
|
|
242
|
+
"wait_all",
|
|
243
|
+
"wait_any",
|
|
244
|
+
]
|
|
@@ -20,10 +20,8 @@ import warnings
|
|
|
20
20
|
|
|
21
21
|
from google.api_core import retry as core_retry
|
|
22
22
|
|
|
23
|
-
from google.cloud.ndb import _batch
|
|
23
|
+
from google.cloud.ndb import _batch, tasklets, utils
|
|
24
24
|
from google.cloud.ndb import context as context_module
|
|
25
|
-
from google.cloud.ndb import tasklets
|
|
26
|
-
from google.cloud.ndb import utils
|
|
27
25
|
|
|
28
26
|
_LOCKED_FOR_READ = b"0-"
|
|
29
27
|
_LOCKED_FOR_WRITE = b"00"
|
|
@@ -117,18 +115,18 @@ class _GlobalCacheBatch(object):
|
|
|
117
115
|
"""
|
|
118
116
|
exception = cache_call.exception()
|
|
119
117
|
if exception:
|
|
120
|
-
for future in self.futures:
|
|
118
|
+
for future in self.futures: # type: ignore[attr-defined]
|
|
121
119
|
future.set_exception(exception)
|
|
122
120
|
|
|
123
121
|
else:
|
|
124
|
-
for future in self.futures:
|
|
122
|
+
for future in self.futures: # type: ignore[attr-defined]
|
|
125
123
|
future.set_result(None)
|
|
126
124
|
|
|
127
125
|
def make_call(self):
|
|
128
126
|
"""Make the actual call to the global cache. To be overridden."""
|
|
129
127
|
raise NotImplementedError
|
|
130
128
|
|
|
131
|
-
def future_info(self, key):
|
|
129
|
+
def future_info(self, key, value=None):
|
|
132
130
|
"""Generate info string for Future. To be overridden."""
|
|
133
131
|
raise NotImplementedError
|
|
134
132
|
|
|
@@ -279,7 +277,7 @@ class _GlobalCacheGetBatch(_GlobalCacheBatch):
|
|
|
279
277
|
"""Call :method:`GlobalCache.get`."""
|
|
280
278
|
return _global_cache().get(self.keys)
|
|
281
279
|
|
|
282
|
-
def future_info(self, key):
|
|
280
|
+
def future_info(self, key, value=None):
|
|
283
281
|
"""Generate info string for Future."""
|
|
284
282
|
return "GlobalCache.get({})".format(key)
|
|
285
283
|
|
|
@@ -373,7 +371,7 @@ class _GlobalCacheSetBatch(_GlobalCacheBatch):
|
|
|
373
371
|
"""Call :method:`GlobalCache.set`."""
|
|
374
372
|
return _global_cache().set(self.todo, expires=self.expires)
|
|
375
373
|
|
|
376
|
-
def future_info(self, key, value):
|
|
374
|
+
def future_info(self, key, value=None):
|
|
377
375
|
"""Generate info string for Future."""
|
|
378
376
|
return "GlobalCache.set({}, {})".format(key, value)
|
|
379
377
|
|
|
@@ -436,7 +434,7 @@ class _GlobalCacheSetIfNotExistsBatch(_GlobalCacheSetBatch):
|
|
|
436
434
|
"""Call :method:`GlobalCache.set`."""
|
|
437
435
|
return _global_cache().set_if_not_exists(self.todo, expires=self.expires)
|
|
438
436
|
|
|
439
|
-
def future_info(self, key, value):
|
|
437
|
+
def future_info(self, key, value=None):
|
|
440
438
|
"""Generate info string for Future."""
|
|
441
439
|
return "GlobalCache.set_if_not_exists({}, {})".format(key, value)
|
|
442
440
|
|
|
@@ -482,7 +480,7 @@ class _GlobalCacheDeleteBatch(_GlobalCacheBatch):
|
|
|
482
480
|
"""Call :method:`GlobalCache.delete`."""
|
|
483
481
|
return _global_cache().delete(self.keys)
|
|
484
482
|
|
|
485
|
-
def future_info(self, key):
|
|
483
|
+
def future_info(self, key, value=None):
|
|
486
484
|
"""Generate info string for Future."""
|
|
487
485
|
return "GlobalCache.delete({})".format(key)
|
|
488
486
|
|
|
@@ -513,7 +511,7 @@ class _GlobalCacheWatchBatch(_GlobalCacheSetBatch):
|
|
|
513
511
|
"""Call :method:`GlobalCache.watch`."""
|
|
514
512
|
return _global_cache().watch(self.todo)
|
|
515
513
|
|
|
516
|
-
def future_info(self, key, value):
|
|
514
|
+
def future_info(self, key, value=None):
|
|
517
515
|
"""Generate info string for Future."""
|
|
518
516
|
return "GlobalCache.watch({}, {})".format(key, value)
|
|
519
517
|
|
|
@@ -543,7 +541,7 @@ class _GlobalCacheUnwatchBatch(_GlobalCacheDeleteBatch):
|
|
|
543
541
|
"""Call :method:`GlobalCache.unwatch`."""
|
|
544
542
|
return _global_cache().unwatch(self.keys)
|
|
545
543
|
|
|
546
|
-
def future_info(self, key):
|
|
544
|
+
def future_info(self, key, value=None):
|
|
547
545
|
"""Generate info string for Future."""
|
|
548
546
|
return "GlobalCache.unwatch({})".format(key)
|
|
549
547
|
|
|
@@ -580,7 +578,7 @@ class _GlobalCacheCompareAndSwapBatch(_GlobalCacheSetBatch):
|
|
|
580
578
|
"""Call :method:`GlobalCache.compare_and_swap`."""
|
|
581
579
|
return _global_cache().compare_and_swap(self.todo, expires=self.expires)
|
|
582
580
|
|
|
583
|
-
def future_info(self, key, value):
|
|
581
|
+
def future_info(self, key, value=None):
|
|
584
582
|
"""Generate info string for Future."""
|
|
585
583
|
return "GlobalCache.compare_and_swap({}, {})".format(key, value)
|
|
586
584
|
|
|
@@ -627,8 +625,7 @@ def global_lock_for_write(key):
|
|
|
627
625
|
tasklets.Future: Eventual result will be a lock value to be used later with
|
|
628
626
|
:func:`global_unlock`.
|
|
629
627
|
"""
|
|
630
|
-
lock = "." + str(uuid.uuid4())
|
|
631
|
-
lock = lock.encode("ascii")
|
|
628
|
+
lock = ("." + str(uuid.uuid4())).encode("ascii")
|
|
632
629
|
utils.logging_debug(log, "lock for write: {}", lock)
|
|
633
630
|
|
|
634
631
|
def new_value(old_value):
|
|
@@ -14,25 +14,27 @@
|
|
|
14
14
|
|
|
15
15
|
"""Functions that interact with Datastore backend."""
|
|
16
16
|
|
|
17
|
-
import grpc
|
|
18
17
|
import itertools
|
|
19
18
|
import logging
|
|
20
19
|
|
|
20
|
+
import grpc
|
|
21
21
|
from google.api_core import exceptions as core_exceptions
|
|
22
22
|
from google.api_core import gapic_v1
|
|
23
23
|
from google.cloud.datastore import helpers
|
|
24
24
|
from google.cloud.datastore_v1.types import datastore as datastore_pb2
|
|
25
25
|
from google.cloud.datastore_v1.types import entity as entity_pb2
|
|
26
26
|
|
|
27
|
+
from google.cloud.ndb import (
|
|
28
|
+
_batch,
|
|
29
|
+
_cache,
|
|
30
|
+
_eventloop,
|
|
31
|
+
_options,
|
|
32
|
+
_remote,
|
|
33
|
+
_retry,
|
|
34
|
+
tasklets,
|
|
35
|
+
utils,
|
|
36
|
+
)
|
|
27
37
|
from google.cloud.ndb import context as context_module
|
|
28
|
-
from google.cloud.ndb import _batch
|
|
29
|
-
from google.cloud.ndb import _cache
|
|
30
|
-
from google.cloud.ndb import _eventloop
|
|
31
|
-
from google.cloud.ndb import _options
|
|
32
|
-
from google.cloud.ndb import _remote
|
|
33
|
-
from google.cloud.ndb import _retry
|
|
34
|
-
from google.cloud.ndb import tasklets
|
|
35
|
-
from google.cloud.ndb import utils
|
|
36
38
|
|
|
37
39
|
EVENTUAL = datastore_pb2.ReadOptions.ReadConsistency.EVENTUAL
|
|
38
40
|
EVENTUAL_CONSISTENCY = EVENTUAL # Legacy NDB
|
|
@@ -168,7 +170,7 @@ def lookup(key, options):
|
|
|
168
170
|
if use_global_cache and not key_locked:
|
|
169
171
|
if entity_pb is not _NOT_FOUND:
|
|
170
172
|
expires = context._global_cache_timeout(key, options)
|
|
171
|
-
serialized = entity_pb._pb.SerializeToString()
|
|
173
|
+
serialized = entity_pb._pb.SerializeToString() # type: ignore[attr-defined]
|
|
172
174
|
yield _cache.global_compare_and_swap(
|
|
173
175
|
cache_key, serialized, expires=expires
|
|
174
176
|
)
|
|
@@ -20,20 +20,15 @@ import functools
|
|
|
20
20
|
import logging
|
|
21
21
|
import os
|
|
22
22
|
|
|
23
|
-
from google.cloud import
|
|
24
|
-
|
|
23
|
+
from google.cloud.datastore import Key, helpers
|
|
25
24
|
from google.cloud.datastore_v1.types import datastore as datastore_pb2
|
|
26
25
|
from google.cloud.datastore_v1.types import entity as entity_pb2
|
|
27
26
|
from google.cloud.datastore_v1.types import query as query_pb2
|
|
28
|
-
from google.cloud.datastore import helpers, Key
|
|
29
27
|
|
|
28
|
+
from google.cloud import environment_vars
|
|
29
|
+
from google.cloud.ndb import _datastore_api, exceptions, model, tasklets, utils
|
|
30
30
|
from google.cloud.ndb import context as context_module
|
|
31
|
-
from google.cloud.ndb import _datastore_api
|
|
32
|
-
from google.cloud.ndb import exceptions
|
|
33
31
|
from google.cloud.ndb import key as key_module
|
|
34
|
-
from google.cloud.ndb import model
|
|
35
|
-
from google.cloud.ndb import tasklets
|
|
36
|
-
from google.cloud.ndb import utils
|
|
37
32
|
|
|
38
33
|
log = logging.getLogger(__name__)
|
|
39
34
|
|
|
@@ -342,6 +337,10 @@ class _QueryIteratorImpl(QueryIterator):
|
|
|
342
337
|
if self._batch is None:
|
|
343
338
|
yield self._next_batch() # First time
|
|
344
339
|
|
|
340
|
+
if self._batch is None:
|
|
341
|
+
raise TypeError("self._batch cannot be None")
|
|
342
|
+
if self._index is None:
|
|
343
|
+
raise TypeError("self._index cannot be None")
|
|
345
344
|
if self._index < len(self._batch):
|
|
346
345
|
raise tasklets.Return(True)
|
|
347
346
|
|
|
@@ -359,7 +358,9 @@ class _QueryIteratorImpl(QueryIterator):
|
|
|
359
358
|
return (
|
|
360
359
|
self._batch is None # Haven't even started yet
|
|
361
360
|
or self._has_next_batch # There's another batch to fetch
|
|
362
|
-
or
|
|
361
|
+
or (
|
|
362
|
+
self._index is not None and self._index < len(self._batch)
|
|
363
|
+
) # Not done with current batch
|
|
363
364
|
)
|
|
364
365
|
|
|
365
366
|
@tasklets.tasklet
|
|
@@ -421,6 +422,10 @@ class _QueryIteratorImpl(QueryIterator):
|
|
|
421
422
|
self._cursor_before = None
|
|
422
423
|
raise StopIteration
|
|
423
424
|
|
|
425
|
+
if self._batch is None:
|
|
426
|
+
raise TypeError("self._batch cannot be None")
|
|
427
|
+
if self._index is None:
|
|
428
|
+
raise TypeError("self._index cannot be None")
|
|
424
429
|
# Won't block
|
|
425
430
|
next_result = self._batch[self._index]
|
|
426
431
|
self._index += 1
|
|
@@ -446,7 +451,7 @@ class _QueryIteratorImpl(QueryIterator):
|
|
|
446
451
|
batch = self._batch
|
|
447
452
|
index = self._index
|
|
448
453
|
|
|
449
|
-
if batch and index < len(batch):
|
|
454
|
+
if batch and index is not None and index < len(batch):
|
|
450
455
|
return batch[index]
|
|
451
456
|
|
|
452
457
|
raise KeyError(index)
|
|
@@ -554,6 +559,8 @@ class _PostFilterQueryIteratorImpl(QueryIterator):
|
|
|
554
559
|
if not self.has_next():
|
|
555
560
|
raise StopIteration()
|
|
556
561
|
|
|
562
|
+
if self._next_result is None:
|
|
563
|
+
raise TypeError("self._next_result cannot be None")
|
|
557
564
|
# Won't block
|
|
558
565
|
next_result = self._next_result
|
|
559
566
|
self._next_result = None
|
|
@@ -718,6 +725,8 @@ class _MultiQueryIteratorImpl(QueryIterator):
|
|
|
718
725
|
if not self.has_next():
|
|
719
726
|
raise StopIteration()
|
|
720
727
|
|
|
728
|
+
if self._next_result is None:
|
|
729
|
+
raise TypeError("self._next_result cannot be None")
|
|
721
730
|
# Won't block
|
|
722
731
|
next_result = self._next_result
|
|
723
732
|
self._next_result = None
|
|
@@ -949,7 +958,7 @@ def _query_to_protobuf(query):
|
|
|
949
958
|
filter_pb = ancestor_filter_pb
|
|
950
959
|
|
|
951
960
|
elif isinstance(filter_pb, query_pb2.CompositeFilter):
|
|
952
|
-
filter_pb.filters._pb.add(property_filter=ancestor_filter_pb._pb)
|
|
961
|
+
filter_pb.filters._pb.add(property_filter=ancestor_filter_pb._pb) # type: ignore[attr-defined]
|
|
953
962
|
|
|
954
963
|
else:
|
|
955
964
|
filter_pb = query_pb2.CompositeFilter(
|
|
@@ -24,7 +24,6 @@ import functools
|
|
|
24
24
|
|
|
25
25
|
from google.cloud.ndb import exceptions
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
_MAX_STRING_LENGTH = 1500
|
|
29
28
|
|
|
30
29
|
|
|
@@ -55,12 +54,13 @@ class BlobKey(object):
|
|
|
55
54
|
if isinstance(blob_key, bytes):
|
|
56
55
|
if len(blob_key) > _MAX_STRING_LENGTH:
|
|
57
56
|
raise exceptions.BadValueError(
|
|
58
|
-
"blob key must be under {:d}
|
|
57
|
+
"blob key must be under {:d} bytes.".format(_MAX_STRING_LENGTH)
|
|
59
58
|
)
|
|
60
59
|
elif blob_key is not None:
|
|
61
60
|
raise exceptions.BadValueError(
|
|
62
|
-
"blob key should be bytes; received "
|
|
63
|
-
|
|
61
|
+
"blob key should be bytes; received {} (a {})".format(
|
|
62
|
+
blob_key, type(blob_key).__name__
|
|
63
|
+
)
|
|
64
64
|
)
|
|
65
65
|
|
|
66
66
|
self._blob_key = blob_key
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
This should handle both asynchronous ``ndb`` objects and arbitrary callbacks.
|
|
18
18
|
"""
|
|
19
|
+
|
|
19
20
|
import collections
|
|
20
21
|
import logging
|
|
21
|
-
import uuid
|
|
22
|
-
import time
|
|
23
|
-
|
|
24
22
|
import queue
|
|
23
|
+
import time
|
|
24
|
+
import uuid
|
|
25
25
|
|
|
26
26
|
from google.cloud.ndb import utils
|
|
27
27
|
|
|
@@ -116,12 +116,15 @@ class EventLoop(object):
|
|
|
116
116
|
"""
|
|
117
117
|
|
|
118
118
|
def __init__(self):
|
|
119
|
-
self.
|
|
120
|
-
|
|
119
|
+
self._init()
|
|
120
|
+
|
|
121
|
+
def _init(self):
|
|
122
|
+
self.current: collections.deque = collections.deque()
|
|
123
|
+
self.idlers: collections.deque = collections.deque()
|
|
121
124
|
self.inactive = 0
|
|
122
125
|
self.queue = []
|
|
123
126
|
self.rpcs = {}
|
|
124
|
-
self.rpc_results = queue.Queue()
|
|
127
|
+
self.rpc_results: queue.Queue = queue.Queue()
|
|
125
128
|
|
|
126
129
|
def clear(self):
|
|
127
130
|
"""Remove all pending events without running any."""
|
|
@@ -139,7 +142,7 @@ class EventLoop(object):
|
|
|
139
142
|
utils.logging_debug(log, " queue = {}", queue)
|
|
140
143
|
if rpcs:
|
|
141
144
|
utils.logging_debug(log, " rpcs = {}", rpcs)
|
|
142
|
-
self.
|
|
145
|
+
self._init()
|
|
143
146
|
current.clear()
|
|
144
147
|
idlers.clear()
|
|
145
148
|
queue[:] = []
|