Skip to content

Commit 09270f2

Browse files
author
Dan Choi
committed
add returns
1 parent 849e95a commit 09270f2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/sagemaker/local/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,11 @@ def _write_json_file(filename, content):
659659
def _ecr_login_if_needed(boto_session, image):
660660
# Only ECR images need login
661661
if not ('dkr.ecr' in image and 'amazonaws.com' in image):
662-
return
662+
return False
663663

664664
# do we have the image?
665665
if _check_output('docker images -q %s' % image).strip():
666-
return
666+
return False
667667

668668
if not boto_session:
669669
raise RuntimeError('A boto session is required to login to ECR.'

tests/unit/test_image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,20 +537,22 @@ def test_prepare_serving_volumes_with_local_model(get_data_source_instance, sage
537537

538538
def test_ecr_login_non_ecr():
539539
session_mock = Mock()
540-
sagemaker.local.image._ecr_login_if_needed(session_mock, 'ubuntu')
540+
result = sagemaker.local.image._ecr_login_if_needed(session_mock, 'ubuntu')
541541

542542
session_mock.assert_not_called()
543+
assert result is False
543544

544545

545546
@patch('sagemaker.local.image._check_output', return_value='123451324')
546547
def test_ecr_login_image_exists(_check_output):
547548
session_mock = Mock()
548549

549550
image = '520713654638.dkr.ecr.us-east-1.amazonaws.com/image-i-have:1.0'
550-
sagemaker.local.image._ecr_login_if_needed(session_mock, image)
551+
result = sagemaker.local.image._ecr_login_if_needed(session_mock, image)
551552

552553
session_mock.assert_not_called()
553554
_check_output.assert_called()
555+
assert result is False
554556

555557

556558
@patch('subprocess.check_output', return_value=''.encode('utf-8'))

0 commit comments

Comments
 (0)