From 2edd4b499f8a0fe6f469670a455214e12ecc9e49 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 14 Dec 2018 13:57:42 -0800 Subject: [PATCH 1/4] Change hostnames to lowercase --- src/sagemaker/local/image.py | 2 +- tests/unit/test_image.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/sagemaker/local/image.py b/src/sagemaker/local/image.py index 75cb58e046..74de1587ee 100644 --- a/src/sagemaker/local/image.py +++ b/src/sagemaker/local/image.py @@ -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 diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index 4e6123583b..eb792d73f8 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -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') From 4e930974aed0c001a7ba6c15e6919c82b664295c Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 14 Dec 2018 14:53:59 -0800 Subject: [PATCH 2/4] Handle PR request --- CHANGELOG.rst | 5 +++++ tests/unit/test_image.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0322d8d7e3..7ec64811b6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ CHANGELOG ========= +1.16.4.dev +====== + +* bug-fix: Local Mode: Allow support for SSH in local mode + 1.16.3 ====== diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index eb792d73f8..ed686c4dab 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -88,7 +88,7 @@ def sagemaker_session(): def test_sagemaker_container_hosts_should_have_lowercase_names(): random.seed(a=42) - sagemaker_container = _SageMakerContainer('local', 2, 'my-image') + sagemaker_container = _SageMakerContainer('local', 2, 'my-image', sagemaker_session=Mock()) assert sagemaker_container.hosts == ['algo-1-hbrpo', 'algo-2-hbrpo'] sagemaker_container = _SageMakerContainer('local', 10, 'my-image') From 1010a7e8f348f95dd520a1355c9ab1a532bca2a3 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 14 Dec 2018 16:14:13 -0800 Subject: [PATCH 3/4] Fix tests --- tests/unit/test_image.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index ed686c4dab..4701ffa92f 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -88,17 +88,19 @@ def sagemaker_session(): def test_sagemaker_container_hosts_should_have_lowercase_names(): random.seed(a=42) + + def assert_all_lowercase(hosts): + for host in hosts: + assert host.lower() == host + sagemaker_container = _SageMakerContainer('local', 2, 'my-image', sagemaker_session=Mock()) - assert sagemaker_container.hosts == ['algo-1-hbrpo', 'algo-2-hbrpo'] + assert_all_lowercase(sagemaker_container.hosts) 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'] + assert_all_lowercase(sagemaker_container.hosts) sagemaker_container = _SageMakerContainer('local', 1, 'my-image') - assert sagemaker_container.hosts == ['algo-1-cbfno'] + assert_all_lowercase(sagemaker_container.hosts) @patch('sagemaker.local.local_session.LocalSession') From 7df4ec4d6853d39dd7fb05eb99b509edf78c0767 Mon Sep 17 00:00:00 2001 From: Marcio Dos Santos Date: Fri, 14 Dec 2018 17:26:03 -0800 Subject: [PATCH 4/4] Fix tests --- tests/unit/test_image.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_image.py b/tests/unit/test_image.py index 4701ffa92f..01c478c80b 100644 --- a/tests/unit/test_image.py +++ b/tests/unit/test_image.py @@ -96,10 +96,10 @@ def assert_all_lowercase(hosts): sagemaker_container = _SageMakerContainer('local', 2, 'my-image', sagemaker_session=Mock()) assert_all_lowercase(sagemaker_container.hosts) - sagemaker_container = _SageMakerContainer('local', 10, 'my-image') + sagemaker_container = _SageMakerContainer('local', 10, 'my-image', sagemaker_session=Mock()) assert_all_lowercase(sagemaker_container.hosts) - sagemaker_container = _SageMakerContainer('local', 1, 'my-image') + sagemaker_container = _SageMakerContainer('local', 1, 'my-image', sagemaker_session=Mock()) assert_all_lowercase(sagemaker_container.hosts)