12
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
See the License for the specific language governing permissions and
14
14
limitations under the License.
15
- */
15
+ */
16
16
17
- // ECS Model Construct.
18
17
import { ISecurityGroup , IVpc , SubnetSelection } from 'aws-cdk-lib/aws-ec2' ;
19
18
import { AmiHardwareType } from 'aws-cdk-lib/aws-ecs' ;
20
19
import { Bucket } from 'aws-cdk-lib/aws-s3' ;
21
20
import { Construct } from 'constructs' ;
22
21
23
22
import { ECSCluster } from './ecsCluster' ;
24
23
import { getModelIdentifier } from './utils' ;
25
- import { BaseProps , Config , Ec2Metadata , EcsSourceType , ModelConfig } from './ecs- schema' ;
24
+ import { BaseProps , Config , Ec2Metadata , EcsClusterConfig , EcsSourceType } from '../../../lib/ schema' ;
26
25
import { StringParameter } from 'aws-cdk-lib/aws-ssm' ;
27
26
28
27
// This is the amount of memory to buffer (or subtract off) from the total instance memory, if we don't include this,
@@ -33,11 +32,11 @@ const CONTAINER_MEMORY_BUFFER = 1024 * 5;
33
32
* Properties for the EcsModel Construct.
34
33
*
35
34
* @property {IVpc } vpc - The virtual private cloud (VPC).
36
- * @property {SecurityGroup } securityGroup - The security group to use for the ECS cluster
37
- * @property {ModelConfig } modelConfig - The model configuration.
35
+ * @property {ISecurityGroup } securityGroup - The security group to use for the ECS cluster
36
+ * @property {EcsClusterConfig } modelConfig - The model configuration.
38
37
*/
39
38
type ECSModelProps = {
40
- modelConfig : ModelConfig ;
39
+ modelConfig : EcsClusterConfig ;
41
40
securityGroup : ISecurityGroup ;
42
41
vpc : IVpc ;
43
42
subnetSelection ?: SubnetSelection ;
@@ -51,10 +50,10 @@ export class EcsModel extends Construct {
51
50
public readonly endpointUrl : string ;
52
51
53
52
/**
54
- * @param {Construct } scope - The parent or owner of the construct.
55
- * @param {string } id - The unique identifier for the construct within its scope.
56
- * @param {ECSModelProps } props - The properties of the construct.
57
- */
53
+ * @param {Construct } scope - The parent or owner of the construct.
54
+ * @param {string } id - The unique identifier for the construct within its scope.
55
+ * @param {ECSModelProps } props - The properties of the construct.
56
+ */
58
57
constructor ( scope : Construct , id : string , props : ECSModelProps ) {
59
58
super ( scope , id ) ;
60
59
const { config, modelConfig, securityGroup, vpc, subnetSelection } = props ;
@@ -87,15 +86,15 @@ export class EcsModel extends Construct {
87
86
}
88
87
89
88
/**
90
- * Generates environment variables for Docker at runtime based on the configuration. The environment variables
91
- * include the local model path, S3 bucket for models, model name, and other variables depending on the model type.
92
- *
93
- * @param {Config } config - The application configuration.
94
- * @param {ModelConfig } modelConfig - Configuration for the specific model.
95
- * @returns {Object } An object containing the environment variables. The object has string keys and values, which
96
- * represent the environment variables for Docker at runtime.
97
- */
98
- private getEnvironmentVariables ( config : Config , modelConfig : ModelConfig ) : { [ key : string ] : string } {
89
+ * Generates environment variables for Docker at runtime based on the configuration. The environment variables
90
+ * include the local model path, S3 bucket for models, model name, and other variables depending on the model type.
91
+ *
92
+ * @param {Config } config - The application configuration.
93
+ * @param {EcsClusterConfig } modelConfig - Configuration for the specific model.
94
+ * @returns {Object } An object containing the environment variables. The object has string keys and values, which
95
+ * represent the environment variables for Docker at runtime.
96
+ */
97
+ private getEnvironmentVariables ( config : Config , modelConfig : EcsClusterConfig ) : { [ key : string ] : string } {
99
98
const environment : { [ key : string ] : string } = {
100
99
LOCAL_MODEL_PATH : `${ config . nvmeContainerMountPath } /model` ,
101
100
S3_BUCKET_MODELS : config . s3BucketModels ,
@@ -127,15 +126,15 @@ export class EcsModel extends Construct {
127
126
}
128
127
129
128
/**
130
- * Generates build arguments for the Docker build based on the configuration. The build arguments include the base
131
- * image, and depending on the model type, either the local code path or the S3 deb URL.
132
- *
133
- * @param {Config } config - The application configuration.
134
- * @param {ModelConfig } modelConfig - Configuration for the specific model.
135
- * @returns {Object } An object containing the build arguments. The object has string keys and values, which represent
136
- * the arguments for the Docker build.
137
- */
138
- private getBuildArguments ( config : Config , modelConfig : ModelConfig ) : { [ key : string ] : string } | undefined {
129
+ * Generates build arguments for the Docker build based on the configuration. The build arguments include the base
130
+ * image, and depending on the model type, either the local code path or the S3 deb URL.
131
+ *
132
+ * @param {Config } config - The application configuration.
133
+ * @param {EcsClusterConfig } modelConfig - Configuration for the specific model.
134
+ * @returns {Object } An object containing the build arguments. The object has string keys and values, which represent
135
+ * the arguments for the Docker build.
136
+ */
137
+ private getBuildArguments ( config : Config , modelConfig : EcsClusterConfig ) : { [ key : string ] : string } | undefined {
139
138
if ( modelConfig . containerConfig . image . type !== EcsSourceType . ASSET ) {
140
139
return undefined ;
141
140
}
0 commit comments