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

Function find_cached_model_missing_shard

cake-core/src/utils/hf.rs:321–350  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

319
320 #[test]
321 fn find_cached_model_missing_shard() {
322 let _lock = ENV_LOCK.lock().unwrap();
323 let tmp = tempfile::tempdir().unwrap();
324 let cache = tmp.path();
325 std::env::set_var("HF_HUB_CACHE", cache.to_str().unwrap());
326
327 let snap = cache
328 .join("models--org--partial")
329 .join("snapshots")
330 .join("ghi789");
331 fs::create_dir_all(&snap).unwrap();
332 fs::write(snap.join("config.json"), "{}").unwrap();
333 let index = serde_json::json!({
334 "weight_map": {
335 "layer.0.weight": "shard-00001.safetensors",
336 "layer.1.weight": "shard-00002.safetensors"
337 }
338 });
339 fs::write(
340 snap.join("model.safetensors.index.json"),
341 serde_json::to_string(&index).unwrap(),
342 )
343 .unwrap();
344 fs::write(snap.join("shard-00001.safetensors"), "data").unwrap();
345
346 let result = find_cached_model("org/partial");
347 assert!(result.is_none());
348
349 std::env::remove_var("HF_HUB_CACHE");
350 }
351
352 #[test]
353 fn find_cached_model_not_present() {

Callers

nothing calls this directly

Calls 1

find_cached_modelFunction · 0.85

Tested by

no test coverage detected