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

Function scan_cake_cache

cake-core/src/utils/models.rs:293–323  ·  view source on GitHub ↗

Scan the Cake cluster cache for worker-received models.

(cake_cache: &Path, models: &mut Vec<LocalModel>)

Source from the content-addressed store, hash-verified

291
292/// Scan the Cake cluster cache for worker-received models.
293fn scan_cake_cache(cake_cache: &Path, models: &mut Vec<LocalModel>) -> Result<()> {
294 let entries = match std::fs::read_dir(cake_cache) {
295 Ok(e) => e,
296 Err(_) => return Ok(()),
297 };
298
299 for entry in entries.flatten() {
300 let dir = entry.path();
301 if !dir.is_dir() {
302 continue;
303 }
304
305 let cluster_hash = entry.file_name().to_string_lossy().to_string();
306
307 if let Some((status, size_bytes)) = check_model_dir(&dir) {
308 // Try to extract a model name from config.json
309 let name = read_model_name_from_config(&dir)
310 .unwrap_or_else(|| format!("cluster:{}", &cluster_hash));
311
312 models.push(LocalModel {
313 name,
314 path: dir,
315 source: ModelSource::ClusterCache { cluster_hash },
316 status,
317 size_bytes,
318 });
319 }
320 }
321
322 Ok(())
323}
324
325/// Try to read a model name from config.json (e.g. _name_or_path field).
326fn read_model_name_from_config(dir: &Path) -> Option<String> {

Callers 1

list_modelsFunction · 0.85

Calls 3

check_model_dirFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected