Skip to content

Lowercase container hostnames #559

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 8 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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/local/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, instance_type, instance_count, image, sagemaker_session=None)
self.image = image
# Since we are using a single docker network, Generate a random suffix to attach to the container names.
# This way multiple jobs can run in parallel.
suffix = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(5))
suffix = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(5))
self.hosts = ['{}-{}-{}'.format(CONTAINER_PREFIX, i, suffix) for i in range(1, self.instance_count + 1)]
self.container_root = None
self.container = None
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ def sagemaker_session():
return sms


def test_sagemaker_container_hosts_should_have_lowercase_names():
random.seed(a=42)
sagemaker_container = _SageMakerContainer('local', 2, 'my-image')
assert sagemaker_container.hosts == ['algo-1-hbrpo', 'algo-2-hbrpo']

sagemaker_container = _SageMakerContainer('local', 10, 'my-image')
assert sagemaker_container.hosts == [
'algo-1-ig8f1', 'algo-2-ig8f1', 'algo-3-ig8f1', 'algo-4-ig8f1',
'algo-5-ig8f1', 'algo-6-ig8f1', 'algo-7-ig8f1', 'algo-8-ig8f1',
'algo-9-ig8f1', 'algo-10-ig8f1']

sagemaker_container = _SageMakerContainer('local', 1, 'my-image')
assert sagemaker_container.hosts == ['algo-1-cbfno']


@patch('sagemaker.local.local_session.LocalSession')
def test_write_config_file(LocalSession, tmpdir):
sagemaker_container = _SageMakerContainer('local', 2, 'my-image')
Expand Down