Skip to content

Commit

Permalink
Add test for ML's Predict operation
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Feb 5, 2021
1 parent ec280a8 commit ff2fd08
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/1.0/spec/aws/customizations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ AWS Service Customizations

apigateway-customizations
glacier-customizations
machinelearning-customizations
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
======================================
Amazon Machine Learning Customizations
======================================

.. contents:: Table of contents
:depth: 1
:local:
:backlinks: none


----------------------------------------
Set host to value of ``PredictEndpoint``
----------------------------------------

The `Predict operation`_ makes use of an endpoint provided by other operations
in the service. The operation expects that the request will be sent to the
host specified in the ``PredictEndpoint`` parameter. An AWS client SHOULD
automatically set the host for the request to the host from the
``PredictEndpoint`` value.


.. _Predict operation: https://docs.aws.amazon.com/machine-learning/latest/APIReference/API_Predict.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
$version: "1.0"

namespace com.amazonaws.machinelearning

use aws.api#service
use aws.auth#sigv4
use aws.protocols#awsJson1_1
use smithy.test#httpRequestTests

@service(
sdkId: "Machine Learning",
arnNamespace: "machinelearning",
cloudFormationName: "MachineLearning",
cloudTrailEventSource: "machinelearning.amazonaws.com",
endpointPrefix: "machinelearning",
)
@sigv4(
name: "machinelearning",
)
@awsJson1_1
@title("Amazon Machine Learning")
@xmlNamespace(
uri: "http://machinelearning.amazonaws.com/doc/2014-12-12/",
)
service AmazonML_20141212 {
version: "2014-12-12",
operations: [
Predict,
],
}

@httpRequestTests([
{
id: "MachinelearningPredictEndpoint",
documentation: """
MachineLearning's api makes use of generated endpoints that the
customer is then expected to use for the Predict operation. Having
to alter the endpoint for a specific operation would be cumbersome,
so an AWS client should be able to do it for them.""",
protocol: awsJson1_1,
method: "POST",
uri: "/",
host: "example.com",
resolvedHost: "custom.example.com",
body: "{\"MLModelId\": \"foo\", \"Record\": {}, \"PredictEndpoint\": \"https://custom.example.com\"}",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/x-amz-json-1.1"},
params: {
MLModelId: "foo",
Record: {},
PredictEndpoint: "https://custom.example.com/",
}
}
])
operation Predict {
input: PredictInput,
output: PredictOutput,
errors: [
InternalServerException,
InvalidInputException,
LimitExceededException,
PredictorNotMountedException,
ResourceNotFoundException,
],
}

@error("server")
@httpError(500)
structure InternalServerException {
message: ErrorMessage,
code: ErrorCode,
}

@error("client")
@httpError(400)
structure InvalidInputException {
message: ErrorMessage,
code: ErrorCode,
}

@error("client")
@httpError(417)
structure LimitExceededException {
message: ErrorMessage,
code: ErrorCode,
}

structure PredictInput {
@required
MLModelId: EntityId,
@required
Record: Record,
@required
PredictEndpoint: VipURLUnvalidated,
}

structure Prediction {
predictedLabel: Label,
predictedValue: floatLabel,
predictedScores: ScoreValuePerLabelMap,
details: DetailsMap,
}

@error("client")
@httpError(400)
structure PredictorNotMountedException {
message: ErrorMessage,
}

structure PredictOutput {
Prediction: Prediction,
}

@error("client")
@httpError(404)
structure ResourceNotFoundException {
message: ErrorMessage,
code: ErrorCode,
}

map DetailsMap {
key: DetailsAttributes,
value: DetailsValue,
}

map Record {
key: VariableName,
value: VariableValue,
}

map ScoreValuePerLabelMap {
key: Label,
value: ScoreValue,
}

@enum([
{
value: "PredictiveModelType",
name: "PREDICTIVE_MODEL_TYPE",
},
{
value: "Algorithm",
name: "ALGORITHM",
},
])
string DetailsAttributes

@length(
min: 1,
)
string DetailsValue

@length(
min: 1,
max: 64,
)
@pattern("[a-zA-Z0-9_.-]+")
string EntityId

integer ErrorCode

@length(
min: 0,
max: 2048,
)
string ErrorMessage

@box
float floatLabel

@length(
min: 1,
)
string Label

float ScoreValue

string VariableName

string VariableValue

string VipURLUnvalidated

0 comments on commit ff2fd08

Please sign in to comment.