Skip to content

fix: Cross-Platform File URI for Processing #1890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 7, 2020
8 changes: 5 additions & 3 deletions src/sagemaker/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import pathlib

from six.moves.urllib.parse import urlparse
from six.moves.urllib.request import url2pathname

from sagemaker import s3
from sagemaker.job import _Job
Expand Down Expand Up @@ -535,21 +536,22 @@ def _handle_user_code_url(self, code):
user_code_s3_uri = code
elif code_url.scheme == "" or code_url.scheme == "file":
# Validate that the file exists locally and is not a directory.
if not os.path.exists(code):
code_path = url2pathname(code_url.path)
if not os.path.exists(code_path):
raise ValueError(
"""code {} wasn't found. Please make sure that the file exists.
""".format(
code
)
)
if not os.path.isfile(code):
if not os.path.isfile(code_path):
raise ValueError(
"""code {} must be a file, not a directory. Please pass a path to a file.
""".format(
code
)
)
user_code_s3_uri = self._upload_code(code)
user_code_s3_uri = self._upload_code(code_path)
else:
raise ValueError(
"code {} url scheme {} is not recognized. Please pass a file path or S3 url".format(
Expand Down