Skip to content

Commit 9fef369

Browse files
committed
add docstring
1 parent 7e00970 commit 9fef369

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/sagemaker/local/utils.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def move_to_destination(source, destination, job_name, sagemaker_session):
6262
final_uri = destination
6363
elif parsed_uri.scheme == "s3":
6464
bucket = parsed_uri.netloc
65-
path = _create_s3_path(parsed_uri.path, job_name)
65+
path = _create_s3_prefix(parsed_uri.path, job_name)
6666
final_uri = "s3://%s/%s" % (bucket, path)
6767
sagemaker_session.upload_data(source, bucket, path)
6868
else:
@@ -72,9 +72,20 @@ def move_to_destination(source, destination, job_name, sagemaker_session):
7272
return final_uri
7373

7474

75-
def _create_s3_path(prefix, job_name):
76-
prefix = prefix.strip("/")
77-
return job_name if prefix == "" else "/".join((prefix, job_name))
75+
def _create_s3_prefix(path, job_name):
76+
"""Constructs a path out of the given path and job name to be
77+
used as an S3 prefix.
78+
79+
Args:
80+
path (str): the original path. If the path is only ``"/"``,
81+
then it is ignored.
82+
job_name (str): the job name to be appended to the path.
83+
84+
Returns:
85+
str: an S3 prefix of the form ``"path/job_name"``
86+
"""
87+
path = path.strip("/")
88+
return job_name if path == "" else "/".join((path, job_name))
7889

7990

8091
def recursive_copy(source, destination):

0 commit comments

Comments
 (0)