@@ -1721,6 +1721,7 @@ def wait_for_auto_ml_job(self, job, poll=5):
1721
1721
(dict): Return value from the ``DescribeAutoMLJob`` API.
1722
1722
1723
1723
Raises:
1724
+ exceptions.CapacityError: If the auto ml job fails with CapacityError.
1724
1725
exceptions.UnexpectedStatusException: If the auto ml job fails.
1725
1726
"""
1726
1727
desc = _wait_until (lambda : _auto_ml_job_status (self .sagemaker_client , job ), poll )
@@ -1743,7 +1744,8 @@ def logs_for_auto_ml_job( # noqa: C901 - suppress complexity warning for this m
1743
1744
completion (default: 5).
1744
1745
1745
1746
Raises:
1746
- exceptions.UnexpectedStatusException: If waiting and the training job fails.
1747
+ exceptions.CapacityError: If waiting and auto ml job fails with CapacityError.
1748
+ exceptions.UnexpectedStatusException: If waiting and auto ml job fails.
1747
1749
"""
1748
1750
1749
1751
description = self .sagemaker_client .describe_auto_ml_job (AutoMLJobName = job_name )
@@ -2845,6 +2847,10 @@ def wait_for_model_package(self, model_package_name, poll=5):
2845
2847
2846
2848
Returns:
2847
2849
dict: Return value from the ``DescribeEndpoint`` API.
2850
+
2851
+ Raises:
2852
+ exceptions.CapacityError: If the Model Package job fails with CapacityError.
2853
+ exceptions.UnexpectedStatusException: If waiting and the Model Package job fails.
2848
2854
"""
2849
2855
desc = _wait_until (
2850
2856
lambda : _create_model_package_status (self .sagemaker_client , model_package_name ), poll
@@ -2853,10 +2859,17 @@ def wait_for_model_package(self, model_package_name, poll=5):
2853
2859
2854
2860
if status != "Completed" :
2855
2861
reason = desc .get ("FailureReason" , None )
2862
+ message = "Error creating model package {package}: {status} Reason: {reason}" .format (
2863
+ package = model_package_name , status = status , reason = reason
2864
+ )
2865
+ if "CapacityError" in str (reason ):
2866
+ raise exceptions .CapacityError (
2867
+ message = message ,
2868
+ allowed_statuses = ["InService" ],
2869
+ actual_status = status ,
2870
+ )
2856
2871
raise exceptions .UnexpectedStatusException (
2857
- message = "Error creating model package {package}: {status} Reason: {reason}" .format (
2858
- package = model_package_name , status = status , reason = reason
2859
- ),
2872
+ message = message ,
2860
2873
allowed_statuses = ["Completed" ],
2861
2874
actual_status = status ,
2862
2875
)
@@ -3147,6 +3160,7 @@ def wait_for_job(self, job, poll=5):
3147
3160
(dict): Return value from the ``DescribeTrainingJob`` API.
3148
3161
3149
3162
Raises:
3163
+ exceptions.CapacityError: If the training job fails with CapacityError.
3150
3164
exceptions.UnexpectedStatusException: If the training job fails.
3151
3165
"""
3152
3166
desc = _wait_until_training_done (
@@ -3166,7 +3180,8 @@ def wait_for_processing_job(self, job, poll=5):
3166
3180
(dict): Return value from the ``DescribeProcessingJob`` API.
3167
3181
3168
3182
Raises:
3169
- exceptions.UnexpectedStatusException: If the compilation job fails.
3183
+ exceptions.CapacityError: If the processing job fails with CapacityError.
3184
+ exceptions.UnexpectedStatusException: If the processing job fails.
3170
3185
"""
3171
3186
desc = _wait_until (lambda : _processing_job_status (self .sagemaker_client , job ), poll )
3172
3187
self ._check_job_status (job , desc , "ProcessingJobStatus" )
@@ -3183,6 +3198,7 @@ def wait_for_compilation_job(self, job, poll=5):
3183
3198
(dict): Return value from the ``DescribeCompilationJob`` API.
3184
3199
3185
3200
Raises:
3201
+ exceptions.CapacityError: If the compilation job fails with CapacityError.
3186
3202
exceptions.UnexpectedStatusException: If the compilation job fails.
3187
3203
"""
3188
3204
desc = _wait_until (lambda : _compilation_job_status (self .sagemaker_client , job ), poll )
@@ -3200,7 +3216,8 @@ def wait_for_edge_packaging_job(self, job, poll=5):
3200
3216
(dict): Return value from the ``DescribeEdgePackagingJob`` API.
3201
3217
3202
3218
Raises:
3203
- exceptions.UnexpectedStatusException: If the compilation job fails.
3219
+ exceptions.CapacityError: If the edge packaging job fails with CapacityError.
3220
+ exceptions.UnexpectedStatusException: If the edge packaging job fails.
3204
3221
"""
3205
3222
desc = _wait_until (lambda : _edge_packaging_job_status (self .sagemaker_client , job ), poll )
3206
3223
self ._check_job_status (job , desc , "EdgePackagingJobStatus" )
@@ -3217,6 +3234,7 @@ def wait_for_tuning_job(self, job, poll=5):
3217
3234
(dict): Return value from the ``DescribeHyperParameterTuningJob`` API.
3218
3235
3219
3236
Raises:
3237
+ exceptions.CapacityError: If the hyperparameter tuning job fails with CapacityError.
3220
3238
exceptions.UnexpectedStatusException: If the hyperparameter tuning job fails.
3221
3239
"""
3222
3240
desc = _wait_until (lambda : _tuning_job_status (self .sagemaker_client , job ), poll )
@@ -3245,6 +3263,7 @@ def wait_for_transform_job(self, job, poll=5):
3245
3263
(dict): Return value from the ``DescribeTransformJob`` API.
3246
3264
3247
3265
Raises:
3266
+ exceptions.CapacityError: If the transform job fails with CapacityError.
3248
3267
exceptions.UnexpectedStatusException: If the transform job fails.
3249
3268
"""
3250
3269
desc = _wait_until (lambda : _transform_job_status (self .sagemaker_client , job ), poll )
@@ -3283,6 +3302,7 @@ def _check_job_status(self, job, desc, status_key_name):
3283
3302
status_key_name (str): Status key name to check for.
3284
3303
3285
3304
Raises:
3305
+ exceptions.CapacityError: If the training job fails with CapacityError.
3286
3306
exceptions.UnexpectedStatusException: If the training job fails.
3287
3307
"""
3288
3308
status = desc [status_key_name ]
@@ -3298,10 +3318,17 @@ def _check_job_status(self, job, desc, status_key_name):
3298
3318
elif status != "Completed" :
3299
3319
reason = desc .get ("FailureReason" , "(No reason provided)" )
3300
3320
job_type = status_key_name .replace ("JobStatus" , " job" )
3321
+ message = "Error for {job_type} {job_name}: {status}. Reason: {reason}" .format (
3322
+ job_type = job_type , job_name = job , status = status , reason = reason
3323
+ )
3324
+ if "CapacityError" in str (reason ):
3325
+ raise exceptions .CapacityError (
3326
+ message = message ,
3327
+ allowed_statuses = ["Completed" , "Stopped" ],
3328
+ actual_status = status ,
3329
+ )
3301
3330
raise exceptions .UnexpectedStatusException (
3302
- message = "Error for {job_type} {job_name}: {status}. Reason: {reason}" .format (
3303
- job_type = job_type , job_name = job , status = status , reason = reason
3304
- ),
3331
+ message = message ,
3305
3332
allowed_statuses = ["Completed" , "Stopped" ],
3306
3333
actual_status = status ,
3307
3334
)
@@ -3313,6 +3340,10 @@ def wait_for_endpoint(self, endpoint, poll=30):
3313
3340
endpoint (str): Name of the ``Endpoint`` to wait for.
3314
3341
poll (int): Polling interval in seconds (default: 5).
3315
3342
3343
+ Raises:
3344
+ exceptions.CapacityError: If the endpoint creation job fails with CapacityError.
3345
+ exceptions.UnexpectedStatusException: If the endpoint creation job fails.
3346
+
3316
3347
Returns:
3317
3348
dict: Return value from the ``DescribeEndpoint`` API.
3318
3349
"""
@@ -3321,10 +3352,17 @@ def wait_for_endpoint(self, endpoint, poll=30):
3321
3352
3322
3353
if status != "InService" :
3323
3354
reason = desc .get ("FailureReason" , None )
3355
+ message = "Error hosting endpoint {endpoint}: {status}. Reason: {reason}." .format (
3356
+ endpoint = endpoint , status = status , reason = reason
3357
+ )
3358
+ if "CapacityError" in str (reason ):
3359
+ raise exceptions .CapacityError (
3360
+ message = message ,
3361
+ allowed_statuses = ["InService" ],
3362
+ actual_status = status ,
3363
+ )
3324
3364
raise exceptions .UnexpectedStatusException (
3325
- message = "Error hosting endpoint {endpoint}: {status}. Reason: {reason}." .format (
3326
- endpoint = endpoint , status = status , reason = reason
3327
- ),
3365
+ message = message ,
3328
3366
allowed_statuses = ["InService" ],
3329
3367
actual_status = status ,
3330
3368
)
@@ -3649,6 +3687,7 @@ def logs_for_job( # noqa: C901 - suppress complexity warning for this method
3649
3687
completion (default: 5).
3650
3688
3651
3689
Raises:
3690
+ exceptions.CapacityError: If the training job fails with CapacityError.
3652
3691
exceptions.UnexpectedStatusException: If waiting and the training job fails.
3653
3692
"""
3654
3693
0 commit comments