@@ -2215,6 +2215,7 @@ def run(
2215
2215
disable_retries : bool = False ,
2216
2216
persistent_resource_id : Optional [str ] = None ,
2217
2217
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
2218
+ max_wait_duration : Optional [int ] = None ,
2218
2219
) -> None :
2219
2220
"""Run this configured CustomJob.
2220
2221
@@ -2285,6 +2286,10 @@ def run(
2285
2286
PersistentResource, otherwise, the job will be rejected.
2286
2287
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
2287
2288
Optional. Indicates the job scheduling strategy.
2289
+ max_wait_duration (int):
2290
+ This is the maximum duration that a job will wait for the
2291
+ requested resources to be provisioned in seconds. If set to 0,
2292
+ the job will wait indefinitely. The default is 1 day.
2288
2293
"""
2289
2294
network = network or initializer .global_config .network
2290
2295
service_account = service_account or initializer .global_config .service_account
@@ -2303,6 +2308,7 @@ def run(
2303
2308
disable_retries = disable_retries ,
2304
2309
persistent_resource_id = persistent_resource_id ,
2305
2310
scheduling_strategy = scheduling_strategy ,
2311
+ max_wait_duration = max_wait_duration ,
2306
2312
)
2307
2313
2308
2314
@base .optional_sync ()
@@ -2321,6 +2327,7 @@ def _run(
2321
2327
disable_retries : bool = False ,
2322
2328
persistent_resource_id : Optional [str ] = None ,
2323
2329
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
2330
+ max_wait_duration : Optional [int ] = None ,
2324
2331
) -> None :
2325
2332
"""Helper method to ensure network synchronization and to run the configured CustomJob.
2326
2333
@@ -2389,6 +2396,10 @@ def _run(
2389
2396
PersistentResource, otherwise, the job will be rejected.
2390
2397
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
2391
2398
Optional. Indicates the job scheduling strategy.
2399
+ max_wait_duration (int):
2400
+ This is the maximum duration that a job will wait for the
2401
+ requested resources to be provisioned in seconds. If set to 0,
2402
+ the job will wait indefinitely. The default is 1 day.
2392
2403
"""
2393
2404
self .submit (
2394
2405
service_account = service_account ,
@@ -2403,6 +2414,7 @@ def _run(
2403
2414
disable_retries = disable_retries ,
2404
2415
persistent_resource_id = persistent_resource_id ,
2405
2416
scheduling_strategy = scheduling_strategy ,
2417
+ max_wait_duration = max_wait_duration ,
2406
2418
)
2407
2419
2408
2420
self ._block_until_complete ()
@@ -2422,6 +2434,7 @@ def submit(
2422
2434
disable_retries : bool = False ,
2423
2435
persistent_resource_id : Optional [str ] = None ,
2424
2436
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
2437
+ max_wait_duration : Optional [int ] = None ,
2425
2438
) -> None :
2426
2439
"""Submit the configured CustomJob.
2427
2440
@@ -2487,6 +2500,10 @@ def submit(
2487
2500
PersistentResource, otherwise, the job will be rejected.
2488
2501
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
2489
2502
Optional. Indicates the job scheduling strategy.
2503
+ max_wait_duration (int):
2504
+ This is the maximum duration that a job will wait for the
2505
+ requested resources to be provisioned in seconds. If set to 0,
2506
+ the job will wait indefinitely. The default is 1 day.
2490
2507
2491
2508
Raises:
2492
2509
ValueError:
@@ -2514,13 +2531,20 @@ def submit(
2514
2531
or restart_job_on_worker_restart
2515
2532
or disable_retries
2516
2533
or scheduling_strategy
2534
+ or max_wait_duration
2517
2535
):
2518
2536
timeout = duration_pb2 .Duration (seconds = timeout ) if timeout else None
2537
+ max_wait_duration = (
2538
+ duration_pb2 .Duration (seconds = max_wait_duration )
2539
+ if max_wait_duration
2540
+ else None
2541
+ )
2519
2542
self ._gca_resource .job_spec .scheduling = gca_custom_job_compat .Scheduling (
2520
2543
timeout = timeout ,
2521
2544
restart_job_on_worker_restart = restart_job_on_worker_restart ,
2522
2545
disable_retries = disable_retries ,
2523
2546
strategy = scheduling_strategy ,
2547
+ max_wait_duration = max_wait_duration ,
2524
2548
)
2525
2549
2526
2550
if enable_web_access :
@@ -2886,6 +2910,7 @@ def run(
2886
2910
create_request_timeout : Optional [float ] = None ,
2887
2911
disable_retries : bool = False ,
2888
2912
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
2913
+ max_wait_duration : Optional [int ] = None , # seconds
2889
2914
) -> None :
2890
2915
"""Run this configured CustomJob.
2891
2916
@@ -2936,6 +2961,10 @@ def run(
2936
2961
`restart_job_on_worker_restart` to False.
2937
2962
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
2938
2963
Optional. Indicates the job scheduling strategy.
2964
+ max_wait_duration (int):
2965
+ This is the maximum duration that a job will wait for the
2966
+ requested resources to be provisioned in seconds. If set to 0,
2967
+ the job will wait indefinitely. The default is 1 day.
2939
2968
"""
2940
2969
network = network or initializer .global_config .network
2941
2970
service_account = service_account or initializer .global_config .service_account
@@ -2951,6 +2980,7 @@ def run(
2951
2980
create_request_timeout = create_request_timeout ,
2952
2981
disable_retries = disable_retries ,
2953
2982
scheduling_strategy = scheduling_strategy ,
2983
+ max_wait_duration = max_wait_duration ,
2954
2984
)
2955
2985
2956
2986
@base .optional_sync ()
@@ -2966,6 +2996,7 @@ def _run(
2966
2996
create_request_timeout : Optional [float ] = None ,
2967
2997
disable_retries : bool = False ,
2968
2998
scheduling_strategy : Optional [gca_custom_job_compat .Scheduling .Strategy ] = None ,
2999
+ max_wait_duration : Optional [int ] = None , # seconds
2969
3000
) -> None :
2970
3001
"""Helper method to ensure network synchronization and to run the configured CustomJob.
2971
3002
@@ -3014,6 +3045,10 @@ def _run(
3014
3045
`restart_job_on_worker_restart` to False.
3015
3046
scheduling_strategy (gca_custom_job_compat.Scheduling.Strategy):
3016
3047
Optional. Indicates the job scheduling strategy.
3048
+ max_wait_duration (int):
3049
+ This is the maximum duration that a job will wait for the
3050
+ requested resources to be provisioned in seconds. If set to 0,
3051
+ the job will wait indefinitely. The default is 1 day.
3017
3052
"""
3018
3053
if service_account :
3019
3054
self ._gca_resource .trial_job_spec .service_account = service_account
@@ -3025,15 +3060,22 @@ def _run(
3025
3060
timeout
3026
3061
or restart_job_on_worker_restart
3027
3062
or disable_retries
3063
+ or max_wait_duration
3028
3064
or scheduling_strategy
3029
3065
):
3030
- duration = duration_pb2 .Duration (seconds = timeout ) if timeout else None
3066
+ timeout = duration_pb2 .Duration (seconds = timeout ) if timeout else None
3067
+ max_wait_duration = (
3068
+ duration_pb2 .Duration (seconds = max_wait_duration )
3069
+ if max_wait_duration
3070
+ else None
3071
+ )
3031
3072
self ._gca_resource .trial_job_spec .scheduling = (
3032
3073
gca_custom_job_compat .Scheduling (
3033
- timeout = duration ,
3074
+ timeout = timeout ,
3034
3075
restart_job_on_worker_restart = restart_job_on_worker_restart ,
3035
3076
disable_retries = disable_retries ,
3036
3077
strategy = scheduling_strategy ,
3078
+ max_wait_duration = max_wait_duration ,
3037
3079
)
3038
3080
)
3039
3081
0 commit comments