google-cloud-bigtable 2.30.0__py3-none-any.whl

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.
Files changed (115) hide show
  1. google/cloud/bigtable/__init__.py +25 -0
  2. google/cloud/bigtable/app_profile.py +377 -0
  3. google/cloud/bigtable/backup.py +490 -0
  4. google/cloud/bigtable/batcher.py +414 -0
  5. google/cloud/bigtable/client.py +475 -0
  6. google/cloud/bigtable/cluster.py +541 -0
  7. google/cloud/bigtable/column_family.py +362 -0
  8. google/cloud/bigtable/data/__init__.py +103 -0
  9. google/cloud/bigtable/data/_async/__init__.py +25 -0
  10. google/cloud/bigtable/data/_async/_mutate_rows.py +226 -0
  11. google/cloud/bigtable/data/_async/_read_rows.py +363 -0
  12. google/cloud/bigtable/data/_async/client.py +1522 -0
  13. google/cloud/bigtable/data/_async/mutations_batcher.py +534 -0
  14. google/cloud/bigtable/data/_cross_sync/__init__.py +20 -0
  15. google/cloud/bigtable/data/_cross_sync/_decorators.py +441 -0
  16. google/cloud/bigtable/data/_cross_sync/_mapping_meta.py +64 -0
  17. google/cloud/bigtable/data/_cross_sync/cross_sync.py +334 -0
  18. google/cloud/bigtable/data/_helpers.py +249 -0
  19. google/cloud/bigtable/data/_sync_autogen/_mutate_rows.py +182 -0
  20. google/cloud/bigtable/data/_sync_autogen/_read_rows.py +304 -0
  21. google/cloud/bigtable/data/_sync_autogen/client.py +1293 -0
  22. google/cloud/bigtable/data/_sync_autogen/mutations_batcher.py +449 -0
  23. google/cloud/bigtable/data/exceptions.py +340 -0
  24. google/cloud/bigtable/data/execute_query/__init__.py +43 -0
  25. google/cloud/bigtable/data/execute_query/_async/__init__.py +13 -0
  26. google/cloud/bigtable/data/execute_query/_async/execute_query_iterator.py +291 -0
  27. google/cloud/bigtable/data/execute_query/_byte_cursor.py +123 -0
  28. google/cloud/bigtable/data/execute_query/_checksum.py +43 -0
  29. google/cloud/bigtable/data/execute_query/_parameters_formatting.py +155 -0
  30. google/cloud/bigtable/data/execute_query/_query_result_parsing_utils.py +134 -0
  31. google/cloud/bigtable/data/execute_query/_reader.py +122 -0
  32. google/cloud/bigtable/data/execute_query/_sync_autogen/execute_query_iterator.py +239 -0
  33. google/cloud/bigtable/data/execute_query/metadata.py +399 -0
  34. google/cloud/bigtable/data/execute_query/values.py +123 -0
  35. google/cloud/bigtable/data/mutations.py +380 -0
  36. google/cloud/bigtable/data/read_modify_write_rules.py +112 -0
  37. google/cloud/bigtable/data/read_rows_query.py +536 -0
  38. google/cloud/bigtable/data/row.py +535 -0
  39. google/cloud/bigtable/data/row_filters.py +968 -0
  40. google/cloud/bigtable/encryption_info.py +64 -0
  41. google/cloud/bigtable/enums.py +223 -0
  42. google/cloud/bigtable/error.py +64 -0
  43. google/cloud/bigtable/gapic_version.py +16 -0
  44. google/cloud/bigtable/helpers.py +31 -0
  45. google/cloud/bigtable/instance.py +789 -0
  46. google/cloud/bigtable/policy.py +255 -0
  47. google/cloud/bigtable/row.py +1267 -0
  48. google/cloud/bigtable/row_data.py +380 -0
  49. google/cloud/bigtable/row_filters.py +838 -0
  50. google/cloud/bigtable/row_merger.py +250 -0
  51. google/cloud/bigtable/row_set.py +213 -0
  52. google/cloud/bigtable/table.py +1409 -0
  53. google/cloud/bigtable_admin/__init__.py +410 -0
  54. google/cloud/bigtable_admin/gapic_version.py +16 -0
  55. google/cloud/bigtable_admin/py.typed +2 -0
  56. google/cloud/bigtable_admin_v2/__init__.py +250 -0
  57. google/cloud/bigtable_admin_v2/gapic_metadata.json +962 -0
  58. google/cloud/bigtable_admin_v2/gapic_version.py +16 -0
  59. google/cloud/bigtable_admin_v2/py.typed +2 -0
  60. google/cloud/bigtable_admin_v2/services/__init__.py +15 -0
  61. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/__init__.py +22 -0
  62. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/async_client.py +3465 -0
  63. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/client.py +3944 -0
  64. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/pagers.py +681 -0
  65. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/__init__.py +40 -0
  66. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/base.py +751 -0
  67. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc.py +1249 -0
  68. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/grpc_asyncio.py +1579 -0
  69. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest.py +6820 -0
  70. google/cloud/bigtable_admin_v2/services/bigtable_instance_admin/transports/rest_base.py +1746 -0
  71. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/__init__.py +22 -0
  72. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/async_client.py +3472 -0
  73. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/client.py +3949 -0
  74. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/pagers.py +669 -0
  75. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/__init__.py +40 -0
  76. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/base.py +708 -0
  77. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc.py +1257 -0
  78. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/grpc_asyncio.py +1549 -0
  79. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest.py +6609 -0
  80. google/cloud/bigtable_admin_v2/services/bigtable_table_admin/transports/rest_base.py +1714 -0
  81. google/cloud/bigtable_admin_v2/types/__init__.py +248 -0
  82. google/cloud/bigtable_admin_v2/types/bigtable_instance_admin.py +1364 -0
  83. google/cloud/bigtable_admin_v2/types/bigtable_table_admin.py +1715 -0
  84. google/cloud/bigtable_admin_v2/types/common.py +81 -0
  85. google/cloud/bigtable_admin_v2/types/instance.py +819 -0
  86. google/cloud/bigtable_admin_v2/types/table.py +1028 -0
  87. google/cloud/bigtable_admin_v2/types/types.py +776 -0
  88. google/cloud/bigtable_v2/__init__.py +136 -0
  89. google/cloud/bigtable_v2/gapic_metadata.json +193 -0
  90. google/cloud/bigtable_v2/gapic_version.py +16 -0
  91. google/cloud/bigtable_v2/py.typed +2 -0
  92. google/cloud/bigtable_v2/services/__init__.py +15 -0
  93. google/cloud/bigtable_v2/services/bigtable/__init__.py +22 -0
  94. google/cloud/bigtable_v2/services/bigtable/async_client.py +1741 -0
  95. google/cloud/bigtable_v2/services/bigtable/client.py +2194 -0
  96. google/cloud/bigtable_v2/services/bigtable/transports/__init__.py +38 -0
  97. google/cloud/bigtable_v2/services/bigtable/transports/base.py +343 -0
  98. google/cloud/bigtable_v2/services/bigtable/transports/grpc.py +660 -0
  99. google/cloud/bigtable_v2/services/bigtable/transports/grpc_asyncio.py +762 -0
  100. google/cloud/bigtable_v2/services/bigtable/transports/rest.py +2489 -0
  101. google/cloud/bigtable_v2/services/bigtable/transports/rest_base.py +711 -0
  102. google/cloud/bigtable_v2/types/__init__.py +138 -0
  103. google/cloud/bigtable_v2/types/bigtable.py +1531 -0
  104. google/cloud/bigtable_v2/types/data.py +1612 -0
  105. google/cloud/bigtable_v2/types/feature_flags.py +119 -0
  106. google/cloud/bigtable_v2/types/request_stats.py +171 -0
  107. google/cloud/bigtable_v2/types/response_params.py +64 -0
  108. google/cloud/bigtable_v2/types/types.py +579 -0
  109. google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_admin_v2_keywords.py +233 -0
  110. google_cloud_bigtable-2.30.0.data/scripts/fixup_bigtable_v2_keywords.py +186 -0
  111. google_cloud_bigtable-2.30.0.dist-info/LICENSE +202 -0
  112. google_cloud_bigtable-2.30.0.dist-info/METADATA +154 -0
  113. google_cloud_bigtable-2.30.0.dist-info/RECORD +115 -0
  114. google_cloud_bigtable-2.30.0.dist-info/WHEEL +5 -0
  115. google_cloud_bigtable-2.30.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,64 @@
