From c4f0bacf33221d3586a5b0ef6a0c15bd14415950 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 6 Dec 2024 13:03:23 +0000 Subject: [PATCH 1/8] addWaiterTimeoutHandling --- src/sagemaker/predictor_async.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index ef70b93599..725286e520 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -271,6 +271,7 @@ def _check_output_and_failure_paths(self, output_path, failure_path, waiter_conf output_file_found = threading.Event() failure_file_found = threading.Event() + waiter_error_catched = threading.Event() def check_output_file(): try: @@ -282,6 +283,7 @@ def check_output_file(): ) output_file_found.set() except WaiterError: + waiter_error_catched.set() pass def check_failure_file(): @@ -294,6 +296,7 @@ def check_failure_file(): ) failure_file_found.set() except WaiterError: + waiter_error_catched.set() pass output_thread = threading.Thread(target=check_output_file) @@ -302,7 +305,7 @@ def check_failure_file(): output_thread.start() failure_thread.start() - while not output_file_found.is_set() and not failure_file_found.is_set(): + while not output_file_found.is_set() and not failure_file_found.is_set() and not waiter_error_catched.is_set(): time.sleep(1) if output_file_found.is_set(): @@ -310,18 +313,16 @@ def check_failure_file(): result = self.predictor._handle_response(response=s3_object) return result - failure_object = self.s3_client.get_object(Bucket=failure_bucket, Key=failure_key) - failure_response = self.predictor._handle_response(response=failure_object) + if failure_file_found.is_set(): + failure_object = self.s3_client.get_object(Bucket=failure_bucket, Key=failure_key) + failure_response = self.predictor._handle_response(response=failure_object) + raise AsyncInferenceModelError(message=failure_response) - raise ( - AsyncInferenceModelError(message=failure_response) - if failure_file_found.is_set() - else PollingTimeoutError( + raise PollingTimeoutError( message="Inference could still be running", output_path=output_path, seconds=waiter_config.delay * waiter_config.max_attempts, ) - ) def update_endpoint( self, From 09d226a856f0981dac2653d2f0cbb84261c9b152 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 09:43:36 +0000 Subject: [PATCH 2/8] codeStyleUpdate --- src/sagemaker/predictor_async.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index 725286e520..c91c0b971c 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -284,7 +284,6 @@ def check_output_file(): output_file_found.set() except WaiterError: waiter_error_catched.set() - pass def check_failure_file(): try: @@ -297,7 +296,6 @@ def check_failure_file(): failure_file_found.set() except WaiterError: waiter_error_catched.set() - pass output_thread = threading.Thread(target=check_output_file) failure_thread = threading.Thread(target=check_failure_file) @@ -305,7 +303,9 @@ def check_failure_file(): output_thread.start() failure_thread.start() - while not output_file_found.is_set() and not failure_file_found.is_set() and not waiter_error_catched.is_set(): + while (not output_file_found.is_set() and + not failure_file_found.is_set() + and not waiter_error_catched.is_set()): time.sleep(1) if output_file_found.is_set(): From d25e9bff90865c32f788815380927503917b9843 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 13:35:18 +0000 Subject: [PATCH 3/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index c91c0b971c..84e39ce174 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -303,8 +303,8 @@ def check_failure_file(): output_thread.start() failure_thread.start() - while (not output_file_found.is_set() and - not failure_file_found.is_set() + while (not output_file_found.is_set() and + not failure_file_found.is_set() and not waiter_error_catched.is_set()): time.sleep(1) From a174c1e97ea02963f9078898a119577cd4bd828a Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 13:47:28 +0000 Subject: [PATCH 4/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index 84e39ce174..2656ee1696 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -304,8 +304,8 @@ def check_failure_file(): failure_thread.start() while (not output_file_found.is_set() and - not failure_file_found.is_set() - and not waiter_error_catched.is_set()): + not failure_file_found.is_set() and + not waiter_error_catched.is_set()): time.sleep(1) if output_file_found.is_set(): @@ -319,10 +319,10 @@ def check_failure_file(): raise AsyncInferenceModelError(message=failure_response) raise PollingTimeoutError( - message="Inference could still be running", - output_path=output_path, - seconds=waiter_config.delay * waiter_config.max_attempts, - ) + message="Inference could still be running", + output_path=output_path, + seconds=waiter_config.delay * waiter_config.max_attempts, + ) def update_endpoint( self, From b822c39f39de45c0695aad7d07d6d7830728bbc2 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 13:49:19 +0000 Subject: [PATCH 5/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index 2656ee1696..ebc30d0c24 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -304,7 +304,7 @@ def check_failure_file(): failure_thread.start() while (not output_file_found.is_set() and - not failure_file_found.is_set() and + not failure_file_found.is_set() and not waiter_error_catched.is_set()): time.sleep(1) From d285e51392533169bd739e5a60c113b33e796caa Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 14:11:00 +0000 Subject: [PATCH 6/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index ebc30d0c24..27d5865020 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -303,9 +303,9 @@ def check_failure_file(): output_thread.start() failure_thread.start() - while (not output_file_found.is_set() and - not failure_file_found.is_set() and - not waiter_error_catched.is_set()): + while not output_file_found.is_set() and \ + not failure_file_found.is_set() and \ + not waiter_error_catched.is_set(): time.sleep(1) if output_file_found.is_set(): From 5d1e6278c056e09a33f0193d6b45c6eef00d926b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 14:17:11 +0000 Subject: [PATCH 7/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index 27d5865020..b73768052f 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -304,8 +304,8 @@ def check_failure_file(): failure_thread.start() while not output_file_found.is_set() and \ - not failure_file_found.is_set() and \ - not waiter_error_catched.is_set(): + not failure_file_found.is_set() and \ + not waiter_error_catched.is_set(): time.sleep(1) if output_file_found.is_set(): From b7e40f1a557806a487e6a6ea6d038bf7e6cb3031 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 20 Jan 2025 14:25:51 +0000 Subject: [PATCH 8/8] updateCodeStyle --- src/sagemaker/predictor_async.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/predictor_async.py b/src/sagemaker/predictor_async.py index b73768052f..783d034011 100644 --- a/src/sagemaker/predictor_async.py +++ b/src/sagemaker/predictor_async.py @@ -303,9 +303,11 @@ def check_failure_file(): output_thread.start() failure_thread.start() - while not output_file_found.is_set() and \ - not failure_file_found.is_set() and \ - not waiter_error_catched.is_set(): + while ( + not output_file_found.is_set() + and not failure_file_found.is_set() + and not waiter_error_catched.is_set() + ): time.sleep(1) if output_file_found.is_set():