Skip to content

Commit

Permalink
Add description within visualisation (#742)
Browse files Browse the repository at this point in the history
This makes it easier to understand visualization.

## Before

```mermaid
        flowchart TB
  dora-microphone
  dora-vad
  dora-distil-whisper
  dora-rerun[/dora-rerun\]
subgraph ___dora___ [dora]
  subgraph ___timer_timer___ [timer]
    dora/timer/secs/2[\secs/2/]
  end
end
  dora/timer/secs/2 -- tick --> dora-microphone
  dora-microphone -- audio --> dora-vad
  dora-vad -- audio as input --> dora-distil-whisper
  dora-distil-whisper -- text as original_text --> dora-rerun
```

## After

```mermaid
        flowchart TB
  dora-microphone[**dora-microphone**<hr/>*Microphone sending samples of audio data*]
  dora-vad[**dora-vad**<hr/>*Voice Activity Detection using Sidero model filtering audio samples into audio samples including voice.*]
  dora-distil-whisper[**dora-distil-whisper**<hr/>*Whisper model able to transcribe audio.*]
  dora-rerun[/**dora-rerun**<hr/>*Real time visualisation using Rerun.*\]
subgraph ___dora___ [dora]
  subgraph ___timer_timer___ [timer]
    dora/timer/secs/2[\secs/2/]
  end
end
  dora/timer/secs/2 -- tick --> dora-microphone
  dora-microphone -- audio --> dora-vad
  dora-vad -- audio as input --> dora-distil-whisper
  dora-distil-whisper -- text as original_text --> dora-rerun
```
  • Loading branch information
haixuanTao authored Jan 4, 2025
2 parents 36cf2c9 + 39fd51d commit 93a3a69
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions libraries/core/src/descriptor/visualize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,41 @@ fn collect_dora_nodes(

fn visualize_node(node: &ResolvedNode, flowchart: &mut String) {
let node_id = &node.id;
let description = if let Some(desc) = &node.description {
format!("<hr/>*{desc}*")
} else {
"".to_string()
};

match &node.kind {
CoreNodeKind::Custom(node) => visualize_custom_node(node_id, node, flowchart),
CoreNodeKind::Custom(node) => visualize_custom_node(node_id, description, node, flowchart),
CoreNodeKind::Runtime(RuntimeNode { operators, .. }) => {
visualize_runtime_node(node_id, operators, flowchart)
visualize_runtime_node(node_id, description, operators, flowchart)
}
}
}

fn visualize_custom_node(node_id: &NodeId, node: &CustomNode, flowchart: &mut String) {
fn visualize_custom_node(
node_id: &NodeId,
description: String,
node: &CustomNode,
flowchart: &mut String,
) {
if node.run_config.inputs.is_empty() {
// source node
writeln!(flowchart, " {node_id}[\\{node_id}/]").unwrap();
writeln!(flowchart, " {node_id}[\\\"**{node_id}**{description}\"/]").unwrap();
} else if node.run_config.outputs.is_empty() {
// sink node
writeln!(flowchart, " {node_id}[/{node_id}\\]").unwrap();
writeln!(flowchart, " {node_id}[/\"**{node_id}**{description}\"\\]").unwrap();
} else {
// normal node
writeln!(flowchart, " {node_id}").unwrap();
writeln!(flowchart, " {node_id}[\"**{node_id}**{description}\"]").unwrap();
}
}

fn visualize_runtime_node(
node_id: &NodeId,
_description: String,
operators: &[OperatorDefinition],
flowchart: &mut String,
) {
Expand Down

0 comments on commit 93a3a69

Please sign in to comment.