From c66201a3e151b90b4e60fb5ba19b42846d3c41c8 Mon Sep 17 00:00:00 2001 From: Will Childs-Klein Date: Tue, 3 Jun 2025 17:30:14 +0000 Subject: [PATCH 1/3] fix: Allow import failure for _hashlib module --- src/sagemaker/workflow/utilities.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sagemaker/workflow/utilities.py b/src/sagemaker/workflow/utilities.py index 4fc98eb29a..632a4bac14 100644 --- a/src/sagemaker/workflow/utilities.py +++ b/src/sagemaker/workflow/utilities.py @@ -21,7 +21,14 @@ import hashlib from urllib.parse import unquote, urlparse from contextlib import contextmanager -from _hashlib import HASH as Hash + +try: + # _hashlib is an internal python module, and is not present in + # statically linked interpreters. + from _hashlib import HASH as Hash +except ImportError as e: + import typing + Hash = typing.Any from sagemaker.utils import base_from_name from sagemaker.workflow.parameters import Parameter From a59057235ffac937c077f0852c605b3d4222906f Mon Sep 17 00:00:00 2001 From: Will Childs-Klein Date: Thu, 5 Jun 2025 20:47:41 +0000 Subject: [PATCH 2/3] Fix formatting --- src/sagemaker/workflow/utilities.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sagemaker/workflow/utilities.py b/src/sagemaker/workflow/utilities.py index 632a4bac14..823347a8e0 100644 --- a/src/sagemaker/workflow/utilities.py +++ b/src/sagemaker/workflow/utilities.py @@ -28,6 +28,7 @@ from _hashlib import HASH as Hash except ImportError as e: import typing + Hash = typing.Any from sagemaker.utils import base_from_name From cd1ad54ce1fc8385cd2278acaf65ce5e8790cd8a Mon Sep 17 00:00:00 2001 From: Will Childs-Klein Date: Thu, 5 Jun 2025 21:41:40 +0000 Subject: [PATCH 3/3] Appease flake8 --- src/sagemaker/workflow/utilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sagemaker/workflow/utilities.py b/src/sagemaker/workflow/utilities.py index 823347a8e0..961972da4d 100644 --- a/src/sagemaker/workflow/utilities.py +++ b/src/sagemaker/workflow/utilities.py @@ -26,7 +26,7 @@ # _hashlib is an internal python module, and is not present in # statically linked interpreters. from _hashlib import HASH as Hash -except ImportError as e: +except ImportError: import typing Hash = typing.Any