@aws/ml-container-creator 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/LICENSE-THIRD-PARTY +68620 -0
- package/NOTICE +2 -0
- package/README.md +106 -0
- package/bin/cli.js +365 -0
- package/config/defaults.json +32 -0
- package/config/presets/transformers-djl.json +26 -0
- package/config/presets/transformers-gpu.json +24 -0
- package/config/presets/transformers-lmi.json +27 -0
- package/package.json +129 -0
- package/servers/README.md +419 -0
- package/servers/base-image-picker/catalogs/model-servers.json +1191 -0
- package/servers/base-image-picker/catalogs/python-slim.json +38 -0
- package/servers/base-image-picker/catalogs/triton-backends.json +51 -0
- package/servers/base-image-picker/catalogs/triton.json +38 -0
- package/servers/base-image-picker/index.js +495 -0
- package/servers/base-image-picker/manifest.json +17 -0
- package/servers/base-image-picker/package.json +15 -0
- package/servers/hyperpod-cluster-picker/LICENSE +202 -0
- package/servers/hyperpod-cluster-picker/index.js +424 -0
- package/servers/hyperpod-cluster-picker/manifest.json +14 -0
- package/servers/hyperpod-cluster-picker/package.json +17 -0
- package/servers/instance-recommender/LICENSE +202 -0
- package/servers/instance-recommender/catalogs/instances.json +852 -0
- package/servers/instance-recommender/index.js +284 -0
- package/servers/instance-recommender/manifest.json +16 -0
- package/servers/instance-recommender/package.json +15 -0
- package/servers/lib/LICENSE +202 -0
- package/servers/lib/bedrock-client.js +160 -0
- package/servers/lib/custom-validators.js +46 -0
- package/servers/lib/dynamic-resolver.js +36 -0
- package/servers/lib/package.json +11 -0
- package/servers/lib/schemas/image-catalog.schema.json +185 -0
- package/servers/lib/schemas/instances.schema.json +124 -0
- package/servers/lib/schemas/manifest.schema.json +64 -0
- package/servers/lib/schemas/model-catalog.schema.json +91 -0
- package/servers/lib/schemas/regions.schema.json +26 -0
- package/servers/lib/schemas/triton-backends.schema.json +51 -0
- package/servers/model-picker/catalogs/jumpstart-public.json +66 -0
- package/servers/model-picker/catalogs/popular-diffusors.json +88 -0
- package/servers/model-picker/catalogs/popular-transformers.json +226 -0
- package/servers/model-picker/index.js +1693 -0
- package/servers/model-picker/manifest.json +18 -0
- package/servers/model-picker/package.json +20 -0
- package/servers/region-picker/LICENSE +202 -0
- package/servers/region-picker/catalogs/regions.json +263 -0
- package/servers/region-picker/index.js +230 -0
- package/servers/region-picker/manifest.json +16 -0
- package/servers/region-picker/package.json +15 -0
- package/src/app.js +1007 -0
- package/src/copy-tpl.js +77 -0
- package/src/lib/accelerator-validator.js +39 -0
- package/src/lib/asset-manager.js +385 -0
- package/src/lib/aws-profile-parser.js +181 -0
- package/src/lib/bootstrap-command-handler.js +1647 -0
- package/src/lib/bootstrap-config.js +238 -0
- package/src/lib/ci-register-helpers.js +124 -0
- package/src/lib/ci-report-helpers.js +158 -0
- package/src/lib/ci-stage-helpers.js +268 -0
- package/src/lib/cli-handler.js +529 -0
- package/src/lib/comment-generator.js +544 -0
- package/src/lib/community-reports-validator.js +91 -0
- package/src/lib/config-manager.js +2106 -0
- package/src/lib/configuration-exporter.js +204 -0
- package/src/lib/configuration-manager.js +695 -0
- package/src/lib/configuration-matcher.js +221 -0
- package/src/lib/cpu-validator.js +36 -0
- package/src/lib/cuda-validator.js +57 -0
- package/src/lib/deployment-config-resolver.js +103 -0
- package/src/lib/deployment-entry-schema.js +125 -0
- package/src/lib/deployment-registry.js +598 -0
- package/src/lib/docker-introspection-validator.js +51 -0
- package/src/lib/engine-prefix-resolver.js +60 -0
- package/src/lib/huggingface-client.js +172 -0
- package/src/lib/key-value-parser.js +37 -0
- package/src/lib/known-flags-validator.js +200 -0
- package/src/lib/manifest-cli.js +280 -0
- package/src/lib/mcp-client.js +303 -0
- package/src/lib/mcp-command-handler.js +532 -0
- package/src/lib/neuron-validator.js +80 -0
- package/src/lib/parameter-schema-validator.js +284 -0
- package/src/lib/prompt-runner.js +1349 -0
- package/src/lib/prompts.js +1138 -0
- package/src/lib/registry-command-handler.js +519 -0
- package/src/lib/registry-loader.js +198 -0
- package/src/lib/rocm-validator.js +80 -0
- package/src/lib/schema-validator.js +157 -0
- package/src/lib/sensitive-redactor.js +59 -0
- package/src/lib/template-engine.js +156 -0
- package/src/lib/template-manager.js +341 -0
- package/src/lib/validation-engine.js +314 -0
- package/src/prompt-adapter.js +63 -0
- package/templates/Dockerfile +300 -0
- package/templates/IAM_PERMISSIONS.md +84 -0
- package/templates/MIGRATION.md +488 -0
- package/templates/PROJECT_README.md +439 -0
- package/templates/TEMPLATE_SYSTEM.md +243 -0
- package/templates/buildspec.yml +64 -0
- package/templates/code/chat_template.jinja +1 -0
- package/templates/code/flask/gunicorn_config.py +35 -0
- package/templates/code/flask/wsgi.py +10 -0
- package/templates/code/model_handler.py +387 -0
- package/templates/code/serve +300 -0
- package/templates/code/serve.py +175 -0
- package/templates/code/serving.properties +105 -0
- package/templates/code/start_server.py +39 -0
- package/templates/code/start_server.sh +39 -0
- package/templates/diffusors/Dockerfile +72 -0
- package/templates/diffusors/patch_image_api.py +35 -0
- package/templates/diffusors/serve +115 -0
- package/templates/diffusors/start_server.sh +114 -0
- package/templates/do/.gitkeep +1 -0
- package/templates/do/README.md +541 -0
- package/templates/do/build +83 -0
- package/templates/do/ci +681 -0
- package/templates/do/clean +811 -0
- package/templates/do/config +260 -0
- package/templates/do/deploy +1560 -0
- package/templates/do/export +306 -0
- package/templates/do/logs +319 -0
- package/templates/do/manifest +12 -0
- package/templates/do/push +119 -0
- package/templates/do/register +580 -0
- package/templates/do/run +113 -0
- package/templates/do/submit +417 -0
- package/templates/do/test +1147 -0
- package/templates/hyperpod/configmap.yaml +24 -0
- package/templates/hyperpod/deployment.yaml +71 -0
- package/templates/hyperpod/pvc.yaml +42 -0
- package/templates/hyperpod/service.yaml +17 -0
- package/templates/nginx-diffusors.conf +74 -0
- package/templates/nginx-predictors.conf +47 -0
- package/templates/nginx-tensorrt.conf +74 -0
- package/templates/requirements.txt +61 -0
- package/templates/sample_model/test_inference.py +123 -0
- package/templates/sample_model/train_abalone.py +252 -0
- package/templates/test/test_endpoint.sh +79 -0
- package/templates/test/test_local_image.sh +80 -0
- package/templates/test/test_model_handler.py +180 -0
- package/templates/triton/Dockerfile +128 -0
- package/templates/triton/config.pbtxt +163 -0
- package/templates/triton/model.py +130 -0
- package/templates/triton/requirements.txt +11 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parameter Schema Validator
|
|
6
|
+
*
|
|
7
|
+
* Validates infrastructure parameters (endpoint, iC) against constraints
|
|
8
|
+
* defined in the Parameter_Schema JSON file. Supports schema loading from
|
|
9
|
+
* a file path or programmatic object override.
|
|
10
|
+
*
|
|
11
|
+
* Requirements: 10.1, 10.5, 10.6
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import fs from 'fs';
|
|
15
|
+
import path from 'path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
const __dirname = path.dirname(__filename);
|
|
20
|
+
|
|
21
|
+
const BUNDLED_SCHEMA_PATH = path.resolve(__dirname, '..', '..', 'config', 'parameter-schema.json');
|
|
22
|
+
|
|
23
|
+
const SUPPORTED_SCHEMA_VERSION = '1.0.0';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Maps ConfigManager parameter keys to schema lookup paths.
|
|
27
|
+
* Format: 'deploymentTarget.category.schemaKey'
|
|
28
|
+
*/
|
|
29
|
+
const PARAMETER_NAME_MAP = {
|
|
30
|
+
endpointInitialInstanceCount: 'managed-inference.endpoint.initialInstanceCount',
|
|
31
|
+
endpointDataCapturePercent: 'managed-inference.endpoint.dataCapturePercent',
|
|
32
|
+
endpointVariantName: 'managed-inference.endpoint.variantName',
|
|
33
|
+
endpointVolumeSize: 'managed-inference.endpoint.volumeSize',
|
|
34
|
+
icCpuCount: 'managed-inference.inferenceComponent.cpuCount',
|
|
35
|
+
icMemorySize: 'managed-inference.inferenceComponent.memorySize',
|
|
36
|
+
icGpuCount: 'managed-inference.inferenceComponent.gpuCount',
|
|
37
|
+
icCopyCount: 'managed-inference.inferenceComponent.copyCount',
|
|
38
|
+
icModelWeight: 'managed-inference.inferenceComponent.modelWeight'
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default class ParameterSchemaValidator {
|
|
42
|
+
/**
|
|
43
|
+
* @param {string|Object} schemaSource - File path to schema JSON, or schema object override
|
|
44
|
+
*/
|
|
45
|
+
constructor(schemaSource) {
|
|
46
|
+
this.schema = null;
|
|
47
|
+
this._loadSchema(schemaSource);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Load schema from file path or object override.
|
|
52
|
+
* Falls back to bundled baseline on failure.
|
|
53
|
+
* @param {string|Object} schemaSource
|
|
54
|
+
*/
|
|
55
|
+
_loadSchema(schemaSource) {
|
|
56
|
+
if (schemaSource && typeof schemaSource === 'object') {
|
|
57
|
+
this.schema = schemaSource;
|
|
58
|
+
this._checkSchemaVersion();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const filePath = typeof schemaSource === 'string' ? schemaSource : BUNDLED_SCHEMA_PATH;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
66
|
+
this.schema = JSON.parse(raw);
|
|
67
|
+
this._checkSchemaVersion();
|
|
68
|
+
} catch (err) {
|
|
69
|
+
if (filePath !== BUNDLED_SCHEMA_PATH) {
|
|
70
|
+
console.warn(`Parameter schema not found at ${filePath}, using bundled baseline`);
|
|
71
|
+
try {
|
|
72
|
+
const raw = fs.readFileSync(BUNDLED_SCHEMA_PATH, 'utf8');
|
|
73
|
+
this.schema = JSON.parse(raw);
|
|
74
|
+
this._checkSchemaVersion();
|
|
75
|
+
} catch (fallbackErr) {
|
|
76
|
+
console.warn(`Failed to load bundled parameter schema: ${fallbackErr.message}`);
|
|
77
|
+
this.schema = { schemaVersion: SUPPORTED_SCHEMA_VERSION, deploymentTargets: {} };
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
console.warn(`Failed to load bundled parameter schema: ${err.message}`);
|
|
81
|
+
this.schema = { schemaVersion: SUPPORTED_SCHEMA_VERSION, deploymentTargets: {} };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check schema version compatibility.
|
|
88
|
+
*/
|
|
89
|
+
_checkSchemaVersion() {
|
|
90
|
+
const version = this.schema && this.schema.schemaVersion;
|
|
91
|
+
if (version && version !== SUPPORTED_SCHEMA_VERSION) {
|
|
92
|
+
console.warn(`Schema version ${version} is not supported by this generator version`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a parameter name to its schema constraint object.
|
|
98
|
+
* @param {string} parameterName - ConfigManager key (e.g., 'endpointVolumeSize')
|
|
99
|
+
* @param {string} [deploymentTarget] - Deployment target override (e.g., 'managed-inference')
|
|
100
|
+
* @returns {Object|null} Constraint object or null if not found
|
|
101
|
+
*/
|
|
102
|
+
_resolveConstraint(parameterName, deploymentTarget) {
|
|
103
|
+
const schemaPath = PARAMETER_NAME_MAP[parameterName];
|
|
104
|
+
if (!schemaPath) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const parts = schemaPath.split('.');
|
|
109
|
+
let target = parts[0];
|
|
110
|
+
const category = parts[1];
|
|
111
|
+
const key = parts[2];
|
|
112
|
+
|
|
113
|
+
// Allow deployment target override
|
|
114
|
+
if (deploymentTarget) {
|
|
115
|
+
target = deploymentTarget;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const targets = this.schema && this.schema.deploymentTargets;
|
|
119
|
+
if (!targets || !targets[target] || !targets[target][category]) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return targets[target][category][key] || null;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Validate a parameter value against schema constraints.
|
|
128
|
+
* @param {string} parameterName - ConfigManager key (e.g., 'endpointVolumeSize')
|
|
129
|
+
* @param {*} value - The value to validate
|
|
130
|
+
* @param {string} [deploymentTarget] - Deployment target (defaults to schema path target)
|
|
131
|
+
* @returns {{ valid: boolean, error?: string }}
|
|
132
|
+
*/
|
|
133
|
+
validate(parameterName, value, deploymentTarget) {
|
|
134
|
+
const constraint = this._resolveConstraint(parameterName, deploymentTarget);
|
|
135
|
+
if (!constraint) {
|
|
136
|
+
return { valid: true };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Null/undefined values are valid (parameter is optional)
|
|
140
|
+
if (value === null || value === undefined) {
|
|
141
|
+
return { valid: true };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Type validation
|
|
145
|
+
const typeResult = this._validateType(value, constraint);
|
|
146
|
+
if (!typeResult.valid) {
|
|
147
|
+
return {
|
|
148
|
+
valid: false,
|
|
149
|
+
error: this.getErrorMessage(parameterName, value, constraint)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Range validation for numeric types
|
|
154
|
+
if (constraint.type === 'integer' || constraint.type === 'number') {
|
|
155
|
+
const rangeResult = this._validateRange(value, constraint);
|
|
156
|
+
if (!rangeResult.valid) {
|
|
157
|
+
return {
|
|
158
|
+
valid: false,
|
|
159
|
+
error: this.getErrorMessage(parameterName, value, constraint)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Pattern validation for string types
|
|
165
|
+
if (constraint.type === 'string' && constraint.pattern) {
|
|
166
|
+
const patternResult = this._validatePattern(value, constraint);
|
|
167
|
+
if (!patternResult.valid) {
|
|
168
|
+
return {
|
|
169
|
+
valid: false,
|
|
170
|
+
error: this.getErrorMessage(parameterName, value, constraint)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return { valid: true };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Get constraints for a parameter.
|
|
180
|
+
* @param {string} parameterName - ConfigManager key
|
|
181
|
+
* @param {string} [deploymentTarget] - Deployment target override
|
|
182
|
+
* @returns {Object|null} Constraint object or null
|
|
183
|
+
*/
|
|
184
|
+
getConstraints(parameterName, deploymentTarget) {
|
|
185
|
+
return this._resolveConstraint(parameterName, deploymentTarget);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Build a constraint-referencing error message.
|
|
190
|
+
* @param {string} parameterName - ConfigManager key
|
|
191
|
+
* @param {*} value - The invalid value
|
|
192
|
+
* @param {Object} constraint - The constraint object from schema
|
|
193
|
+
* @returns {string} Error message with API reference
|
|
194
|
+
*/
|
|
195
|
+
getErrorMessage(parameterName, value, constraint) {
|
|
196
|
+
const description = this._buildConstraintDescription(constraint);
|
|
197
|
+
const apiRef = constraint.apiReference || 'unknown';
|
|
198
|
+
return `${parameterName} must be ${description} per ${apiRef}`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Build a human-readable constraint description.
|
|
203
|
+
* @param {Object} constraint
|
|
204
|
+
* @returns {string}
|
|
205
|
+
*/
|
|
206
|
+
_buildConstraintDescription(constraint) {
|
|
207
|
+
if (constraint.type === 'string' && constraint.pattern) {
|
|
208
|
+
return `a string matching pattern ${constraint.pattern}`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const parts = [];
|
|
212
|
+
|
|
213
|
+
if (constraint.type === 'integer') {
|
|
214
|
+
parts.push('an integer');
|
|
215
|
+
} else if (constraint.type === 'number') {
|
|
216
|
+
parts.push('a number');
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (constraint.min !== undefined && constraint.max !== undefined) {
|
|
220
|
+
parts.push(`\u2265 ${constraint.min} and \u2264 ${constraint.max}`);
|
|
221
|
+
} else if (constraint.min !== undefined) {
|
|
222
|
+
parts.push(`\u2265 ${constraint.min}`);
|
|
223
|
+
} else if (constraint.max !== undefined) {
|
|
224
|
+
parts.push(`\u2264 ${constraint.max}`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return parts.join(' ') || `a valid ${constraint.type}`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Validate value type against constraint type.
|
|
232
|
+
* @param {*} value
|
|
233
|
+
* @param {Object} constraint
|
|
234
|
+
* @returns {{ valid: boolean }}
|
|
235
|
+
*/
|
|
236
|
+
_validateType(value, constraint) {
|
|
237
|
+
if (constraint.type === 'integer') {
|
|
238
|
+
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
239
|
+
return { valid: false };
|
|
240
|
+
}
|
|
241
|
+
} else if (constraint.type === 'number') {
|
|
242
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
243
|
+
return { valid: false };
|
|
244
|
+
}
|
|
245
|
+
} else if (constraint.type === 'string') {
|
|
246
|
+
if (typeof value !== 'string') {
|
|
247
|
+
return { valid: false };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return { valid: true };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Validate numeric value against min/max bounds.
|
|
255
|
+
* @param {number} value
|
|
256
|
+
* @param {Object} constraint
|
|
257
|
+
* @returns {{ valid: boolean }}
|
|
258
|
+
*/
|
|
259
|
+
_validateRange(value, constraint) {
|
|
260
|
+
if (constraint.min !== undefined && value < constraint.min) {
|
|
261
|
+
return { valid: false };
|
|
262
|
+
}
|
|
263
|
+
if (constraint.max !== undefined && value > constraint.max) {
|
|
264
|
+
return { valid: false };
|
|
265
|
+
}
|
|
266
|
+
return { valid: true };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Validate string value against pattern.
|
|
271
|
+
* @param {string} value
|
|
272
|
+
* @param {Object} constraint
|
|
273
|
+
* @returns {{ valid: boolean }}
|
|
274
|
+
*/
|
|
275
|
+
_validatePattern(value, constraint) {
|
|
276
|
+
const regex = new RegExp(constraint.pattern);
|
|
277
|
+
if (!regex.test(value)) {
|
|
278
|
+
return { valid: false };
|
|
279
|
+
}
|
|
280
|
+
return { valid: true };
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export { PARAMETER_NAME_MAP, SUPPORTED_SCHEMA_VERSION, BUNDLED_SCHEMA_PATH };
|