@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.
Files changed (143) hide show
  1. package/LICENSE +202 -0
  2. package/LICENSE-THIRD-PARTY +68620 -0
  3. package/NOTICE +2 -0
  4. package/README.md +106 -0
  5. package/bin/cli.js +365 -0
  6. package/config/defaults.json +32 -0
  7. package/config/presets/transformers-djl.json +26 -0
  8. package/config/presets/transformers-gpu.json +24 -0
  9. package/config/presets/transformers-lmi.json +27 -0
  10. package/package.json +129 -0
  11. package/servers/README.md +419 -0
  12. package/servers/base-image-picker/catalogs/model-servers.json +1191 -0
  13. package/servers/base-image-picker/catalogs/python-slim.json +38 -0
  14. package/servers/base-image-picker/catalogs/triton-backends.json +51 -0
  15. package/servers/base-image-picker/catalogs/triton.json +38 -0
  16. package/servers/base-image-picker/index.js +495 -0
  17. package/servers/base-image-picker/manifest.json +17 -0
  18. package/servers/base-image-picker/package.json +15 -0
  19. package/servers/hyperpod-cluster-picker/LICENSE +202 -0
  20. package/servers/hyperpod-cluster-picker/index.js +424 -0
  21. package/servers/hyperpod-cluster-picker/manifest.json +14 -0
  22. package/servers/hyperpod-cluster-picker/package.json +17 -0
  23. package/servers/instance-recommender/LICENSE +202 -0
  24. package/servers/instance-recommender/catalogs/instances.json +852 -0
  25. package/servers/instance-recommender/index.js +284 -0
  26. package/servers/instance-recommender/manifest.json +16 -0
  27. package/servers/instance-recommender/package.json +15 -0
  28. package/servers/lib/LICENSE +202 -0
  29. package/servers/lib/bedrock-client.js +160 -0
  30. package/servers/lib/custom-validators.js +46 -0
  31. package/servers/lib/dynamic-resolver.js +36 -0
  32. package/servers/lib/package.json +11 -0
  33. package/servers/lib/schemas/image-catalog.schema.json +185 -0
  34. package/servers/lib/schemas/instances.schema.json +124 -0
  35. package/servers/lib/schemas/manifest.schema.json +64 -0
  36. package/servers/lib/schemas/model-catalog.schema.json +91 -0
  37. package/servers/lib/schemas/regions.schema.json +26 -0
  38. package/servers/lib/schemas/triton-backends.schema.json +51 -0
  39. package/servers/model-picker/catalogs/jumpstart-public.json +66 -0
  40. package/servers/model-picker/catalogs/popular-diffusors.json +88 -0
  41. package/servers/model-picker/catalogs/popular-transformers.json +226 -0
  42. package/servers/model-picker/index.js +1693 -0
  43. package/servers/model-picker/manifest.json +18 -0
  44. package/servers/model-picker/package.json +20 -0
  45. package/servers/region-picker/LICENSE +202 -0
  46. package/servers/region-picker/catalogs/regions.json +263 -0
  47. package/servers/region-picker/index.js +230 -0
  48. package/servers/region-picker/manifest.json +16 -0
  49. package/servers/region-picker/package.json +15 -0
  50. package/src/app.js +1007 -0
  51. package/src/copy-tpl.js +77 -0
  52. package/src/lib/accelerator-validator.js +39 -0
  53. package/src/lib/asset-manager.js +385 -0
  54. package/src/lib/aws-profile-parser.js +181 -0
  55. package/src/lib/bootstrap-command-handler.js +1647 -0
  56. package/src/lib/bootstrap-config.js +238 -0
  57. package/src/lib/ci-register-helpers.js +124 -0
  58. package/src/lib/ci-report-helpers.js +158 -0
  59. package/src/lib/ci-stage-helpers.js +268 -0
  60. package/src/lib/cli-handler.js +529 -0
  61. package/src/lib/comment-generator.js +544 -0
  62. package/src/lib/community-reports-validator.js +91 -0
  63. package/src/lib/config-manager.js +2106 -0
  64. package/src/lib/configuration-exporter.js +204 -0
  65. package/src/lib/configuration-manager.js +695 -0
  66. package/src/lib/configuration-matcher.js +221 -0
  67. package/src/lib/cpu-validator.js +36 -0
  68. package/src/lib/cuda-validator.js +57 -0
  69. package/src/lib/deployment-config-resolver.js +103 -0
  70. package/src/lib/deployment-entry-schema.js +125 -0
  71. package/src/lib/deployment-registry.js +598 -0
  72. package/src/lib/docker-introspection-validator.js +51 -0
  73. package/src/lib/engine-prefix-resolver.js +60 -0
  74. package/src/lib/huggingface-client.js +172 -0
  75. package/src/lib/key-value-parser.js +37 -0
  76. package/src/lib/known-flags-validator.js +200 -0
  77. package/src/lib/manifest-cli.js +280 -0
  78. package/src/lib/mcp-client.js +303 -0
  79. package/src/lib/mcp-command-handler.js +532 -0
  80. package/src/lib/neuron-validator.js +80 -0
  81. package/src/lib/parameter-schema-validator.js +284 -0
  82. package/src/lib/prompt-runner.js +1349 -0
  83. package/src/lib/prompts.js +1138 -0
  84. package/src/lib/registry-command-handler.js +519 -0
  85. package/src/lib/registry-loader.js +198 -0
  86. package/src/lib/rocm-validator.js +80 -0
  87. package/src/lib/schema-validator.js +157 -0
  88. package/src/lib/sensitive-redactor.js +59 -0
  89. package/src/lib/template-engine.js +156 -0
  90. package/src/lib/template-manager.js +341 -0
  91. package/src/lib/validation-engine.js +314 -0
  92. package/src/prompt-adapter.js +63 -0
  93. package/templates/Dockerfile +300 -0
  94. package/templates/IAM_PERMISSIONS.md +84 -0
  95. package/templates/MIGRATION.md +488 -0
  96. package/templates/PROJECT_README.md +439 -0
  97. package/templates/TEMPLATE_SYSTEM.md +243 -0
  98. package/templates/buildspec.yml +64 -0
  99. package/templates/code/chat_template.jinja +1 -0
  100. package/templates/code/flask/gunicorn_config.py +35 -0
  101. package/templates/code/flask/wsgi.py +10 -0
  102. package/templates/code/model_handler.py +387 -0
  103. package/templates/code/serve +300 -0
  104. package/templates/code/serve.py +175 -0
  105. package/templates/code/serving.properties +105 -0
  106. package/templates/code/start_server.py +39 -0
  107. package/templates/code/start_server.sh +39 -0
  108. package/templates/diffusors/Dockerfile +72 -0
  109. package/templates/diffusors/patch_image_api.py +35 -0
  110. package/templates/diffusors/serve +115 -0
  111. package/templates/diffusors/start_server.sh +114 -0
  112. package/templates/do/.gitkeep +1 -0
  113. package/templates/do/README.md +541 -0
  114. package/templates/do/build +83 -0
  115. package/templates/do/ci +681 -0
  116. package/templates/do/clean +811 -0
  117. package/templates/do/config +260 -0
  118. package/templates/do/deploy +1560 -0
  119. package/templates/do/export +306 -0
  120. package/templates/do/logs +319 -0
  121. package/templates/do/manifest +12 -0
  122. package/templates/do/push +119 -0
  123. package/templates/do/register +580 -0
  124. package/templates/do/run +113 -0
  125. package/templates/do/submit +417 -0
  126. package/templates/do/test +1147 -0
  127. package/templates/hyperpod/configmap.yaml +24 -0
  128. package/templates/hyperpod/deployment.yaml +71 -0
  129. package/templates/hyperpod/pvc.yaml +42 -0
  130. package/templates/hyperpod/service.yaml +17 -0
  131. package/templates/nginx-diffusors.conf +74 -0
  132. package/templates/nginx-predictors.conf +47 -0
  133. package/templates/nginx-tensorrt.conf +74 -0
  134. package/templates/requirements.txt +61 -0
  135. package/templates/sample_model/test_inference.py +123 -0
  136. package/templates/sample_model/train_abalone.py +252 -0
  137. package/templates/test/test_endpoint.sh +79 -0
  138. package/templates/test/test_local_image.sh +80 -0
  139. package/templates/test/test_model_handler.py +180 -0
  140. package/templates/triton/Dockerfile +128 -0
  141. package/templates/triton/config.pbtxt +163 -0
  142. package/templates/triton/model.py +130 -0
  143. package/templates/triton/requirements.txt +11 -0
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Configuration Exporter
3
+ *
4
+ * Handles prompting users to export configurations for community contribution
5
+ * and saving exported configurations to files.
6
+ *
7
+ * Requirements: 7.1, 7.2, 7.3, 7.4
8
+ */
9
+
10
+ import fs from 'fs';
11
+ import path from 'path';
12
+ import { runPrompts } from '../prompt-adapter.js';
13
+
14
+ export default class ConfigurationExporter {
15
+ constructor() {
16
+ // No generator dependency — uses console.log and runPrompts directly
17
+ }
18
+
19
+ /**
20
+ * Detect if configuration should be offered for export
21
+ * Offers export for experimental or unknown configurations
22
+ *
23
+ * @param {Object} config - Configuration profile
24
+ * @returns {boolean} Whether to offer export
25
+ *
26
+ * Requirements: 7.1
27
+ */
28
+ shouldOfferExport(config) {
29
+ if (!config) return false;
30
+
31
+ const validationLevel = config.validationLevel || 'unknown';
32
+
33
+ // Offer export for experimental or unknown configurations
34
+ return validationLevel === 'experimental' || validationLevel === 'unknown';
35
+ }
36
+
37
+ /**
38
+ * Prompt user to export configuration
39
+ * Captures testing notes and deployment results
40
+ *
41
+ * @param {Object} config - Configuration profile to export
42
+ * @returns {Promise<Object|null>} Export data or null if user declined
43
+ *
44
+ * Requirements: 7.1, 7.2, 7.3, 7.4
45
+ */
46
+ async promptForExport(config) {
47
+ if (!this.shouldOfferExport(config)) {
48
+ return null;
49
+ }
50
+
51
+ console.log('\n📤 Configuration Export');
52
+ console.log('━'.repeat(50));
53
+ console.log(`This configuration has validation level: ${config.validationLevel || 'unknown'}`);
54
+ console.log('If you successfully deploy and test this configuration, please consider');
55
+ console.log('sharing it with the community to help others!');
56
+ console.log('');
57
+
58
+ // Ask if user wants to export
59
+ const { wantsToExport } = await runPrompts([
60
+ {
61
+ type: 'confirm',
62
+ name: 'wantsToExport',
63
+ message: 'Would you like to export this configuration for community contribution?',
64
+ default: false
65
+ }
66
+ ]);
67
+
68
+ if (!wantsToExport) {
69
+ console.log('Skipping export. You can always export later after testing.');
70
+ return null;
71
+ }
72
+
73
+ // Collect testing information
74
+ const exportData = await runPrompts([
75
+ {
76
+ type: 'input',
77
+ name: 'instanceType',
78
+ message: 'What instance type did you use (or plan to use) for testing?',
79
+ default: config.recommendedInstanceTypes?.[0] || 'ml.g5.xlarge',
80
+ validate: (input) => {
81
+ if (!input || input.trim() === '') {
82
+ return 'Instance type is required';
83
+ }
84
+ return true;
85
+ }
86
+ },
87
+ {
88
+ type: 'confirm',
89
+ name: 'deploymentSuccess',
90
+ message: 'Did the deployment succeed?',
91
+ default: false
92
+ },
93
+ {
94
+ type: 'confirm',
95
+ name: 'inferenceSuccess',
96
+ message: 'Did inference work correctly?',
97
+ default: false,
98
+ when: (answers) => answers.deploymentSuccess
99
+ },
100
+ {
101
+ type: 'input',
102
+ name: 'testingNotes',
103
+ message: 'Any notes about your testing experience? (optional)',
104
+ default: ''
105
+ },
106
+ {
107
+ type: 'input',
108
+ name: 'testerName',
109
+ message: 'Your name or GitHub handle (optional, for attribution):',
110
+ default: 'Anonymous'
111
+ }
112
+ ]);
113
+
114
+ return exportData;
115
+ }
116
+
117
+ /**
118
+ * Save exported configuration to file
119
+ * Creates a file in the project directory with export instructions
120
+ *
121
+ * @param {Object} exportResult - Result from ConfigurationManager.exportConfiguration()
122
+ * @param {string} destinationPath - Destination directory path
123
+ *
124
+ * Requirements: 7.2, 7.3, 7.5, 7.6
125
+ */
126
+ saveExportToFile(exportResult, destinationPath) {
127
+ const { registryType, configEntry, submissionInstructions, metadata } = exportResult;
128
+
129
+ // Create export filename
130
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').split('T')[0];
131
+ const filename = `config-export-${registryType}-${timestamp}.md`;
132
+ const filepath = path.join(destinationPath, filename);
133
+
134
+ // Create export file content
135
+ const content = `${submissionInstructions}
136
+
137
+ ## Export Metadata
138
+
139
+ \`\`\`json
140
+ ${JSON.stringify(metadata, null, 2)}
141
+ \`\`\`
142
+
143
+ ## Configuration Entry (JSON)
144
+
145
+ \`\`\`json
146
+ ${JSON.stringify(configEntry, null, 2)}
147
+ \`\`\`
148
+ `;
149
+
150
+ // Write file
151
+ fs.writeFileSync(filepath, content, 'utf-8');
152
+
153
+ return filename;
154
+ }
155
+
156
+ /**
157
+ * Display export success message
158
+ *
159
+ * @param {string} filename - Name of exported file
160
+ */
161
+ displayExportSuccess(filename) {
162
+ console.log('');
163
+ console.log('✅ Configuration exported successfully!');
164
+ console.log(`📄 Export saved to: ${filename}`);
165
+ console.log('');
166
+ console.log('Next steps:');
167
+ console.log('1. Review the export file');
168
+ console.log('2. Test your deployment');
169
+ console.log('3. Submit via GitHub issue or pull request');
170
+ console.log('4. Help the community! 🎉');
171
+ console.log('');
172
+ }
173
+
174
+ /**
175
+ * Complete export workflow
176
+ * Prompts user, exports configuration, and saves to file
177
+ *
178
+ * @param {Object} config - Configuration profile
179
+ * @param {Object} configurationManager - ConfigurationManager instance
180
+ * @param {string} destinationPath - Destination directory path
181
+ * @returns {Promise<boolean>} Whether export was completed
182
+ *
183
+ * Requirements: 7.1, 7.2, 7.3, 7.4, 7.5, 7.6
184
+ */
185
+ async exportWorkflow(config, configurationManager, destinationPath) {
186
+ // Prompt for export
187
+ const exportData = await this.promptForExport(config);
188
+
189
+ if (!exportData) {
190
+ return false;
191
+ }
192
+
193
+ // Export configuration
194
+ const exportResult = configurationManager.exportConfiguration(config, exportData);
195
+
196
+ // Save to file
197
+ const filename = this.saveExportToFile(exportResult, destinationPath);
198
+
199
+ // Display success message
200
+ this.displayExportSuccess(filename);
201
+
202
+ return true;
203
+ }
204
+ }