17
17
18
18
import datetime
19
19
import time
20
- from typing import Dict , List , Optional , Sequence , Tuple , Union
20
+ from typing import Dict , List , Literal , Optional , Sequence , Tuple , Union
21
21
from google .protobuf import json_format
22
22
23
23
import abc
@@ -1404,6 +1404,11 @@ def _prepare_and_validate_run(
1404
1404
reduction_server_replica_count : int = 0 ,
1405
1405
reduction_server_machine_type : Optional [str ] = None ,
1406
1406
tpu_topology : Optional [str ] = None ,
1407
+ reservation_affinity_type : Optional [
1408
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
1409
+ ] = None ,
1410
+ reservation_affinity_key : Optional [str ] = None ,
1411
+ reservation_affinity_values : Optional [List [str ]] = None ,
1407
1412
) -> Tuple [worker_spec_utils ._DistributedTrainingSpec , Optional [gca_model .Model ]]:
1408
1413
"""Create worker pool specs and managed model as well validating the
1409
1414
run.
@@ -1451,6 +1456,23 @@ def _prepare_and_validate_run(
1451
1456
tpu_topology (str):
1452
1457
Optional. Only required if the machine type is a TPU
1453
1458
v5 version.
1459
+ reservation_affinity_type (str):
1460
+ Optional. The type of reservation affinity. One of:
1461
+ * "NO_RESERVATION" : No reservation is used.
1462
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
1463
+ can be used.
1464
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
1465
+ used. See reservation_affinity_key and
1466
+ reservation_affinity_values for how to specify the reservation.
1467
+ reservation_affinity_key (str):
1468
+ Optional. Corresponds to the label key of a reservation resource.
1469
+ To target a SPECIFIC_RESERVATION by name, use
1470
+ `compute.googleapis.com/reservation-name` as the key
1471
+ and specify the name of your reservation as its value.
1472
+ reservation_affinity_values (List[str]):
1473
+ Optional. Corresponds to the label values of a reservation resource.
1474
+ This must be the full resource name of the reservation.
1475
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
1454
1476
1455
1477
Returns:
1456
1478
Worker pools specs and managed model for run.
@@ -1490,6 +1512,9 @@ def _prepare_and_validate_run(
1490
1512
reduction_server_replica_count = reduction_server_replica_count ,
1491
1513
reduction_server_machine_type = reduction_server_machine_type ,
1492
1514
tpu_topology = tpu_topology ,
1515
+ reservation_affinity_type = reservation_affinity_type ,
1516
+ reservation_affinity_key = reservation_affinity_key ,
1517
+ reservation_affinity_values = reservation_affinity_values ,
1493
1518
).pool_specs
1494
1519
)
1495
1520
@@ -3016,6 +3041,11 @@ def run(
3016
3041
persistent_resource_id : Optional [str ] = None ,
3017
3042
tpu_topology : Optional [str ] = None ,
3018
3043
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
3044
+ reservation_affinity_type : Optional [
3045
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
3046
+ ] = None ,
3047
+ reservation_affinity_key : Optional [str ] = None ,
3048
+ reservation_affinity_values : Optional [List [str ]] = None ,
3019
3049
) -> Optional [models .Model ]:
3020
3050
"""Runs the custom training job.
3021
3051
@@ -3373,6 +3403,23 @@ def run(
3373
3403
be a supported value for the TPU machine type.
3374
3404
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
3375
3405
Optional. Indicates the job scheduling strategy.
3406
+ reservation_affinity_type (str):
3407
+ Optional. The type of reservation affinity. One of:
3408
+ * "NO_RESERVATION" : No reservation is used.
3409
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
3410
+ can be used.
3411
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
3412
+ used. See reservation_affinity_key and
3413
+ reservation_affinity_values for how to specify the reservation.
3414
+ reservation_affinity_key (str):
3415
+ Optional. Corresponds to the label key of a reservation resource.
3416
+ To target a SPECIFIC_RESERVATION by name, use
3417
+ `compute.googleapis.com/reservation-name` as the key
3418
+ and specify the name of your reservation as its value.
3419
+ reservation_affinity_values (List[str]):
3420
+ Optional. Corresponds to the label values of a reservation resource.
3421
+ This must be the full resource name of the reservation.
3422
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
3376
3423
3377
3424
Returns:
3378
3425
The trained Vertex AI model resource or None if the training
@@ -3393,6 +3440,9 @@ def run(
3393
3440
reduction_server_replica_count = reduction_server_replica_count ,
3394
3441
reduction_server_machine_type = reduction_server_machine_type ,
3395
3442
tpu_topology = tpu_topology ,
3443
+ reservation_affinity_type = reservation_affinity_type ,
3444
+ reservation_affinity_key = reservation_affinity_key ,
3445
+ reservation_affinity_values = reservation_affinity_values ,
3396
3446
)
3397
3447
3398
3448
# make and copy package
@@ -3430,9 +3480,11 @@ def run(
3430
3480
enable_web_access = enable_web_access ,
3431
3481
enable_dashboard_access = enable_dashboard_access ,
3432
3482
tensorboard = tensorboard ,
3433
- reduction_server_container_uri = reduction_server_container_uri
3434
- if reduction_server_replica_count > 0
3435
- else None ,
3483
+ reduction_server_container_uri = (
3484
+ reduction_server_container_uri
3485
+ if reduction_server_replica_count > 0
3486
+ else None
3487
+ ),
3436
3488
sync = sync ,
3437
3489
create_request_timeout = create_request_timeout ,
3438
3490
disable_retries = disable_retries ,
@@ -3492,6 +3544,11 @@ def submit(
3492
3544
persistent_resource_id : Optional [str ] = None ,
3493
3545
tpu_topology : Optional [str ] = None ,
3494
3546
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
3547
+ reservation_affinity_type : Optional [
3548
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
3549
+ ] = None ,
3550
+ reservation_affinity_key : Optional [str ] = None ,
3551
+ reservation_affinity_values : Optional [List [str ]] = None ,
3495
3552
) -> Optional [models .Model ]:
3496
3553
"""Submits the custom training job without blocking until completion.
3497
3554
@@ -3794,6 +3851,23 @@ def submit(
3794
3851
be a supported value for the TPU machine type.
3795
3852
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
3796
3853
Optional. Indicates the job scheduling strategy.
3854
+ reservation_affinity_type (str):
3855
+ Optional. The type of reservation affinity. One of:
3856
+ * "NO_RESERVATION" : No reservation is used.
3857
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
3858
+ can be used.
3859
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
3860
+ used. See reservation_affinity_key and
3861
+ reservation_affinity_values for how to specify the reservation.
3862
+ reservation_affinity_key (str):
3863
+ Optional. Corresponds to the label key of a reservation resource.
3864
+ To target a SPECIFIC_RESERVATION by name, use
3865
+ `compute.googleapis.com/reservation-name` as the key
3866
+ and specify the name of your reservation as its value.
3867
+ reservation_affinity_values (List[str]):
3868
+ Optional. Corresponds to the label values of a reservation resource.
3869
+ This must be the full resource name of the reservation.
3870
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
3797
3871
3798
3872
Returns:
3799
3873
model: The trained Vertex AI Model resource or None if training did not
@@ -3813,6 +3887,9 @@ def submit(
3813
3887
reduction_server_replica_count = reduction_server_replica_count ,
3814
3888
reduction_server_machine_type = reduction_server_machine_type ,
3815
3889
tpu_topology = tpu_topology ,
3890
+ reservation_affinity_type = reservation_affinity_type ,
3891
+ reservation_affinity_key = reservation_affinity_key ,
3892
+ reservation_affinity_values = reservation_affinity_values ,
3816
3893
)
3817
3894
3818
3895
# make and copy package
@@ -3850,9 +3927,11 @@ def submit(
3850
3927
enable_web_access = enable_web_access ,
3851
3928
enable_dashboard_access = enable_dashboard_access ,
3852
3929
tensorboard = tensorboard ,
3853
- reduction_server_container_uri = reduction_server_container_uri
3854
- if reduction_server_replica_count > 0
3855
- else None ,
3930
+ reduction_server_container_uri = (
3931
+ reduction_server_container_uri
3932
+ if reduction_server_replica_count > 0
3933
+ else None
3934
+ ),
3856
3935
sync = sync ,
3857
3936
create_request_timeout = create_request_timeout ,
3858
3937
block = False ,
@@ -4485,6 +4564,11 @@ def run(
4485
4564
persistent_resource_id : Optional [str ] = None ,
4486
4565
tpu_topology : Optional [str ] = None ,
4487
4566
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
4567
+ reservation_affinity_type : Optional [
4568
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
4569
+ ] = None ,
4570
+ reservation_affinity_key : Optional [str ] = None ,
4571
+ reservation_affinity_values : Optional [List [str ]] = None ,
4488
4572
) -> Optional [models .Model ]:
4489
4573
"""Runs the custom training job.
4490
4574
@@ -4780,6 +4864,23 @@ def run(
4780
4864
must be a supported value for the TPU machine type.
4781
4865
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
4782
4866
Optional. Indicates the job scheduling strategy.
4867
+ reservation_affinity_type (str):
4868
+ Optional. The type of reservation affinity. One of:
4869
+ * "NO_RESERVATION" : No reservation is used.
4870
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
4871
+ can be used.
4872
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
4873
+ used. See reservation_affinity_key and
4874
+ reservation_affinity_values for how to specify the reservation.
4875
+ reservation_affinity_key (str):
4876
+ Optional. Corresponds to the label key of a reservation resource.
4877
+ To target a SPECIFIC_RESERVATION by name, use
4878
+ `compute.googleapis.com/reservation-name` as the key
4879
+ and specify the name of your reservation as its value.
4880
+ reservation_affinity_values (List[str]):
4881
+ Optional. Corresponds to the label values of a reservation resource.
4882
+ This must be the full resource name of the reservation.
4883
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
4783
4884
4784
4885
Returns:
4785
4886
model: The trained Vertex AI Model resource or None if training did not
@@ -4805,6 +4906,9 @@ def run(
4805
4906
reduction_server_replica_count = reduction_server_replica_count ,
4806
4907
reduction_server_machine_type = reduction_server_machine_type ,
4807
4908
tpu_topology = tpu_topology ,
4909
+ reservation_affinity_type = reservation_affinity_type ,
4910
+ reservation_affinity_key = reservation_affinity_key ,
4911
+ reservation_affinity_values = reservation_affinity_values ,
4808
4912
)
4809
4913
4810
4914
return self ._run (
@@ -4836,9 +4940,11 @@ def run(
4836
4940
enable_web_access = enable_web_access ,
4837
4941
enable_dashboard_access = enable_dashboard_access ,
4838
4942
tensorboard = tensorboard ,
4839
- reduction_server_container_uri = reduction_server_container_uri
4840
- if reduction_server_replica_count > 0
4841
- else None ,
4943
+ reduction_server_container_uri = (
4944
+ reduction_server_container_uri
4945
+ if reduction_server_replica_count > 0
4946
+ else None
4947
+ ),
4842
4948
sync = sync ,
4843
4949
create_request_timeout = create_request_timeout ,
4844
4950
disable_retries = disable_retries ,
@@ -4898,6 +5004,11 @@ def submit(
4898
5004
persistent_resource_id : Optional [str ] = None ,
4899
5005
tpu_topology : Optional [str ] = None ,
4900
5006
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
5007
+ reservation_affinity_type : Optional [
5008
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
5009
+ ] = None ,
5010
+ reservation_affinity_key : Optional [str ] = None ,
5011
+ reservation_affinity_values : Optional [List [str ]] = None ,
4901
5012
) -> Optional [models .Model ]:
4902
5013
"""Submits the custom training job without blocking until completion.
4903
5014
@@ -5193,6 +5304,23 @@ def submit(
5193
5304
must be a supported value for the TPU machine type.
5194
5305
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
5195
5306
Optional. Indicates the job scheduling strategy.
5307
+ reservation_affinity_type (str):
5308
+ Optional. The type of reservation affinity. One of:
5309
+ * "NO_RESERVATION" : No reservation is used.
5310
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
5311
+ can be used.
5312
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
5313
+ used. See reservation_affinity_key and
5314
+ reservation_affinity_values for how to specify the reservation.
5315
+ reservation_affinity_key (str):
5316
+ Optional. Corresponds to the label key of a reservation resource.
5317
+ To target a SPECIFIC_RESERVATION by name, use
5318
+ `compute.googleapis.com/reservation-name` as the key
5319
+ and specify the name of your reservation as its value.
5320
+ reservation_affinity_values (List[str]):
5321
+ Optional. Corresponds to the label values of a reservation resource.
5322
+ This must be the full resource name of the reservation.
5323
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
5196
5324
5197
5325
Returns:
5198
5326
model: The trained Vertex AI Model resource or None if training did not
@@ -5217,6 +5345,9 @@ def submit(
5217
5345
reduction_server_replica_count = reduction_server_replica_count ,
5218
5346
reduction_server_machine_type = reduction_server_machine_type ,
5219
5347
tpu_topology = tpu_topology ,
5348
+ reservation_affinity_type = reservation_affinity_type ,
5349
+ reservation_affinity_key = reservation_affinity_key ,
5350
+ reservation_affinity_values = reservation_affinity_values ,
5220
5351
)
5221
5352
5222
5353
return self ._run (
@@ -5248,9 +5379,11 @@ def submit(
5248
5379
enable_web_access = enable_web_access ,
5249
5380
enable_dashboard_access = enable_dashboard_access ,
5250
5381
tensorboard = tensorboard ,
5251
- reduction_server_container_uri = reduction_server_container_uri
5252
- if reduction_server_replica_count > 0
5253
- else None ,
5382
+ reduction_server_container_uri = (
5383
+ reduction_server_container_uri
5384
+ if reduction_server_replica_count > 0
5385
+ else None
5386
+ ),
5254
5387
sync = sync ,
5255
5388
create_request_timeout = create_request_timeout ,
5256
5389
block = False ,
@@ -7572,6 +7705,11 @@ def run(
7572
7705
persistent_resource_id : Optional [str ] = None ,
7573
7706
tpu_topology : Optional [str ] = None ,
7574
7707
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
7708
+ reservation_affinity_type : Optional [
7709
+ Literal ["NO_RESERVATION" , "ANY_RESERVATION" , "SPECIFIC_RESERVATION" ]
7710
+ ] = None ,
7711
+ reservation_affinity_key : Optional [str ] = None ,
7712
+ reservation_affinity_values : Optional [List [str ]] = None ,
7575
7713
) -> Optional [models .Model ]:
7576
7714
"""Runs the custom training job.
7577
7715
@@ -7868,6 +8006,23 @@ def run(
7868
8006
must be a supported value for the TPU machine type.
7869
8007
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
7870
8008
Optional. Indicates the job scheduling strategy.
8009
+ reservation_affinity_type (str):
8010
+ Optional. The type of reservation affinity. One of:
8011
+ * "NO_RESERVATION" : No reservation is used.
8012
+ * "ANY_RESERVATION" : Any reservation that matches machine spec
8013
+ can be used.
8014
+ * "SPECIFIC_RESERVATION" : A specific reservation must be use
8015
+ used. See reservation_affinity_key and
8016
+ reservation_affinity_values for how to specify the reservation.
8017
+ reservation_affinity_key (str):
8018
+ Optional. Corresponds to the label key of a reservation resource.
8019
+ To target a SPECIFIC_RESERVATION by name, use
8020
+ `compute.googleapis.com/reservation-name` as the key
8021
+ and specify the name of your reservation as its value.
8022
+ reservation_affinity_values (List[str]):
8023
+ Optional. Corresponds to the label values of a reservation resource.
8024
+ This must be the full resource name of the reservation.
8025
+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
7871
8026
7872
8027
Returns:
7873
8028
model: The trained Vertex AI Model resource or None if training did not
@@ -7888,6 +8043,9 @@ def run(
7888
8043
reduction_server_replica_count = reduction_server_replica_count ,
7889
8044
reduction_server_machine_type = reduction_server_machine_type ,
7890
8045
tpu_topology = tpu_topology ,
8046
+ reservation_affinity_type = reservation_affinity_type ,
8047
+ reservation_affinity_key = reservation_affinity_key ,
8048
+ reservation_affinity_values = reservation_affinity_values ,
7891
8049
)
7892
8050
7893
8051
return self ._run (
@@ -7919,9 +8077,11 @@ def run(
7919
8077
enable_web_access = enable_web_access ,
7920
8078
enable_dashboard_access = enable_dashboard_access ,
7921
8079
tensorboard = tensorboard ,
7922
- reduction_server_container_uri = reduction_server_container_uri
7923
- if reduction_server_replica_count > 0
7924
- else None ,
8080
+ reduction_server_container_uri = (
8081
+ reduction_server_container_uri
8082
+ if reduction_server_replica_count > 0
8083
+ else None
8084
+ ),
7925
8085
sync = sync ,
7926
8086
create_request_timeout = create_request_timeout ,
7927
8087
disable_retries = disable_retries ,
0 commit comments