Skip to content

Commit ca56e2f

Browse files
author
Namrata Madan
committed
fix: adjacent slash in s3 key
1 parent f2d5e41 commit ca56e2f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/sagemaker/tensorflow/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ def prepare_container_def(
396396
# model is not yet there, defer repacking to later during pipeline execution
397397
if isinstance(self.sagemaker_session, PipelineSession):
398398
self.sagemaker_session.context.need_runtime_repack.add(id(self))
399-
self.sagemaker_session.context.runtime_repack_output_prefix = "s3://{}/{}".format(
400-
bucket, key_prefix
399+
self.sagemaker_session.context.runtime_repack_output_prefix = s3.s3_path_join(
400+
"s3://", bucket, key_prefix
401401
)
402402
else:
403403
logging.warning(

tests/unit/sagemaker/workflow/test_model_step.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
_TENSORFLOW_PATH = os.path.join(DATA_DIR, "tfs/tfs-test-entrypoint-and-dependencies")
7070
_REPACK_OUTPUT_KEY_PREFIX = "code-output"
7171
_MODEL_CODE_LOCATION = f"s3://{_BUCKET}/{_REPACK_OUTPUT_KEY_PREFIX}"
72+
_MODEL_CODE_LOCATION_TRAILING_SLASH = _MODEL_CODE_LOCATION + "/"
7273

7374

7475
@pytest.fixture
@@ -690,7 +691,7 @@ def test_conditional_model_create_and_regis(
690691
entry_point=f"{DATA_DIR}/{_SCRIPT_NAME}",
691692
role=_ROLE,
692693
enable_network_isolation=True,
693-
code_location=_MODEL_CODE_LOCATION,
694+
code_location=_MODEL_CODE_LOCATION_TRAILING_SLASH,
694695
),
695696
2,
696697
),
@@ -714,7 +715,7 @@ def test_conditional_model_create_and_regis(
714715
entry_point=f"{DATA_DIR}/{_SCRIPT_NAME}",
715716
role=_ROLE,
716717
framework_version="1.5.0",
717-
code_location=_MODEL_CODE_LOCATION,
718+
code_location=_MODEL_CODE_LOCATION_TRAILING_SLASH,
718719
),
719720
2,
720721
),
@@ -746,7 +747,7 @@ def test_conditional_model_create_and_regis(
746747
image_uri=_IMAGE_URI,
747748
entry_point=f"{DATA_DIR}/{_SCRIPT_NAME}",
748749
role=_ROLE,
749-
code_location=_MODEL_CODE_LOCATION,
750+
code_location=_MODEL_CODE_LOCATION_TRAILING_SLASH,
750751
),
751752
2,
752753
),
@@ -769,7 +770,9 @@ def assert_test_result(steps: list):
769770
assert len(steps) == expected_step_num
770771
if expected_step_num == 2:
771772
assert steps[0]["Type"] == "Training"
772-
if model.key_prefix == _REPACK_OUTPUT_KEY_PREFIX:
773+
if model.key_prefix is not None and model.key_prefix.startswith(
774+
_REPACK_OUTPUT_KEY_PREFIX
775+
):
773776
assert steps[0]["Arguments"]["OutputDataConfig"]["S3OutputPath"] == (
774777
f"{_MODEL_CODE_LOCATION}/{model.name}"
775778
)

0 commit comments

Comments
 (0)