Skip to content

Commit 67ef671

Browse files
bstrinerajaykarpur
andauthored
fix: cross-platform file URI for Processing (#1890)
fix: cross-platform file URI support for processing Co-authored-by: Ajay Karpur <[email protected]>
1 parent ee13440 commit 67ef671

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/sagemaker/processing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import pathlib
2222

2323
from six.moves.urllib.parse import urlparse
24+
from six.moves.urllib.request import url2pathname
2425

2526
from sagemaker import s3
2627
from sagemaker.job import _Job
@@ -535,21 +536,22 @@ def _handle_user_code_url(self, code):
535536
user_code_s3_uri = code
536537
elif code_url.scheme == "" or code_url.scheme == "file":
537538
# Validate that the file exists locally and is not a directory.
538-
if not os.path.exists(code):
539+
code_path = url2pathname(code_url.path)
540+
if not os.path.exists(code_path):
539541
raise ValueError(
540542
"""code {} wasn't found. Please make sure that the file exists.
541543
""".format(
542544
code
543545
)
544546
)
545-
if not os.path.isfile(code):
547+
if not os.path.isfile(code_path):
546548
raise ValueError(
547549
"""code {} must be a file, not a directory. Please pass a path to a file.
548550
""".format(
549551
code
550552
)
551553
)
552-
user_code_s3_uri = self._upload_code(code)
554+
user_code_s3_uri = self._upload_code(code_path)
553555
else:
554556
raise ValueError(
555557
"code {} url scheme {} is not recognized. Please pass a file path or S3 url".format(

0 commit comments

Comments
 (0)