Skip to content

Commit 6f00c28

Browse files
committed
feature: Add failure model endpoint
1 parent 6f787ae commit 6f00c28

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

lib/osml/model_endpoint/me_test_endpoints.ts

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ export class METestEndpointsConfig extends BaseConfig {
7979
*/
8080
public DEPLOY_MULTI_CONTAINER_ENDPOINT: boolean;
8181

82+
/**
83+
* Whether to deploy the SageMaker failure model endpoint.
84+
* @default true
85+
*/
86+
public DEPLOY_SM_FAILURE_ENDPOINT: boolean;
87+
8288
/**
8389
* The CPU allocation for the HTTP endpoint.
8490
* @default 4096
@@ -162,6 +168,12 @@ export class METestEndpointsConfig extends BaseConfig {
162168
*/
163169
public SM_FLOOD_MODEL: string;
164170

171+
/**
172+
* The name of the SageMaker endpoint for the failure model.
173+
* @default "failure"
174+
*/
175+
public SM_FAILURE_MODEL: string;
176+
165177
/**
166178
* The SageMaker GPU instance type.
167179
*/
@@ -189,6 +201,7 @@ export class METestEndpointsConfig extends BaseConfig {
189201
DEPLOY_SM_CENTERPOINT_ENDPOINT: true,
190202
DEPLOY_SM_FLOOD_ENDPOINT: true,
191203
DEPLOY_MULTI_CONTAINER_ENDPOINT: true,
204+
DEPLOY_SM_FAILURE_ENDPOINT: true,
192205
HTTP_ENDPOINT_CPU: 4096,
193206
HTTP_ENDPOINT_CONTAINER_PORT: 8080,
194207
HTTP_ENDPOINT_DOMAIN_NAME: "test-http-model-endpoint",
@@ -201,6 +214,7 @@ export class METestEndpointsConfig extends BaseConfig {
201214
SM_FLOOD_MODEL: "flood",
202215
SM_MULTI_CONTAINER_ENDPOINT: "multi-container",
203216
SM_CPU_INSTANCE_TYPE: "ml.m5.xlarge",
217+
SM_FAILURE_MODEL: "failure",
204218
...config
205219
});
206220
}
@@ -280,6 +294,11 @@ export class METestEndpoints extends Construct {
280294
*/
281295
public floodModelEndpoint?: MESMEndpoint;
282296

297+
/**
298+
* SM model endpoint for the flood model.
299+
*/
300+
public failureModelEndpoint?: MESMEndpoint;
301+
283302
/**
284303
* SM model endpoint for the aircraft model.
285304
*/
@@ -345,7 +364,8 @@ export class METestEndpoints extends Construct {
345364
this.config.DEPLOY_HTTP_AIRCRAFT_ENDPOINT ||
346365
this.config.DEPLOY_SM_CENTERPOINT_ENDPOINT ||
347366
this.config.DEPLOY_SM_AIRCRAFT_ENDPOINT ||
348-
this.config.DEPLOY_SM_FLOOD_ENDPOINT
367+
this.config.DEPLOY_SM_FLOOD_ENDPOINT ||
368+
this.config.DEPLOY_SM_FAILURE_ENDPOINT
349369
) {
350370
this.modelContainer = new OSMLContainer(this, "MEContainer", {
351371
account: props.account,
@@ -467,6 +487,31 @@ export class METestEndpoints extends Construct {
467487
this.floodModelEndpoint.node.addDependency(this.modelContainer);
468488
}
469489

490+
if (this.config.DEPLOY_SM_FAILURE_ENDPOINT) {
491+
// Build an SM endpoint from the failure model container
492+
this.failureModelEndpoint = new MESMEndpoint(
493+
this,
494+
"OSMLFailureModelEndpoint",
495+
{
496+
containerImageUri: this.modelContainer.containerUri,
497+
modelName: this.config.SM_FAILURE_MODEL,
498+
roleArn: this.smRole.roleArn,
499+
instanceType: this.config.SM_CPU_INSTANCE_TYPE,
500+
subnetIds: props.osmlVpc.selectedSubnets.subnetIds,
501+
config: [
502+
new MESMEndpointConfig({
503+
CONTAINER_ENV: {
504+
MODEL_SELECTION: this.config.SM_FAILURE_MODEL
505+
},
506+
SECURITY_GROUP_ID: this.securityGroupId,
507+
REPOSITORY_ACCESS_MODE: this.modelContainer.repositoryAccessMode
508+
})
509+
]
510+
}
511+
);
512+
this.failureModelEndpoint.node.addDependency(this.modelContainer);
513+
}
514+
470515
// Build an SM endpoint for the aircraft model
471516
if (this.config.DEPLOY_SM_AIRCRAFT_ENDPOINT) {
472517
this.aircraftModelEndpoint = new MESMEndpoint(

test/osml/model_endpoint/me_test_endpoints.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Amazon.com, Inc. or its affiliates.
2+
* Copyright 2024-2025 Amazon.com, Inc. or its affiliates.
33
*/
44

55
import { App, Stack } from "aws-cdk-lib";
@@ -41,6 +41,7 @@ describe("METestEndpoints constructor", () => {
4141
expect(testEndpoints.aircraftModelEndpoint).toBeDefined();
4242
expect(testEndpoints.floodModelEndpoint).toBeDefined();
4343
expect(testEndpoints.httpCenterpointModelEndpoint).toBeDefined();
44+
expect(testEndpoints.failureModelEndpoint).toBeDefined();
4445
});
4546
});
4647
});

0 commit comments

Comments
 (0)