File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -668,3 +668,13 @@ def _ecr_login_if_needed(boto_session, image):
668
668
669
669
cmd = "docker login -u AWS -p %s %s" % (token , ecr_url )
670
670
subprocess .check_output (cmd , shell = True )
671
+
672
+ return True
673
+
674
+
675
+ def _pull_image (image ):
676
+ pull_image_command = ('docker pull %s' % image ).strip ()
677
+ print ('docker command: {}' .format (pull_image_command ))
678
+
679
+ subprocess .check_output (pull_image_command , shell = True )
680
+ print ('image pulled: {}' .format (image ))
Original file line number Diff line number Diff line change @@ -513,13 +513,26 @@ def test_ecr_login_needed(check_output):
513
513
}
514
514
session_mock .client ('ecr' ).get_authorization_token .return_value = response
515
515
image = '520713654638.dkr.ecr.us-east-1.amazonaws.com/image-i-need:1.1'
516
- sagemaker .local .image ._ecr_login_if_needed (session_mock , image )
516
+ result = sagemaker .local .image ._ecr_login_if_needed (session_mock , image )
517
517
518
518
expected_command = 'docker login -u AWS -p %s https://520713654638.dkr.ecr.us-east-1.amazonaws.com' % token
519
519
520
520
check_output .assert_called_with (expected_command , shell = True )
521
521
session_mock .client ('ecr' ).get_authorization_token .assert_called_with (registryIds = ['520713654638' ])
522
522
523
+ assert result
524
+
525
+
526
+ @patch ('subprocess.check_output' , return_value = '' .encode ('utf-8' ))
527
+ def test_pull_image (check_output ):
528
+ image = '520713654638.dkr.ecr.us-east-1.amazonaws.com/image-i-need:1.1'
529
+
530
+ sagemaker .local .image ._pull_image (image )
531
+
532
+ expected_command = 'docker pull %s' % image
533
+
534
+ check_output .assert_called_once_with (expected_command , shell = True )
535
+
523
536
524
537
def test__aws_credentials_with_long_lived_credentials ():
525
538
credentials = Credentials (access_key = _random_string (), secret_key = _random_string (), token = None )
You can’t perform that action at this time.
0 commit comments