1
+ # Copyright 2021 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
+
15
+ """Class for encryption info for tables and backups."""
16
+
17
+ from google.cloud.bigtable.error import Status
18
+
19
+
20
+ class EncryptionInfo:
21
+ """Encryption information for a given resource.
22
+
23
+ If this resource is protected with customer managed encryption, the in-use Google
24
+ Cloud Key Management Service (KMS) key versions will be specified along with their
25
+ status.
26
+
27
+ :type encryption_type: int
28
+ :param encryption_type: See :class:`enums.EncryptionInfo.EncryptionType`
29
+
30
+ :type encryption_status: google.cloud.bigtable.encryption.Status
31
+ :param encryption_status: The encryption status.
32
+
33
+ :type kms_key_version: str
34
+ :param kms_key_version: The key version used for encryption.
35
+ """
36
+
37
+ @classmethod
38
+ def _from_pb(cls, info_pb):
39
+ return cls(
40
+ info_pb.encryption_type,
41
+ Status(info_pb.encryption_status),
42
+ info_pb.kms_key_version,
43
+ )
44
+
45
+ def __init__(self, encryption_type, encryption_status, kms_key_version):
46
+ self.encryption_type = encryption_type
47
+ self.encryption_status = encryption_status
48
+ self.kms_key_version = kms_key_version
49
+
50
+ def __eq__(self, other):
51
+ if self is other:
52
+ return True
53
+
54
+ if not isinstance(other, type(self)):
55
+ return NotImplemented
56
+
57
+ return (
58
+ self.encryption_type == other.encryption_type
59
+ and self.encryption_status == other.encryption_status
60
+ and self.kms_key_version == other.kms_key_version
61
+ )
62
+
63
+ def __ne__(self, other):
64
+ return not self == other
@@ -0,0 +1,223 @@
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
+ """Wrappers for gapic enum types."""
15
+
16
+ from google.cloud.bigtable_admin_v2.types import common
17
+ from google.cloud.bigtable_admin_v2.types import instance
18
+ from google.cloud.bigtable_admin_v2.types import table
19
+
20
+
21
+ class StorageType(object):
22
+ """
23
+ Storage media types for persisting Bigtable data.
24
+
25
+ Attributes:
26
+ UNSPECIFIED (int): The user did not specify a storage type.
27
+ SSD (int): Flash (SSD) storage should be used.
28
+ HDD (int): Magnetic drive (HDD) storage should be used.
29
+ """
30
+
31
+ UNSPECIFIED = common.StorageType.STORAGE_TYPE_UNSPECIFIED
32
+ SSD = common.StorageType.SSD
33
+ HDD = common.StorageType.HDD
34
+
35
+
36
+ class Instance(object):
37
+ class State(object):
38
+ """
39
+ Possible states of an instance.
40
+
41
+ Attributes:
42
+ STATE_NOT_KNOWN (int): The state of the instance could not be
43
+ determined.
44
+ READY (int): The instance has been successfully created and can
45
+ serve requests to its tables.
46
+ CREATING (int): The instance is currently being created, and may be
47
+ destroyed if the creation process encounters an error.
48
+ """
49
+
50
+ NOT_KNOWN = instance.Instance.State.STATE_NOT_KNOWN
51
+ READY = instance.Instance.State.READY
52
+ CREATING = instance.Instance.State.CREATING
53
+
54
+ class Type(object):
55
+ """
56
+ The type of the instance.
57
+
58
+ Attributes:
59
+ UNSPECIFIED (int): The type of the instance is unspecified.
60
+ If set when creating an instance, a ``PRODUCTION`` instance will
61
+ be created. If set when updating an instance, the type will be
62
+ left unchanged.
63
+ PRODUCTION (int): An instance meant for production use.
64
+ ``serve_nodes`` must be set on the cluster.
65
+ DEVELOPMENT (int): The instance is meant for development and testing
66
+ purposes only; it has no performance or uptime guarantees and is not
67
+ covered by SLA.
68
+ After a development instance is created, it can be upgraded by
69
+ updating the instance to type ``PRODUCTION``. An instance created
70
+ as a production instance cannot be changed to a development instance.
71
+ When creating a development instance, ``serve_nodes`` on the cluster
72
+ must not be set.
73
+ """
74
+
75
+ UNSPECIFIED = instance.Instance.Type.TYPE_UNSPECIFIED
76
+ PRODUCTION = instance.Instance.Type.PRODUCTION
77
+ DEVELOPMENT = instance.Instance.Type.DEVELOPMENT
78
+
79
+
80
+ class Cluster(object):
81
+ class State(object):
82
+ """
83
+ Possible states of a cluster.
84
+
85
+ Attributes:
86
+ NOT_KNOWN (int): The state of the cluster could not be determined.
87
+ READY (int): The cluster has been successfully created and is ready
88
+ to serve requests.
89
+ CREATING (int): The cluster is currently being created, and may be
90
+ destroyed if the creation process encounters an error.
91
+ A cluster may not be able to serve requests while being created.
92
+ RESIZING (int): The cluster is currently being resized, and may
93
+ revert to its previous node count if the process encounters an error.
94
+ A cluster is still capable of serving requests while being resized,
95
+ but may exhibit performance as if its number of allocated nodes is
96
+ between the starting and requested states.
97
+ DISABLED (int): The cluster has no backing nodes. The data (tables)
98
+ still exist, but no operations can be performed on the cluster.
99
+ """
100
+
101
+ NOT_KNOWN = instance.Cluster.State.STATE_NOT_KNOWN
102
+ READY = instance.Cluster.State.READY
103
+ CREATING = instance.Cluster.State.CREATING
104
+ RESIZING = instance.Cluster.State.RESIZING
105
+ DISABLED = instance.Cluster.State.DISABLED
106
+
107
+
108
+ class RoutingPolicyType(object):
109
+ """
110
+ The type of the routing policy for app_profile.
111
+
112
+ Attributes:
113
+ ANY (int): Read/write requests may be routed to any cluster in the
114
+ instance, and will fail over to another cluster in the event of
115
+ transient errors or delays.
116
+ Choosing this option sacrifices read-your-writes consistency to
117
+ improve availability.
118
+ See
119
+ https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.bigtable.admin.v2#google.bigtable.admin.v2.AppProfile.MultiClusterRoutingUseAny
120
+
121
+ SINGLE (int): Unconditionally routes all read/write requests to a
122
+ specific cluster.
123
+ This option preserves read-your-writes consistency, but does not improve
124
+ availability.
125
+ See
126
+ https://cloud.google.com/bigtable/docs/reference/admin/rpc/google.bigtable.admin.v2#google.bigtable.admin.v2.AppProfile.SingleClusterRouting
127
+ """
128
+
129
+ ANY = 1
130
+ SINGLE = 2
131
+
132
+
133
+ class Table(object):
134
+ class View(object):
135
+ """
136
+ Defines a view over a table's fields.
137
+
138
+ Attributes:
139
+ VIEW_UNSPECIFIED (int): Uses the default view for each method
140
+ as documented in its request.
141
+ NAME_ONLY (int): Only populates ``name``.
142
+ SCHEMA_VIEW (int): Only populates ``name`` and fields related
143
+ to the table's schema.
144
+ REPLICATION_VIEW (int): This is a private alpha release of
145
+ Cloud Bigtable replication. This feature is not currently available
146
+ to most Cloud Bigtable customers. This feature might be changed in
147
+ backward-incompatible ways and is not recommended for production use.
148
+ It is not subject to any SLA or deprecation policy.
149
+
150
+ Only populates ``name`` and fields related to the table's
151
+ replication state.
152
+ FULL (int): Populates all fields.
153
+ """
154
+
155
+ VIEW_UNSPECIFIED = table.Table.View.VIEW_UNSPECIFIED
156
+ NAME_ONLY = table.Table.View.NAME_ONLY
157
+ SCHEMA_VIEW = table.Table.View.SCHEMA_VIEW
158
+ REPLICATION_VIEW = table.Table.View.REPLICATION_VIEW
159
+ ENCRYPTION_VIEW = table.Table.View.ENCRYPTION_VIEW
160
+ FULL = table.Table.View.FULL
161
+
162
+ class ReplicationState(object):
163
+ """
164
+ Table replication states.
165
+
166
+ Attributes:
167
+ STATE_NOT_KNOWN (int): The replication state of the table is unknown
168
+ in this cluster.
169
+ INITIALIZING (int): The cluster was recently created, and the table
170
+ must finish copying
171
+ over pre-existing data from other clusters before it can begin
172
+ receiving live replication updates and serving
173
+ ``Data API`` requests.
174
+ PLANNED_MAINTENANCE (int): The table is temporarily unable to serve
175
+ ``Data API`` requests from this
176
+ cluster due to planned internal maintenance.
177
+ UNPLANNED_MAINTENANCE (int): The table is temporarily unable to serve
178
+ ``Data API`` requests from this
179
+ cluster due to unplanned or emergency maintenance.
180
+ READY (int): The table can serve
181
+ ``Data API`` requests from this
182
+ cluster. Depending on replication delay, reads may not immediately
183
+ reflect the state of the table in other clusters.
184
+ """
185
+
186
+ STATE_NOT_KNOWN = table.Table.ClusterState.ReplicationState.STATE_NOT_KNOWN
187
+ INITIALIZING = table.Table.ClusterState.ReplicationState.INITIALIZING
188
+ PLANNED_MAINTENANCE = (
189
+ table.Table.ClusterState.ReplicationState.PLANNED_MAINTENANCE
190
+ )
191
+ UNPLANNED_MAINTENANCE = (
192
+ table.Table.ClusterState.ReplicationState.UNPLANNED_MAINTENANCE
193
+ )
194
+ READY = table.Table.ClusterState.ReplicationState.READY
195
+
196
+
197
+ class EncryptionInfo:
198
+ class EncryptionType:
199
+ """Possible encryption types for a resource.
200
+
201
+ Attributes:
202
+ ENCRYPTION_TYPE_UNSPECIFIED (int): Encryption type was not specified, though
203
+ data at rest remains encrypted.
204
+ GOOGLE_DEFAULT_ENCRYPTION (int): The data backing this resource is encrypted
205
+ at rest with a key that is fully managed by Google. No key version or
206
+ status will be populated. This is the default state.
207
+ CUSTOMER_MANAGED_ENCRYPTION (int): The data backing this resource is
208
+ encrypted at rest with a key that is managed by the customer. The in-use
209
+ version of the key and its status are populated for CMEK-protected
210
+ tables. CMEK-protected backups are pinned to the key version that was in
211
+ use at the time the backup was taken. This key version is populated but
212
+ its status is not tracked and is reported as `UNKNOWN`.
213
+ """
214
+
215
+ ENCRYPTION_TYPE_UNSPECIFIED = (
216
+ table.EncryptionInfo.EncryptionType.ENCRYPTION_TYPE_UNSPECIFIED
217
+ )
218
+ GOOGLE_DEFAULT_ENCRYPTION = (
219
+ table.EncryptionInfo.EncryptionType.GOOGLE_DEFAULT_ENCRYPTION
220
+ )
221
+ CUSTOMER_MANAGED_ENCRYPTION = (
222
+ table.EncryptionInfo.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION
223
+ )
@@ -0,0 +1,64 @@
1
+ # Copyright 2021 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
+
15
+ """Class for error status."""
16
+
17
+
18
+ class Status:
19
+ """A status, comprising a code and a message.
20
+
21
+ See: `Cloud APIs Errors <https://cloud.google.com/apis/design/errors>`_
22
+
23
+ This is a thin wrapper for ``google.rpc.status_pb2.Status``.
24
+
25
+ :type status_pb: google.rpc.status_pb2.Status
26
+ :param status_pb: The status protocol buffer.
27
+ """
28
+
29
+ def __init__(self, status_pb):
30
+ self.status_pb = status_pb
31
+
32
+ @property
33
+ def code(self):
34
+ """The status code.
35
+
36
+ Values are defined in ``google.rpc.code_pb2.Code``.
37
+
38
+ See: `google.rpc.Code
39
+ <https://github.com/googleapis/googleapis/blob/main/google/rpc/code.proto>`_
40
+
41
+ :rtype: int
42
+ :returns: The status code.
43
+ """
44
+ return self.status_pb.code
45
+
46
+ @property
47
+ def message(self):
48
+ """A human readable status message.
49
+
50
+ :rypte: str
51
+ :returns: The status message.
52
+ """
53
+ return self.status_pb.message
54
+
55
+ def __repr__(self):
56
+ return repr(self.status_pb)
57
+
58
+ def __eq__(self, other):
59
+ if isinstance(other, type(self)):
60
+ return self.status_pb == other.status_pb
61
+ return NotImplemented
62
+
63
+ def __ne__(self, other):
64
+ return not self == other
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2022 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
+ __version__ = "2.30.0" # {x-release-please-version}
@@ -0,0 +1,31 @@
1
+ # Copyright 2024 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
+
15
+ from typing import TypeVar, Iterable, Generator, Tuple
16
+
17
+ from itertools import islice
18
+
19
+ T = TypeVar("T")
20
+
21
+
22
+ # batched landed in standard library in Python 3.11.
23
+ def batched(iterable: Iterable[T], n) -> Generator[Tuple[T, ...], None, None]:
24
+ # batched('ABCDEFG', 3) → ABC DEF G
25
+ if n < 1:
26
+ raise ValueError("n must be at least one")
27
+ it = iter(iterable)
28
+ batch = tuple(islice(it, n))
29
+ while batch:
30
+ yield batch
31
+ batch = tuple(islice(it, n))