|
| 1 | +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +from __future__ import absolute_import |
| 14 | + |
| 15 | +import pytest |
| 16 | +from sagemaker import image_uris |
| 17 | +from tests.unit.sagemaker.image_uris import expected_uris |
| 18 | + |
| 19 | + |
| 20 | +def _test_ecr_uri(account, region, version, tag): |
| 21 | + actual_uri = image_uris.retrieve("sagemaker-geospatial", region=region, version=version) |
| 22 | + expected_uri = expected_uris.algo_uri_with_tag( |
| 23 | + "sagemaker-geospatial-v1-0", |
| 24 | + account, |
| 25 | + region, |
| 26 | + tag=tag, |
| 27 | + ) |
| 28 | + return expected_uri == actual_uri |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.parametrize("load_config", ["sagemaker-geospatial.json"], indirect=True) |
| 32 | +@pytest.mark.parametrize("extract_versions_for_image_scope", ["processing"], indirect=True) |
| 33 | +def test_sagemaker_geospatial_ecr_uri(load_config, extract_versions_for_image_scope): |
| 34 | + VERSIONS = extract_versions_for_image_scope |
| 35 | + for version in VERSIONS: |
| 36 | + SAGEMAKER_GEOSPATIAL_ACCOUNTS = load_config["processing"]["versions"][version]["registries"] |
| 37 | + for region in SAGEMAKER_GEOSPATIAL_ACCOUNTS.keys(): |
| 38 | + |
| 39 | + assert _test_ecr_uri( |
| 40 | + account=SAGEMAKER_GEOSPATIAL_ACCOUNTS[region], |
| 41 | + region=region, |
| 42 | + version=version, |
| 43 | + tag="latest", |
| 44 | + ) |
| 45 | + |
| 46 | + |
| 47 | +@pytest.mark.parametrize("load_config", ["sagemaker-geospatial.json"], indirect=True) |
| 48 | +def test_sagemaker_geospatial_ecr_uri_no_version(load_config): |
| 49 | + region = "us-west-2" |
| 50 | + SAGEMAKER_GEOSPATIAL_ACCOUNTS = load_config["processing"]["versions"]["1.x"]["registries"] |
| 51 | + actual_uri = image_uris.retrieve("sagemaker-geospatial", region=region) |
| 52 | + expected_uri = expected_uris.algo_uri_with_tag( |
| 53 | + "sagemaker-geospatial-v1-0", SAGEMAKER_GEOSPATIAL_ACCOUNTS[region], region, tag="latest" |
| 54 | + ) |
| 55 | + assert expected_uri == actual_uri |
0 commit comments