def test_model_name_exception(self): mock_client = MagicMock() mock_args = vars(self.parser.parse_args(required_args)) mock_args['model_name_1'] = None with self.assertRaises(Exception): _utils.create_endpoint_config_request(mock_args)
def test_pass_most_args(self): arguments = [ '--region', 'us-west-2', '--endpoint_url', 'fake-url', '--endpoint_config_name', 'EndpointConfig-test-1', '--model_name_1', 'model-test-1', '--accelerator_type_1', 'ml.eia1.medium', '--model_name_2', 'model-test-2', '--accelerator_type_2', 'ml.eia1.medium', '--model_name_3', 'model-test-3', '--accelerator_type_3', 'ml.eia1.medium', '--resource_encryption_key', 'fake-key', '--endpoint_config_tags', '{"fake_config_key": "fake_config_value"}', '--endpoint_tags', '{"fake_key": "fake_value"}' ] response = _utils.create_endpoint_config_request( vars(self.parser.parse_args(arguments))) self.assertEqual( response, { 'EndpointConfigName': 'EndpointConfig-test-1', 'KmsKeyId': 'fake-key', 'ProductionVariants': [{ 'InitialInstanceCount': 1, 'AcceleratorType': 'ml.eia1.medium', 'InitialVariantWeight': 1.0, 'InstanceType': 'ml.m4.xlarge', 'ModelName': 'model-test-1', 'VariantName': 'variant-name-1' }, { 'InitialInstanceCount': 1, 'AcceleratorType': 'ml.eia1.medium', 'InitialVariantWeight': 1.0, 'InstanceType': 'ml.m4.xlarge', 'ModelName': 'model-test-2', 'VariantName': 'variant-name-2' }, { 'InitialInstanceCount': 1, 'AcceleratorType': 'ml.eia1.medium', 'InitialVariantWeight': 1.0, 'InstanceType': 'ml.m4.xlarge', 'ModelName': 'model-test-3', 'VariantName': 'variant-name-3' }], 'Tags': [{ 'Key': 'fake_config_key', 'Value': 'fake_config_value' }] })