MCPcopy Create free account
hub / github.com/evilsocket/cake / check_model_dir_sharded_complete

Function check_model_dir_sharded_complete

cake-core/src/utils/models.rs:375–396  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

373
374 #[test]
375 fn check_model_dir_sharded_complete() {
376 let tmp = tempfile::tempdir().unwrap();
377 fs::write(tmp.path().join("config.json"), "{}").unwrap();
378 let index = serde_json::json!({
379 "weight_map": {
380 "layer.0.weight": "shard-00001.safetensors",
381 "layer.1.weight": "shard-00002.safetensors"
382 }
383 });
384 fs::write(
385 tmp.path().join("model.safetensors.index.json"),
386 serde_json::to_string(&index).unwrap(),
387 )
388 .unwrap();
389 fs::write(tmp.path().join("shard-00001.safetensors"), "data1").unwrap();
390 fs::write(tmp.path().join("shard-00002.safetensors"), "data2").unwrap();
391
392 let result = check_model_dir(tmp.path());
393 assert!(result.is_some());
394 let (status, _size) = result.unwrap();
395 assert_eq!(status, ModelStatus::Complete);
396 }
397
398 #[test]
399 fn check_model_dir_sharded_missing_shard() {

Callers

nothing calls this directly

Calls 1

check_model_dirFunction · 0.85

Tested by

no test coverage detected