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

Function build_cluster_lines

cake-cli/src/chat.rs:500–633  ·  view source on GitHub ↗
(topo: &TopologyResponse, width: usize)

Source from the content-addressed store, hash-verified

498}
499
500fn build_cluster_lines(topo: &TopologyResponse, width: usize) -> Vec<Line<'static>> {
501 let mut lines: Vec<Line<'static>> = Vec::new();
502
503 // Collect all nodes for VRAM bar scaling
504 let all_vram: Vec<u64> = std::iter::once(topo.master.vram_bytes)
505 .chain(topo.workers.iter().map(|w| w.vram_bytes))
506 .collect();
507 let max_vram = all_vram.iter().copied().max().unwrap_or(1).max(1);
508 let bar_max_width = width.saturating_sub(30).min(40);
509
510 // ── Model info ──
511 lines.push(Line::from(""));
512 lines.push(Line::from(vec![
513 Span::styled(" Model: ", Style::default().fg(Color::DarkGray)),
514 Span::styled(
515 topo.model_id.clone(),
516 Style::default()
517 .fg(Color::White)
518 .add_modifier(Modifier::BOLD),
519 ),
520 ]));
521 lines.push(Line::from(vec![
522 Span::styled(" Layers: ", Style::default().fg(Color::DarkGray)),
523 Span::styled(
524 format!("{}", topo.num_layers),
525 Style::default().fg(Color::White),
526 ),
527 Span::styled(" dtype: ", Style::default().fg(Color::DarkGray)),
528 Span::styled(topo.dtype.clone(), Style::default().fg(Color::White)),
529 Span::styled(" memory: ", Style::default().fg(Color::DarkGray)),
530 Span::styled(
531 human_bytes(topo.memory_bytes),
532 Style::default().fg(Color::White),
533 ),
534 ]));
535 lines.push(Line::from(""));
536 lines.push(Line::from(Span::styled(
537 format!(" {}", "-".repeat(width.saturating_sub(4))),
538 Style::default().fg(Color::DarkGray),
539 )));
540
541 // ── Master node ──
542 let master_label = if topo.master.hostname.is_empty() {
543 "master".to_string()
544 } else {
545 topo.master.hostname.clone()
546 };
547 render_node(
548 &mut lines,
549 &master_label,
550 &topo.master.backend,
551 &topo.master.os,
552 topo.master.vram_bytes,
553 topo.master.tflops,
554 &topo.master.layers,
555 max_vram,
556 bar_max_width,
557 Color::Yellow,

Callers 1

draw_clusterFunction · 0.85

Calls 4

render_nodeFunction · 0.85
push_layer_barFunction · 0.85
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected