Commit b5bcb07
authored
test: add TestAutoModelfile (#84)
* test: add TestAutoModelfile
Signed-off-by: Zhao Chen <[email protected]>
* feat: add cleanModelName function for model name sanitization
Adds a new cleanModelName function to sanitize model names by:
- Removing trailing slashes
- Replacing invalid characters with underscores
- Trimming leading/trailing underscores
- Providing a default name for empty inputs
Updates AutoModelfile to use the new cleanModelName function when generating model names
Signed-off-by: Zhao Chen <[email protected]>
* refactor: change Paramsize type from string to uint64
This change modifies the Paramsize field in ModelfileGenConfig from a string to a uint64, updating related code in generate.go, modelfile.go, and modelfile_test.go to support numeric parameter size representation. The changes include:
- Updated CLI flag type from string to uint64
- Modified ModelfileGenConfig struct
- Updated test cases to use numeric parameter sizes
- Converted Paramsize to string representation when needed
Signed-off-by: Zhao Chen <[email protected]>
* refactor: improve modelfile generation error handling and validation
- Add more descriptive error messages for modelfile generation
- Enhance validation checks in AutoModelfile method
- Improve handling of unrecognized files and empty directories
- Add nil config check and more informative error messages
- Update comments for better code readability
Signed-off-by: Zhao Chen <[email protected]>
* refactor: change Paramsize back to string type
- Reverted Paramsize type from uint64 to string
- Updated CLI flag to accept string parameter sizes like "7B", "13B"
- Modified ModelfileGenConfig and related code to support string-based parameter sizes
- Updated test cases to use string parameter size representation
Signed-off-by: Zhao Chen <[email protected]>
* refactor: improve modelfile generation path handling and skippable file detection
- Convert model and modelfile paths to absolute paths
- Remove redundant absolute path conversion
- Add special handling for current and parent directory in skippable file detection
- Simplify error handling for path-related operations
Signed-off-by: Zhao Chen <[email protected]>
---------
Signed-off-by: Zhao Chen <[email protected]>1 parent 315dec6 commit b5bcb07
File tree
4 files changed
+240
-20
lines changed- cmd
- pkg/modelfile
4 files changed
+240
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | 72 | | |
74 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
75 | 85 | | |
76 | 86 | | |
77 | | - | |
78 | | - | |
| 87 | + | |
79 | 88 | | |
80 | 89 | | |
81 | 90 | | |
82 | | - | |
| 91 | + | |
83 | 92 | | |
84 | | - | |
| 93 | + | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
88 | 97 | | |
89 | | - | |
| 98 | + | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
93 | 102 | | |
94 | | - | |
| 103 | + | |
95 | 104 | | |
96 | 105 | | |
97 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
186 | 191 | | |
187 | 192 | | |
188 | 193 | | |
| |||
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
198 | 229 | | |
199 | 230 | | |
200 | 231 | | |
| |||
284 | 315 | | |
285 | 316 | | |
286 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
287 | 323 | | |
288 | 324 | | |
289 | 325 | | |
290 | 326 | | |
291 | 327 | | |
292 | 328 | | |
293 | 329 | | |
294 | | - | |
| 330 | + | |
295 | 331 | | |
296 | | - | |
| 332 | + | |
297 | 333 | | |
298 | 334 | | |
299 | 335 | | |
| |||
306 | 342 | | |
307 | 343 | | |
308 | 344 | | |
309 | | - | |
| 345 | + | |
310 | 346 | | |
311 | 347 | | |
312 | 348 | | |
| |||
318 | 354 | | |
319 | 355 | | |
320 | 356 | | |
321 | | - | |
| 357 | + | |
322 | 358 | | |
323 | 359 | | |
324 | 360 | | |
| |||
332 | 368 | | |
333 | 369 | | |
334 | 370 | | |
335 | | - | |
| 371 | + | |
336 | 372 | | |
337 | 373 | | |
338 | 374 | | |
339 | | - | |
| 375 | + | |
340 | 376 | | |
341 | 377 | | |
342 | 378 | | |
| |||
346 | 382 | | |
347 | 383 | | |
348 | 384 | | |
349 | | - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
350 | 391 | | |
351 | 392 | | |
352 | 393 | | |
353 | 394 | | |
354 | | - | |
| 395 | + | |
355 | 396 | | |
356 | 397 | | |
357 | 398 | | |
| |||
533 | 574 | | |
534 | 575 | | |
535 | 576 | | |
536 | | - | |
| 577 | + | |
537 | 578 | | |
538 | 579 | | |
539 | 580 | | |
| |||
563 | 604 | | |
564 | 605 | | |
565 | 606 | | |
566 | | - | |
| 607 | + | |
567 | 608 | | |
568 | 609 | | |
569 | 610 | | |
| |||
588 | 629 | | |
589 | 630 | | |
590 | 631 | | |
591 | | - | |
| 632 | + | |
592 | 633 | | |
593 | 634 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
0 commit comments