Skip to content

Commit 2089892

Browse files
committed
Document models checkpoint structure and fix packageName usage
Clarifies that packageName should be '' (empty string) for flat checkpoint structure that matches workflow caching expectations. Adds inline comments explaining why each call uses packageName=''. Changes: - Remove PACKAGE_NAME constant (was confusing) - Add comments above each packageName='' explaining workflow requirement - Makes it clear this is intentional for workflow caching compatibility No functional changes - just better documentation to prevent future mistakes.
1 parent 7f55cea commit 2089892

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

packages/models/scripts/build.mjs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ const {
8282
outputFinalDir,
8383
} = getBuildPaths(BUILD_MODE)
8484
const DIST_MODE = outputFinalDir
85-
// Use empty string for packageName to create flat checkpoint structure
86-
// (workflow expects checkpoints at build/{mode}/checkpoints/, not build/{mode}/checkpoints/models/)
87-
const PACKAGE_NAME = ''
8885

8986
const logger = getDefaultLogger()
9087

@@ -113,11 +110,12 @@ const MODEL_SOURCES = {
113110
* Download model from Hugging Face.
114111
*/
115112
async function downloadModel(modelKey) {
113+
// Use empty packageName for flat checkpoint structure (workflow caching requirement)
116114
return downloadModelImpl({
117115
modelKey,
118116
modelSources: MODEL_SOURCES,
119117
buildDir: BUILD,
120-
packageName: PACKAGE_NAME,
118+
packageName: '',
121119
modelsDir: MODELS,
122120
forceRebuild: FORCE_BUILD,
123121
})
@@ -127,11 +125,12 @@ async function downloadModel(modelKey) {
127125
* Convert model to ONNX if needed.
128126
*/
129127
async function convertToOnnx(modelKey) {
128+
// Use empty packageName for flat checkpoint structure (workflow caching requirement)
130129
return convertToOnnxImpl({
131130
modelKey,
132131
modelSources: MODEL_SOURCES,
133132
buildDir: BUILD,
134-
packageName: PACKAGE_NAME,
133+
packageName: '',
135134
modelsDir: MODELS,
136135
forceRebuild: FORCE_BUILD,
137136
})
@@ -147,11 +146,12 @@ async function convertToOnnx(modelKey) {
147146
* Results in significant size reduction with minimal accuracy loss.
148147
*/
149148
async function quantizeModel(modelKey, quantLevel) {
149+
// Use empty packageName for flat checkpoint structure (workflow caching requirement)
150150
return quantizeModelImpl({
151151
modelKey,
152152
quantLevel,
153153
buildDir: BUILD,
154-
packageName: PACKAGE_NAME,
154+
packageName: '',
155155
modelsDir: MODELS,
156156
forceRebuild: FORCE_BUILD,
157157
})
@@ -294,7 +294,7 @@ async function main() {
294294
if (outputMissing) {
295295
logger.step('Output artifacts missing - cleaning stale checkpoints')
296296
}
297-
await cleanCheckpoint(BUILD, PACKAGE_NAME)
297+
await cleanCheckpoint(BUILD)
298298
}
299299

300300
// Create directories.
@@ -331,7 +331,6 @@ async function main() {
331331
// Downloaded checkpoint: Archive all downloaded models
332332
await createCheckpoint(
333333
BUILD,
334-
PACKAGE_NAME,
335334
'downloaded',
336335
async () => {
337336
// Smoke test: Verify models directory exists and has models
@@ -353,7 +352,6 @@ async function main() {
353352
// Converted checkpoint: Archive all converted models (same directory)
354353
await createCheckpoint(
355354
BUILD,
356-
PACKAGE_NAME,
357355
'converted',
358356
async () => {
359357
// Smoke test: Verify at least one ONNX file exists
@@ -379,7 +377,6 @@ async function main() {
379377
// Quantized checkpoint: Archive all quantized models (same directory)
380378
await createCheckpoint(
381379
BUILD,
382-
PACKAGE_NAME,
383380
'quantized',
384381
async () => {
385382
// Smoke test: Verify at least one quantized model exists
@@ -426,7 +423,6 @@ async function main() {
426423
// Create finalized checkpoint for caching
427424
await createCheckpoint(
428425
BUILD,
429-
PACKAGE_NAME,
430426
'finalized',
431427
async () => {
432428
// Smoke test: Verify final output files exist

0 commit comments

Comments
 (0)