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

Function load_index_from_json_file

cake-core/src/utils/split.rs:255–276  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

253
254 #[test]
255 fn load_index_from_json_file() {
256 let tmp = tempfile::tempdir().unwrap();
257 let index_json = serde_json::json!({
258 "weight_map": {
259 "model.layers.0.self_attn.q_proj.weight": "shard-00001.safetensors",
260 "model.layers.0.self_attn.k_proj.weight": "shard-00001.safetensors",
261 "model.layers.1.self_attn.q_proj.weight": "shard-00002.safetensors"
262 }
263 });
264 fs::write(
265 tmp.path().join("model.safetensors.index.json"),
266 serde_json::to_string(&index_json).unwrap(),
267 )
268 .unwrap();
269
270 let index = load_index(tmp.path()).unwrap();
271 assert_eq!(index.weight_map.len(), 3);
272 assert_eq!(
273 index.weight_map["model.layers.0.self_attn.q_proj.weight"],
274 "shard-00001.safetensors"
275 );
276 }
277
278 #[test]
279 fn load_index_missing_both_files() {

Callers

nothing calls this directly

Calls 1

load_indexFunction · 0.85

Tested by

no test coverage detected