@@ -319,7 +319,7 @@ def cancel(self) -> None:
319319 getattr (self .api_client , self ._cancel_method )(name = self .resource_name )
320320
321321
322- class BatchPredictionJob (_Job ):
322+ class BatchPredictionJob (_Job , base . PreviewMixin ):
323323
324324 _resource_noun = "batchPredictionJobs"
325325 _getter_method = "get_batch_prediction_job"
@@ -329,6 +329,7 @@ class BatchPredictionJob(_Job):
329329 _job_type = "batch-predictions"
330330 _parse_resource_name_method = "parse_batch_prediction_job_path"
331331 _format_resource_name_method = "batch_prediction_job_path"
332+ _preview_class = "google.cloud.aiplatform.aiplatform.preview.jobs.BatchPredictionJob"
332333
333334 def __init__ (
334335 self ,
@@ -949,6 +950,9 @@ def _submit_impl(
949950 ] = None ,
950951 analysis_instance_schema_uri : Optional [str ] = None ,
951952 service_account : Optional [str ] = None ,
953+ reservation_affinity_type : Optional [str ] = None ,
954+ reservation_affinity_key : Optional [str ] = None ,
955+ reservation_affinity_values : Optional [Sequence [str ]] = None ,
952956 wait_for_completion : bool = False ,
953957 ) -> "BatchPredictionJob" :
954958 """Create a batch prediction job.
@@ -1136,6 +1140,18 @@ def _submit_impl(
11361140 service_account (str):
11371141 Optional. Specifies the service account for workload run-as account.
11381142 Users submitting jobs must have act-as permission on this run-as account.
1143+ reservation_affinity_type (str):
1144+ Optional. The type of reservation affinity.
1145+ One of NO_RESERVATION, ANY_RESERVATION, SPECIFIC_RESERVATION,
1146+ SPECIFIC_THEN_ANY_RESERVATION, SPECIFIC_THEN_NO_RESERVATION
1147+ reservation_affinity_key (str):
1148+ Optional. Corresponds to the label key of a reservation resource.
1149+ To target a SPECIFIC_RESERVATION by name, use `compute.googleapis.com/reservation-name` as the key
1150+ and specify the name of your reservation as its value.
1151+ reservation_affinity_values (List[str]):
1152+ Optional. Corresponds to the label values of a reservation resource.
1153+ This must be the full resource name of the reservation.
1154+ Format: 'projects/{project_id_or_number}/zones/{zone}/reservations/{reservation_name}'
11391155 wait_for_completion (bool):
11401156 Whether to wait for the job completion.
11411157 Returns:
@@ -1268,6 +1284,13 @@ def _submit_impl(
12681284 machine_spec .accelerator_type = accelerator_type
12691285 machine_spec .accelerator_count = accelerator_count
12701286
1287+ if reservation_affinity_type :
1288+ machine_spec .reservation_affinity = utils .get_reservation_affinity (
1289+ reservation_affinity_type ,
1290+ reservation_affinity_key ,
1291+ reservation_affinity_values ,
1292+ )
1293+
12711294 dedicated_resources = gca_machine_resources_compat .BatchDedicatedResources ()
12721295
12731296 dedicated_resources .machine_spec = machine_spec
0 commit comments