Skip to content

Commit 85650ed

Browse files
authored
Cross-Platform File URI for Processing
fix: cross-platform file URI support for processing
1 parent cc98dd0 commit 85650ed

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
@@ -510,21 +511,22 @@ def _handle_user_code_url(self, code):
510511
user_code_s3_uri = code
511512
elif code_url.scheme == "" or code_url.scheme == "file":
512513
# Validate that the file exists locally and is not a directory.
513-
if not os.path.exists(code):
514+
code_path = url2pathname(code_url.path)
515+
if not os.path.exists(code_path):
514516
raise ValueError(
515517
"""code {} wasn't found. Please make sure that the file exists.
516518
""".format(
517519
code
518520
)
519521
)
520-
if not os.path.isfile(code):
522+
if not os.path.isfile(code_path):
521523
raise ValueError(
522524
"""code {} must be a file, not a directory. Please pass a path to a file.
523525
""".format(
524526
code
525527
)
526528
)
527-
user_code_s3_uri = self._upload_code(code)
529+
user_code_s3_uri = self._upload_code(code_path)
528530
else:
529531
raise ValueError(
530532
"code {} url scheme {} is not recognized. Please pass a file path or S3 url".format(

0 commit comments

Comments
 (0)