Skip to content

fix: xgboost, sklearn network isolation for jumpstart #3060

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def _script_mode_env_vars(self):
dir_name = None
if self.uploaded_code:
script_name = self.uploaded_code.script_name
if self.enable_network_isolation():
if self.repacked_model_data or self.enable_network_isolation():
dir_name = "/opt/ml/model/code"
else:
dir_name = self.uploaded_code.s3_prefix
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/sagemaker/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,25 @@ def test_all_framework_models_add_jumpstart_base_name(

sagemaker_session.create_model.reset_mock()
sagemaker_session.endpoint_from_production_variants.reset_mock()


@patch("sagemaker.utils.repack_model")
def test_script_mode_model_uses_proper_sagemaker_submit_dir(repack_model, sagemaker_session):

source_dir = "s3://blah/blah/blah"
t = Model(
entry_point=ENTRY_POINT_INFERENCE,
role=ROLE,
sagemaker_session=sagemaker_session,
source_dir=source_dir,
image_uri=IMAGE_URI,
model_data=MODEL_DATA,
)
t.deploy(instance_type=INSTANCE_TYPE, initial_instance_count=INSTANCE_COUNT)

assert (
sagemaker_session.create_model.call_args_list[0][0][2]["Environment"][
"SAGEMAKER_SUBMIT_DIRECTORY"
]
== "/opt/ml/model/code"
)