Sagemaker models (#3105)
* First failing test, and enough framework to run it.
* Rudimentary passing test.
* Sagemaker Notebook Support, take-1: create, describe, start, stop, delete.
* Added list_tags.
* Merged in model support from https://github.com/porthunt/moto/tree/sagemaker-support.
* Re-org'd
* Fixed up describe_model exception when no matching model.
* Segregated tests by Sagemaker entity. Model arn check by regex..
* Python2 compabitility changes.
* Added sagemaker to list of known backends. Corrected urls.
* Added sagemaker special case to moto.server.infer_service_region_host due to irregular url format (use of 'api' subdomain) to support server mode.
* Changes for PR 3105 comments of July 10, 2020
* PR3105 July 10, 2020, 8:55 AM EDT comment: dropped unnecessary re-addition of arn when formulating model list response.
* PR 3105 July 15, 2020 9:10 AM EDT Comment: clean-up SageMakerModelBackend.describe_models logic for finding the model in the dict.
* Optimized imports
Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-07-16 08:12:25 -04:00
|
|
|
from __future__ import unicode_literals
|
2021-09-02 20:45:47 +08:00
|
|
|
from moto.core.exceptions import RESTError, JsonRESTError, AWSError
|
Sagemaker models (#3105)
* First failing test, and enough framework to run it.
* Rudimentary passing test.
* Sagemaker Notebook Support, take-1: create, describe, start, stop, delete.
* Added list_tags.
* Merged in model support from https://github.com/porthunt/moto/tree/sagemaker-support.
* Re-org'd
* Fixed up describe_model exception when no matching model.
* Segregated tests by Sagemaker entity. Model arn check by regex..
* Python2 compabitility changes.
* Added sagemaker to list of known backends. Corrected urls.
* Added sagemaker special case to moto.server.infer_service_region_host due to irregular url format (use of 'api' subdomain) to support server mode.
* Changes for PR 3105 comments of July 10, 2020
* PR3105 July 10, 2020, 8:55 AM EDT comment: dropped unnecessary re-addition of arn when formulating model list response.
* PR 3105 July 15, 2020 9:10 AM EDT Comment: clean-up SageMakerModelBackend.describe_models logic for finding the model in the dict.
* Optimized imports
Co-authored-by: Joseph Weitekamp <jweite@amazon.com>
2020-07-16 08:12:25 -04:00
|
|
|
|
|
|
|
ERROR_WITH_MODEL_NAME = """{% extends 'single_error' %}
|
|
|
|
{% block extra %}<ModelName>{{ model }}</ModelName>{% endblock %}
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
class SagemakerClientError(RESTError):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
kwargs.setdefault("template", "single_error")
|
|
|
|
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
|
|
|
super(SagemakerClientError, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class ModelError(RESTError):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
kwargs.setdefault("template", "model_error")
|
|
|
|
self.templates["model_error"] = ERROR_WITH_MODEL_NAME
|
|
|
|
super(ModelError, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
class MissingModel(ModelError):
|
|
|
|
code = 404
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(MissingModel, self).__init__(
|
|
|
|
"NoSuchModel", "Could not find model", *args, **kwargs
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-10-30 17:05:06 -04:00
|
|
|
class ValidationError(JsonRESTError):
|
|
|
|
def __init__(self, message, **kwargs):
|
|
|
|
super(ValidationError, self).__init__("ValidationException", message, **kwargs)
|
2021-09-02 20:45:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
class AWSValidationException(AWSError):
|
|
|
|
TYPE = "ValidationException"
|