Skip to content

Change: Raise error if custom VPC is halfway defined #4269

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 3 commits into from
Dec 14, 2023
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
11 changes: 11 additions & 0 deletions src/sagemaker/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ def __init__(
self.dependencies = dependencies or []
self.uploaded_code: Optional[UploadedCode] = None

# Check that the user properly sets both subnet and secutiry_groupe_ids
if (
subnets is not None
and security_group_ids is None
or security_group_ids is not None
and subnets is None
):
raise RuntimeError(
"When setting up custom VPC, both subnets and security_group_ids must be set"
)

if self.instance_type in ("local", "local_gpu"):
if self.instance_type == "local_gpu" and self.instance_count > 1:
raise RuntimeError("Distributed Training in Local GPU is not supported")
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,24 @@ def test_framework_all_init_args(sagemaker_session):
}


def test_subnets_without_security_groups(sagemaker_session):
with pytest.raises(RuntimeError):
DummyFramework(
entry_point=SCRIPT_PATH,
sagemaker_session=sagemaker_session,
subnets=["123"],
)


def test_security_groups_without_subnets(sagemaker_session):
with pytest.raises(RuntimeError):
DummyFramework(
entry_point=SCRIPT_PATH,
sagemaker_session=sagemaker_session,
security_group_ids=["123"],
)


def test_framework_without_role_parameter(sagemaker_session):
with pytest.raises(ValueError):
DummyFramework(
Expand Down