ZTWHHH commited on
Commit
6f21ea2
·
verified ·
1 Parent(s): f4cafa4

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. evalkit_tf437/lib/python3.10/site-packages/google/api_core/__pycache__/iam.cpython-310.pyc +0 -0
  2. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__init__.py +40 -0
  3. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/__init__.cpython-310.pyc +0 -0
  4. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_base_client.cpython-310.pyc +0 -0
  5. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_async_client.cpython-310.pyc +0 -0
  6. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client.cpython-310.pyc +0 -0
  7. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client_config.cpython-310.pyc +0 -0
  8. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_rest_client_async.cpython-310.pyc +0 -0
  9. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_async.cpython-310.pyc +0 -0
  10. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_base.cpython-310.pyc +0 -0
  11. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/abstract_operations_client.py +387 -0
  12. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client_config.py +60 -0
  13. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/pagers.py +67 -0
  14. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_async.py +71 -0
  15. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/__init__.cpython-310.pyc +0 -0
  16. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest.cpython-310.pyc +0 -0
  17. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest_asyncio.cpython-310.pyc +0 -0
  18. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/base.py +282 -0
  19. evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/rest.py +473 -0
  20. evalkit_tf437/lib/python3.10/site-packages/google/oauth2/__init__.py +36 -0
  21. evalkit_tf437/lib/python3.10/site-packages/google/oauth2/_service_account_async.py +132 -0
  22. evalkit_tf437/lib/python3.10/site-packages/google/oauth2/gdch_credentials.py +251 -0
  23. evalkit_tf437/lib/python3.10/site-packages/google/oauth2/sts.py +176 -0
  24. evalkit_tf437/lib/python3.10/site-packages/google/oauth2/webauthn_types.py +156 -0
  25. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__init__.py +61 -0
  26. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/__init__.cpython-310.pyc +0 -0
  27. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/_helpers.cpython-310.pyc +0 -0
  28. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/_upload.cpython-310.pyc +0 -0
  29. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/common.cpython-310.pyc +0 -0
  30. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/common.py +179 -0
  31. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/__pycache__/__init__.cpython-310.pyc +0 -0
  32. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/__pycache__/_request_helpers.cpython-310.pyc +0 -0
  33. evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/_request_helpers.py +180 -0
  34. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  35. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/iris.arff +225 -0
  36. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/missing.arff +8 -0
  37. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/nodata.arff +11 -0
  38. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
  39. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test1.arff +10 -0
  40. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test10.arff +0 -0
  41. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test11.arff +11 -0
  42. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test4.arff +11 -0
  43. evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/test_arffread.py +421 -0
  44. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/_byteordercodes.cpython-310.pyc +0 -0
  45. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/mio4.cpython-310.pyc +0 -0
  46. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/miobase.cpython-310.pyc +0 -0
  47. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
  48. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/little_endian.mat +0 -0
  49. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
  50. evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
