google-genai 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- google/genai/_api_client.py +72 -78
- google/genai/_api_module.py +24 -0
- google/genai/_automatic_function_calling_util.py +43 -22
- google/genai/_common.py +0 -6
- google/genai/_extra_utils.py +22 -16
- google/genai/_replay_api_client.py +2 -2
- google/genai/_test_api_client.py +1 -1
- google/genai/_transformers.py +218 -97
- google/genai/batches.py +194 -155
- google/genai/caches.py +117 -134
- google/genai/chats.py +22 -18
- google/genai/client.py +31 -37
- google/genai/files.py +94 -125
- google/genai/live.py +11 -5
- google/genai/models.py +500 -254
- google/genai/tunings.py +85 -422
- google/genai/types.py +495 -458
- google/genai/version.py +1 -1
- {google_genai-0.6.0.dist-info → google_genai-0.7.0.dist-info}/METADATA +116 -68
- google_genai-0.7.0.dist-info/RECORD +26 -0
- google_genai-0.6.0.dist-info/RECORD +0 -25
- {google_genai-0.6.0.dist-info → google_genai-0.7.0.dist-info}/LICENSE +0 -0
- {google_genai-0.6.0.dist-info → google_genai-0.7.0.dist-info}/WHEEL +0 -0
- {google_genai-0.6.0.dist-info → google_genai-0.7.0.dist-info}/top_level.txt +0 -0
google/genai/batches.py
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
from typing import Optional, Union
|
19
19
|
from urllib.parse import urlencode
|
20
|
+
from . import _api_module
|
20
21
|
from . import _common
|
21
22
|
from . import _extra_utils
|
22
23
|
from . import _transformers as t
|
@@ -34,13 +35,13 @@ def _BatchJobSource_to_mldev(
|
|
34
35
|
) -> dict:
|
35
36
|
to_object = {}
|
36
37
|
if getv(from_object, ['format']) is not None:
|
37
|
-
raise ValueError('format parameter is not supported in
|
38
|
+
raise ValueError('format parameter is not supported in Gemini API.')
|
38
39
|
|
39
40
|
if getv(from_object, ['gcs_uri']) is not None:
|
40
|
-
raise ValueError('gcs_uri parameter is not supported in
|
41
|
+
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
41
42
|
|
42
43
|
if getv(from_object, ['bigquery_uri']) is not None:
|
43
|
-
raise ValueError('bigquery_uri parameter is not supported in
|
44
|
+
raise ValueError('bigquery_uri parameter is not supported in Gemini API.')
|
44
45
|
|
45
46
|
return to_object
|
46
47
|
|
@@ -74,13 +75,13 @@ def _BatchJobDestination_to_mldev(
|
|
74
75
|
) -> dict:
|
75
76
|
to_object = {}
|
76
77
|
if getv(from_object, ['format']) is not None:
|
77
|
-
raise ValueError('format parameter is not supported in
|
78
|
+
raise ValueError('format parameter is not supported in Gemini API.')
|
78
79
|
|
79
80
|
if getv(from_object, ['gcs_uri']) is not None:
|
80
|
-
raise ValueError('gcs_uri parameter is not supported in
|
81
|
+
raise ValueError('gcs_uri parameter is not supported in Gemini API.')
|
81
82
|
|
82
83
|
if getv(from_object, ['bigquery_uri']) is not None:
|
83
|
-
raise ValueError('bigquery_uri parameter is not supported in
|
84
|
+
raise ValueError('bigquery_uri parameter is not supported in Gemini API.')
|
84
85
|
|
85
86
|
return to_object
|
86
87
|
|
@@ -117,14 +118,12 @@ def _CreateBatchJobConfig_to_mldev(
|
|
117
118
|
parent_object: dict = None,
|
118
119
|
) -> dict:
|
119
120
|
to_object = {}
|
120
|
-
if getv(from_object, ['http_options']) is not None:
|
121
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
122
121
|
|
123
122
|
if getv(from_object, ['display_name']) is not None:
|
124
123
|
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
125
124
|
|
126
125
|
if getv(from_object, ['dest']) is not None:
|
127
|
-
raise ValueError('dest parameter is not supported in
|
126
|
+
raise ValueError('dest parameter is not supported in Gemini API.')
|
128
127
|
|
129
128
|
return to_object
|
130
129
|
|
@@ -135,8 +134,6 @@ def _CreateBatchJobConfig_to_vertex(
|
|
135
134
|
parent_object: dict = None,
|
136
135
|
) -> dict:
|
137
136
|
to_object = {}
|
138
|
-
if getv(from_object, ['http_options']) is not None:
|
139
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
140
137
|
|
141
138
|
if getv(from_object, ['display_name']) is not None:
|
142
139
|
setv(parent_object, ['displayName'], getv(from_object, ['display_name']))
|
@@ -162,10 +159,10 @@ def _CreateBatchJobParameters_to_mldev(
|
|
162
159
|
) -> dict:
|
163
160
|
to_object = {}
|
164
161
|
if getv(from_object, ['model']) is not None:
|
165
|
-
raise ValueError('model parameter is not supported in
|
162
|
+
raise ValueError('model parameter is not supported in Gemini API.')
|
166
163
|
|
167
164
|
if getv(from_object, ['src']) is not None:
|
168
|
-
raise ValueError('src parameter is not supported in
|
165
|
+
raise ValueError('src parameter is not supported in Gemini API.')
|
169
166
|
|
170
167
|
if getv(from_object, ['config']) is not None:
|
171
168
|
setv(
|
@@ -215,30 +212,6 @@ def _CreateBatchJobParameters_to_vertex(
|
|
215
212
|
return to_object
|
216
213
|
|
217
214
|
|
218
|
-
def _GetBatchJobConfig_to_mldev(
|
219
|
-
api_client: ApiClient,
|
220
|
-
from_object: Union[dict, object],
|
221
|
-
parent_object: dict = None,
|
222
|
-
) -> dict:
|
223
|
-
to_object = {}
|
224
|
-
if getv(from_object, ['http_options']) is not None:
|
225
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
226
|
-
|
227
|
-
return to_object
|
228
|
-
|
229
|
-
|
230
|
-
def _GetBatchJobConfig_to_vertex(
|
231
|
-
api_client: ApiClient,
|
232
|
-
from_object: Union[dict, object],
|
233
|
-
parent_object: dict = None,
|
234
|
-
) -> dict:
|
235
|
-
to_object = {}
|
236
|
-
if getv(from_object, ['http_options']) is not None:
|
237
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
238
|
-
|
239
|
-
return to_object
|
240
|
-
|
241
|
-
|
242
215
|
def _GetBatchJobParameters_to_mldev(
|
243
216
|
api_client: ApiClient,
|
244
217
|
from_object: Union[dict, object],
|
@@ -246,16 +219,10 @@ def _GetBatchJobParameters_to_mldev(
|
|
246
219
|
) -> dict:
|
247
220
|
to_object = {}
|
248
221
|
if getv(from_object, ['name']) is not None:
|
249
|
-
raise ValueError('name parameter is not supported in
|
222
|
+
raise ValueError('name parameter is not supported in Gemini API.')
|
250
223
|
|
251
224
|
if getv(from_object, ['config']) is not None:
|
252
|
-
setv(
|
253
|
-
to_object,
|
254
|
-
['config'],
|
255
|
-
_GetBatchJobConfig_to_mldev(
|
256
|
-
api_client, getv(from_object, ['config']), to_object
|
257
|
-
),
|
258
|
-
)
|
225
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
259
226
|
|
260
227
|
return to_object
|
261
228
|
|
@@ -274,37 +241,7 @@ def _GetBatchJobParameters_to_vertex(
|
|
274
241
|
)
|
275
242
|
|
276
243
|
if getv(from_object, ['config']) is not None:
|
277
|
-
setv(
|
278
|
-
to_object,
|
279
|
-
['config'],
|
280
|
-
_GetBatchJobConfig_to_vertex(
|
281
|
-
api_client, getv(from_object, ['config']), to_object
|
282
|
-
),
|
283
|
-
)
|
284
|
-
|
285
|
-
return to_object
|
286
|
-
|
287
|
-
|
288
|
-
def _CancelBatchJobConfig_to_mldev(
|
289
|
-
api_client: ApiClient,
|
290
|
-
from_object: Union[dict, object],
|
291
|
-
parent_object: dict = None,
|
292
|
-
) -> dict:
|
293
|
-
to_object = {}
|
294
|
-
if getv(from_object, ['http_options']) is not None:
|
295
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
296
|
-
|
297
|
-
return to_object
|
298
|
-
|
299
|
-
|
300
|
-
def _CancelBatchJobConfig_to_vertex(
|
301
|
-
api_client: ApiClient,
|
302
|
-
from_object: Union[dict, object],
|
303
|
-
parent_object: dict = None,
|
304
|
-
) -> dict:
|
305
|
-
to_object = {}
|
306
|
-
if getv(from_object, ['http_options']) is not None:
|
307
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
244
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
308
245
|
|
309
246
|
return to_object
|
310
247
|
|
@@ -316,16 +253,10 @@ def _CancelBatchJobParameters_to_mldev(
|
|
316
253
|
) -> dict:
|
317
254
|
to_object = {}
|
318
255
|
if getv(from_object, ['name']) is not None:
|
319
|
-
raise ValueError('name parameter is not supported in
|
256
|
+
raise ValueError('name parameter is not supported in Gemini API.')
|
320
257
|
|
321
258
|
if getv(from_object, ['config']) is not None:
|
322
|
-
setv(
|
323
|
-
to_object,
|
324
|
-
['config'],
|
325
|
-
_CancelBatchJobConfig_to_mldev(
|
326
|
-
api_client, getv(from_object, ['config']), to_object
|
327
|
-
),
|
328
|
-
)
|
259
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
329
260
|
|
330
261
|
return to_object
|
331
262
|
|
@@ -344,25 +275,17 @@ def _CancelBatchJobParameters_to_vertex(
|
|
344
275
|
)
|
345
276
|
|
346
277
|
if getv(from_object, ['config']) is not None:
|
347
|
-
setv(
|
348
|
-
to_object,
|
349
|
-
['config'],
|
350
|
-
_CancelBatchJobConfig_to_vertex(
|
351
|
-
api_client, getv(from_object, ['config']), to_object
|
352
|
-
),
|
353
|
-
)
|
278
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
354
279
|
|
355
280
|
return to_object
|
356
281
|
|
357
282
|
|
358
|
-
def
|
283
|
+
def _ListBatchJobsConfig_to_mldev(
|
359
284
|
api_client: ApiClient,
|
360
285
|
from_object: Union[dict, object],
|
361
286
|
parent_object: dict = None,
|
362
287
|
) -> dict:
|
363
288
|
to_object = {}
|
364
|
-
if getv(from_object, ['http_options']) is not None:
|
365
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
366
289
|
|
367
290
|
if getv(from_object, ['page_size']) is not None:
|
368
291
|
setv(
|
@@ -377,19 +300,17 @@ def _ListBatchJobConfig_to_mldev(
|
|
377
300
|
)
|
378
301
|
|
379
302
|
if getv(from_object, ['filter']) is not None:
|
380
|
-
raise ValueError('filter parameter is not supported in
|
303
|
+
raise ValueError('filter parameter is not supported in Gemini API.')
|
381
304
|
|
382
305
|
return to_object
|
383
306
|
|
384
307
|
|
385
|
-
def
|
308
|
+
def _ListBatchJobsConfig_to_vertex(
|
386
309
|
api_client: ApiClient,
|
387
310
|
from_object: Union[dict, object],
|
388
311
|
parent_object: dict = None,
|
389
312
|
) -> dict:
|
390
313
|
to_object = {}
|
391
|
-
if getv(from_object, ['http_options']) is not None:
|
392
|
-
setv(to_object, ['httpOptions'], getv(from_object, ['http_options']))
|
393
314
|
|
394
315
|
if getv(from_object, ['page_size']) is not None:
|
395
316
|
setv(
|
@@ -409,19 +330,19 @@ def _ListBatchJobConfig_to_vertex(
|
|
409
330
|
return to_object
|
410
331
|
|
411
332
|
|
412
|
-
def
|
333
|
+
def _ListBatchJobsParameters_to_mldev(
|
413
334
|
api_client: ApiClient,
|
414
335
|
from_object: Union[dict, object],
|
415
336
|
parent_object: dict = None,
|
416
337
|
) -> dict:
|
417
338
|
to_object = {}
|
418
339
|
if getv(from_object, ['config']) is not None:
|
419
|
-
raise ValueError('config parameter is not supported in
|
340
|
+
raise ValueError('config parameter is not supported in Gemini API.')
|
420
341
|
|
421
342
|
return to_object
|
422
343
|
|
423
344
|
|
424
|
-
def
|
345
|
+
def _ListBatchJobsParameters_to_vertex(
|
425
346
|
api_client: ApiClient,
|
426
347
|
from_object: Union[dict, object],
|
427
348
|
parent_object: dict = None,
|
@@ -431,7 +352,7 @@ def _ListBatchJobParameters_to_vertex(
|
|
431
352
|
setv(
|
432
353
|
to_object,
|
433
354
|
['config'],
|
434
|
-
|
355
|
+
_ListBatchJobsConfig_to_vertex(
|
435
356
|
api_client, getv(from_object, ['config']), to_object
|
436
357
|
),
|
437
358
|
)
|
@@ -446,7 +367,10 @@ def _DeleteBatchJobParameters_to_mldev(
|
|
446
367
|
) -> dict:
|
447
368
|
to_object = {}
|
448
369
|
if getv(from_object, ['name']) is not None:
|
449
|
-
raise ValueError('name parameter is not supported in
|
370
|
+
raise ValueError('name parameter is not supported in Gemini API.')
|
371
|
+
|
372
|
+
if getv(from_object, ['config']) is not None:
|
373
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
450
374
|
|
451
375
|
return to_object
|
452
376
|
|
@@ -464,6 +388,9 @@ def _DeleteBatchJobParameters_to_vertex(
|
|
464
388
|
t.t_batch_job_name(api_client, getv(from_object, ['name'])),
|
465
389
|
)
|
466
390
|
|
391
|
+
if getv(from_object, ['config']) is not None:
|
392
|
+
setv(to_object, ['config'], getv(from_object, ['config']))
|
393
|
+
|
467
394
|
return to_object
|
468
395
|
|
469
396
|
|
@@ -633,7 +560,7 @@ def _BatchJob_from_vertex(
|
|
633
560
|
return to_object
|
634
561
|
|
635
562
|
|
636
|
-
def
|
563
|
+
def _ListBatchJobsResponse_from_mldev(
|
637
564
|
api_client: ApiClient,
|
638
565
|
from_object: Union[dict, object],
|
639
566
|
parent_object: dict = None,
|
@@ -645,7 +572,7 @@ def _ListBatchJobResponse_from_mldev(
|
|
645
572
|
return to_object
|
646
573
|
|
647
574
|
|
648
|
-
def
|
575
|
+
def _ListBatchJobsResponse_from_vertex(
|
649
576
|
api_client: ApiClient,
|
650
577
|
from_object: Union[dict, object],
|
651
578
|
parent_object: dict = None,
|
@@ -701,7 +628,7 @@ def _DeleteResourceJob_from_vertex(
|
|
701
628
|
return to_object
|
702
629
|
|
703
630
|
|
704
|
-
class Batches(
|
631
|
+
class Batches(_api_module.BaseModule):
|
705
632
|
|
706
633
|
def _create(
|
707
634
|
self,
|
@@ -728,8 +655,14 @@ class Batches(_common.BaseModule):
|
|
728
655
|
if query_params:
|
729
656
|
path = f'{path}?{urlencode(query_params)}'
|
730
657
|
# TODO: remove the hack that pops config.
|
731
|
-
|
732
|
-
|
658
|
+
request_dict.pop('config', None)
|
659
|
+
|
660
|
+
http_options = None
|
661
|
+
if isinstance(config, dict):
|
662
|
+
http_options = config.get('http_options', None)
|
663
|
+
elif hasattr(config, 'http_options'):
|
664
|
+
http_options = config.http_options
|
665
|
+
|
733
666
|
request_dict = _common.convert_to_dict(request_dict)
|
734
667
|
request_dict = _common.encode_unserializable_types(request_dict)
|
735
668
|
|
@@ -742,7 +675,9 @@ class Batches(_common.BaseModule):
|
|
742
675
|
else:
|
743
676
|
response_dict = _BatchJob_from_mldev(self._api_client, response_dict)
|
744
677
|
|
745
|
-
return_value = types.BatchJob._from_response(
|
678
|
+
return_value = types.BatchJob._from_response(
|
679
|
+
response=response_dict, kwargs=parameter_model
|
680
|
+
)
|
746
681
|
self._api_client._verify_response(return_value)
|
747
682
|
return return_value
|
748
683
|
|
@@ -784,8 +719,14 @@ class Batches(_common.BaseModule):
|
|
784
719
|
if query_params:
|
785
720
|
path = f'{path}?{urlencode(query_params)}'
|
786
721
|
# TODO: remove the hack that pops config.
|
787
|
-
|
788
|
-
|
722
|
+
request_dict.pop('config', None)
|
723
|
+
|
724
|
+
http_options = None
|
725
|
+
if isinstance(config, dict):
|
726
|
+
http_options = config.get('http_options', None)
|
727
|
+
elif hasattr(config, 'http_options'):
|
728
|
+
http_options = config.http_options
|
729
|
+
|
789
730
|
request_dict = _common.convert_to_dict(request_dict)
|
790
731
|
request_dict = _common.encode_unserializable_types(request_dict)
|
791
732
|
|
@@ -798,7 +739,9 @@ class Batches(_common.BaseModule):
|
|
798
739
|
else:
|
799
740
|
response_dict = _BatchJob_from_mldev(self._api_client, response_dict)
|
800
741
|
|
801
|
-
return_value = types.BatchJob._from_response(
|
742
|
+
return_value = types.BatchJob._from_response(
|
743
|
+
response=response_dict, kwargs=parameter_model
|
744
|
+
)
|
802
745
|
self._api_client._verify_response(return_value)
|
803
746
|
return return_value
|
804
747
|
|
@@ -808,6 +751,22 @@ class Batches(_common.BaseModule):
|
|
808
751
|
name: str,
|
809
752
|
config: Optional[types.CancelBatchJobConfigOrDict] = None,
|
810
753
|
) -> None:
|
754
|
+
"""Cancels a batch job.
|
755
|
+
|
756
|
+
Only available for batch jobs that are running or pending.
|
757
|
+
|
758
|
+
Args:
|
759
|
+
name (str): A fully-qualified BatchJob resource name or ID.
|
760
|
+
Example: "projects/.../locations/.../batchPredictionJobs/123456789" or
|
761
|
+
"123456789" when project and location are initialized in the client.
|
762
|
+
|
763
|
+
Usage:
|
764
|
+
|
765
|
+
.. code-block:: python
|
766
|
+
|
767
|
+
client.batches.cancel(name='123456789')
|
768
|
+
"""
|
769
|
+
|
811
770
|
parameter_model = types._CancelBatchJobParameters(
|
812
771
|
name=name,
|
813
772
|
config=config,
|
@@ -827,8 +786,14 @@ class Batches(_common.BaseModule):
|
|
827
786
|
if query_params:
|
828
787
|
path = f'{path}?{urlencode(query_params)}'
|
829
788
|
# TODO: remove the hack that pops config.
|
830
|
-
|
831
|
-
|
789
|
+
request_dict.pop('config', None)
|
790
|
+
|
791
|
+
http_options = None
|
792
|
+
if isinstance(config, dict):
|
793
|
+
http_options = config.get('http_options', None)
|
794
|
+
elif hasattr(config, 'http_options'):
|
795
|
+
http_options = config.http_options
|
796
|
+
|
832
797
|
request_dict = _common.convert_to_dict(request_dict)
|
833
798
|
request_dict = _common.encode_unserializable_types(request_dict)
|
834
799
|
|
@@ -837,16 +802,16 @@ class Batches(_common.BaseModule):
|
|
837
802
|
)
|
838
803
|
|
839
804
|
def _list(
|
840
|
-
self, *, config: types.
|
841
|
-
) -> types.
|
842
|
-
parameter_model = types.
|
805
|
+
self, *, config: types.ListBatchJobsConfigOrDict
|
806
|
+
) -> types.ListBatchJobsResponse:
|
807
|
+
parameter_model = types._ListBatchJobsParameters(
|
843
808
|
config=config,
|
844
809
|
)
|
845
810
|
|
846
811
|
if not self._api_client.vertexai:
|
847
812
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
848
813
|
else:
|
849
|
-
request_dict =
|
814
|
+
request_dict = _ListBatchJobsParameters_to_vertex(
|
850
815
|
self._api_client, parameter_model
|
851
816
|
)
|
852
817
|
path = 'batchPredictionJobs'.format_map(request_dict.get('_url'))
|
@@ -855,8 +820,14 @@ class Batches(_common.BaseModule):
|
|
855
820
|
if query_params:
|
856
821
|
path = f'{path}?{urlencode(query_params)}'
|
857
822
|
# TODO: remove the hack that pops config.
|
858
|
-
|
859
|
-
|
823
|
+
request_dict.pop('config', None)
|
824
|
+
|
825
|
+
http_options = None
|
826
|
+
if isinstance(config, dict):
|
827
|
+
http_options = config.get('http_options', None)
|
828
|
+
elif hasattr(config, 'http_options'):
|
829
|
+
http_options = config.http_options
|
830
|
+
|
860
831
|
request_dict = _common.convert_to_dict(request_dict)
|
861
832
|
request_dict = _common.encode_unserializable_types(request_dict)
|
862
833
|
|
@@ -865,21 +836,26 @@ class Batches(_common.BaseModule):
|
|
865
836
|
)
|
866
837
|
|
867
838
|
if self._api_client.vertexai:
|
868
|
-
response_dict =
|
839
|
+
response_dict = _ListBatchJobsResponse_from_vertex(
|
869
840
|
self._api_client, response_dict
|
870
841
|
)
|
871
842
|
else:
|
872
|
-
response_dict =
|
843
|
+
response_dict = _ListBatchJobsResponse_from_mldev(
|
873
844
|
self._api_client, response_dict
|
874
845
|
)
|
875
846
|
|
876
|
-
return_value = types.
|
877
|
-
response_dict, parameter_model
|
847
|
+
return_value = types.ListBatchJobsResponse._from_response(
|
848
|
+
response=response_dict, kwargs=parameter_model
|
878
849
|
)
|
879
850
|
self._api_client._verify_response(return_value)
|
880
851
|
return return_value
|
881
852
|
|
882
|
-
def delete(
|
853
|
+
def delete(
|
854
|
+
self,
|
855
|
+
*,
|
856
|
+
name: str,
|
857
|
+
config: Optional[types.DeleteBatchJobConfigOrDict] = None,
|
858
|
+
) -> types.DeleteResourceJob:
|
883
859
|
"""Deletes a batch job.
|
884
860
|
|
885
861
|
Args:
|
@@ -899,6 +875,7 @@ class Batches(_common.BaseModule):
|
|
899
875
|
|
900
876
|
parameter_model = types._DeleteBatchJobParameters(
|
901
877
|
name=name,
|
878
|
+
config=config,
|
902
879
|
)
|
903
880
|
|
904
881
|
if not self._api_client.vertexai:
|
@@ -913,8 +890,14 @@ class Batches(_common.BaseModule):
|
|
913
890
|
if query_params:
|
914
891
|
path = f'{path}?{urlencode(query_params)}'
|
915
892
|
# TODO: remove the hack that pops config.
|
916
|
-
|
917
|
-
|
893
|
+
request_dict.pop('config', None)
|
894
|
+
|
895
|
+
http_options = None
|
896
|
+
if isinstance(config, dict):
|
897
|
+
http_options = config.get('http_options', None)
|
898
|
+
elif hasattr(config, 'http_options'):
|
899
|
+
http_options = config.http_options
|
900
|
+
|
918
901
|
request_dict = _common.convert_to_dict(request_dict)
|
919
902
|
request_dict = _common.encode_unserializable_types(request_dict)
|
920
903
|
|
@@ -932,7 +915,7 @@ class Batches(_common.BaseModule):
|
|
932
915
|
)
|
933
916
|
|
934
917
|
return_value = types.DeleteResourceJob._from_response(
|
935
|
-
response_dict, parameter_model
|
918
|
+
response=response_dict, kwargs=parameter_model
|
936
919
|
)
|
937
920
|
self._api_client._verify_response(return_value)
|
938
921
|
return return_value
|
@@ -970,12 +953,12 @@ class Batches(_common.BaseModule):
|
|
970
953
|
return self._create(model=model, src=src, config=config)
|
971
954
|
|
972
955
|
def list(
|
973
|
-
self, *, config: Optional[types.
|
956
|
+
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
974
957
|
) -> Pager[types.BatchJob]:
|
975
958
|
"""Lists batch jobs.
|
976
959
|
|
977
960
|
Args:
|
978
|
-
config (
|
961
|
+
config (ListBatchJobsConfig): Optional configuration for the list request.
|
979
962
|
|
980
963
|
Returns:
|
981
964
|
A Pager object that contains one page of batch jobs. When iterating over
|
@@ -997,7 +980,7 @@ class Batches(_common.BaseModule):
|
|
997
980
|
)
|
998
981
|
|
999
982
|
|
1000
|
-
class AsyncBatches(
|
983
|
+
class AsyncBatches(_api_module.BaseModule):
|
1001
984
|
|
1002
985
|
async def _create(
|
1003
986
|
self,
|
@@ -1024,8 +1007,14 @@ class AsyncBatches(_common.BaseModule):
|
|
1024
1007
|
if query_params:
|
1025
1008
|
path = f'{path}?{urlencode(query_params)}'
|
1026
1009
|
# TODO: remove the hack that pops config.
|
1027
|
-
|
1028
|
-
|
1010
|
+
request_dict.pop('config', None)
|
1011
|
+
|
1012
|
+
http_options = None
|
1013
|
+
if isinstance(config, dict):
|
1014
|
+
http_options = config.get('http_options', None)
|
1015
|
+
elif hasattr(config, 'http_options'):
|
1016
|
+
http_options = config.http_options
|
1017
|
+
|
1029
1018
|
request_dict = _common.convert_to_dict(request_dict)
|
1030
1019
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1031
1020
|
|
@@ -1038,7 +1027,9 @@ class AsyncBatches(_common.BaseModule):
|
|
1038
1027
|
else:
|
1039
1028
|
response_dict = _BatchJob_from_mldev(self._api_client, response_dict)
|
1040
1029
|
|
1041
|
-
return_value = types.BatchJob._from_response(
|
1030
|
+
return_value = types.BatchJob._from_response(
|
1031
|
+
response=response_dict, kwargs=parameter_model
|
1032
|
+
)
|
1042
1033
|
self._api_client._verify_response(return_value)
|
1043
1034
|
return return_value
|
1044
1035
|
|
@@ -1080,8 +1071,14 @@ class AsyncBatches(_common.BaseModule):
|
|
1080
1071
|
if query_params:
|
1081
1072
|
path = f'{path}?{urlencode(query_params)}'
|
1082
1073
|
# TODO: remove the hack that pops config.
|
1083
|
-
|
1084
|
-
|
1074
|
+
request_dict.pop('config', None)
|
1075
|
+
|
1076
|
+
http_options = None
|
1077
|
+
if isinstance(config, dict):
|
1078
|
+
http_options = config.get('http_options', None)
|
1079
|
+
elif hasattr(config, 'http_options'):
|
1080
|
+
http_options = config.http_options
|
1081
|
+
|
1085
1082
|
request_dict = _common.convert_to_dict(request_dict)
|
1086
1083
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1087
1084
|
|
@@ -1094,7 +1091,9 @@ class AsyncBatches(_common.BaseModule):
|
|
1094
1091
|
else:
|
1095
1092
|
response_dict = _BatchJob_from_mldev(self._api_client, response_dict)
|
1096
1093
|
|
1097
|
-
return_value = types.BatchJob._from_response(
|
1094
|
+
return_value = types.BatchJob._from_response(
|
1095
|
+
response=response_dict, kwargs=parameter_model
|
1096
|
+
)
|
1098
1097
|
self._api_client._verify_response(return_value)
|
1099
1098
|
return return_value
|
1100
1099
|
|
@@ -1104,6 +1103,22 @@ class AsyncBatches(_common.BaseModule):
|
|
1104
1103
|
name: str,
|
1105
1104
|
config: Optional[types.CancelBatchJobConfigOrDict] = None,
|
1106
1105
|
) -> None:
|
1106
|
+
"""Cancels a batch job.
|
1107
|
+
|
1108
|
+
Only available for batch jobs that are running or pending.
|
1109
|
+
|
1110
|
+
Args:
|
1111
|
+
name (str): A fully-qualified BatchJob resource name or ID.
|
1112
|
+
Example: "projects/.../locations/.../batchPredictionJobs/123456789" or
|
1113
|
+
"123456789" when project and location are initialized in the client.
|
1114
|
+
|
1115
|
+
Usage:
|
1116
|
+
|
1117
|
+
.. code-block:: python
|
1118
|
+
|
1119
|
+
client.batches.cancel(name='123456789')
|
1120
|
+
"""
|
1121
|
+
|
1107
1122
|
parameter_model = types._CancelBatchJobParameters(
|
1108
1123
|
name=name,
|
1109
1124
|
config=config,
|
@@ -1123,8 +1138,14 @@ class AsyncBatches(_common.BaseModule):
|
|
1123
1138
|
if query_params:
|
1124
1139
|
path = f'{path}?{urlencode(query_params)}'
|
1125
1140
|
# TODO: remove the hack that pops config.
|
1126
|
-
|
1127
|
-
|
1141
|
+
request_dict.pop('config', None)
|
1142
|
+
|
1143
|
+
http_options = None
|
1144
|
+
if isinstance(config, dict):
|
1145
|
+
http_options = config.get('http_options', None)
|
1146
|
+
elif hasattr(config, 'http_options'):
|
1147
|
+
http_options = config.http_options
|
1148
|
+
|
1128
1149
|
request_dict = _common.convert_to_dict(request_dict)
|
1129
1150
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1130
1151
|
|
@@ -1133,16 +1154,16 @@ class AsyncBatches(_common.BaseModule):
|
|
1133
1154
|
)
|
1134
1155
|
|
1135
1156
|
async def _list(
|
1136
|
-
self, *, config: types.
|
1137
|
-
) -> types.
|
1138
|
-
parameter_model = types.
|
1157
|
+
self, *, config: types.ListBatchJobsConfigOrDict
|
1158
|
+
) -> types.ListBatchJobsResponse:
|
1159
|
+
parameter_model = types._ListBatchJobsParameters(
|
1139
1160
|
config=config,
|
1140
1161
|
)
|
1141
1162
|
|
1142
1163
|
if not self._api_client.vertexai:
|
1143
1164
|
raise ValueError('This method is only supported in the Vertex AI client.')
|
1144
1165
|
else:
|
1145
|
-
request_dict =
|
1166
|
+
request_dict = _ListBatchJobsParameters_to_vertex(
|
1146
1167
|
self._api_client, parameter_model
|
1147
1168
|
)
|
1148
1169
|
path = 'batchPredictionJobs'.format_map(request_dict.get('_url'))
|
@@ -1151,8 +1172,14 @@ class AsyncBatches(_common.BaseModule):
|
|
1151
1172
|
if query_params:
|
1152
1173
|
path = f'{path}?{urlencode(query_params)}'
|
1153
1174
|
# TODO: remove the hack that pops config.
|
1154
|
-
|
1155
|
-
|
1175
|
+
request_dict.pop('config', None)
|
1176
|
+
|
1177
|
+
http_options = None
|
1178
|
+
if isinstance(config, dict):
|
1179
|
+
http_options = config.get('http_options', None)
|
1180
|
+
elif hasattr(config, 'http_options'):
|
1181
|
+
http_options = config.http_options
|
1182
|
+
|
1156
1183
|
request_dict = _common.convert_to_dict(request_dict)
|
1157
1184
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1158
1185
|
|
@@ -1161,21 +1188,26 @@ class AsyncBatches(_common.BaseModule):
|
|
1161
1188
|
)
|
1162
1189
|
|
1163
1190
|
if self._api_client.vertexai:
|
1164
|
-
response_dict =
|
1191
|
+
response_dict = _ListBatchJobsResponse_from_vertex(
|
1165
1192
|
self._api_client, response_dict
|
1166
1193
|
)
|
1167
1194
|
else:
|
1168
|
-
response_dict =
|
1195
|
+
response_dict = _ListBatchJobsResponse_from_mldev(
|
1169
1196
|
self._api_client, response_dict
|
1170
1197
|
)
|
1171
1198
|
|
1172
|
-
return_value = types.
|
1173
|
-
response_dict, parameter_model
|
1199
|
+
return_value = types.ListBatchJobsResponse._from_response(
|
1200
|
+
response=response_dict, kwargs=parameter_model
|
1174
1201
|
)
|
1175
1202
|
self._api_client._verify_response(return_value)
|
1176
1203
|
return return_value
|
1177
1204
|
|
1178
|
-
async def delete(
|
1205
|
+
async def delete(
|
1206
|
+
self,
|
1207
|
+
*,
|
1208
|
+
name: str,
|
1209
|
+
config: Optional[types.DeleteBatchJobConfigOrDict] = None,
|
1210
|
+
) -> types.DeleteResourceJob:
|
1179
1211
|
"""Deletes a batch job.
|
1180
1212
|
|
1181
1213
|
Args:
|
@@ -1195,6 +1227,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1195
1227
|
|
1196
1228
|
parameter_model = types._DeleteBatchJobParameters(
|
1197
1229
|
name=name,
|
1230
|
+
config=config,
|
1198
1231
|
)
|
1199
1232
|
|
1200
1233
|
if not self._api_client.vertexai:
|
@@ -1209,8 +1242,14 @@ class AsyncBatches(_common.BaseModule):
|
|
1209
1242
|
if query_params:
|
1210
1243
|
path = f'{path}?{urlencode(query_params)}'
|
1211
1244
|
# TODO: remove the hack that pops config.
|
1212
|
-
|
1213
|
-
|
1245
|
+
request_dict.pop('config', None)
|
1246
|
+
|
1247
|
+
http_options = None
|
1248
|
+
if isinstance(config, dict):
|
1249
|
+
http_options = config.get('http_options', None)
|
1250
|
+
elif hasattr(config, 'http_options'):
|
1251
|
+
http_options = config.http_options
|
1252
|
+
|
1214
1253
|
request_dict = _common.convert_to_dict(request_dict)
|
1215
1254
|
request_dict = _common.encode_unserializable_types(request_dict)
|
1216
1255
|
|
@@ -1228,7 +1267,7 @@ class AsyncBatches(_common.BaseModule):
|
|
1228
1267
|
)
|
1229
1268
|
|
1230
1269
|
return_value = types.DeleteResourceJob._from_response(
|
1231
|
-
response_dict, parameter_model
|
1270
|
+
response=response_dict, kwargs=parameter_model
|
1232
1271
|
)
|
1233
1272
|
self._api_client._verify_response(return_value)
|
1234
1273
|
return return_value
|
@@ -1265,12 +1304,12 @@ class AsyncBatches(_common.BaseModule):
|
|
1265
1304
|
return await self._create(model=model, src=src, config=config)
|
1266
1305
|
|
1267
1306
|
async def list(
|
1268
|
-
self, *, config: Optional[types.
|
1307
|
+
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
|
1269
1308
|
) -> AsyncPager[types.BatchJob]:
|
1270
1309
|
"""Lists batch jobs asynchronously.
|
1271
1310
|
|
1272
1311
|
Args:
|
1273
|
-
config (
|
1312
|
+
config (ListBatchJobsConfig): Optional configuration for the list request.
|
1274
1313
|
|
1275
1314
|
Returns:
|
1276
1315
|
A Pager object that contains one page of batch jobs. When iterating over
|