-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathapp.py
66 lines (53 loc) · 1.92 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab
import os
import aws_cdk as cdk
from cdk_stacks import (
SageMakerExecutionRoleStack,
SageMakerHuggingFaceModelStack,
SageMakerRealtimeEndpointStack,
SageMakerInferenceComponentStack
)
APP_ENV = cdk.Environment(
account=os.environ["CDK_DEFAULT_ACCOUNT"],
region=os.environ["CDK_DEFAULT_REGION"]
)
app = cdk.App()
sm_execution_role = SageMakerExecutionRoleStack(app, 'SageMakerExecutionRoleStack',
env=APP_ENV
)
sm_endpoint = SageMakerRealtimeEndpointStack(app, 'SageMakerRealtimeEndpointStack',
execution_role=sm_execution_role.sagemaker_execution_role,
env=APP_ENV
)
sm_endpoint.add_dependency(sm_execution_role)
sm_model_1 = SageMakerHuggingFaceModelStack(app, 'SageMakerHuggingFaceModel1',
model_id="dolly-v2-7b",
execution_role=sm_execution_role.sagemaker_execution_role,
env=APP_ENV
)
sm_model_1.add_dependency(sm_endpoint)
sm_model_2 = SageMakerHuggingFaceModelStack(app, 'SageMakerHuggingFaceModel2',
model_id="flan-t5-xxl",
execution_role=sm_execution_role.sagemaker_execution_role,
env=APP_ENV
)
sm_model_2.add_dependency(sm_model_1)
sm_inference_component_1 = SageMakerInferenceComponentStack(app, 'SageMakerInferenceComponent1',
inference_component_name="ic-dolly-v2-7b",
model_name=sm_model_1.model.model_name,
endpoint_name=sm_endpoint.sagemaker_endpoint.endpoint_name,
variant_name=sm_endpoint.sagemaker_endpoint_variant_name,
env=APP_ENV
)
sm_inference_component_1.add_dependency(sm_model_2)
sm_inference_component_2 = SageMakerInferenceComponentStack(app, 'SageMakerInferenceComponent2',
inference_component_name="ic-flan-t5-xxl",
model_name=sm_model_2.model.model_name,
endpoint_name=sm_endpoint.sagemaker_endpoint.endpoint_name,
variant_name=sm_endpoint.sagemaker_endpoint_variant_name,
env=APP_ENV
)
sm_inference_component_2.add_dependency(sm_inference_component_1)
app.synth()