Skip to content

feature: add region check for Neo service #806

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 2 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ def _compilation_job_config(self, target_instance_type, input_shape, output_path
'tags': tags,
'job_name': job_name}

def check_neo_region(self, region):
"""Check if this ``Model`` in the available region where neo support.

Args:
region (str): Specifies the region where want to execute compilation
Returns:
bool: boolean value whether if neo is available in the specified region
"""
if region in NEO_IMAGE_ACCOUNT:
return True
else:
return False

def _neo_image_account(self, region):
if region not in NEO_IMAGE_ACCOUNT:
raise ValueError("Neo is not currently supported in {}, "
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,19 @@ def test_compile_model_for_cloud(sagemaker_session, tmpdir):
model.compile(target_instance_family='ml_c4', input_shape={'data': [1, 3, 1024, 1024]},
output_path='s3://output', role='role', framework='tensorflow', job_name="compile-model")
assert model._is_compiled_model is True


def test_check_neo_region(sagemaker_session, tmpdir):
sagemaker_session.wait_for_compilation_job = Mock(
return_value=DESCRIBE_COMPILATION_JOB_RESPONSE)
model = DummyFrameworkModel(sagemaker_session, source_dir=str(tmpdir))
ec2_region_list = ['us-east-2', 'us-east-1', 'us-west-1', 'us-west-2', 'ap-east-1', 'ap-south-1',
'ap-northeast-3', 'ap-northeast-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1',
'ca-central-1', 'cn-north-1', 'cn-northwest-1', 'eu-central-1', ' eu-west-1', 'eu-west-2',
'eu-west-3', 'eu-north-1', 'sa-east-1', 'us-gov-east-1', 'us-gov-west-1']
neo_support_region = ['us-west-2', 'eu-west-1', 'us-east-1', 'us-east-2']
for region_name in ec2_region_list:
if region_name in neo_support_region:
assert model.check_neo_region(region_name) is True
else:
assert model.check_neo_region(region_name) is False