vsview-graph 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ from vsview.api import WidgetPluginBase, hookimpl
6
+
7
+ from .plugin import GraphPlugin
8
+
9
+
10
+ @hookimpl
11
+ def vsview_register_toolpanel() -> type[WidgetPluginBase[Any, Any]]:
12
+ return GraphPlugin
@@ -0,0 +1,322 @@
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ from collections import Counter, defaultdict, deque
5
+ from collections.abc import Iterable, Sequence
6
+ from enum import StrEnum
7
+ from fractions import Fraction
8
+ from logging import getLogger
9
+ from typing import Any, NotRequired, Self, TypedDict
10
+
11
+ import vapoursynth as vs
12
+ import vsgraph
13
+
14
+ logger = getLogger(__name__)
15
+
16
+
17
+ class Severity(StrEnum):
18
+ WARNING = "warning", 0
19
+ INFO = "info", 1
20
+
21
+ order: int
22
+
23
+ def __new__(cls, value: str, order: int) -> Self:
24
+ obj = str.__new__(cls, value)
25
+ obj._value_ = value
26
+ obj.order = order
27
+ return obj
28
+
29
+
30
+ class WarningCode(StrEnum):
31
+ FRAME_STATE = (
32
+ "framestate",
33
+ "Frame-state serialization",
34
+ "Serializes the entire frame lifecycle to one frame at a time, bypassing parallelism.",
35
+ )
36
+ UNORDERED = (
37
+ "unordered",
38
+ "Single-threaded execution (Unordered)",
39
+ "Only one thread can execute the filter's getFrame at a time, with calls in arbitrary order.",
40
+ )
41
+ NO_FRAME_REUSE = (
42
+ "no-frame-reuse",
43
+ "No input frame reuse",
44
+ "Requests each upstream frame at most once, disabling the upstream cache when it has a single consumer.",
45
+ )
46
+ STRICT_SPATIAL = (
47
+ "strict-spatial",
48
+ "Strict 1:1 frame requests (Strict spatial)",
49
+ "Only requests input frame n for output frame n, disabling the upstream cache when it has a single consumer.",
50
+ )
51
+ FRAME_REUSE_LAST_ONLY = (
52
+ "frame-reuse-last-only",
53
+ "Last-frame reuse only",
54
+ (
55
+ "Requests each upstream frame at most once except the last frame, "
56
+ "caching only the last frame when it has a single consumer."
57
+ ),
58
+ )
59
+
60
+ wtitle: str
61
+ description: str
62
+
63
+ def __new__(cls, value: str, wtitle: str, description: str) -> Self:
64
+ obj = str.__new__(cls, value)
65
+ obj._value_ = value
66
+ obj.wtitle = wtitle
67
+ obj.description = description
68
+ return obj
69
+
70
+
71
+ class WarningGroup(TypedDict):
72
+ code: WarningCode
73
+ severity: Severity
74
+ title: str
75
+ description: str
76
+ nodeIds: list[str]
77
+ count: int
78
+
79
+
80
+ class GraphWarning(TypedDict):
81
+ code: WarningCode
82
+ severity: Severity
83
+ nodeId: str
84
+ edgeId: NotRequired[str]
85
+
86
+
87
+ class MediaTransitionGroup(TypedDict):
88
+ signature: str
89
+ fields: list[str]
90
+ transitions: list[MediaTransition]
91
+ targetNodeIds: list[str]
92
+
93
+
94
+ class MediaTransition(TypedDict):
95
+ edgeId: str
96
+ sourceId: str
97
+ targetId: str
98
+ delta: MediaDelta
99
+
100
+
101
+ class MediaDelta(TypedDict):
102
+ fields: list[str]
103
+ label: str
104
+
105
+
106
+ class NameCount(TypedDict):
107
+ name: str
108
+ count: int
109
+
110
+
111
+ def enrich_cytoscape_payload(graph: vsgraph.Graph[Any], payload: dict[str, Any]) -> dict[str, Any]:
112
+ node_depths = compute_node_depths(graph)
113
+ for node_elem in payload.get("nodes", ()):
114
+ node_data = node_elem["data"]
115
+ node_data["depth"] = node_depths.get(node_data["id"], 0)
116
+
117
+ edge_ids = [edge_elem["data"]["id"] for edge_elem in payload.get("edges", ())]
118
+ transitions = collect_media_transitions(graph, edge_ids)
119
+ deltas_by_edge_id = {t["edgeId"]: t["delta"] for t in transitions}
120
+
121
+ for edge_elem in payload.get("edges", ()):
122
+ edge_data = edge_elem["data"]
123
+ if (delta := deltas_by_edge_id.get(edge_data["id"])) is not None:
124
+ edge_data["media_label"] = delta["label"]
125
+ edge_data["media_fields"] = delta["fields"]
126
+
127
+ warnings = collect_warnings(graph, edge_ids)
128
+
129
+ payload["analysis"] = {
130
+ "nodeCount": len(graph.nodes),
131
+ "edgeCount": len(graph.edges),
132
+ "depth": compute_depth(graph),
133
+ "modes": count_by(node.filter_mode.name for node in graph.nodes),
134
+ "patterns": count_by(edge.pattern.name for edge in graph.edges),
135
+ "formats": count_by(node.media_info.format.name for node in graph.nodes),
136
+ "warningCount": len(warnings),
137
+ "warningGroups": group_warnings(warnings),
138
+ "transitionCount": len(transitions),
139
+ "transitionGroups": group_media_transitions(transitions),
140
+ }
141
+
142
+ return payload
143
+
144
+
145
+ def collect_media_transitions(graph: vsgraph.Graph[Any], edge_ids: Sequence[str]) -> list[MediaTransition]:
146
+ """Collect every edge of the graph whose endpoints disagree on media info."""
147
+ by_id = graph.nodes_by_id
148
+ transitions = list[MediaTransition]()
149
+
150
+ for edge, edge_id in zip(graph.edges, edge_ids, strict=True):
151
+ src_node = by_id.get(edge.source)
152
+ dst_node = by_id.get(edge.target)
153
+
154
+ if not src_node or not dst_node:
155
+ logger.warning("Skipping edge %s -> %s: endpoint node missing from graph", edge.source, edge.target)
156
+ continue
157
+
158
+ if not (delta := describe_media_delta(src_node.media_info, dst_node.media_info)):
159
+ continue
160
+
161
+ transitions.append(MediaTransition(edgeId=edge_id, sourceId=edge.source, targetId=edge.target, delta=delta))
162
+
163
+ return transitions
164
+
165
+
166
+ def describe_media_delta(from_info: vsgraph.VideoMediaInfo, to_info: vsgraph.VideoMediaInfo) -> MediaDelta | None:
167
+ """Describe how media properties changed along a single edge."""
168
+ changes = list[tuple[str, str]]()
169
+
170
+ def format_fps(fps: Fraction) -> str:
171
+ """Format rational frame rate with up to 3 decimal places and stripped trailing zeros."""
172
+ return "0" if math.isclose(fps, 0) else f"{fps.numerator / fps.denominator:.3f}".rstrip("0").rstrip(".")
173
+
174
+ if from_info.format_id != to_info.format_id or from_info.format.name != to_info.format.name:
175
+ changes.append(("format", f"{from_info.format.name}→{to_info.format.name}"))
176
+
177
+ if (from_info.width, from_info.height) != (to_info.width, to_info.height):
178
+ changes.append(("resolution", f"{from_info.width}x{from_info.height}→{to_info.width}x{to_info.height}"))
179
+
180
+ if from_info.fps != to_info.fps:
181
+ changes.append(("fps", f"{format_fps(from_info.fps)}→{format_fps(to_info.fps)} fps"))
182
+
183
+ if from_info.num_frames != to_info.num_frames:
184
+ changes.append(("frames", f"{from_info.num_frames}→{to_info.num_frames} frames"))
185
+
186
+ if not changes:
187
+ return None
188
+
189
+ fields, labels = zip(*changes)
190
+ return MediaDelta(fields=list(fields), label=", ".join(labels))
191
+
192
+
193
+ def collect_warnings(graph: vsgraph.Graph[Any], edge_ids: Sequence[str]) -> list[GraphWarning]:
194
+ """Collect concurrency and request-pattern warnings."""
195
+ unique = dict[tuple[str, str, str], GraphWarning]()
196
+
197
+ for node in graph.nodes:
198
+ if node.filter_mode is vs.FilterMode.FRAME_STATE:
199
+ w = GraphWarning(code=WarningCode.FRAME_STATE, severity=Severity.WARNING, nodeId=node.id)
200
+ elif node.filter_mode is vs.FilterMode.UNORDERED:
201
+ w = GraphWarning(code=WarningCode.UNORDERED, severity=Severity.INFO, nodeId=node.id)
202
+ else:
203
+ continue
204
+ unique.setdefault((w["code"], w["nodeId"], ""), w)
205
+
206
+ for edge, edge_id in zip(graph.edges, edge_ids, strict=True):
207
+ if edge.pattern is vsgraph.RequestPattern.NO_FRAME_REUSE:
208
+ w = GraphWarning(
209
+ code=WarningCode.NO_FRAME_REUSE, severity=Severity.WARNING, edgeId=edge_id, nodeId=edge.target
210
+ )
211
+ elif edge.pattern is vsgraph.RequestPattern.STRICT_SPATIAL:
212
+ w = GraphWarning(
213
+ code=WarningCode.STRICT_SPATIAL, severity=Severity.INFO, edgeId=edge_id, nodeId=edge.target
214
+ )
215
+ elif edge.pattern is vsgraph.RequestPattern.FRAME_REUSE_LAST_ONLY:
216
+ w = GraphWarning(
217
+ code=WarningCode.FRAME_REUSE_LAST_ONLY, severity=Severity.INFO, edgeId=edge_id, nodeId=edge.target
218
+ )
219
+ else:
220
+ continue
221
+ unique.setdefault((w["code"], w["nodeId"], w.get("edgeId", "")), w)
222
+
223
+ return sorted(unique.values(), key=lambda w: (w["severity"].order, w["code"]))
224
+
225
+
226
+ def compute_depth(graph: vsgraph.Graph[Any]) -> int:
227
+ """
228
+ Longest dependency chain length, in nodes.
229
+
230
+ Uses a Kahn-style traversal so cycles stop contributing without hanging.
231
+ """
232
+ ids = {node.id for node in graph.nodes}
233
+ indegree = dict.fromkeys(ids, 0)
234
+ adjacency: defaultdict[str, list[str]] = defaultdict(list)
235
+
236
+ for edge in graph.edges:
237
+ if edge.source in ids and edge.target in ids:
238
+ adjacency[edge.source].append(edge.target)
239
+ indegree[edge.target] += 1
240
+
241
+ depth = dict.fromkeys(ids, 1)
242
+ queue = deque(node_id for node_id, degree in indegree.items() if degree == 0)
243
+
244
+ while queue:
245
+ node_id = queue.popleft()
246
+ for nxt in adjacency[node_id]:
247
+ depth[nxt] = max(depth[nxt], depth[node_id] + 1)
248
+ indegree[nxt] -= 1
249
+ if indegree[nxt] == 0:
250
+ queue.append(nxt)
251
+
252
+ return max(depth.values(), default=0)
253
+
254
+
255
+ def compute_node_depths(graph: vsgraph.Graph[Any]) -> dict[str, int]:
256
+ """Longest path, in edges, from each node down to a sink. Nodes on or upstream of a cycle stay at 0."""
257
+ ids = {node.id for node in graph.nodes}
258
+ outdegree = dict.fromkeys(ids, 0)
259
+ parents: defaultdict[str, list[str]] = defaultdict(list)
260
+
261
+ for edge in graph.edges:
262
+ if edge.source in ids and edge.target in ids:
263
+ parents[edge.target].append(edge.source)
264
+ outdegree[edge.source] += 1
265
+
266
+ depth = dict.fromkeys(ids, 0)
267
+ queue = deque(node_id for node_id, degree in outdegree.items() if degree == 0)
268
+
269
+ while queue:
270
+ node_id = queue.popleft()
271
+ for parent in parents[node_id]:
272
+ depth[parent] = max(depth[parent], depth[node_id] + 1)
273
+ outdegree[parent] -= 1
274
+ if outdegree[parent] == 0:
275
+ queue.append(parent)
276
+
277
+ return depth
278
+
279
+
280
+ def count_by(values: Iterable[str]) -> list[NameCount]:
281
+ counts = Counter(values)
282
+ return [NameCount(name=name, count=count) for name, count in sorted(counts.items(), key=lambda kv: (-kv[1], kv[0]))]
283
+
284
+
285
+ def group_warnings(warnings: Sequence[GraphWarning]) -> list[WarningGroup]:
286
+ by_code: defaultdict[WarningCode, list[GraphWarning]] = defaultdict(list)
287
+ for w in warnings:
288
+ by_code[w["code"]].append(w)
289
+
290
+ groups = list[WarningGroup]()
291
+ for code, members in by_code.items():
292
+ groups.append(
293
+ WarningGroup(
294
+ code=code,
295
+ severity=members[0]["severity"],
296
+ title=code.wtitle,
297
+ description=code.description,
298
+ nodeIds=list(dict.fromkeys(node_id for w in members if (node_id := w.get("nodeId")))),
299
+ count=len(members),
300
+ )
301
+ )
302
+
303
+ return sorted(groups, key=lambda g: (g["severity"].order, -g["count"], g["title"]))
304
+
305
+
306
+ def group_media_transitions(transitions: Iterable[MediaTransition]) -> list[MediaTransitionGroup]:
307
+ """Group media transitions by their transition signature label."""
308
+ by_signature: defaultdict[str, list[MediaTransition]] = defaultdict(list)
309
+ for t in transitions:
310
+ by_signature[t["delta"]["label"]].append(t)
311
+
312
+ groups = [
313
+ MediaTransitionGroup(
314
+ signature=signature,
315
+ fields=members[0]["delta"]["fields"],
316
+ transitions=members,
317
+ targetNodeIds=list(dict.fromkeys(t["targetId"] for t in members)), # ordered de-dup
318
+ )
319
+ for signature, members in by_signature.items()
320
+ ]
321
+
322
+ return sorted(groups, key=lambda g: (-len(g["transitions"]), g["signature"]))
vsview_graph/bridge.py ADDED
@@ -0,0 +1,168 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping, Sequence
4
+ from enum import StrEnum
5
+ from typing import Any, Literal, Self, TypedDict, overload, override
6
+
7
+ from vsview.api import BaseWebChannelBridge
8
+
9
+
10
+ class PyToJsCommand(StrEnum):
11
+ SET_DATA = "graph.setData"
12
+ SET_OPTIONS = "graph.setOptions"
13
+ UPDATE_TIMINGS = "graph.updateTimings"
14
+ SET_OUTPUTS = "graph.setOutputs"
15
+ SELECT_NODE = "graph.selectNode"
16
+ SET_KEYBINDINGS = "graph.setKeybindings"
17
+ FIT_VIEW = "graph.fitView"
18
+ RESET_VIEW = "graph.resetView"
19
+ REQUEST_PNG_EXPORT = "graph.requestPngExport"
20
+ SET_ERROR = "graph.setError"
21
+ THEME_UPDATE = "theme.update"
22
+
23
+
24
+ class JsToPyCommand(StrEnum):
25
+ RELOAD = "graph.reload"
26
+ EXPORT_GRAPH = "graph.exportGraph"
27
+ SAVE_IMAGE = "graph.saveImage"
28
+ OUTPUT_SELECT = "output.select"
29
+ NODE_SELECT = "node.select"
30
+ NODE_DESELECT = "node.deselect"
31
+ NODE_COPY = "node.copy"
32
+ CONTEXT_MENU = "contextmenu.request"
33
+
34
+
35
+ class NodeCopyTarget(StrEnum):
36
+ """Supported node copy targets from the inspector drawer."""
37
+
38
+ description: str
39
+
40
+ ID = "id", "node id"
41
+ CALL = "call", "filter call"
42
+ REPORT = "report", "node report"
43
+
44
+ def __new__(cls, value: str, description: str = "") -> Self:
45
+ obj = str.__new__(cls, value)
46
+ obj._value_ = value
47
+ obj.description = description
48
+ return obj
49
+
50
+
51
+ class ExportFormat(StrEnum):
52
+ suffix: str
53
+ file_filter: str
54
+ label: str
55
+
56
+ DOT = "dot", ".dot", "Graphviz DOT (*.dot)", "DOT"
57
+ MERMAID = "mermaid", ".mmd", "Mermaid flowchart (*.mmd)", "Mermaid"
58
+ ASCII = "ascii", ".txt", "Plain text (*.txt)", "ASCII"
59
+ JSON = "json", ".json", "JSON (*.json)", "JSON"
60
+
61
+ def __new__(cls, value: str, suffix: str = "", file_filter: str = "", label: str = "") -> Self:
62
+ obj = str.__new__(cls, value)
63
+ obj._value_ = value
64
+ obj.suffix = suffix
65
+ obj.file_filter = file_filter
66
+ obj.label = label
67
+ return obj
68
+
69
+
70
+ class OutputItem(TypedDict):
71
+ index: int
72
+ name: str
73
+ isActive: bool
74
+
75
+
76
+ class SetOutputsPayload(TypedDict):
77
+ outputs: Sequence[OutputItem]
78
+ following: bool
79
+
80
+
81
+ class GraphOptionsPayload(TypedDict, total=False):
82
+ direction: Literal["TB", "LR"]
83
+ layout: Literal["dagre", "breadthfirst", "concentric", "grid"]
84
+ rankSep: int
85
+ nodeSep: int
86
+ heatmap: bool
87
+ showTimings: bool
88
+ timingUnit: Literal["auto", "ms", "ns"]
89
+ autoFitOnReload: bool
90
+
91
+
92
+ class NodeTimingUpdate(TypedDict):
93
+ id: str
94
+ processing_time_ns: int
95
+ processing_time_ms: float
96
+
97
+
98
+ class UpdateTimingsPayload(TypedDict):
99
+ timings: Sequence[NodeTimingUpdate]
100
+
101
+
102
+ class SelectNodePayload(TypedDict):
103
+ id: str
104
+
105
+
106
+ class KeybindingRule(TypedDict):
107
+ action: str
108
+ key: str
109
+ ctrl: bool
110
+ shift: bool
111
+ alt: bool
112
+ meta: bool
113
+
114
+
115
+ class SetKeybindingsPayload(TypedDict):
116
+ keybindings: Sequence[KeybindingRule]
117
+
118
+
119
+ class RequestPngExportPayload(TypedDict):
120
+ destination: Literal["clipboard", "file"]
121
+
122
+
123
+ class SetErrorPayload(TypedDict):
124
+ message: str
125
+
126
+
127
+ class ThemeTokens(TypedDict):
128
+ isDark: bool
129
+ bg: str
130
+ surface: str
131
+ surfaceElevated: str
132
+ surfaceHover: str
133
+ border: str
134
+ textPrimary: str
135
+ textSecondary: str
136
+ textMuted: str
137
+ accent: str
138
+ accentAmber: str
139
+ accentEmerald: str
140
+ danger: str
141
+
142
+
143
+ class GraphBridge(BaseWebChannelBridge[PyToJsCommand, JsToPyCommand]):
144
+ @overload # type: ignore[override]
145
+ def dispatch(self, command: Literal[PyToJsCommand.FIT_VIEW, PyToJsCommand.RESET_VIEW]) -> None: ...
146
+ @overload
147
+ def dispatch(self, command: Literal[PyToJsCommand.SET_DATA], payload: Mapping[str, Any]) -> None: ...
148
+ @overload
149
+ def dispatch(self, command: Literal[PyToJsCommand.SET_OPTIONS], payload: GraphOptionsPayload) -> None: ...
150
+ @overload
151
+ def dispatch(self, command: Literal[PyToJsCommand.UPDATE_TIMINGS], payload: UpdateTimingsPayload) -> None: ...
152
+ @overload
153
+ def dispatch(self, command: Literal[PyToJsCommand.SET_OUTPUTS], payload: SetOutputsPayload) -> None: ...
154
+ @overload
155
+ def dispatch(self, command: Literal[PyToJsCommand.SELECT_NODE], payload: SelectNodePayload) -> None: ...
156
+ @overload
157
+ def dispatch(self, command: Literal[PyToJsCommand.SET_KEYBINDINGS], payload: SetKeybindingsPayload) -> None: ...
158
+ @overload
159
+ def dispatch(
160
+ self, command: Literal[PyToJsCommand.REQUEST_PNG_EXPORT], payload: RequestPngExportPayload
161
+ ) -> None: ...
162
+ @overload
163
+ def dispatch(self, command: Literal[PyToJsCommand.SET_ERROR], payload: SetErrorPayload) -> None: ...
164
+ @overload
165
+ def dispatch(self, command: Literal[PyToJsCommand.THEME_UPDATE], payload: ThemeTokens) -> None: ...
166
+ @override
167
+ def dispatch(self, command: PyToJsCommand, payload: Mapping[str, Any] | None = None) -> None:
168
+ super().dispatch(command, payload)
vsview_graph/call.py ADDED
@@ -0,0 +1,122 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from collections.abc import Generator, Sequence
5
+ from itertools import count, islice
6
+ from logging import getLogger
7
+ from typing import Any
8
+
9
+ import vsgraph
10
+
11
+ logger = getLogger(__name__)
12
+
13
+
14
+ def format_timing(nanoseconds: int) -> str:
15
+ if nanoseconds <= 0:
16
+ return ""
17
+ if nanoseconds < 1_000_000:
18
+ return f"{nanoseconds} ns"
19
+ return f"{nanoseconds / 1_000_000:.2f} ms"
20
+
21
+
22
+ def format_python_value(value: Any) -> str:
23
+ match value:
24
+ case None:
25
+ return "None"
26
+ case int() | bool() | float():
27
+ return str(value)
28
+ case str():
29
+ return json.dumps(value)
30
+ case vsgraph.NodeRef() | vsgraph.FrameInfo() | vsgraph.FuncRef():
31
+ return format_python_value(value.to_dict())
32
+ case Sequence():
33
+ return f"[{', '.join(format_python_value(item) for item in value)}]"
34
+ case dict():
35
+ entries = [f"{json.dumps(str(k))}: {format_python_value(v)}" for k, v in value.items()]
36
+ return f"{{{', '.join(entries)}}}"
37
+ case _:
38
+ logger.warning("Invalid Python value %r", value)
39
+ return "<invalid>"
40
+
41
+
42
+ def build_filter_call(node: vsgraph.Node[Any], frame_idx: int = 0) -> str:
43
+ """Reconstruct the Python call recorded at `frame_idx` in the node's call stack (0 is the innermost frame)."""
44
+ if not node.call_stack:
45
+ return f"# {node.name} [{node.id}]: no call frame recorded"
46
+
47
+ if not 0 <= frame_idx < len(node.call_stack):
48
+ return f"# {node.name} [{node.id}]: no call frame at index {frame_idx}"
49
+
50
+ def generate_clip_names() -> Generator[str]:
51
+ yield "clip"
52
+ for n in count(2):
53
+ yield f"clip{n}"
54
+
55
+ frame = node.call_stack[frame_idx]
56
+ clip_names = generate_clip_names()
57
+ positional = list[str]()
58
+ keyword = list[str]()
59
+
60
+ for key, value in frame.to_dict()["arguments"].items():
61
+ if is_clip_reference(value):
62
+ # Arguments are in signature order: once a keyword was emitted, a positional clip would bind to it.
63
+ if keyword:
64
+ keyword.append(f"{key}={next(clip_names)}")
65
+ else:
66
+ positional.append(next(clip_names))
67
+ elif isinstance(value, list) and value and all(map(is_clip_reference, value)):
68
+ names = ", ".join(islice(clip_names, len(value)))
69
+ keyword.append(f"{key}=[{names}]")
70
+ else:
71
+ keyword.append(f"{key}={format_python_value(value)}")
72
+
73
+ clip_names.close()
74
+
75
+ args = ", ".join([*positional, *keyword])
76
+ return f"core.{frame.plugin_ns}.{frame.function}({args})"
77
+
78
+
79
+ def build_node_report(node: vsgraph.Node[Any], *, is_root: bool) -> str:
80
+ """Build a plain-text report of everything recorded for a node."""
81
+ match node.media_info:
82
+ case vsgraph.VideoMediaInfo() as vi:
83
+ media_line = (
84
+ f"Media: {vi.format.name} {vi.width}x{vi.height} @ "
85
+ f"{vi.fps_num}/{vi.fps_den} fps, {vi.num_frames} frames"
86
+ )
87
+ case vsgraph.AudioMediaInfo() as ai:
88
+ media_line = (
89
+ f"Media: {ai.format.name} {ai.sample_rate} Hz, " # no fmt
90
+ f"{ai.num_samples} samples, {ai.num_frames} frames"
91
+ )
92
+ case other:
93
+ media_line = f"Media: {other}"
94
+
95
+ lines = [
96
+ f"{node.name} [{node.id}]",
97
+ f"Mode: {node.filter_mode.name}",
98
+ f"Time: {format_timing(node.processing_time_ns)}",
99
+ media_line,
100
+ "Output root: yes" if is_root else "Output root: no",
101
+ "",
102
+ "Call stack:",
103
+ ]
104
+
105
+ if not node.call_stack:
106
+ lines.append(" (none recorded)")
107
+ return "\n".join(lines)
108
+
109
+ for frame in node.call_stack:
110
+ lines.append(f" [{frame.level}] {frame.plugin_ns}.{frame.function} ({frame.plugin_id})")
111
+ for key, value in frame.to_dict()["arguments"].items():
112
+ lines.append(f" {key} = {format_python_value(value)}")
113
+
114
+ return "\n".join(lines)
115
+
116
+
117
+ def is_clip_reference(value: Any) -> bool:
118
+ if isinstance(value, vsgraph.NodeRef):
119
+ return True
120
+ if isinstance(value, dict):
121
+ return value.get("type") in ("vnode", "anode")
122
+ return False
@@ -0,0 +1,2 @@
1
+ PLUGIN_IDENTIFIER = "jet_vsview_graph"
2
+ PLUGIN_DISPLAY_NAME = "Dependency Graph"