Skip to content

Commit d2f3984

Browse files
authored
fix: use .format instead of os.path.join for Processing S3 paths. (#1391)
S3 paths always use forward slashes ("/") regardless of the OS, so using an os.path.join will cause issues when the user is on Windows.
1 parent 94344a1 commit d2f3984

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/sagemaker/processing.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,9 @@ def _normalize_inputs(self, inputs=None):
213213
# and save the S3 uri in the ProcessingInput source.
214214
parse_result = urlparse(file_input.source)
215215
if parse_result.scheme != "s3":
216-
desired_s3_uri = os.path.join(
217-
"s3://",
216+
desired_s3_uri = "s3://{}/{}/input/{}".format(
218217
self.sagemaker_session.default_bucket(),
219218
self._current_job_name,
220-
"input",
221219
file_input.input_name,
222220
)
223221
s3_uri = S3Uploader.upload(
@@ -259,11 +257,9 @@ def _normalize_outputs(self, outputs=None):
259257
# If the output's destination is not an s3_uri, create one.
260258
parse_result = urlparse(output.destination)
261259
if parse_result.scheme != "s3":
262-
s3_uri = os.path.join(
263-
"s3://",
260+
s3_uri = "s3://{}/{}/output/{}".format(
264261
self.sagemaker_session.default_bucket(),
265262
self._current_job_name,
266-
"output",
267263
output.output_name,
268264
)
269265
output.destination = s3_uri
@@ -475,11 +471,9 @@ def _upload_code(self, code):
475471
str: The S3 URI of the uploaded file or directory.
476472
477473
"""
478-
desired_s3_uri = os.path.join(
479-
"s3://",
474+
desired_s3_uri = "s3://{}/{}/input/{}".format(
480475
self.sagemaker_session.default_bucket(),
481476
self._current_job_name,
482-
"input",
483477
self._CODE_CONTAINER_INPUT_NAME,
484478
)
485479
return S3Uploader.upload(

0 commit comments

Comments
 (0)