evalkit_tf437/lib/python3.10/site-packages/google/api_core/__pycache__/iam.cpython-310.pyc ADDED
Binary file (12.1 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__init__.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 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
+ """Package for interacting with the google.longrunning.operations meta-API."""
16
+
17
+ from google.api_core.operations_v1.abstract_operations_client import AbstractOperationsClient
18
+ from google.api_core.operations_v1.operations_async_client import OperationsAsyncClient
19
+ from google.api_core.operations_v1.operations_client import OperationsClient
20
+ from google.api_core.operations_v1.transports.rest import OperationsRestTransport
21
+
22
+ __all__ = [
23
+ "AbstractOperationsClient",
24
+ "OperationsAsyncClient",
25
+ "OperationsClient",
26
+ "OperationsRestTransport"
27
+ ]
28
+
29
+ try:
30
+ from google.api_core.operations_v1.transports.rest_asyncio import (
31
+ AsyncOperationsRestTransport,
32
+ )
33
+ from google.api_core.operations_v1.operations_rest_client_async import AsyncOperationsRestClient
34
+
35
+ __all__ += ["AsyncOperationsRestClient", "AsyncOperationsRestTransport"]
36
+ except ImportError:
37
+ # This import requires the `async_rest` extra.
38
+ # Don't raise an exception if `AsyncOperationsRestTransport` cannot be imported
39
+ # as other transports are still available.
40
+ pass
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (986 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/abstract_operations_base_client.cpython-310.pyc ADDED
Binary file (12.7 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_async_client.cpython-310.pyc ADDED
Binary file (12.3 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client.cpython-310.pyc ADDED
Binary file (12.8 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_client_config.cpython-310.pyc ADDED
Binary file (943 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/operations_rest_client_async.cpython-310.pyc ADDED
Binary file (11.2 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_async.cpython-310.pyc ADDED
Binary file (2.52 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/__pycache__/pagers_base.cpython-310.pyc ADDED
Binary file (2.59 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/abstract_operations_client.py ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2020 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
+ from typing import Optional, Sequence, Tuple, Union
17
+
18
+ from google.api_core import client_options as client_options_lib # type: ignore
19
+ from google.api_core import gapic_v1 # type: ignore
20
+ from google.api_core import retry as retries # type: ignore
21
+ from google.api_core.operations_v1 import pagers
22
+ from google.api_core.operations_v1.transports.base import (
23
+ DEFAULT_CLIENT_INFO,
24
+ OperationsTransport,
25
+ )
26
+ from google.api_core.operations_v1.abstract_operations_base_client import (
27
+ AbstractOperationsBaseClient,
28
+ )
29
+ from google.auth import credentials as ga_credentials # type: ignore
30
+ from google.longrunning import operations_pb2
31
+ from google.oauth2 import service_account # type: ignore
32
+ import grpc
33
+
34
+ OptionalRetry = Union[retries.Retry, object]
35
+
36
+
37
+ class AbstractOperationsClient(AbstractOperationsBaseClient):
38
+ """Manages long-running operations with an API service.
39
+
40
+ When an API method normally takes long time to complete, it can be
41
+ designed to return [Operation][google.api_core.operations_v1.Operation] to the
42
+ client, and the client can use this interface to receive the real
43
+ response asynchronously by polling the operation resource, or pass
44
+ the operation resource to another API (such as Google Cloud Pub/Sub
45
+ API) to receive the response. Any API service that returns
46
+ long-running operations should implement the ``Operations``
47
+ interface so developers can have a consistent client experience.
48
+ """
49
+
50
+ def __init__(
51
+ self,
52
+ *,
53
+ credentials: Optional[ga_credentials.Credentials] = None,
54
+ transport: Union[str, OperationsTransport, None] = None,
55
+ client_options: Optional[client_options_lib.ClientOptions] = None,
56
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
57
+ ) -> None:
58
+ """Instantiates the operations client.
59
+
60
+ Args:
61
+ credentials (Optional[google.auth.credentials.Credentials]): The
62
+ authorization credentials to attach to requests. These
63
+ credentials identify the application to the service; if none
64
+ are specified, the client will attempt to ascertain the
65
+ credentials from the environment.
66
+ transport (Union[str, OperationsTransport]): The
67
+ transport to use. If set to None, a transport is chosen
68
+ automatically.
69
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
70
+ client. It won't take effect if a ``transport`` instance is provided.
71
+ (1) The ``api_endpoint`` property can be used to override the
72
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
73
+ environment variable can also be used to override the endpoint:
74
+ "always" (always use the default mTLS endpoint), "never" (always
75
+ use the default regular endpoint) and "auto" (auto switch to the
76
+ default mTLS endpoint if client certificate is present, this is
77
+ the default value). However, the ``api_endpoint`` property takes
78
+ precedence if provided.
79
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
80
+ is "true", then the ``client_cert_source`` property can be used
81
+ to provide client certificate for mutual TLS transport. If
82
+ not provided, the default SSL client certificate will be used if
83
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
84
+ set, no client certificate will be used.
85
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
86
+ The client info used to send a user-agent string along with
87
+ API requests. If ``None``, then default info will be used.
88
+ Generally, you only need to set this if you're developing
89
+ your own client library.
90
+
91
+ Raises:
92
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
93
+ creation failed for any reason.
94
+ """
95
+ super().__init__(
96
+ credentials=credentials,
97
+ transport=transport,
98
+ client_options=client_options,
99
+ client_info=client_info,
100
+ )
101
+
102
+ @classmethod
103
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
104
+ """Creates an instance of this client using the provided credentials
105
+ info.
106
+
107
+ Args:
108
+ info (dict): The service account private key info.
109
+ args: Additional arguments to pass to the constructor.
110
+ kwargs: Additional arguments to pass to the constructor.
111
+
112
+ Returns:
113
+ AbstractOperationsClient: The constructed client.
114
+ """
115
+ credentials = service_account.Credentials.from_service_account_info(info)
116
+ kwargs["credentials"] = credentials
117
+ return cls(*args, **kwargs)
118
+
119
+ @classmethod
120
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
121
+ """Creates an instance of this client using the provided credentials
122
+ file.
123
+
124
+ Args:
125
+ filename (str): The path to the service account private key json
126
+ file.
127
+ args: Additional arguments to pass to the constructor.
128
+ kwargs: Additional arguments to pass to the constructor.
129
+
130
+ Returns:
131
+ AbstractOperationsClient: The constructed client.
132
+ """
133
+ credentials = service_account.Credentials.from_service_account_file(filename)
134
+ kwargs["credentials"] = credentials
135
+ return cls(*args, **kwargs)
136
+
137
+ from_service_account_json = from_service_account_file
138
+
139
+ def list_operations(
140
+ self,
141
+ name: str,
142
+ filter_: Optional[str] = None,
143
+ *,
144
+ page_size: Optional[int] = None,
145
+ page_token: Optional[str] = None,
146
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
147
+ timeout: Optional[float] = None,
148
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
149
+ metadata: Sequence[Tuple[str, str]] = (),
150
+ ) -> pagers.ListOperationsPager:
151
+ r"""Lists operations that match the specified filter in the request.
152
+ If the server doesn't support this method, it returns
153
+ ``UNIMPLEMENTED``.
154
+
155
+ NOTE: the ``name`` binding allows API services to override the
156
+ binding to use different resource name schemes, such as
157
+ ``users/*/operations``. To override the binding, API services
158
+ can add a binding such as ``"/v1/{name=users/*}/operations"`` to
159
+ their service configuration. For backwards compatibility, the
160
+ default name includes the operations collection id, however
161
+ overriding users must ensure the name binding is the parent
162
+ resource, without the operations collection id.
163
+
164
+ Args:
165
+ name (str):
166
+ The name of the operation's parent
167
+ resource.
168
+ filter_ (str):
169
+ The standard list filter.
170
+ This corresponds to the ``filter`` field
171
+ on the ``request`` instance; if ``request`` is provided, this
172
+ should not be set.
173
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
174
+ should be retried.
175
+ timeout (float): The timeout for this request.
176
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
177
+ sent along with the request as metadata.
178
+
179
+ Returns:
180
+ google.api_core.operations_v1.pagers.ListOperationsPager:
181
+ The response message for
182
+ [Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].
183
+
184
+ Iterating over this object will yield results and
185
+ resolve additional pages automatically.
186
+
187
+ """
188
+ # Create a protobuf request object.
189
+ request = operations_pb2.ListOperationsRequest(name=name, filter=filter_)
190
+ if page_size is not None:
191
+ request.page_size = page_size
192
+ if page_token is not None:
193
+ request.page_token = page_token
194
+
195
+ # Wrap the RPC method; this adds retry and timeout information,
196
+ # and friendly error handling.
197
+ rpc = self._transport._wrapped_methods[self._transport.list_operations]
198
+
199
+ # Certain fields should be provided within the metadata header;
200
+ # add these here.
201
+ metadata = tuple(metadata or ()) + (
202
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
203
+ )
204
+
205
+ # Send the request.
206
+ response = rpc(
207
+ request,
208
+ retry=retry,
209
+ timeout=timeout,
210
+ compression=compression,
211
+ metadata=metadata,
212
+ )
213
+
214
+ # This method is paged; wrap the response in a pager, which provides
215
+ # an `__iter__` convenience method.
216
+ response = pagers.ListOperationsPager(
217
+ method=rpc,
218
+ request=request,
219
+ response=response,
220
+ metadata=metadata,
221
+ )
222
+
223
+ # Done; return the response.
224
+ return response
225
+
226
+ def get_operation(
227
+ self,
228
+ name: str,
229
+ *,
230
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
231
+ timeout: Optional[float] = None,
232
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
233
+ metadata: Sequence[Tuple[str, str]] = (),
234
+ ) -> operations_pb2.Operation:
235
+ r"""Gets the latest state of a long-running operation.
236
+ Clients can use this method to poll the operation result
237
+ at intervals as recommended by the API service.
238
+
239
+ Args:
240
+ name (str):
241
+ The name of the operation resource.
242
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
243
+ should be retried.
244
+ timeout (float): The timeout for this request.
245
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
246
+ sent along with the request as metadata.
247
+
248
+ Returns:
249
+ google.longrunning.operations_pb2.Operation:
250
+ This resource represents a long-
251
+ running operation that is the result of a
252
+ network API call.
253
+
254
+ """
255
+
256
+ request = operations_pb2.GetOperationRequest(name=name)
257
+
258
+ # Wrap the RPC method; this adds retry and timeout information,
259
+ # and friendly error handling.
260
+ rpc = self._transport._wrapped_methods[self._transport.get_operation]
261
+
262
+ # Certain fields should be provided within the metadata header;
263
+ # add these here.
264
+ metadata = tuple(metadata or ()) + (
265
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
266
+ )
267
+
268
+ # Send the request.
269
+ response = rpc(
270
+ request,
271
+ retry=retry,
272
+ timeout=timeout,
273
+ compression=compression,
274
+ metadata=metadata,
275
+ )
276
+
277
+ # Done; return the response.
278
+ return response
279
+
280
+ def delete_operation(
281
+ self,
282
+ name: str,
283
+ *,
284
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
285
+ timeout: Optional[float] = None,
286
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
287
+ metadata: Sequence[Tuple[str, str]] = (),
288
+ ) -> None:
289
+ r"""Deletes a long-running operation. This method indicates that the
290
+ client is no longer interested in the operation result. It does
291
+ not cancel the operation. If the server doesn't support this
292
+ method, it returns ``google.rpc.Code.UNIMPLEMENTED``.
293
+
294
+ Args:
295
+ name (str):
296
+ The name of the operation resource to
297
+ be deleted.
298
+
299
+ This corresponds to the ``name`` field
300
+ on the ``request`` instance; if ``request`` is provided, this
301
+ should not be set.
302
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
303
+ should be retried.
304
+ timeout (float): The timeout for this request.
305
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
306
+ sent along with the request as metadata.
307
+ """
308
+ # Create the request object.
309
+ request = operations_pb2.DeleteOperationRequest(name=name)
310
+
311
+ # Wrap the RPC method; this adds retry and timeout information,
312
+ # and friendly error handling.
313
+ rpc = self._transport._wrapped_methods[self._transport.delete_operation]
314
+
315
+ # Certain fields should be provided within the metadata header;
316
+ # add these here.
317
+ metadata = tuple(metadata or ()) + (
318
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
319
+ )
320
+
321
+ # Send the request.
322
+ rpc(
323
+ request,
324
+ retry=retry,
325
+ timeout=timeout,
326
+ compression=compression,
327
+ metadata=metadata,
328
+ )
329
+
330
+ def cancel_operation(
331
+ self,
332
+ name: Optional[str] = None,
333
+ *,
334
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
335
+ timeout: Optional[float] = None,
336
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
337
+ metadata: Sequence[Tuple[str, str]] = (),
338
+ ) -> None:
339
+ r"""Starts asynchronous cancellation on a long-running operation.
340
+ The server makes a best effort to cancel the operation, but
341
+ success is not guaranteed. If the server doesn't support this
342
+ method, it returns ``google.rpc.Code.UNIMPLEMENTED``. Clients
343
+ can use
344
+ [Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation]
345
+ or other methods to check whether the cancellation succeeded or
346
+ whether the operation completed despite cancellation. On
347
+ successful cancellation, the operation is not deleted; instead,
348
+ it becomes an operation with an
349
+ [Operation.error][google.api_core.operations_v1.Operation.error] value with
350
+ a [google.rpc.Status.code][google.rpc.Status.code] of 1,
351
+ corresponding to ``Code.CANCELLED``.
352
+
353
+ Args:
354
+ name (str):
355
+ The name of the operation resource to
356
+ be cancelled.
357
+
358
+ This corresponds to the ``name`` field
359
+ on the ``request`` instance; if ``request`` is provided, this
360
+ should not be set.
361
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
362
+ should be retried.
363
+ timeout (float): The timeout for this request.
364
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
365
+ sent along with the request as metadata.
366
+ """
367
+ # Create the request object.
368
+ request = operations_pb2.CancelOperationRequest(name=name)
369
+
370
+ # Wrap the RPC method; this adds retry and timeout information,
371
+ # and friendly error handling.
372
+ rpc = self._transport._wrapped_methods[self._transport.cancel_operation]
373
+
374
+ # Certain fields should be provided within the metadata header;
375
+ # add these here.
376
+ metadata = tuple(metadata or ()) + (
377
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
378
+ )
379
+
380
+ # Send the request.
381
+ rpc(
382
+ request,
383
+ retry=retry,
384
+ timeout=timeout,
385
+ compression=compression,
386
+ metadata=metadata,
387
+ )
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/operations_client_config.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 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
+ """gapic configuration for the google.longrunning.operations client."""
16
+
17
+ # DEPRECATED: retry and timeout classes are instantiated directly
18
+ config = {
19
+ "interfaces": {
20
+ "google.longrunning.Operations": {
21
+ "retry_codes": {
22
+ "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
23
+ "non_idempotent": [],
24
+ },
25
+ "retry_params": {
26
+ "default": {
27
+ "initial_retry_delay_millis": 100,
28
+ "retry_delay_multiplier": 1.3,
29
+ "max_retry_delay_millis": 60000,
30
+ "initial_rpc_timeout_millis": 20000,
31
+ "rpc_timeout_multiplier": 1.0,
32
+ "max_rpc_timeout_millis": 600000,
33
+ "total_timeout_millis": 600000,
34
+ }
35
+ },
36
+ "methods": {
37
+ "GetOperation": {
38
+ "timeout_millis": 60000,
39
+ "retry_codes_name": "idempotent",
40
+ "retry_params_name": "default",
41
+ },
42
+ "ListOperations": {
43
+ "timeout_millis": 60000,
44
+ "retry_codes_name": "idempotent",
45
+ "retry_params_name": "default",
46
+ },
47
+ "CancelOperation": {
48
+ "timeout_millis": 60000,
49
+ "retry_codes_name": "idempotent",
50
+ "retry_params_name": "default",
51
+ },
52
+ "DeleteOperation": {
53
+ "timeout_millis": 60000,
54
+ "retry_codes_name": "idempotent",
55
+ "retry_params_name": "default",
56
+ },
57
+ },
58
+ }
59
+ }
60
+ }
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/pagers.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2020 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
+ from typing import (
17
+ Callable,
18
+ Iterator,
19
+ Sequence,
20
+ Tuple,
21
+ )
22
+
23
+ from google.longrunning import operations_pb2
24
+ from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
25
+
26
+
27
+ class ListOperationsPager(ListOperationsPagerBase):
28
+ """A pager for iterating through ``list_operations`` requests.
29
+
30
+ This class thinly wraps an initial
31
+ :class:`google.longrunning.operations_pb2.ListOperationsResponse` object, and
32
+ provides an ``__iter__`` method to iterate through its
33
+ ``operations`` field.
34
+
35
+ If there are more pages, the ``__iter__`` method will make additional
36
+ ``ListOperations`` requests and continue to iterate
37
+ through the ``operations`` field on the
38
+ corresponding responses.
39
+
40
+ All the usual :class:`google.longrunning.operations_pb2.ListOperationsResponse`
41
+ attributes are available on the pager. If multiple requests are made, only
42
+ the most recent response is retained, and thus used for attribute lookup.
43
+ """
44
+
45
+ def __init__(
46
+ self,
47
+ method: Callable[..., operations_pb2.ListOperationsResponse],
48
+ request: operations_pb2.ListOperationsRequest,
49
+ response: operations_pb2.ListOperationsResponse,
50
+ *,
51
+ metadata: Sequence[Tuple[str, str]] = ()
52
+ ):
53
+ super().__init__(
54
+ method=method, request=request, response=response, metadata=metadata
55
+ )
56
+
57
+ @property
58
+ def pages(self) -> Iterator[operations_pb2.ListOperationsResponse]:
59
+ yield self._response
60
+ while self._response.next_page_token:
61
+ self._request.page_token = self._response.next_page_token
62
+ self._response = self._method(self._request, metadata=self._metadata)
63
+ yield self._response
64
+
65
+ def __iter__(self) -> Iterator[operations_pb2.Operation]:
66
+ for page in self.pages:
67
+ yield from page.operations
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/pagers_async.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2024 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
+ from typing import (
17
+ Callable,
18
+ AsyncIterator,
19
+ Sequence,
20
+ Tuple,
21
+ )
22
+
23
+ from google.longrunning import operations_pb2
24
+ from google.api_core.operations_v1.pagers_base import ListOperationsPagerBase
25
+
26
+
27
+ class ListOperationsAsyncPager(ListOperationsPagerBase):
28
+ """A pager for iterating through ``list_operations`` requests.
29
+
30
+ This class thinly wraps an initial
31
+ :class:`google.longrunning.operations_pb2.ListOperationsResponse` object, and
32
+ provides an ``__iter__`` method to iterate through its
33
+ ``operations`` field.
34
+
35
+ If there are more pages, the ``__iter__`` method will make additional
36
+ ``ListOperations`` requests and continue to iterate
37
+ through the ``operations`` field on the
38
+ corresponding responses.
39
+
40
+ All the usual :class:`google.longrunning.operations_pb2.ListOperationsResponse`
41
+ attributes are available on the pager. If multiple requests are made, only
42
+ the most recent response is retained, and thus used for attribute lookup.
43
+ """
44
+
45
+ def __init__(
46
+ self,
47
+ method: Callable[..., operations_pb2.ListOperationsResponse],
48
+ request: operations_pb2.ListOperationsRequest,
49
+ response: operations_pb2.ListOperationsResponse,
50
+ *,
51
+ metadata: Sequence[Tuple[str, str]] = ()
52
+ ):
53
+ super().__init__(
54
+ method=method, request=request, response=response, metadata=metadata
55
+ )
56
+
57
+ @property
58
+ async def pages(self) -> AsyncIterator[operations_pb2.ListOperationsResponse]:
59
+ yield self._response
60
+ while self._response.next_page_token:
61
+ self._request.page_token = self._response.next_page_token
62
+ self._response = await self._method(self._request, metadata=self._metadata)
63
+ yield self._response
64
+
65
+ def __aiter__(self) -> AsyncIterator[operations_pb2.Operation]:
66
+ async def async_generator():
67
+ async for page in self.pages:
68
+ for operation in page.operations:
69
+ yield operation
70
+
71
+ return async_generator()
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (706 Bytes). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest.cpython-310.pyc ADDED
Binary file (12.8 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/__pycache__/rest_asyncio.cpython-310.pyc ADDED
Binary file (13.8 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/base.py ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2020 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
+ import abc
17
+ import re
18
+ from typing import Awaitable, Callable, Optional, Sequence, Union
19
+
20
+ import google.api_core # type: ignore
21
+ from google.api_core import exceptions as core_exceptions # type: ignore
22
+ from google.api_core import gapic_v1 # type: ignore
23
+ from google.api_core import retry as retries # type: ignore
24
+ from google.api_core import version
25
+ import google.auth # type: ignore
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.longrunning import operations_pb2
28
+ from google.oauth2 import service_account # type: ignore
29
+ import google.protobuf
30
+ from google.protobuf import empty_pb2, json_format # type: ignore
31
+ from grpc import Compression
32
+
33
+
34
+ PROTOBUF_VERSION = google.protobuf.__version__
35
+
36
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
37
+ gapic_version=version.__version__,
38
+ )
39
+
40
+
41
+ class OperationsTransport(abc.ABC):
42
+ """Abstract transport class for Operations."""
43
+
44
+ AUTH_SCOPES = ()
45
+
46
+ DEFAULT_HOST: str = "longrunning.googleapis.com"
47
+
48
+ def __init__(
49
+ self,
50
+ *,
51
+ host: str = DEFAULT_HOST,
52
+ # TODO(https://github.com/googleapis/python-api-core/issues/709): update type hint for credentials to include `google.auth.aio.Credentials`.
53
+ credentials: Optional[ga_credentials.Credentials] = None,
54
+ credentials_file: Optional[str] = None,
55
+ scopes: Optional[Sequence[str]] = None,
56
+ quota_project_id: Optional[str] = None,
57
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
58
+ always_use_jwt_access: Optional[bool] = False,
59
+ url_scheme="https",
60
+ **kwargs,
61
+ ) -> None:
62
+ """Instantiate the transport.
63
+
64
+ Args:
65
+ host (Optional[str]):
66
+ The hostname to connect to.
67
+ credentials (Optional[google.auth.credentials.Credentials]): The
68
+ authorization credentials to attach to requests. These
69
+ credentials identify the application to the service; if none
70
+ are specified, the client will attempt to ascertain the
71
+ credentials from the environment.
72
+ credentials_file (Optional[str]): A file with credentials that can
73
+ be loaded with :func:`google.auth.load_credentials_from_file`.
74
+ This argument is mutually exclusive with credentials.
75
+ scopes (Optional[Sequence[str]]): A list of scopes.
76
+ quota_project_id (Optional[str]): An optional project to use for billing
77
+ and quota.
78
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
79
+ The client info used to send a user-agent string along with
80
+ API requests. If ``None``, then default info will be used.
81
+ Generally, you only need to set this if you're developing
82
+ your own client library.
83
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
84
+ be used for service account credentials.
85
+ url_scheme: the protocol scheme for the API endpoint. Normally
86
+ "https", but for testing or local servers,
87
+ "http" can be specified.
88
+ """
89
+ maybe_url_match = re.match("^(?P<scheme>http(?:s)?://)?(?P<host>.*)$", host)
90
+ if maybe_url_match is None:
91
+ raise ValueError(
92
+ f"Unexpected hostname structure: {host}"
93
+ ) # pragma: NO COVER
94
+
95
+ url_match_items = maybe_url_match.groupdict()
96
+
97
+ host = f"{url_scheme}://{host}" if not url_match_items["scheme"] else host
98
+
99
+ # Save the hostname. Default to port 443 (HTTPS) if none is specified.
100
+ if ":" not in host:
101
+ host += ":443" # pragma: NO COVER
102
+ self._host = host
103
+
104
+ scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
105
+
106
+ # Save the scopes.
107
+ self._scopes = scopes
108
+
109
+ # If no credentials are provided, then determine the appropriate
110
+ # defaults.
111
+ if credentials and credentials_file:
112
+ raise core_exceptions.DuplicateCredentialArgs(
113
+ "'credentials_file' and 'credentials' are mutually exclusive"
114
+ )
115
+
116
+ if credentials_file is not None:
117
+ credentials, _ = google.auth.load_credentials_from_file(
118
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
119
+ )
120
+
121
+ elif credentials is None:
122
+ credentials, _ = google.auth.default(
123
+ **scopes_kwargs, quota_project_id=quota_project_id
124
+ )
125
+
126
+ # If the credentials are service account credentials, then always try to use self signed JWT.
127
+ if (
128
+ always_use_jwt_access
129
+ and isinstance(credentials, service_account.Credentials)
130
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
131
+ ):
132
+ credentials = credentials.with_always_use_jwt_access(True)
133
+
134
+ # Save the credentials.
135
+ self._credentials = credentials
136
+
137
+ def _prep_wrapped_messages(self, client_info):
138
+ # Precompute the wrapped methods.
139
+ self._wrapped_methods = {
140
+ self.list_operations: gapic_v1.method.wrap_method(
141
+ self.list_operations,
142
+ default_retry=retries.Retry(
143
+ initial=0.5,
144
+ maximum=10.0,
145
+ multiplier=2.0,
146
+ predicate=retries.if_exception_type(
147
+ core_exceptions.ServiceUnavailable,
148
+ ),
149
+ deadline=10.0,
150
+ ),
151
+ default_timeout=10.0,
152
+ default_compression=Compression.NoCompression,
153
+ client_info=client_info,
154
+ ),
155
+ self.get_operation: gapic_v1.method.wrap_method(
156
+ self.get_operation,
157
+ default_retry=retries.Retry(
158
+ initial=0.5,
159
+ maximum=10.0,
160
+ multiplier=2.0,
161
+ predicate=retries.if_exception_type(
162
+ core_exceptions.ServiceUnavailable,
163
+ ),
164
+ deadline=10.0,
165
+ ),
166
+ default_timeout=10.0,
167
+ default_compression=Compression.NoCompression,
168
+ client_info=client_info,
169
+ ),
170
+ self.delete_operation: gapic_v1.method.wrap_method(
171
+ self.delete_operation,
172
+ default_retry=retries.Retry(
173
+ initial=0.5,
174
+ maximum=10.0,
175
+ multiplier=2.0,
176
+ predicate=retries.if_exception_type(
177
+ core_exceptions.ServiceUnavailable,
178
+ ),
179
+ deadline=10.0,
180
+ ),
181
+ default_timeout=10.0,
182
+ default_compression=Compression.NoCompression,
183
+ client_info=client_info,
184
+ ),
185
+ self.cancel_operation: gapic_v1.method.wrap_method(
186
+ self.cancel_operation,
187
+ default_retry=retries.Retry(
188
+ initial=0.5,
189
+ maximum=10.0,
190
+ multiplier=2.0,
191
+ predicate=retries.if_exception_type(
192
+ core_exceptions.ServiceUnavailable,
193
+ ),
194
+ deadline=10.0,
195
+ ),
196
+ default_timeout=10.0,
197
+ default_compression=Compression.NoCompression,
198
+ client_info=client_info,
199
+ ),
200
+ }
201
+
202
+ def close(self):
203
+ """Closes resources associated with the transport.
204
+
205
+ .. warning::
206
+ Only call this method if the transport is NOT shared
207
+ with other clients - this may cause errors in other clients!
208
+ """
209
+ raise NotImplementedError()
210
+
211
+ def _convert_protobuf_message_to_dict(
212
+ self, message: google.protobuf.message.Message
213
+ ):
214
+ r"""Converts protobuf message to a dictionary.
215
+
216
+ When the dictionary is encoded to JSON, it conforms to proto3 JSON spec.
217
+
218
+ Args:
219
+ message(google.protobuf.message.Message): The protocol buffers message
220
+ instance to serialize.
221
+
222
+ Returns:
223
+ A dict representation of the protocol buffer message.
224
+ """
225
+ # TODO(https://github.com/googleapis/python-api-core/issues/643): For backwards compatibility
226
+ # with protobuf 3.x 4.x, Remove once support for protobuf 3.x and 4.x is dropped.
227
+ if PROTOBUF_VERSION[0:2] in ["3.", "4."]:
228
+ result = json_format.MessageToDict(
229
+ message,
230
+ preserving_proto_field_name=True,
231
+ including_default_value_fields=True, # type: ignore # backward compatibility
232
+ )
233
+ else:
234
+ result = json_format.MessageToDict(
235
+ message,
236
+ preserving_proto_field_name=True,
237
+ always_print_fields_with_no_presence=True,
238
+ )
239
+
240
+ return result
241
+
242
+ @property
243
+ def list_operations(
244
+ self,
245
+ ) -> Callable[
246
+ [operations_pb2.ListOperationsRequest],
247
+ Union[
248
+ operations_pb2.ListOperationsResponse,
249
+ Awaitable[operations_pb2.ListOperationsResponse],
250
+ ],
251
+ ]:
252
+ raise NotImplementedError()
253
+
254
+ @property
255
+ def get_operation(
256
+ self,
257
+ ) -> Callable[
258
+ [operations_pb2.GetOperationRequest],
259
+ Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
260
+ ]:
261
+ raise NotImplementedError()
262
+
263
+ @property
264
+ def delete_operation(
265
+ self,
266
+ ) -> Callable[
267
+ [operations_pb2.DeleteOperationRequest],
268
+ Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
269
+ ]:
270
+ raise NotImplementedError()
271
+
272
+ @property
273
+ def cancel_operation(
274
+ self,
275
+ ) -> Callable[
276
+ [operations_pb2.CancelOperationRequest],
277
+ Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]],
278
+ ]:
279
+ raise NotImplementedError()
280
+
281
+
282
+ __all__ = ("OperationsTransport",)
evalkit_tf437/lib/python3.10/site-packages/google/api_core/operations_v1/transports/rest.py ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright 2020 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
+
17
+ from typing import Callable, Dict, Optional, Sequence, Tuple, Union
18
+
19
+ from requests import __version__ as requests_version
20
+
21
+ from google.api_core import exceptions as core_exceptions # type: ignore
22
+ from google.api_core import gapic_v1 # type: ignore
23
+ from google.api_core import path_template # type: ignore
24
+ from google.api_core import rest_helpers # type: ignore
25
+ from google.api_core import retry as retries # type: ignore
26
+ from google.auth import credentials as ga_credentials # type: ignore
27
+ from google.auth.transport.requests import AuthorizedSession # type: ignore
28
+ from google.longrunning import operations_pb2 # type: ignore
29
+ from google.protobuf import empty_pb2 # type: ignore
30
+ from google.protobuf import json_format # type: ignore
31
+ import google.protobuf
32
+
33
+ import grpc
34
+ from .base import DEFAULT_CLIENT_INFO as BASE_DEFAULT_CLIENT_INFO, OperationsTransport
35
+
36
+ PROTOBUF_VERSION = google.protobuf.__version__
37
+
38
+ OptionalRetry = Union[retries.Retry, object]
39
+
40
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
41
+ gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version,
42
+ grpc_version=None,
43
+ rest_version=f"requests@{requests_version}",
44
+ )
45
+
46
+
47
+ class OperationsRestTransport(OperationsTransport):
48
+ """REST backend transport for Operations.
49
+
50
+ Manages long-running operations with an API service.
51
+
52
+ When an API method normally takes long time to complete, it can be
53
+ designed to return [Operation][google.api_core.operations_v1.Operation] to the
54
+ client, and the client can use this interface to receive the real
55
+ response asynchronously by polling the operation resource, or pass
56
+ the operation resource to another API (such as Google Cloud Pub/Sub
57
+ API) to receive the response. Any API service that returns
58
+ long-running operations should implement the ``Operations``
59
+ interface so developers can have a consistent client experience.
60
+
61
+ This class defines the same methods as the primary client, so the
62
+ primary client can load the underlying transport implementation
63
+ and call it.
64
+
65
+ It sends JSON representations of protocol buffers over HTTP/1.1
66
+ """
67
+
68
+ def __init__(
69
+ self,
70
+ *,
71
+ host: str = "longrunning.googleapis.com",
72
+ credentials: Optional[ga_credentials.Credentials] = None,
73
+ credentials_file: Optional[str] = None,
74
+ scopes: Optional[Sequence[str]] = None,
75
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
76
+ quota_project_id: Optional[str] = None,
77
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
78
+ always_use_jwt_access: Optional[bool] = False,
79
+ url_scheme: str = "https",
80
+ http_options: Optional[Dict] = None,
81
+ path_prefix: str = "v1",
82
+ ) -> None:
83
+ """Instantiate the transport.
84
+
85
+ Args:
86
+ host (Optional[str]):
87
+ The hostname to connect to.
88
+ credentials (Optional[google.auth.credentials.Credentials]): The
89
+ authorization credentials to attach to requests. These
90
+ credentials identify the application to the service; if none
91
+ are specified, the client will attempt to ascertain the
92
+ credentials from the environment.
93
+
94
+ credentials_file (Optional[str]): A file with credentials that can
95
+ be loaded with :func:`google.auth.load_credentials_from_file`.
96
+ This argument is ignored if ``channel`` is provided.
97
+ scopes (Optional(Sequence[str])): A list of scopes. This argument is
98
+ ignored if ``channel`` is provided.
99
+ client_cert_source_for_mtls (Callable[[], Tuple[bytes, bytes]]): Client
100
+ certificate to configure mutual TLS HTTP channel. It is ignored
101
+ if ``channel`` is provided.
102
+ quota_project_id (Optional[str]): An optional project to use for billing
103
+ and quota.
104
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
105
+ The client info used to send a user-agent string along with
106
+ API requests. If ``None``, then default info will be used.
107
+ Generally, you only need to set this if you're developing
108
+ your own client library.
109
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
110
+ be used for service account credentials.
111
+ url_scheme: the protocol scheme for the API endpoint. Normally
112
+ "https", but for testing or local servers,
113
+ "http" can be specified.
114
+ http_options: a dictionary of http_options for transcoding, to override
115
+ the defaults from operations.proto. Each method has an entry
116
+ with the corresponding http rules as value.
117
+ path_prefix: path prefix (usually represents API version). Set to
118
+ "v1" by default.
119
+
120
+ """
121
+ # Run the base constructor
122
+ # TODO(yon-mg): resolve other ctor params i.e. scopes, quota, etc.
123
+ # TODO: When custom host (api_endpoint) is set, `scopes` must *also* be set on the
124
+ # credentials object
125
+ super().__init__(
126
+ host=host,
127
+ credentials=credentials,
128
+ client_info=client_info,
129
+ always_use_jwt_access=always_use_jwt_access,
130
+ )
131
+ self._session = AuthorizedSession(
132
+ self._credentials, default_host=self.DEFAULT_HOST
133
+ )
134
+ if client_cert_source_for_mtls:
135
+ self._session.configure_mtls_channel(client_cert_source_for_mtls)
136
+ # TODO(https://github.com/googleapis/python-api-core/issues/720): Add wrap logic directly to the property methods for callables.
137
+ self._prep_wrapped_messages(client_info)
138
+ self._http_options = http_options or {}
139
+ self._path_prefix = path_prefix
140
+
141
+ def _list_operations(
142
+ self,
143
+ request: operations_pb2.ListOperationsRequest,
144
+ *,
145
+ # TODO(https://github.com/googleapis/python-api-core/issues/723): Leverage `retry`
146
+ # to allow configuring retryable error codes.
147
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
148
+ timeout: Optional[float] = None,
149
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
150
+ metadata: Sequence[Tuple[str, str]] = (),
151
+ ) -> operations_pb2.ListOperationsResponse:
152
+ r"""Call the list operations method over HTTP.
153
+
154
+ Args:
155
+ request (~.operations_pb2.ListOperationsRequest):
156
+ The request object. The request message for
157
+ [Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].
158
+
159
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
160
+ should be retried.
161
+ timeout (float): The timeout for this request.
162
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
163
+ sent along with the request as metadata.
164
+
165
+ Returns:
166
+ ~.operations_pb2.ListOperationsResponse:
167
+ The response message for
168
+ [Operations.ListOperations][google.api_core.operations_v1.Operations.ListOperations].
169
+
170
+ """
171
+
172
+ http_options = [
173
+ {
174
+ "method": "get",
175
+ "uri": "/{}/{{name=**}}/operations".format(self._path_prefix),
176
+ },
177
+ ]
178
+ if "google.longrunning.Operations.ListOperations" in self._http_options:
179
+ http_options = self._http_options[
180
+ "google.longrunning.Operations.ListOperations"
181
+ ]
182
+
183
+ request_kwargs = self._convert_protobuf_message_to_dict(request)
184
+ transcoded_request = path_template.transcode(http_options, **request_kwargs)
185
+
186
+ uri = transcoded_request["uri"]
187
+ method = transcoded_request["method"]
188
+
189
+ # Jsonify the query params
190
+ query_params_request = operations_pb2.ListOperationsRequest()
191
+ json_format.ParseDict(transcoded_request["query_params"], query_params_request)
192
+ query_params = json_format.MessageToDict(
193
+ query_params_request,
194
+ preserving_proto_field_name=False,
195
+ use_integers_for_enums=False,
196
+ )
197
+
198
+ # Send the request
199
+ headers = dict(metadata)
200
+ headers["Content-Type"] = "application/json"
201
+ # TODO(https://github.com/googleapis/python-api-core/issues/721): Update incorrect use of `uri`` variable name.
202
+ response = getattr(self._session, method)(
203
+ "{host}{uri}".format(host=self._host, uri=uri),
204
+ timeout=timeout,
205
+ headers=headers,
206
+ params=rest_helpers.flatten_query_params(query_params),
207
+ )
208
+
209
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
210
+ # subclass.
211
+ if response.status_code >= 400:
212
+ raise core_exceptions.from_http_response(response)
213
+
214
+ # Return the response
215
+ api_response = operations_pb2.ListOperationsResponse()
216
+ json_format.Parse(response.content, api_response, ignore_unknown_fields=False)
217
+ return api_response
218
+
219
+ def _get_operation(
220
+ self,
221
+ request: operations_pb2.GetOperationRequest,
222
+ *,
223
+ # TODO(https://github.com/googleapis/python-api-core/issues/723): Leverage `retry`
224
+ # to allow configuring retryable error codes.
225
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
226
+ timeout: Optional[float] = None,
227
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
228
+ metadata: Sequence[Tuple[str, str]] = (),
229
+ ) -> operations_pb2.Operation:
230
+ r"""Call the get operation method over HTTP.
231
+
232
+ Args:
233
+ request (~.operations_pb2.GetOperationRequest):
234
+ The request object. The request message for
235
+ [Operations.GetOperation][google.api_core.operations_v1.Operations.GetOperation].
236
+
237
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
238
+ should be retried.
239
+ timeout (float): The timeout for this request.
240
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
241
+ sent along with the request as metadata.
242
+
243
+ Returns:
244
+ ~.operations_pb2.Operation:
245
+ This resource represents a long-
246
+ running operation that is the result of a
247
+ network API call.
248
+
249
+ """
250
+
251
+ http_options = [
252
+ {
253
+ "method": "get",
254
+ "uri": "/{}/{{name=**/operations/*}}".format(self._path_prefix),
255
+ },
256
+ ]
257
+ if "google.longrunning.Operations.GetOperation" in self._http_options:
258
+ http_options = self._http_options[
259
+ "google.longrunning.Operations.GetOperation"
260
+ ]
261
+
262
+ request_kwargs = self._convert_protobuf_message_to_dict(request)
263
+ transcoded_request = path_template.transcode(http_options, **request_kwargs)
264
+
265
+ uri = transcoded_request["uri"]
266
+ method = transcoded_request["method"]
267
+
268
+ # Jsonify the query params
269
+ query_params_request = operations_pb2.GetOperationRequest()
270
+ json_format.ParseDict(transcoded_request["query_params"], query_params_request)
271
+ query_params = json_format.MessageToDict(
272
+ query_params_request,
273
+ preserving_proto_field_name=False,
274
+ use_integers_for_enums=False,
275
+ )
276
+
277
+ # Send the request
278
+ headers = dict(metadata)
279
+ headers["Content-Type"] = "application/json"
280
+ # TODO(https://github.com/googleapis/python-api-core/issues/721): Update incorrect use of `uri`` variable name.
281
+ response = getattr(self._session, method)(
282
+ "{host}{uri}".format(host=self._host, uri=uri),
283
+ timeout=timeout,
284
+ headers=headers,
285
+ params=rest_helpers.flatten_query_params(query_params),
286
+ )
287
+
288
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
289
+ # subclass.
290
+ if response.status_code >= 400:
291
+ raise core_exceptions.from_http_response(response)
292
+
293
+ # Return the response
294
+ api_response = operations_pb2.Operation()
295
+ json_format.Parse(response.content, api_response, ignore_unknown_fields=False)
296
+ return api_response
297
+
298
+ def _delete_operation(
299
+ self,
300
+ request: operations_pb2.DeleteOperationRequest,
301
+ *,
302
+ # TODO(https://github.com/googleapis/python-api-core/issues/723): Leverage `retry`
303
+ # to allow configuring retryable error codes.
304
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
305
+ timeout: Optional[float] = None,
306
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
307
+ metadata: Sequence[Tuple[str, str]] = (),
308
+ ) -> empty_pb2.Empty:
309
+ r"""Call the delete operation method over HTTP.
310
+
311
+ Args:
312
+ request (~.operations_pb2.DeleteOperationRequest):
313
+ The request object. The request message for
314
+ [Operations.DeleteOperation][google.api_core.operations_v1.Operations.DeleteOperation].
315
+
316
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
317
+ should be retried.
318
+ timeout (float): The timeout for this request.
319
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
320
+ sent along with the request as metadata.
321
+ """
322
+
323
+ http_options = [
324
+ {
325
+ "method": "delete",
326
+ "uri": "/{}/{{name=**/operations/*}}".format(self._path_prefix),
327
+ },
328
+ ]
329
+ if "google.longrunning.Operations.DeleteOperation" in self._http_options:
330
+ http_options = self._http_options[
331
+ "google.longrunning.Operations.DeleteOperation"
332
+ ]
333
+
334
+ request_kwargs = self._convert_protobuf_message_to_dict(request)
335
+ transcoded_request = path_template.transcode(http_options, **request_kwargs)
336
+
337
+ uri = transcoded_request["uri"]
338
+ method = transcoded_request["method"]
339
+
340
+ # Jsonify the query params
341
+ query_params_request = operations_pb2.DeleteOperationRequest()
342
+ json_format.ParseDict(transcoded_request["query_params"], query_params_request)
343
+ query_params = json_format.MessageToDict(
344
+ query_params_request,
345
+ preserving_proto_field_name=False,
346
+ use_integers_for_enums=False,
347
+ )
348
+
349
+ # Send the request
350
+ headers = dict(metadata)
351
+ headers["Content-Type"] = "application/json"
352
+ # TODO(https://github.com/googleapis/python-api-core/issues/721): Update incorrect use of `uri`` variable name.
353
+ response = getattr(self._session, method)(
354
+ "{host}{uri}".format(host=self._host, uri=uri),
355
+ timeout=timeout,
356
+ headers=headers,
357
+ params=rest_helpers.flatten_query_params(query_params),
358
+ )
359
+
360
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
361
+ # subclass.
362
+ if response.status_code >= 400:
363
+ raise core_exceptions.from_http_response(response)
364
+
365
+ return empty_pb2.Empty()
366
+
367
+ def _cancel_operation(
368
+ self,
369
+ request: operations_pb2.CancelOperationRequest,
370
+ *,
371
+ # TODO(https://github.com/googleapis/python-api-core/issues/723): Leverage `retry`
372
+ # to allow configuring retryable error codes.
373
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
374
+ timeout: Optional[float] = None,
375
+ compression: Optional[grpc.Compression] = gapic_v1.method.DEFAULT,
376
+ metadata: Sequence[Tuple[str, str]] = (),
377
+ ) -> empty_pb2.Empty:
378
+ r"""Call the cancel operation method over HTTP.
379
+
380
+ Args:
381
+ request (~.operations_pb2.CancelOperationRequest):
382
+ The request object. The request message for
383
+ [Operations.CancelOperation][google.api_core.operations_v1.Operations.CancelOperation].
384
+
385
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
386
+ should be retried.
387
+ timeout (float): The timeout for this request.
388
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
389
+ sent along with the request as metadata.
390
+ """
391
+
392
+ http_options = [
393
+ {
394
+ "method": "post",
395
+ "uri": "/{}/{{name=**/operations/*}}:cancel".format(self._path_prefix),
396
+ "body": "*",
397
+ },
398
+ ]
399
+ if "google.longrunning.Operations.CancelOperation" in self._http_options:
400
+ http_options = self._http_options[
401
+ "google.longrunning.Operations.CancelOperation"
402
+ ]
403
+
404
+ request_kwargs = self._convert_protobuf_message_to_dict(request)
405
+ transcoded_request = path_template.transcode(http_options, **request_kwargs)
406
+
407
+ # Jsonify the request body
408
+ body_request = operations_pb2.CancelOperationRequest()
409
+ json_format.ParseDict(transcoded_request["body"], body_request)
410
+ body = json_format.MessageToDict(
411
+ body_request,
412
+ preserving_proto_field_name=False,
413
+ use_integers_for_enums=False,
414
+ )
415
+ uri = transcoded_request["uri"]
416
+ method = transcoded_request["method"]
417
+
418
+ # Jsonify the query params
419
+ query_params_request = operations_pb2.CancelOperationRequest()
420
+ json_format.ParseDict(transcoded_request["query_params"], query_params_request)
421
+ query_params = json_format.MessageToDict(
422
+ query_params_request,
423
+ preserving_proto_field_name=False,
424
+ use_integers_for_enums=False,
425
+ )
426
+
427
+ # Send the request
428
+ headers = dict(metadata)
429
+ headers["Content-Type"] = "application/json"
430
+ # TODO(https://github.com/googleapis/python-api-core/issues/721): Update incorrect use of `uri`` variable name.
431
+ response = getattr(self._session, method)(
432
+ "{host}{uri}".format(host=self._host, uri=uri),
433
+ timeout=timeout,
434
+ headers=headers,
435
+ params=rest_helpers.flatten_query_params(query_params),
436
+ data=body,
437
+ )
438
+
439
+ # In case of error, raise the appropriate core_exceptions.GoogleAPICallError exception
440
+ # subclass.
441
+ if response.status_code >= 400:
442
+ raise core_exceptions.from_http_response(response)
443
+
444
+ return empty_pb2.Empty()
445
+
446
+ @property
447
+ def list_operations(
448
+ self,
449
+ ) -> Callable[
450
+ [operations_pb2.ListOperationsRequest], operations_pb2.ListOperationsResponse
451
+ ]:
452
+ return self._list_operations
453
+
454
+ @property
455
+ def get_operation(
456
+ self,
457
+ ) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
458
+ return self._get_operation
459
+
460
+ @property
461
+ def delete_operation(
462
+ self,
463
+ ) -> Callable[[operations_pb2.DeleteOperationRequest], empty_pb2.Empty]:
464
+ return self._delete_operation
465
+
466
+ @property
467
+ def cancel_operation(
468
+ self,
469
+ ) -> Callable[[operations_pb2.CancelOperationRequest], empty_pb2.Empty]:
470
+ return self._cancel_operation
471
+
472
+
473
+ __all__ = ("OperationsRestTransport",)
evalkit_tf437/lib/python3.10/site-packages/google/oauth2/__init__.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2016 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
+ """Google OAuth 2.0 Library for Python."""
16
+
17
+ import sys
18
+ import warnings
19
+
20
+
21
+ class Python37DeprecationWarning(DeprecationWarning): # pragma: NO COVER
22
+ """
23
+ Deprecation warning raised when Python 3.7 runtime is detected.
24
+ Python 3.7 support will be dropped after January 1, 2024.
25
+ """
26
+
27
+ pass
28
+
29
+
30
+ # Checks if the current runtime is Python 3.7.
31
+ if sys.version_info.major == 3 and sys.version_info.minor == 7: # pragma: NO COVER
32
+ message = (
33
+ "After January 1, 2024, new releases of this library will drop support "
34
+ "for Python 3.7."
35
+ )
36
+ warnings.warn(message, Python37DeprecationWarning)
evalkit_tf437/lib/python3.10/site-packages/google/oauth2/_service_account_async.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 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
+ """Service Accounts: JSON Web Token (JWT) Profile for OAuth 2.0
16
+
17
+ NOTE: This file adds asynchronous refresh methods to both credentials
18
+ classes, and therefore async/await syntax is required when calling this
19
+ method when using service account credentials with asynchronous functionality.
20
+ Otherwise, all other methods are inherited from the regular service account
21
+ credentials file google.oauth2.service_account
22
+
23
+ """
24
+
25
+ from google.auth import _credentials_async as credentials_async
26
+ from google.auth import _helpers
27
+ from google.oauth2 import _client_async
28
+ from google.oauth2 import service_account
29
+
30
+
31
+ class Credentials(
32
+ service_account.Credentials, credentials_async.Scoped, credentials_async.Credentials
33
+ ):
34
+ """Service account credentials
35
+
36
+ Usually, you'll create these credentials with one of the helper
37
+ constructors. To create credentials using a Google service account
38
+ private key JSON file::
39
+
40
+ credentials = _service_account_async.Credentials.from_service_account_file(
41
+ 'service-account.json')
42
+
43
+ Or if you already have the service account file loaded::
44
+
45
+ service_account_info = json.load(open('service_account.json'))
46
+ credentials = _service_account_async.Credentials.from_service_account_info(
47
+ service_account_info)
48
+
49
+ Both helper methods pass on arguments to the constructor, so you can
50
+ specify additional scopes and a subject if necessary::
51
+
52
+ credentials = _service_account_async.Credentials.from_service_account_file(
53
+ 'service-account.json',
54
+ scopes=['email'],
55
+ subject='user@example.com')
56
+
57
+ The credentials are considered immutable. If you want to modify the scopes
58
+ or the subject used for delegation, use :meth:`with_scopes` or
59
+ :meth:`with_subject`::
60
+
61
+ scoped_credentials = credentials.with_scopes(['email'])
62
+ delegated_credentials = credentials.with_subject(subject)
63
+
64
+ To add a quota project, use :meth:`with_quota_project`::
65
+
66
+ credentials = credentials.with_quota_project('myproject-123')
67
+ """
68
+
69
+ @_helpers.copy_docstring(credentials_async.Credentials)
70
+ async def refresh(self, request):
71
+ assertion = self._make_authorization_grant_assertion()
72
+ access_token, expiry, _ = await _client_async.jwt_grant(
73
+ request, self._token_uri, assertion
74
+ )
75
+ self.token = access_token
76
+ self.expiry = expiry
77
+
78
+
79
+ class IDTokenCredentials(
80
+ service_account.IDTokenCredentials,
81
+ credentials_async.Signing,
82
+ credentials_async.Credentials,
83
+ ):
84
+ """Open ID Connect ID Token-based service account credentials.
85
+
86
+ These credentials are largely similar to :class:`.Credentials`, but instead
87
+ of using an OAuth 2.0 Access Token as the bearer token, they use an Open
88
+ ID Connect ID Token as the bearer token. These credentials are useful when
89
+ communicating to services that require ID Tokens and can not accept access
90
+ tokens.
91
+
92
+ Usually, you'll create these credentials with one of the helper
93
+ constructors. To create credentials using a Google service account
94
+ private key JSON file::
95
+
96
+ credentials = (
97
+ _service_account_async.IDTokenCredentials.from_service_account_file(
98
+ 'service-account.json'))
99
+
100
+ Or if you already have the service account file loaded::
101
+
102
+ service_account_info = json.load(open('service_account.json'))
103
+ credentials = (
104
+ _service_account_async.IDTokenCredentials.from_service_account_info(
105
+ service_account_info))
106
+
107
+ Both helper methods pass on arguments to the constructor, so you can
108
+ specify additional scopes and a subject if necessary::
109
+
110
+ credentials = (
111
+ _service_account_async.IDTokenCredentials.from_service_account_file(
112
+ 'service-account.json',
113
+ scopes=['email'],
114
+ subject='user@example.com'))
115
+
116
+ The credentials are considered immutable. If you want to modify the scopes
117
+ or the subject used for delegation, use :meth:`with_scopes` or
118
+ :meth:`with_subject`::
119
+
120
+ scoped_credentials = credentials.with_scopes(['email'])
121
+ delegated_credentials = credentials.with_subject(subject)
122
+
123
+ """
124
+
125
+ @_helpers.copy_docstring(credentials_async.Credentials)
126
+ async def refresh(self, request):
127
+ assertion = self._make_authorization_grant_assertion()
128
+ access_token, expiry, _ = await _client_async.id_token_jwt_grant(
129
+ request, self._token_uri, assertion
130
+ )
131
+ self.token = access_token
132
+ self.expiry = expiry
evalkit_tf437/lib/python3.10/site-packages/google/oauth2/gdch_credentials.py ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2022 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
+ """Experimental GDCH credentials support.
16
+ """
17
+
18
+ import datetime
19
+
20
+ from google.auth import _helpers
21
+ from google.auth import _service_account_info
22
+ from google.auth import credentials
23
+ from google.auth import exceptions
24
+ from google.auth import jwt
25
+ from google.oauth2 import _client
26
+
27
+
28
+ TOKEN_EXCHANGE_TYPE = "urn:ietf:params:oauth:token-type:token-exchange"
29
+ ACCESS_TOKEN_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:access_token"
30
+ SERVICE_ACCOUNT_TOKEN_TYPE = "urn:k8s:params:oauth:token-type:serviceaccount"
31
+ JWT_LIFETIME = datetime.timedelta(seconds=3600) # 1 hour
32
+
33
+
34
+ class ServiceAccountCredentials(credentials.Credentials):
35
+ """Credentials for GDCH (`Google Distributed Cloud Hosted`_) for service
36
+ account users.
37
+
38
+ .. _Google Distributed Cloud Hosted:
39
+ https://cloud.google.com/blog/topics/hybrid-cloud/\
40
+ announcing-google-distributed-cloud-edge-and-hosted
41
+
42
+ To create a GDCH service account credential, first create a JSON file of
43
+ the following format::
44
+
45
+ {
46
+ "type": "gdch_service_account",
47
+ "format_version": "1",
48
+ "project": "<project name>",
49
+ "private_key_id": "<key id>",
50
+ "private_key": "-----BEGIN EC PRIVATE KEY-----\n<key bytes>\n-----END EC PRIVATE KEY-----\n",
51
+ "name": "<service identity name>",
52
+ "ca_cert_path": "<CA cert path>",
53
+ "token_uri": "https://service-identity.<Domain>/authenticate"
54
+ }
55
+
56
+ The "format_version" field stands for the format of the JSON file. For now
57
+ it is always "1". The `private_key_id` and `private_key` is used for signing.
58
+ The `ca_cert_path` is used for token server TLS certificate verification.
59
+
60
+ After the JSON file is created, set `GOOGLE_APPLICATION_CREDENTIALS` environment
61
+ variable to the JSON file path, then use the following code to create the
62
+ credential::
63
+
64
+ import google.auth
65
+
66
+ credential, _ = google.auth.default()
67
+ credential = credential.with_gdch_audience("<the audience>")
68
+
69
+ We can also create the credential directly::
70
+
71
+ from google.oauth import gdch_credentials
72
+
73
+ credential = gdch_credentials.ServiceAccountCredentials.from_service_account_file("<the json file path>")
74
+ credential = credential.with_gdch_audience("<the audience>")
75
+
76
+ The token is obtained in the following way. This class first creates a
77
+ self signed JWT. It uses the `name` value as the `iss` and `sub` claim, and
78
+ the `token_uri` as the `aud` claim, and signs the JWT with the `private_key`.
79
+ It then sends the JWT to the `token_uri` to exchange a final token for
80
+ `audience`.
81
+ """
82
+
83
+ def __init__(
84
+ self, signer, service_identity_name, project, audience, token_uri, ca_cert_path
85
+ ):
86
+ """
87
+ Args:
88
+ signer (google.auth.crypt.Signer): The signer used to sign JWTs.
89
+ service_identity_name (str): The service identity name. It will be
90
+ used as the `iss` and `sub` claim in the self signed JWT.
91
+ project (str): The project.
92
+ audience (str): The audience for the final token.
93
+ token_uri (str): The token server uri.
94
+ ca_cert_path (str): The CA cert path for token server side TLS
95
+ certificate verification. If the token server uses well known
96
+ CA, then this parameter can be `None`.
97
+ """
98
+ super(ServiceAccountCredentials, self).__init__()
99
+ self._signer = signer
100
+ self._service_identity_name = service_identity_name
101
+ self._project = project
102
+ self._audience = audience
103
+ self._token_uri = token_uri
104
+ self._ca_cert_path = ca_cert_path
105
+
106
+ def _create_jwt(self):
107
+ now = _helpers.utcnow()
108
+ expiry = now + JWT_LIFETIME
109
+ iss_sub_value = "system:serviceaccount:{}:{}".format(
110
+ self._project, self._service_identity_name
111
+ )
112
+
113
+ payload = {
114
+ "iss": iss_sub_value,
115
+ "sub": iss_sub_value,
116
+ "aud": self._token_uri,
117
+ "iat": _helpers.datetime_to_secs(now),
118
+ "exp": _helpers.datetime_to_secs(expiry),
119
+ }
120
+
121
+ return _helpers.from_bytes(jwt.encode(self._signer, payload))
122
+
123
+ @_helpers.copy_docstring(credentials.Credentials)
124
+ def refresh(self, request):
125
+ import google.auth.transport.requests
126
+
127
+ if not isinstance(request, google.auth.transport.requests.Request):
128
+ raise exceptions.RefreshError(
129
+ "For GDCH service account credentials, request must be a google.auth.transport.requests.Request object"
130
+ )
131
+
132
+ # Create a self signed JWT, and do token exchange.
133
+ jwt_token = self._create_jwt()
134
+ request_body = {
135
+ "grant_type": TOKEN_EXCHANGE_TYPE,
136
+ "audience": self._audience,
137
+ "requested_token_type": ACCESS_TOKEN_TOKEN_TYPE,
138
+ "subject_token": jwt_token,
139
+ "subject_token_type": SERVICE_ACCOUNT_TOKEN_TYPE,
140
+ }
141
+ response_data = _client._token_endpoint_request(
142
+ request,
143
+ self._token_uri,
144
+ request_body,
145
+ access_token=None,
146
+ use_json=True,
147
+ verify=self._ca_cert_path,
148
+ )
149
+
150
+ self.token, _, self.expiry, _ = _client._handle_refresh_grant_response(
151
+ response_data, None
152
+ )
153
+
154
+ def with_gdch_audience(self, audience):
155
+ """Create a copy of GDCH credentials with the specified audience.
156
+
157
+ Args:
158
+ audience (str): The intended audience for GDCH credentials.
159
+ """
160
+ return self.__class__(
161
+ self._signer,
162
+ self._service_identity_name,
163
+ self._project,
164
+ audience,
165
+ self._token_uri,
166
+ self._ca_cert_path,
167
+ )
168
+
169
+ @classmethod
170
+ def _from_signer_and_info(cls, signer, info):
171
+ """Creates a Credentials instance from a signer and service account
172
+ info.
173
+
174
+ Args:
175
+ signer (google.auth.crypt.Signer): The signer used to sign JWTs.
176
+ info (Mapping[str, str]): The service account info.
177
+
178
+ Returns:
179
+ google.oauth2.gdch_credentials.ServiceAccountCredentials: The constructed
180
+ credentials.
181
+
182
+ Raises:
183
+ ValueError: If the info is not in the expected format.
184
+ """
185
+ if info["format_version"] != "1":
186
+ raise ValueError("Only format version 1 is supported")
187
+
188
+ return cls(
189
+ signer,
190
+ info["name"], # service_identity_name
191
+ info["project"],
192
+ None, # audience
193
+ info["token_uri"],
194
+ info.get("ca_cert_path", None),
195
+ )
196
+
197
+ @classmethod
198
+ def from_service_account_info(cls, info):
199
+ """Creates a Credentials instance from parsed service account info.
200
+
201
+ Args:
202
+ info (Mapping[str, str]): The service account info in Google
203
+ format.
204
+ kwargs: Additional arguments to pass to the constructor.
205
+
206
+ Returns:
207
+ google.oauth2.gdch_credentials.ServiceAccountCredentials: The constructed
208
+ credentials.
209
+
210
+ Raises:
211
+ ValueError: If the info is not in the expected format.
212
+ """
213
+ signer = _service_account_info.from_dict(
214
+ info,
215
+ require=[
216
+ "format_version",
217
+ "private_key_id",
218
+ "private_key",
219
+ "name",
220
+ "project",
221
+ "token_uri",
222
+ ],
223
+ use_rsa_signer=False,
224
+ )
225
+ return cls._from_signer_and_info(signer, info)
226
+
227
+ @classmethod
228
+ def from_service_account_file(cls, filename):
229
+ """Creates a Credentials instance from a service account json file.
230
+
231
+ Args:
232
+ filename (str): The path to the service account json file.
233
+ kwargs: Additional arguments to pass to the constructor.
234
+
235
+ Returns:
236
+ google.oauth2.gdch_credentials.ServiceAccountCredentials: The constructed
237
+ credentials.
238
+ """
239
+ info, signer = _service_account_info.from_filename(
240
+ filename,
241
+ require=[
242
+ "format_version",
243
+ "private_key_id",
244
+ "private_key",
245
+ "name",
246
+ "project",
247
+ "token_uri",
248
+ ],
249
+ use_rsa_signer=False,
250
+ )
251
+ return cls._from_signer_and_info(signer, info)
evalkit_tf437/lib/python3.10/site-packages/google/oauth2/sts.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 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
+ """OAuth 2.0 Token Exchange Spec.
16
+
17
+ This module defines a token exchange utility based on the `OAuth 2.0 Token
18
+ Exchange`_ spec. This will be mainly used to exchange external credentials
19
+ for GCP access tokens in workload identity pools to access Google APIs.
20
+
21
+ The implementation will support various types of client authentication as
22
+ allowed in the spec.
23
+
24
+ A deviation on the spec will be for additional Google specific options that
25
+ cannot be easily mapped to parameters defined in the RFC.
26
+
27
+ The returned dictionary response will be based on the `rfc8693 section 2.2.1`_
28
+ spec JSON response.
29
+
30
+ .. _OAuth 2.0 Token Exchange: https://tools.ietf.org/html/rfc8693
31
+ .. _rfc8693 section 2.2.1: https://tools.ietf.org/html/rfc8693#section-2.2.1
32
+ """
33
+
34
+ import http.client as http_client
35
+ import json
36
+ import urllib
37
+
38
+ from google.oauth2 import utils
39
+
40
+
41
+ _URLENCODED_HEADERS = {"Content-Type": "application/x-www-form-urlencoded"}
42
+
43
+
44
+ class Client(utils.OAuthClientAuthHandler):
45
+ """Implements the OAuth 2.0 token exchange spec based on
46
+ https://tools.ietf.org/html/rfc8693.
47
+ """
48
+
49
+ def __init__(self, token_exchange_endpoint, client_authentication=None):
50
+ """Initializes an STS client instance.
51
+
52
+ Args:
53
+ token_exchange_endpoint (str): The token exchange endpoint.
54
+ client_authentication (Optional(google.oauth2.oauth2_utils.ClientAuthentication)):
55
+ The optional OAuth client authentication credentials if available.
56
+ """
57
+ super(Client, self).__init__(client_authentication)
58
+ self._token_exchange_endpoint = token_exchange_endpoint
59
+
60
+ def _make_request(self, request, headers, request_body):
61
+ # Initialize request headers.
62
+ request_headers = _URLENCODED_HEADERS.copy()
63
+
64
+ # Inject additional headers.
65
+ if headers:
66
+ for k, v in dict(headers).items():
67
+ request_headers[k] = v
68
+
69
+ # Apply OAuth client authentication.
70
+ self.apply_client_authentication_options(request_headers, request_body)
71
+
72
+ # Execute request.
73
+ response = request(
74
+ url=self._token_exchange_endpoint,
75
+ method="POST",
76
+ headers=request_headers,
77
+ body=urllib.parse.urlencode(request_body).encode("utf-8"),
78
+ )
79
+
80
+ response_body = (
81
+ response.data.decode("utf-8")
82
+ if hasattr(response.data, "decode")
83
+ else response.data
84
+ )
85
+
86
+ # If non-200 response received, translate to OAuthError exception.
87
+ if response.status != http_client.OK:
88
+ utils.handle_error_response(response_body)
89
+
90
+ response_data = json.loads(response_body)
91
+
92
+ # Return successful response.
93
+ return response_data
94
+
95
+ def exchange_token(
96
+ self,
97
+ request,
98
+ grant_type,
99
+ subject_token,
100
+ subject_token_type,
101
+ resource=None,
102
+ audience=None,
103
+ scopes=None,
104
+ requested_token_type=None,
105
+ actor_token=None,
106
+ actor_token_type=None,
107
+ additional_options=None,
108
+ additional_headers=None,
109
+ ):
110
+ """Exchanges the provided token for another type of token based on the
111
+ rfc8693 spec.
112
+
113
+ Args:
114
+ request (google.auth.transport.Request): A callable used to make
115
+ HTTP requests.
116
+ grant_type (str): The OAuth 2.0 token exchange grant type.
117
+ subject_token (str): The OAuth 2.0 token exchange subject token.
118
+ subject_token_type (str): The OAuth 2.0 token exchange subject token type.
119
+ resource (Optional[str]): The optional OAuth 2.0 token exchange resource field.
120
+ audience (Optional[str]): The optional OAuth 2.0 token exchange audience field.
121
+ scopes (Optional[Sequence[str]]): The optional list of scopes to use.
122
+ requested_token_type (Optional[str]): The optional OAuth 2.0 token exchange requested
123
+ token type.
124
+ actor_token (Optional[str]): The optional OAuth 2.0 token exchange actor token.
125
+ actor_token_type (Optional[str]): The optional OAuth 2.0 token exchange actor token type.
126
+ additional_options (Optional[Mapping[str, str]]): The optional additional
127
+ non-standard Google specific options.
128
+ additional_headers (Optional[Mapping[str, str]]): The optional additional
129
+ headers to pass to the token exchange endpoint.
130
+
131
+ Returns:
132
+ Mapping[str, str]: The token exchange JSON-decoded response data containing
133
+ the requested token and its expiration time.
134
+
135
+ Raises:
136
+ google.auth.exceptions.OAuthError: If the token endpoint returned
137
+ an error.
138
+ """
139
+ # Initialize request body.
140
+ request_body = {
141
+ "grant_type": grant_type,
142
+ "resource": resource,
143
+ "audience": audience,
144
+ "scope": " ".join(scopes or []),
145
+ "requested_token_type": requested_token_type,
146
+ "subject_token": subject_token,
147
+ "subject_token_type": subject_token_type,
148
+ "actor_token": actor_token,
149
+ "actor_token_type": actor_token_type,
150
+ "options": None,
151
+ }
152
+ # Add additional non-standard options.
153
+ if additional_options:
154
+ request_body["options"] = urllib.parse.quote(json.dumps(additional_options))
155
+ # Remove empty fields in request body.
156
+ for k, v in dict(request_body).items():
157
+ if v is None or v == "":
158
+ del request_body[k]
159
+
160
+ return self._make_request(request, additional_headers, request_body)
161
+
162
+ def refresh_token(self, request, refresh_token):
163
+ """Exchanges a refresh token for an access token based on the
164
+ RFC6749 spec.
165
+
166
+ Args:
167
+ request (google.auth.transport.Request): A callable used to make
168
+ HTTP requests.
169
+ subject_token (str): The OAuth 2.0 refresh token.
170
+ """
171
+
172
+ return self._make_request(
173
+ request,
174
+ None,
175
+ {"grant_type": "refresh_token", "refresh_token": refresh_token},
176
+ )
evalkit_tf437/lib/python3.10/site-packages/google/oauth2/webauthn_types.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dataclasses import dataclass
2
+ import json
3
+ from typing import Any, Dict, List, Optional
4
+
5
+ from google.auth import exceptions
6
+
7
+
8
+ @dataclass(frozen=True)
9
+ class PublicKeyCredentialDescriptor:
10
+ """Descriptor for a security key based credential.
11
+
12
+ https://www.w3.org/TR/webauthn-3/#dictionary-credential-descriptor
13
+
14
+ Args:
15
+ id: <url-safe base64-encoded> credential id (key handle).
16
+ transports: <'usb'|'nfc'|'ble'|'internal'> List of supported transports.
17
+ """
18
+
19
+ id: str
20
+ transports: Optional[List[str]] = None
21
+
22
+ def to_dict(self):
23
+ cred = {"type": "public-key", "id": self.id}
24
+ if self.transports:
25
+ cred["transports"] = self.transports
26
+ return cred
27
+
28
+
29
+ @dataclass
30
+ class AuthenticationExtensionsClientInputs:
31
+ """Client extensions inputs for WebAuthn extensions.
32
+
33
+ Args:
34
+ appid: app id that can be asserted with in addition to rpid.
35
+ https://www.w3.org/TR/webauthn-3/#sctn-appid-extension
36
+ """
37
+
38
+ appid: Optional[str] = None
39
+
40
+ def to_dict(self):
41
+ extensions = {}
42
+ if self.appid:
43
+ extensions["appid"] = self.appid
44
+ return extensions
45
+
46
+
47
+ @dataclass
48
+ class GetRequest:
49
+ """WebAuthn get request
50
+
51
+ Args:
52
+ origin: Origin where the WebAuthn get assertion takes place.
53
+ rpid: Relying Party ID.
54
+ challenge: <url-safe base64-encoded> raw challenge.
55
+ timeout_ms: Timeout number in millisecond.
56
+ allow_credentials: List of allowed credentials.
57
+ user_verification: <'required'|'preferred'|'discouraged'> User verification requirement.
58
+ extensions: WebAuthn authentication extensions inputs.
59
+ """
60
+
61
+ origin: str
62
+ rpid: str
63
+ challenge: str
64
+ timeout_ms: Optional[int] = None
65
+ allow_credentials: Optional[List[PublicKeyCredentialDescriptor]] = None
66
+ user_verification: Optional[str] = None
67
+ extensions: Optional[AuthenticationExtensionsClientInputs] = None
68
+
69
+ def to_json(self) -> str:
70
+ req_options: Dict[str, Any] = {"rpid": self.rpid, "challenge": self.challenge}
71
+ if self.timeout_ms:
72
+ req_options["timeout"] = self.timeout_ms
73
+ if self.allow_credentials:
74
+ req_options["allowCredentials"] = [
75
+ c.to_dict() for c in self.allow_credentials
76
+ ]
77
+ if self.user_verification:
78
+ req_options["userVerification"] = self.user_verification
79
+ if self.extensions:
80
+ req_options["extensions"] = self.extensions.to_dict()
81
+ return json.dumps(
82
+ {"type": "get", "origin": self.origin, "requestData": req_options}
83
+ )
84
+
85
+
86
+ @dataclass(frozen=True)
87
+ class AuthenticatorAssertionResponse:
88
+ """Authenticator response to a WebAuthn get (assertion) request.
89
+
90
+ https://www.w3.org/TR/webauthn-3/#authenticatorassertionresponse
91
+
92
+ Args:
93
+ client_data_json: <url-safe base64-encoded> client data JSON.
94
+ authenticator_data: <url-safe base64-encoded> authenticator data.
95
+ signature: <url-safe base64-encoded> signature.
96
+ user_handle: <url-safe base64-encoded> user handle.
97
+ """
98
+
99
+ client_data_json: str
100
+ authenticator_data: str
101
+ signature: str
102
+ user_handle: Optional[str]
103
+
104
+
105
+ @dataclass(frozen=True)
106
+ class GetResponse:
107
+ """WebAuthn get (assertion) response.
108
+
109
+ Args:
110
+ id: <url-safe base64-encoded> credential id (key handle).
111
+ response: The authenticator assertion response.
112
+ authenticator_attachment: <'cross-platform'|'platform'> The attachment status of the authenticator.
113
+ client_extension_results: WebAuthn authentication extensions output results in a dictionary.
114
+ """
115
+
116
+ id: str
117
+ response: AuthenticatorAssertionResponse
118
+ authenticator_attachment: Optional[str]
119
+ client_extension_results: Optional[Dict]
120
+
121
+ @staticmethod
122
+ def from_json(json_str: str):
123
+ """Verify and construct GetResponse from a JSON string."""
124
+ try:
125
+ resp_json = json.loads(json_str)
126
+ except ValueError:
127
+ raise exceptions.MalformedError("Invalid Get JSON response")
128
+ if resp_json.get("type") != "getResponse":
129
+ raise exceptions.MalformedError(
130
+ "Invalid Get response type: {}".format(resp_json.get("type"))
131
+ )
132
+ pk_cred = resp_json.get("responseData")
133
+ if pk_cred is None:
134
+ if resp_json.get("error"):
135
+ raise exceptions.ReauthFailError(
136
+ "WebAuthn.get failure: {}".format(resp_json["error"])
137
+ )
138
+ else:
139
+ raise exceptions.MalformedError("Get response is empty")
140
+ if pk_cred.get("type") != "public-key":
141
+ raise exceptions.MalformedError(
142
+ "Invalid credential type: {}".format(pk_cred.get("type"))
143
+ )
144
+ assertion_json = pk_cred["response"]
145
+ assertion_resp = AuthenticatorAssertionResponse(
146
+ client_data_json=assertion_json["clientDataJSON"],
147
+ authenticator_data=assertion_json["authenticatorData"],
148
+ signature=assertion_json["signature"],
149
+ user_handle=assertion_json.get("userHandle"),
150
+ )
151
+ return GetResponse(
152
+ id=pk_cred["id"],
153
+ response=assertion_resp,
154
+ authenticator_attachment=pk_cred.get("authenticatorAttachment"),
155
+ client_extension_results=pk_cred.get("clientExtensionResults"),
156
+ )
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__init__.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google Inc.
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
+ """Utilities for Google Media Downloads and Resumable Uploads.
16
+
17
+ This package has some general purposes modules, e.g.
18
+ :mod:`~google.resumable_media.common`, but the majority of the
19
+ public interface will be contained in subpackages.
20
+
21
+ ===========
22
+ Subpackages
23
+ ===========
24
+
25
+ Each subpackage is tailored to a specific transport library:
26
+
27
+ * the :mod:`~google.resumable_media.requests` subpackage uses the ``requests``
28
+ transport library.
29
+
30
+ .. _requests: http://docs.python-requests.org/
31
+
32
+ ==========
33
+ Installing
34
+ ==========
35
+
36
+ To install with `pip`_:
37
+
38
+ .. code-block:: console
39
+
40
+ $ pip install --upgrade google-resumable-media
41
+
42
+ .. _pip: https://pip.pypa.io/
43
+ """
44
+
45
+
46
+ from google.resumable_media.common import DataCorruption
47
+ from google.resumable_media.common import InvalidResponse
48
+ from google.resumable_media.common import PERMANENT_REDIRECT
49
+ from google.resumable_media.common import RetryStrategy
50
+ from google.resumable_media.common import TOO_MANY_REQUESTS
51
+ from google.resumable_media.common import UPLOAD_CHUNK_SIZE
52
+
53
+
54
+ __all__ = [
55
+ "DataCorruption",
56
+ "InvalidResponse",
57
+ "PERMANENT_REDIRECT",
58
+ "RetryStrategy",
59
+ "TOO_MANY_REQUESTS",
60
+ "UPLOAD_CHUNK_SIZE",
61
+ ]
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.16 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/_helpers.cpython-310.pyc ADDED
Binary file (12.9 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/_upload.cpython-310.pyc ADDED
Binary file (52.7 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/__pycache__/common.cpython-310.pyc ADDED
Binary file (4.52 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/common.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google Inc.
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
+ """Common utilities for Google Media Downloads and Resumable Uploads.
16
+
17
+ Includes custom exception types, useful constants and shared helpers.
18
+ """
19
+
20
+ import http.client
21
+
22
+ _SLEEP_RETRY_ERROR_MSG = (
23
+ "At most one of `max_cumulative_retry` and `max_retries` " "can be specified."
24
+ )
25
+
26
+ UPLOAD_CHUNK_SIZE = 262144 # 256 * 1024
27
+ """int: Chunks in a resumable upload must come in multiples of 256 KB."""
28
+
29
+ PERMANENT_REDIRECT = http.client.PERMANENT_REDIRECT # type: ignore
30
+ """int: Permanent redirect status code.
31
+
32
+ .. note::
33
+ This is a backward-compatibility alias.
34
+
35
+ It is used by Google services to indicate some (but not all) of
36
+ a resumable upload has been completed.
37
+
38
+ For more information, see `RFC 7238`_.
39
+
40
+ .. _RFC 7238: https://tools.ietf.org/html/rfc7238
41
+ """
42
+
43
+ TOO_MANY_REQUESTS = http.client.TOO_MANY_REQUESTS
44
+ """int: Status code indicating rate-limiting.
45
+
46
+ .. note::
47
+ This is a backward-compatibility alias.
48
+
49
+ For more information, see `RFC 6585`_.
50
+
51
+ .. _RFC 6585: https://tools.ietf.org/html/rfc6585#section-4
52
+ """
53
+
54
+ MAX_SLEEP = 64.0
55
+ """float: Maximum amount of time allowed between requests.
56
+
57
+ Used during the retry process for sleep after a failed request.
58
+ Chosen since it is the power of two nearest to one minute.
59
+ """
60
+
61
+ MAX_CUMULATIVE_RETRY = 600.0
62
+ """float: Maximum total sleep time allowed during retry process.
63
+
64
+ This is provided (10 minutes) as a default. When the cumulative sleep
65
+ exceeds this limit, no more retries will occur.
66
+ """
67
+
68
+ RETRYABLE = (
69
+ http.client.TOO_MANY_REQUESTS, # 429
70
+ http.client.REQUEST_TIMEOUT, # 408
71
+ http.client.INTERNAL_SERVER_ERROR, # 500
72
+ http.client.BAD_GATEWAY, # 502
73
+ http.client.SERVICE_UNAVAILABLE, # 503
74
+ http.client.GATEWAY_TIMEOUT, # 504
75
+ )
76
+ """iterable: HTTP status codes that indicate a retryable error.
77
+
78
+ Connection errors are also retried, but are not listed as they are
79
+ exceptions, not status codes.
80
+ """
81
+
82
+
83
+ class InvalidResponse(Exception):
84
+ """Error class for responses which are not in the correct state.
85
+
86
+ Args:
87
+ response (object): The HTTP response which caused the failure.
88
+ args (tuple): The positional arguments typically passed to an
89
+ exception class.
90
+ """
91
+
92
+ def __init__(self, response, *args):
93
+ super(InvalidResponse, self).__init__(*args)
94
+ self.response = response
95
+ """object: The HTTP response object that caused the failure."""
96
+
97
+
98
+ class DataCorruption(Exception):
99
+ """Error class for corrupt media transfers.
100
+
101
+ Args:
102
+ response (object): The HTTP response which caused the failure.
103
+ args (tuple): The positional arguments typically passed to an
104
+ exception class.
105
+ """
106
+
107
+ def __init__(self, response, *args):
108
+ super(DataCorruption, self).__init__(*args)
109
+ self.response = response
110
+ """object: The HTTP response object that caused the failure."""
111
+
112
+
113
+ class RetryStrategy(object):
114
+ """Configuration class for retrying failed requests.
115
+
116
+ At most one of ``max_cumulative_retry`` and ``max_retries`` can be
117
+ specified (they are both caps on the total number of retries). If
118
+ neither are specified, then ``max_cumulative_retry`` is set as
119
+ :data:`MAX_CUMULATIVE_RETRY`.
120
+
121
+ Args:
122
+ max_sleep (Optional[float]): The maximum amount of time to sleep after
123
+ a failed request. Default is :attr:`MAX_SLEEP`.
124
+ max_cumulative_retry (Optional[float]): The maximum **total** amount of
125
+ time to sleep during retry process.
126
+ max_retries (Optional[int]): The number of retries to attempt.
127
+ initial_delay (Optional[float]): The initial delay. Default 1.0 second.
128
+ muiltiplier (Optional[float]): Exponent of the backoff. Default is 2.0.
129
+
130
+ Attributes:
131
+ max_sleep (float): Maximum amount of time allowed between requests.
132
+ max_cumulative_retry (Optional[float]): Maximum total sleep time
133
+ allowed during retry process.
134
+ max_retries (Optional[int]): The number retries to attempt.
135
+ initial_delay (Optional[float]): The initial delay. Default 1.0 second.
136
+ muiltiplier (Optional[float]): Exponent of the backoff. Default is 2.0.
137
+
138
+ Raises:
139
+ ValueError: If both of ``max_cumulative_retry`` and ``max_retries``
140
+ are passed.
141
+ """
142
+
143
+ def __init__(
144
+ self,
145
+ max_sleep=MAX_SLEEP,
146
+ max_cumulative_retry=None,
147
+ max_retries=None,
148
+ initial_delay=1.0,
149
+ multiplier=2.0,
150
+ ):
151
+ if max_cumulative_retry is not None and max_retries is not None:
152
+ raise ValueError(_SLEEP_RETRY_ERROR_MSG)
153
+ if max_cumulative_retry is None and max_retries is None:
154
+ max_cumulative_retry = MAX_CUMULATIVE_RETRY
155
+
156
+ self.max_sleep = max_sleep
157
+ self.max_cumulative_retry = max_cumulative_retry
158
+ self.max_retries = max_retries
159
+ self.initial_delay = initial_delay
160
+ self.multiplier = multiplier
161
+
162
+ def retry_allowed(self, total_sleep, num_retries):
163
+ """Check if another retry is allowed.
164
+
165
+ Args:
166
+ total_sleep (float): With another retry, the amount of sleep that
167
+ will be accumulated by the caller.
168
+ num_retries (int): With another retry, the number of retries that
169
+ will be attempted by the caller.
170
+
171
+ Returns:
172
+ bool: Indicating if another retry is allowed (depending on either
173
+ the cumulative sleep allowed or the maximum number of retries
174
+ allowed.
175
+ """
176
+ if self.max_cumulative_retry is None:
177
+ return num_retries <= self.max_retries
178
+ else:
179
+ return total_sleep <= self.max_cumulative_retry
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (21.1 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/__pycache__/_request_helpers.cpython-310.pyc ADDED
Binary file (4.58 kB). View file
 
evalkit_tf437/lib/python3.10/site-packages/google/resumable_media/requests/_request_helpers.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2017 Google Inc.
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
+ """Shared utilities used by both downloads and uploads.
16
+
17
+ This utilities are explicitly catered to ``requests``-like transports.
18
+ """
19
+
20
+ import http.client
21
+ import requests.exceptions
22
+ import urllib3.exceptions # type: ignore
23
+
24
+ import time
25
+
26
+ from google.resumable_media import common
27
+ from google.resumable_media import _helpers
28
+
29
+ _DEFAULT_RETRY_STRATEGY = common.RetryStrategy()
30
+ _SINGLE_GET_CHUNK_SIZE = 8192
31
+ # The number of seconds to wait to establish a connection
32
+ # (connect() call on socket). Avoid setting this to a multiple of 3 to not
33
+ # Align with TCP Retransmission timing. (typically 2.5-3s)
34
+ _DEFAULT_CONNECT_TIMEOUT = 61
35
+ # The number of seconds to wait between bytes sent from the server.
36
+ _DEFAULT_READ_TIMEOUT = 60
37
+
38
+ _CONNECTION_ERROR_CLASSES = (
39
+ http.client.BadStatusLine,
40
+ http.client.IncompleteRead,
41
+ http.client.ResponseNotReady,
42
+ requests.exceptions.ConnectionError,
43
+ requests.exceptions.ChunkedEncodingError,
44
+ requests.exceptions.Timeout,
45
+ urllib3.exceptions.PoolError,
46
+ urllib3.exceptions.ProtocolError,
47
+ urllib3.exceptions.SSLError,
48
+ urllib3.exceptions.TimeoutError,
49
+ ConnectionError, # Python 3.x only, superclass of ConnectionResetError.
50
+ )
51
+
52
+
53
+ class RequestsMixin(object):
54
+ """Mix-in class implementing ``requests``-specific behavior.
55
+
56
+ These are methods that are more general purpose, with implementations
57
+ specific to the types defined in ``requests``.
58
+ """
59
+
60
+ @staticmethod
61
+ def _get_status_code(response):
62
+ """Access the status code from an HTTP response.
63
+
64
+ Args:
65
+ response (~requests.Response): The HTTP response object.
66
+
67
+ Returns:
68
+ int: The status code.
69
+ """
70
+ return response.status_code
71
+
72
+ @staticmethod
73
+ def _get_headers(response):
74
+ """Access the headers from an HTTP response.
75
+
76
+ Args:
77
+ response (~requests.Response): The HTTP response object.
78
+
79
+ Returns:
80
+ ~requests.structures.CaseInsensitiveDict: The header mapping (keys
81
+ are case-insensitive).
82
+ """
83
+ return response.headers
84
+
85
+ @staticmethod
86
+ def _get_body(response):
87
+ """Access the response body from an HTTP response.
88
+
89
+ Args:
90
+ response (~requests.Response): The HTTP response object.
91
+
92
+ Returns:
93
+ bytes: The body of the ``response``.
94
+ """
95
+ return response.content
96
+
97
+
98
+ class RawRequestsMixin(RequestsMixin):
99
+ @staticmethod
100
+ def _get_body(response):
101
+ """Access the response body from an HTTP response.
102
+
103
+ Args:
104
+ response (~requests.Response): The HTTP response object.
105
+
106
+ Returns:
107
+ bytes: The body of the ``response``.
108
+ """
109
+ if response._content is False:
110
+ response._content = b"".join(
111
+ response.raw.stream(_SINGLE_GET_CHUNK_SIZE, decode_content=False)
112
+ )
113
+ response._content_consumed = True
114
+ return response._content
115
+
116
+
117
+ def wait_and_retry(func, get_status_code, retry_strategy):
118
+ """Attempts to retry a call to ``func`` until success.
119
+
120
+ Expects ``func`` to return an HTTP response and uses ``get_status_code``
121
+ to check if the response is retry-able.
122
+
123
+ ``func`` is expected to raise a failure status code as a
124
+ common.InvalidResponse, at which point this method will check the code
125
+ against the common.RETRIABLE list of retriable status codes.
126
+
127
+ Will retry until :meth:`~.RetryStrategy.retry_allowed` (on the current
128
+ ``retry_strategy``) returns :data:`False`. Uses
129
+ :func:`_helpers.calculate_retry_wait` to double the wait time (with jitter)
130
+ after each attempt.
131
+
132
+ Args:
133
+ func (Callable): A callable that takes no arguments and produces
134
+ an HTTP response which will be checked as retry-able.
135
+ get_status_code (Callable[Any, int]): Helper to get a status code
136
+ from a response.
137
+ retry_strategy (~google.resumable_media.common.RetryStrategy): The
138
+ strategy to use if the request fails and must be retried.
139
+
140
+ Returns:
141
+ object: The return value of ``func``.
142
+ """
143
+ total_sleep = 0.0
144
+ num_retries = 0
145
+ # base_wait will be multiplied by the multiplier on the first retry.
146
+ base_wait = float(retry_strategy.initial_delay) / retry_strategy.multiplier
147
+
148
+ # Set the retriable_exception_type if possible. We expect requests to be
149
+ # present here and the transport to be using requests.exceptions errors,
150
+ # but due to loose coupling with the transport layer we can't guarantee it.
151
+
152
+ while True: # return on success or when retries exhausted.
153
+ error = None
154
+ try:
155
+ response = func()
156
+ except _CONNECTION_ERROR_CLASSES as e:
157
+ error = e # Fall through to retry, if there are retries left.
158
+ except common.InvalidResponse as e:
159
+ # An InvalidResponse is only retriable if its status code matches.
160
+ # The `process_response()` method on a Download or Upload method
161
+ # will convert the status code into an exception.
162
+ if get_status_code(e.response) in common.RETRYABLE:
163
+ error = e # Fall through to retry, if there are retries left.
164
+ else:
165
+ raise # If the status code is not retriable, raise w/o retry.
166
+ else:
167
+ return response
168
+
169
+ base_wait, wait_time = _helpers.calculate_retry_wait(
170
+ base_wait, retry_strategy.max_sleep, retry_strategy.multiplier
171
+ )
172
+ num_retries += 1
173
+ total_sleep += wait_time
174
+
175
+ # Check if (another) retry is allowed. If retries are exhausted and
176
+ # no acceptable response was received, raise the retriable error.
177
+ if not retry_strategy.retry_allowed(total_sleep, num_retries):
178
+ raise error
179
+
180
+ time.sleep(wait_time)
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (178 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/iris.arff ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % 1. Title: Iris Plants Database
2
+ %
3
+ % 2. Sources:
4
+ % (a) Creator: R.A. Fisher
5
+ % (b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)
6
+ % (c) Date: July, 1988
7
+ %
8
+ % 3. Past Usage:
9
+ % - Publications: too many to mention!!! Here are a few.
10
+ % 1. Fisher,R.A. "The use of multiple measurements in taxonomic problems"
11
+ % Annual Eugenics, 7, Part II, 179-188 (1936); also in "Contributions
12
+ % to Mathematical Statistics" (John Wiley, NY, 1950).
13
+ % 2. Duda,R.O., & Hart,P.E. (1973) Pattern Classification and Scene Analysis.
14
+ % (Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218.
15
+ % 3. Dasarathy, B.V. (1980) "Nosing Around the Neighborhood: A New System
16
+ % Structure and Classification Rule for Recognition in Partially Exposed
17
+ % Environments". IEEE Transactions on Pattern Analysis and Machine
18
+ % Intelligence, Vol. PAMI-2, No. 1, 67-71.
19
+ % -- Results:
20
+ % -- very low misclassification rates (0% for the setosa class)
21
+ % 4. Gates, G.W. (1972) "The Reduced Nearest Neighbor Rule". IEEE
22
+ % Transactions on Information Theory, May 1972, 431-433.
23
+ % -- Results:
24
+ % -- very low misclassification rates again
25
+ % 5. See also: 1988 MLC Proceedings, 54-64. Cheeseman et al's AUTOCLASS II
26
+ % conceptual clustering system finds 3 classes in the data.
27
+ %
28
+ % 4. Relevant Information:
29
+ % --- This is perhaps the best known database to be found in the pattern
30
+ % recognition literature. Fisher's paper is a classic in the field
31
+ % and is referenced frequently to this day. (See Duda & Hart, for
32
+ % example.) The data set contains 3 classes of 50 instances each,
33
+ % where each class refers to a type of iris plant. One class is
34
+ % linearly separable from the other 2; the latter are NOT linearly
35
+ % separable from each other.
36
+ % --- Predicted attribute: class of iris plant.
37
+ % --- This is an exceedingly simple domain.
38
+ %
39
+ % 5. Number of Instances: 150 (50 in each of three classes)
40
+ %
41
+ % 6. Number of Attributes: 4 numeric, predictive attributes and the class
42
+ %
43
+ % 7. Attribute Information:
44
+ % 1. sepal length in cm
45
+ % 2. sepal width in cm
46
+ % 3. petal length in cm
47
+ % 4. petal width in cm
48
+ % 5. class:
49
+ % -- Iris Setosa
50
+ % -- Iris Versicolour
51
+ % -- Iris Virginica
52
+ %
53
+ % 8. Missing Attribute Values: None
54
+ %
55
+ % Summary Statistics:
56
+ % Min Max Mean SD Class Correlation
57
+ % sepal length: 4.3 7.9 5.84 0.83 0.7826
58
+ % sepal width: 2.0 4.4 3.05 0.43 -0.4194
59
+ % petal length: 1.0 6.9 3.76 1.76 0.9490 (high!)
60
+ % petal width: 0.1 2.5 1.20 0.76 0.9565 (high!)
61
+ %
62
+ % 9. Class Distribution: 33.3% for each of 3 classes.
63
+
64
+ @RELATION iris
65
+
66
+ @ATTRIBUTE sepallength REAL
67
+ @ATTRIBUTE sepalwidth REAL
68
+ @ATTRIBUTE petallength REAL
69
+ @ATTRIBUTE petalwidth REAL
70
+ @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}
71
+
72
+ @DATA
73
+ 5.1,3.5,1.4,0.2,Iris-setosa
74
+ 4.9,3.0,1.4,0.2,Iris-setosa
75
+ 4.7,3.2,1.3,0.2,Iris-setosa
76
+ 4.6,3.1,1.5,0.2,Iris-setosa
77
+ 5.0,3.6,1.4,0.2,Iris-setosa
78
+ 5.4,3.9,1.7,0.4,Iris-setosa
79
+ 4.6,3.4,1.4,0.3,Iris-setosa
80
+ 5.0,3.4,1.5,0.2,Iris-setosa
81
+ 4.4,2.9,1.4,0.2,Iris-setosa
82
+ 4.9,3.1,1.5,0.1,Iris-setosa
83
+ 5.4,3.7,1.5,0.2,Iris-setosa
84
+ 4.8,3.4,1.6,0.2,Iris-setosa
85
+ 4.8,3.0,1.4,0.1,Iris-setosa
86
+ 4.3,3.0,1.1,0.1,Iris-setosa
87
+ 5.8,4.0,1.2,0.2,Iris-setosa
88
+ 5.7,4.4,1.5,0.4,Iris-setosa
89
+ 5.4,3.9,1.3,0.4,Iris-setosa
90
+ 5.1,3.5,1.4,0.3,Iris-setosa
91
+ 5.7,3.8,1.7,0.3,Iris-setosa
92
+ 5.1,3.8,1.5,0.3,Iris-setosa
93
+ 5.4,3.4,1.7,0.2,Iris-setosa
94
+ 5.1,3.7,1.5,0.4,Iris-setosa
95
+ 4.6,3.6,1.0,0.2,Iris-setosa
96
+ 5.1,3.3,1.7,0.5,Iris-setosa
97
+ 4.8,3.4,1.9,0.2,Iris-setosa
98
+ 5.0,3.0,1.6,0.2,Iris-setosa
99
+ 5.0,3.4,1.6,0.4,Iris-setosa
100
+ 5.2,3.5,1.5,0.2,Iris-setosa
101
+ 5.2,3.4,1.4,0.2,Iris-setosa
102
+ 4.7,3.2,1.6,0.2,Iris-setosa
103
+ 4.8,3.1,1.6,0.2,Iris-setosa
104
+ 5.4,3.4,1.5,0.4,Iris-setosa
105
+ 5.2,4.1,1.5,0.1,Iris-setosa
106
+ 5.5,4.2,1.4,0.2,Iris-setosa
107
+ 4.9,3.1,1.5,0.1,Iris-setosa
108
+ 5.0,3.2,1.2,0.2,Iris-setosa
109
+ 5.5,3.5,1.3,0.2,Iris-setosa
110
+ 4.9,3.1,1.5,0.1,Iris-setosa
111
+ 4.4,3.0,1.3,0.2,Iris-setosa
112
+ 5.1,3.4,1.5,0.2,Iris-setosa
113
+ 5.0,3.5,1.3,0.3,Iris-setosa
114
+ 4.5,2.3,1.3,0.3,Iris-setosa
115
+ 4.4,3.2,1.3,0.2,Iris-setosa
116
+ 5.0,3.5,1.6,0.6,Iris-setosa
117
+ 5.1,3.8,1.9,0.4,Iris-setosa
118
+ 4.8,3.0,1.4,0.3,Iris-setosa
119
+ 5.1,3.8,1.6,0.2,Iris-setosa
120
+ 4.6,3.2,1.4,0.2,Iris-setosa
121
+ 5.3,3.7,1.5,0.2,Iris-setosa
122
+ 5.0,3.3,1.4,0.2,Iris-setosa
123
+ 7.0,3.2,4.7,1.4,Iris-versicolor
124
+ 6.4,3.2,4.5,1.5,Iris-versicolor
125
+ 6.9,3.1,4.9,1.5,Iris-versicolor
126
+ 5.5,2.3,4.0,1.3,Iris-versicolor
127
+ 6.5,2.8,4.6,1.5,Iris-versicolor
128
+ 5.7,2.8,4.5,1.3,Iris-versicolor
129
+ 6.3,3.3,4.7,1.6,Iris-versicolor
130
+ 4.9,2.4,3.3,1.0,Iris-versicolor
131
+ 6.6,2.9,4.6,1.3,Iris-versicolor
132
+ 5.2,2.7,3.9,1.4,Iris-versicolor
133
+ 5.0,2.0,3.5,1.0,Iris-versicolor
134
+ 5.9,3.0,4.2,1.5,Iris-versicolor
135
+ 6.0,2.2,4.0,1.0,Iris-versicolor
136
+ 6.1,2.9,4.7,1.4,Iris-versicolor
137
+ 5.6,2.9,3.6,1.3,Iris-versicolor
138
+ 6.7,3.1,4.4,1.4,Iris-versicolor
139
+ 5.6,3.0,4.5,1.5,Iris-versicolor
140
+ 5.8,2.7,4.1,1.0,Iris-versicolor
141
+ 6.2,2.2,4.5,1.5,Iris-versicolor
142
+ 5.6,2.5,3.9,1.1,Iris-versicolor
143
+ 5.9,3.2,4.8,1.8,Iris-versicolor
144
+ 6.1,2.8,4.0,1.3,Iris-versicolor
145
+ 6.3,2.5,4.9,1.5,Iris-versicolor
146
+ 6.1,2.8,4.7,1.2,Iris-versicolor
147
+ 6.4,2.9,4.3,1.3,Iris-versicolor
148
+ 6.6,3.0,4.4,1.4,Iris-versicolor
149
+ 6.8,2.8,4.8,1.4,Iris-versicolor
150
+ 6.7,3.0,5.0,1.7,Iris-versicolor
151
+ 6.0,2.9,4.5,1.5,Iris-versicolor
152
+ 5.7,2.6,3.5,1.0,Iris-versicolor
153
+ 5.5,2.4,3.8,1.1,Iris-versicolor
154
+ 5.5,2.4,3.7,1.0,Iris-versicolor
155
+ 5.8,2.7,3.9,1.2,Iris-versicolor
156
+ 6.0,2.7,5.1,1.6,Iris-versicolor
157
+ 5.4,3.0,4.5,1.5,Iris-versicolor
158
+ 6.0,3.4,4.5,1.6,Iris-versicolor
159
+ 6.7,3.1,4.7,1.5,Iris-versicolor
160
+ 6.3,2.3,4.4,1.3,Iris-versicolor
161
+ 5.6,3.0,4.1,1.3,Iris-versicolor
162
+ 5.5,2.5,4.0,1.3,Iris-versicolor
163
+ 5.5,2.6,4.4,1.2,Iris-versicolor
164
+ 6.1,3.0,4.6,1.4,Iris-versicolor
165
+ 5.8,2.6,4.0,1.2,Iris-versicolor
166
+ 5.0,2.3,3.3,1.0,Iris-versicolor
167
+ 5.6,2.7,4.2,1.3,Iris-versicolor
168
+ 5.7,3.0,4.2,1.2,Iris-versicolor
169
+ 5.7,2.9,4.2,1.3,Iris-versicolor
170
+ 6.2,2.9,4.3,1.3,Iris-versicolor
171
+ 5.1,2.5,3.0,1.1,Iris-versicolor
172
+ 5.7,2.8,4.1,1.3,Iris-versicolor
173
+ 6.3,3.3,6.0,2.5,Iris-virginica
174
+ 5.8,2.7,5.1,1.9,Iris-virginica
175
+ 7.1,3.0,5.9,2.1,Iris-virginica
176
+ 6.3,2.9,5.6,1.8,Iris-virginica
177
+ 6.5,3.0,5.8,2.2,Iris-virginica
178
+ 7.6,3.0,6.6,2.1,Iris-virginica
179
+ 4.9,2.5,4.5,1.7,Iris-virginica
180
+ 7.3,2.9,6.3,1.8,Iris-virginica
181
+ 6.7,2.5,5.8,1.8,Iris-virginica
182
+ 7.2,3.6,6.1,2.5,Iris-virginica
183
+ 6.5,3.2,5.1,2.0,Iris-virginica
184
+ 6.4,2.7,5.3,1.9,Iris-virginica
185
+ 6.8,3.0,5.5,2.1,Iris-virginica
186
+ 5.7,2.5,5.0,2.0,Iris-virginica
187
+ 5.8,2.8,5.1,2.4,Iris-virginica
188
+ 6.4,3.2,5.3,2.3,Iris-virginica
189
+ 6.5,3.0,5.5,1.8,Iris-virginica
190
+ 7.7,3.8,6.7,2.2,Iris-virginica
191
+ 7.7,2.6,6.9,2.3,Iris-virginica
192
+ 6.0,2.2,5.0,1.5,Iris-virginica
193
+ 6.9,3.2,5.7,2.3,Iris-virginica
194
+ 5.6,2.8,4.9,2.0,Iris-virginica
195
+ 7.7,2.8,6.7,2.0,Iris-virginica
196
+ 6.3,2.7,4.9,1.8,Iris-virginica
197
+ 6.7,3.3,5.7,2.1,Iris-virginica
198
+ 7.2,3.2,6.0,1.8,Iris-virginica
199
+ 6.2,2.8,4.8,1.8,Iris-virginica
200
+ 6.1,3.0,4.9,1.8,Iris-virginica
201
+ 6.4,2.8,5.6,2.1,Iris-virginica
202
+ 7.2,3.0,5.8,1.6,Iris-virginica
203
+ 7.4,2.8,6.1,1.9,Iris-virginica
204
+ 7.9,3.8,6.4,2.0,Iris-virginica
205
+ 6.4,2.8,5.6,2.2,Iris-virginica
206
+ 6.3,2.8,5.1,1.5,Iris-virginica
207
+ 6.1,2.6,5.6,1.4,Iris-virginica
208
+ 7.7,3.0,6.1,2.3,Iris-virginica
209
+ 6.3,3.4,5.6,2.4,Iris-virginica
210
+ 6.4,3.1,5.5,1.8,Iris-virginica
211
+ 6.0,3.0,4.8,1.8,Iris-virginica
212
+ 6.9,3.1,5.4,2.1,Iris-virginica
213
+ 6.7,3.1,5.6,2.4,Iris-virginica
214
+ 6.9,3.1,5.1,2.3,Iris-virginica
215
+ 5.8,2.7,5.1,1.9,Iris-virginica
216
+ 6.8,3.2,5.9,2.3,Iris-virginica
217
+ 6.7,3.3,5.7,2.5,Iris-virginica
218
+ 6.7,3.0,5.2,2.3,Iris-virginica
219
+ 6.3,2.5,5.0,1.9,Iris-virginica
220
+ 6.5,3.0,5.2,2.0,Iris-virginica
221
+ 6.2,3.4,5.4,2.3,Iris-virginica
222
+ 5.9,3.0,5.1,1.8,Iris-virginica
223
+ %
224
+ %
225
+ %
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/missing.arff ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ % This arff file contains some missing data
2
+ @relation missing
3
+ @attribute yop real
4
+ @attribute yap real
5
+ @data
6
+ 1,5
7
+ 2,4
8
+ ?,?
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/nodata.arff ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @RELATION iris
2
+
3
+ @ATTRIBUTE sepallength REAL
4
+ @ATTRIBUTE sepalwidth REAL
5
+ @ATTRIBUTE petallength REAL
6
+ @ATTRIBUTE petalwidth REAL
7
+ @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}
8
+
9
+ @DATA
10
+
11
+ % This file has no data
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/quoted_nominal.arff ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ % Regression test for issue #10232 : Exception in loadarff with quoted nominal attributes
2
+ % Spaces between elements are stripped by the parser
3
+
4
+ @relation SOME_DATA
5
+ @attribute age numeric
6
+ @attribute smoker {'yes', 'no'}
7
+ @data
8
+ 18, 'no'
9
+ 24, 'yes'
10
+ 44, 'no'
11
+ 56, 'no'
12
+ 89,'yes'
13
+ 11, 'no'
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test1.arff ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ @RELATION test1
2
+
3
+ @ATTRIBUTE attr0 REAL
4
+ @ATTRIBUTE attr1 REAL
5
+ @ATTRIBUTE attr2 REAL
6
+ @ATTRIBUTE attr3 REAL
7
+ @ATTRIBUTE class {class0, class1, class2, class3}
8
+
9
+ @DATA
10
+ 0.1, 0.2, 0.3, 0.4,class1
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test10.arff ADDED
The diff for this file is too large to render. See raw diff
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test11.arff ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @RELATION test11
2
+
3
+ @ATTRIBUTE attr0 REAL
4
+ @ATTRIBUTE attr1 REAL
5
+ @ATTRIBUTE attr2 REAL
6
+ @ATTRIBUTE attr3 REAL
7
+ @ATTRIBUTE class { class0, class1, class2, class3 }
8
+ @DATA
9
+ 0.1, 0.2, 0.3, 0.4,class1
10
+ -0.1, -0.2, -0.3, -0.4,class2
11
+ 1, 2, 3, 4,class3
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/data/test4.arff ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @RELATION test5
2
+
3
+ @ATTRIBUTE attr0 REAL
4
+ @ATTRIBUTE attr1 REAL
5
+ @ATTRIBUTE attr2 REAL
6
+ @ATTRIBUTE attr3 REAL
7
+ @ATTRIBUTE class {class0, class1, class2, class3}
8
+ @DATA
9
+ 0.1, 0.2, 0.3, 0.4,class1
10
+ -0.1, -0.2, -0.3, -0.4,class2
11
+ 1, 2, 3, 4,class3
evalkit_tf449/lib/python3.10/site-packages/scipy/io/arff/tests/test_arffread.py ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datetime
2
+ import os
3
+ import sys
4
+ from os.path import join as pjoin
5
+
6
+ from io import StringIO
7
+
8
+ import numpy as np
9
+
10
+ from numpy.testing import (assert_array_almost_equal,
11
+ assert_array_equal, assert_equal, assert_)
12
+ from pytest import raises as assert_raises
13
+
14
+ from scipy.io.arff import loadarff
15
+ from scipy.io.arff._arffread import read_header, ParseArffError
16
+
17
+
18
+ data_path = pjoin(os.path.dirname(__file__), 'data')
19
+
20
+ test1 = pjoin(data_path, 'test1.arff')
21
+ test2 = pjoin(data_path, 'test2.arff')
22
+ test3 = pjoin(data_path, 'test3.arff')
23
+
24
+ test4 = pjoin(data_path, 'test4.arff')
25
+ test5 = pjoin(data_path, 'test5.arff')
26
+ test6 = pjoin(data_path, 'test6.arff')
27
+ test7 = pjoin(data_path, 'test7.arff')
28
+ test8 = pjoin(data_path, 'test8.arff')
29
+ test9 = pjoin(data_path, 'test9.arff')
30
+ test10 = pjoin(data_path, 'test10.arff')
31
+ test11 = pjoin(data_path, 'test11.arff')
32
+ test_quoted_nominal = pjoin(data_path, 'quoted_nominal.arff')
33
+ test_quoted_nominal_spaces = pjoin(data_path, 'quoted_nominal_spaces.arff')
34
+
35
+ expect4_data = [(0.1, 0.2, 0.3, 0.4, 'class1'),
36
+ (-0.1, -0.2, -0.3, -0.4, 'class2'),
37
+ (1, 2, 3, 4, 'class3')]
38
+ expected_types = ['numeric', 'numeric', 'numeric', 'numeric', 'nominal']
39
+
40
+ missing = pjoin(data_path, 'missing.arff')
41
+ expect_missing_raw = np.array([[1, 5], [2, 4], [np.nan, np.nan]])
42
+ expect_missing = np.empty(3, [('yop', float), ('yap', float)])
43
+ expect_missing['yop'] = expect_missing_raw[:, 0]
44
+ expect_missing['yap'] = expect_missing_raw[:, 1]
45
+
46
+
47
+ class TestData:
48
+ def test1(self):
49
+ # Parsing trivial file with nothing.
50
+ self._test(test4)
51
+
52
+ def test2(self):
53
+ # Parsing trivial file with some comments in the data section.
54
+ self._test(test5)
55
+
56
+ def test3(self):
57
+ # Parsing trivial file with nominal attribute of 1 character.
58
+ self._test(test6)
59
+
60
+ def test4(self):
61
+ # Parsing trivial file with trailing spaces in attribute declaration.
62
+ self._test(test11)
63
+
64
+ def _test(self, test_file):
65
+ data, meta = loadarff(test_file)
66
+ for i in range(len(data)):
67
+ for j in range(4):
68
+ assert_array_almost_equal(expect4_data[i][j], data[i][j])
69
+ assert_equal(meta.types(), expected_types)
70
+
71
+ def test_filelike(self):
72
+ # Test reading from file-like object (StringIO)
73
+ with open(test1) as f1:
74
+ data1, meta1 = loadarff(f1)
75
+ with open(test1) as f2:
76
+ data2, meta2 = loadarff(StringIO(f2.read()))
77
+ assert_(data1 == data2)
78
+ assert_(repr(meta1) == repr(meta2))
79
+
80
+ def test_path(self):
81
+ # Test reading from `pathlib.Path` object
82
+ from pathlib import Path
83
+
84
+ with open(test1) as f1:
85
+ data1, meta1 = loadarff(f1)
86
+
87
+ data2, meta2 = loadarff(Path(test1))
88
+
89
+ assert_(data1 == data2)
90
+ assert_(repr(meta1) == repr(meta2))
91
+
92
+
93
+ class TestMissingData:
94
+ def test_missing(self):
95
+ data, meta = loadarff(missing)
96
+ for i in ['yop', 'yap']:
97
+ assert_array_almost_equal(data[i], expect_missing[i])
98
+
99
+
100
+ class TestNoData:
101
+ def test_nodata(self):
102
+ # The file nodata.arff has no data in the @DATA section.
103
+ # Reading it should result in an array with length 0.
104
+ nodata_filename = os.path.join(data_path, 'nodata.arff')
105
+ data, meta = loadarff(nodata_filename)
106
+ if sys.byteorder == 'big':
107
+ end = '>'
108
+ else:
109
+ end = '<'
110
+ expected_dtype = np.dtype([('sepallength', f'{end}f8'),
111
+ ('sepalwidth', f'{end}f8'),
112
+ ('petallength', f'{end}f8'),
113
+ ('petalwidth', f'{end}f8'),
114
+ ('class', 'S15')])
115
+ assert_equal(data.dtype, expected_dtype)
116
+ assert_equal(data.size, 0)
117
+
118
+
119
+ class TestHeader:
120
+ def test_type_parsing(self):
121
+ # Test parsing type of attribute from their value.
122
+ with open(test2) as ofile:
123
+ rel, attrs = read_header(ofile)
124
+
125
+ expected = ['numeric', 'numeric', 'numeric', 'numeric', 'numeric',
126
+ 'numeric', 'string', 'string', 'nominal', 'nominal']
127
+
128
+ for i in range(len(attrs)):
129
+ assert_(attrs[i].type_name == expected[i])
130
+
131
+ def test_badtype_parsing(self):
132
+ # Test parsing wrong type of attribute from their value.
133
+ def badtype_read():
134
+ with open(test3) as ofile:
135
+ _, _ = read_header(ofile)
136
+
137
+ assert_raises(ParseArffError, badtype_read)
138
+
139
+ def test_fullheader1(self):
140
+ # Parsing trivial header with nothing.
141
+ with open(test1) as ofile:
142
+ rel, attrs = read_header(ofile)
143
+
144
+ # Test relation
145
+ assert_(rel == 'test1')
146
+
147
+ # Test numerical attributes
148
+ assert_(len(attrs) == 5)
149
+ for i in range(4):
150
+ assert_(attrs[i].name == 'attr%d' % i)
151
+ assert_(attrs[i].type_name == 'numeric')
152
+
153
+ # Test nominal attribute
154
+ assert_(attrs[4].name == 'class')
155
+ assert_(attrs[4].values == ('class0', 'class1', 'class2', 'class3'))
156
+
157
+ def test_dateheader(self):
158
+ with open(test7) as ofile:
159
+ rel, attrs = read_header(ofile)
160
+
161
+ assert_(rel == 'test7')
162
+
163
+ assert_(len(attrs) == 5)
164
+
165
+ assert_(attrs[0].name == 'attr_year')
166
+ assert_(attrs[0].date_format == '%Y')
167
+
168
+ assert_(attrs[1].name == 'attr_month')
169
+ assert_(attrs[1].date_format == '%Y-%m')
170
+
171
+ assert_(attrs[2].name == 'attr_date')
172
+ assert_(attrs[2].date_format == '%Y-%m-%d')
173
+
174
+ assert_(attrs[3].name == 'attr_datetime_local')
175
+ assert_(attrs[3].date_format == '%Y-%m-%d %H:%M')
176
+
177
+ assert_(attrs[4].name == 'attr_datetime_missing')
178
+ assert_(attrs[4].date_format == '%Y-%m-%d %H:%M')
179
+
180
+ def test_dateheader_unsupported(self):
181
+ def read_dateheader_unsupported():
182
+ with open(test8) as ofile:
183
+ _, _ = read_header(ofile)
184
+
185
+ assert_raises(ValueError, read_dateheader_unsupported)
186
+
187
+
188
+ class TestDateAttribute:
189
+ def setup_method(self):
190
+ self.data, self.meta = loadarff(test7)
191
+
192
+ def test_year_attribute(self):
193
+ expected = np.array([
194
+ '1999',
195
+ '2004',
196
+ '1817',
197
+ '2100',
198
+ '2013',
199
+ '1631'
200
+ ], dtype='datetime64[Y]')
201
+
202
+ assert_array_equal(self.data["attr_year"], expected)
203
+
204
+ def test_month_attribute(self):
205
+ expected = np.array([
206
+ '1999-01',
207
+ '2004-12',
208
+ '1817-04',
209
+ '2100-09',
210
+ '2013-11',
211
+ '1631-10'
212
+ ], dtype='datetime64[M]')
213
+
214
+ assert_array_equal(self.data["attr_month"], expected)
215
+
216
+ def test_date_attribute(self):
217
+ expected = np.array([
218
+ '1999-01-31',
219
+ '2004-12-01',
220
+ '1817-04-28',
221
+ '2100-09-10',
222
+ '2013-11-30',
223
+ '1631-10-15'
224
+ ], dtype='datetime64[D]')
225
+
226
+ assert_array_equal(self.data["attr_date"], expected)
227
+
228
+ def test_datetime_local_attribute(self):
229
+ expected = np.array([
230
+ datetime.datetime(year=1999, month=1, day=31, hour=0, minute=1),
231
+ datetime.datetime(year=2004, month=12, day=1, hour=23, minute=59),
232
+ datetime.datetime(year=1817, month=4, day=28, hour=13, minute=0),
233
+ datetime.datetime(year=2100, month=9, day=10, hour=12, minute=0),
234
+ datetime.datetime(year=2013, month=11, day=30, hour=4, minute=55),
235
+ datetime.datetime(year=1631, month=10, day=15, hour=20, minute=4)
236
+ ], dtype='datetime64[m]')
237
+
238
+ assert_array_equal(self.data["attr_datetime_local"], expected)
239
+
240
+ def test_datetime_missing(self):
241
+ expected = np.array([
242
+ 'nat',
243
+ '2004-12-01T23:59',
244
+ 'nat',
245
+ 'nat',
246
+ '2013-11-30T04:55',
247
+ '1631-10-15T20:04'
248
+ ], dtype='datetime64[m]')
249
+
250
+ assert_array_equal(self.data["attr_datetime_missing"], expected)
251
+
252
+ def test_datetime_timezone(self):
253
+ assert_raises(ParseArffError, loadarff, test8)
254
+
255
+
256
+ class TestRelationalAttribute:
257
+ def setup_method(self):
258
+ self.data, self.meta = loadarff(test9)
259
+
260
+ def test_attributes(self):
261
+ assert_equal(len(self.meta._attributes), 1)
262
+
263
+ relational = list(self.meta._attributes.values())[0]
264
+
265
+ assert_equal(relational.name, 'attr_date_number')
266
+ assert_equal(relational.type_name, 'relational')
267
+ assert_equal(len(relational.attributes), 2)
268
+ assert_equal(relational.attributes[0].name,
269
+ 'attr_date')
270
+ assert_equal(relational.attributes[0].type_name,
271
+ 'date')
272
+ assert_equal(relational.attributes[1].name,
273
+ 'attr_number')
274
+ assert_equal(relational.attributes[1].type_name,
275
+ 'numeric')
276
+
277
+ def test_data(self):
278
+ dtype_instance = [('attr_date', 'datetime64[D]'),
279
+ ('attr_number', np.float64)]
280
+
281
+ expected = [
282
+ np.array([('1999-01-31', 1), ('1935-11-27', 10)],
283
+ dtype=dtype_instance),
284
+ np.array([('2004-12-01', 2), ('1942-08-13', 20)],
285
+ dtype=dtype_instance),
286
+ np.array([('1817-04-28', 3)],
287
+ dtype=dtype_instance),
288
+ np.array([('2100-09-10', 4), ('1957-04-17', 40),
289
+ ('1721-01-14', 400)],
290
+ dtype=dtype_instance),
291
+ np.array([('2013-11-30', 5)],
292
+ dtype=dtype_instance),
293
+ np.array([('1631-10-15', 6)],
294
+ dtype=dtype_instance)
295
+ ]
296
+
297
+ for i in range(len(self.data["attr_date_number"])):
298
+ assert_array_equal(self.data["attr_date_number"][i],
299
+ expected[i])
300
+
301
+
302
+ class TestRelationalAttributeLong:
303
+ def setup_method(self):
304
+ self.data, self.meta = loadarff(test10)
305
+
306
+ def test_attributes(self):
307
+ assert_equal(len(self.meta._attributes), 1)
308
+
309
+ relational = list(self.meta._attributes.values())[0]
310
+
311
+ assert_equal(relational.name, 'attr_relational')
312
+ assert_equal(relational.type_name, 'relational')
313
+ assert_equal(len(relational.attributes), 1)
314
+ assert_equal(relational.attributes[0].name,
315
+ 'attr_number')
316
+ assert_equal(relational.attributes[0].type_name, 'numeric')
317
+
318
+ def test_data(self):
319
+ dtype_instance = [('attr_number', np.float64)]
320
+
321
+ expected = np.array([(n,) for n in range(30000)],
322
+ dtype=dtype_instance)
323
+
324
+ assert_array_equal(self.data["attr_relational"][0],
325
+ expected)
326
+
327
+
328
+ class TestQuotedNominal:
329
+ """
330
+ Regression test for issue #10232:
331
+
332
+ Exception in loadarff with quoted nominal attributes.
333
+ """
334
+
335
+ def setup_method(self):
336
+ self.data, self.meta = loadarff(test_quoted_nominal)
337
+
338
+ def test_attributes(self):
339
+ assert_equal(len(self.meta._attributes), 2)
340
+
341
+ age, smoker = self.meta._attributes.values()
342
+
343
+ assert_equal(age.name, 'age')
344
+ assert_equal(age.type_name, 'numeric')
345
+ assert_equal(smoker.name, 'smoker')
346
+ assert_equal(smoker.type_name, 'nominal')
347
+ assert_equal(smoker.values, ['yes', 'no'])
348
+
349
+ def test_data(self):
350
+
351
+ age_dtype_instance = np.float64
352
+ smoker_dtype_instance = '<S3'
353
+
354
+ age_expected = np.array([
355
+ 18,
356
+ 24,
357
+ 44,
358
+ 56,
359
+ 89,
360
+ 11,
361
+ ], dtype=age_dtype_instance)
362
+
363
+ smoker_expected = np.array([
364
+ 'no',
365
+ 'yes',
366
+ 'no',
367
+ 'no',
368
+ 'yes',
369
+ 'no',
370
+ ], dtype=smoker_dtype_instance)
371
+
372
+ assert_array_equal(self.data["age"], age_expected)
373
+ assert_array_equal(self.data["smoker"], smoker_expected)
374
+
375
+
376
+ class TestQuotedNominalSpaces:
377
+ """
378
+ Regression test for issue #10232:
379
+
380
+ Exception in loadarff with quoted nominal attributes.
381
+ """
382
+
383
+ def setup_method(self):
384
+ self.data, self.meta = loadarff(test_quoted_nominal_spaces)
385
+
386
+ def test_attributes(self):
387
+ assert_equal(len(self.meta._attributes), 2)
388
+
389
+ age, smoker = self.meta._attributes.values()
390
+
391
+ assert_equal(age.name, 'age')
392
+ assert_equal(age.type_name, 'numeric')
393
+ assert_equal(smoker.name, 'smoker')
394
+ assert_equal(smoker.type_name, 'nominal')
395
+ assert_equal(smoker.values, [' yes', 'no '])
396
+
397
+ def test_data(self):
398
+
399
+ age_dtype_instance = np.float64
400
+ smoker_dtype_instance = '<S5'
401
+
402
+ age_expected = np.array([
403
+ 18,
404
+ 24,
405
+ 44,
406
+ 56,
407
+ 89,
408
+ 11,
409
+ ], dtype=age_dtype_instance)
410
+
411
+ smoker_expected = np.array([
412
+ 'no ',
413
+ ' yes',
414
+ 'no ',
415
+ 'no ',
416
+ ' yes',
417
+ 'no ',
418
+ ], dtype=smoker_dtype_instance)
419
+
420
+ assert_array_equal(self.data["age"], age_expected)
421
+ assert_array_equal(self.data["smoker"], smoker_expected)
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/_byteordercodes.cpython-310.pyc ADDED
Binary file (1.96 kB). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/mio4.cpython-310.pyc ADDED
Binary file (624 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/__pycache__/miobase.cpython-310.pyc ADDED
Binary file (637 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/broken_utf8.mat ADDED
Binary file (216 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/little_endian.mat ADDED
Binary file (265 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/logical_sparse.mat ADDED
Binary file (208 Bytes). View file
 
evalkit_tf449/lib/python3.10/site-packages/scipy/io/matlab/tests/data/single_empty_string.mat ADDED
Binary file (171 Bytes). View file