siliconcompiler 0.32.1__py3-none-any.whl → 0.32.3__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.
Files changed (187) hide show
  1. siliconcompiler/_metadata.py +3 -2
  2. siliconcompiler/apps/sc_install.py +13 -5
  3. siliconcompiler/apps/sc_remote.py +2 -1
  4. siliconcompiler/core.py +68 -55
  5. siliconcompiler/issue.py +3 -1
  6. siliconcompiler/remote/client.py +55 -16
  7. siliconcompiler/report/__init__.py +3 -2
  8. siliconcompiler/report/dashboard/__init__.py +61 -170
  9. siliconcompiler/report/dashboard/cli/__init__.py +788 -0
  10. siliconcompiler/report/dashboard/web/__init__.py +196 -0
  11. siliconcompiler/report/dashboard/{components → web/components}/__init__.py +4 -4
  12. siliconcompiler/report/dashboard/{components → web/components}/graph.py +1 -1
  13. siliconcompiler/report/dashboard/{layouts → web/layouts}/__init__.py +3 -3
  14. siliconcompiler/report/dashboard/{layouts → web/layouts}/_common.py +1 -1
  15. siliconcompiler/report/dashboard/{layouts → web/layouts}/vertical_flowgraph.py +5 -5
  16. siliconcompiler/report/dashboard/{layouts → web/layouts}/vertical_flowgraph_node_tab.py +6 -6
  17. siliconcompiler/report/dashboard/{layouts → web/layouts}/vertical_flowgraph_sac_tabs.py +6 -6
  18. siliconcompiler/report/dashboard/{viewer.py → web/viewer.py} +4 -4
  19. siliconcompiler/scheduler/__init__.py +44 -13
  20. siliconcompiler/scheduler/docker_runner.py +2 -1
  21. siliconcompiler/sphinx_ext/dynamicgen.py +11 -11
  22. siliconcompiler/templates/replay/replay.sh.j2 +2 -2
  23. siliconcompiler/templates/tcl/manifest.tcl.j2 +4 -120
  24. siliconcompiler/tools/_common/__init__.py +2 -0
  25. siliconcompiler/tools/_common/tcl/sc_schema_access.tcl +126 -0
  26. siliconcompiler/tools/openroad/_apr.py +7 -0
  27. siliconcompiler/tools/openroad/fillmetal_insertion.py +14 -14
  28. siliconcompiler/tools/openroad/scripts/apr/sc_antenna_repair.tcl +1 -1
  29. siliconcompiler/tools/openroad/scripts/apr/sc_clock_tree_synthesis.tcl +1 -1
  30. siliconcompiler/tools/openroad/scripts/apr/sc_detailed_placement.tcl +1 -1
  31. siliconcompiler/tools/openroad/scripts/apr/sc_detailed_route.tcl +1 -1
  32. siliconcompiler/tools/openroad/scripts/apr/sc_endcap_tapcell_insertion.tcl +1 -1
  33. siliconcompiler/tools/openroad/scripts/apr/sc_fillercell_insertion.tcl +1 -1
  34. siliconcompiler/tools/openroad/scripts/apr/sc_fillmetal_insertion.tcl +2 -2
  35. siliconcompiler/tools/openroad/scripts/apr/sc_global_placement.tcl +1 -1
  36. siliconcompiler/tools/openroad/scripts/apr/sc_global_route.tcl +1 -1
  37. siliconcompiler/tools/openroad/scripts/apr/sc_init_floorplan.tcl +1 -1
  38. siliconcompiler/tools/openroad/scripts/apr/sc_macro_placement.tcl +1 -1
  39. siliconcompiler/tools/openroad/scripts/apr/sc_metrics.tcl +1 -1
  40. siliconcompiler/tools/openroad/scripts/apr/sc_pin_placement.tcl +1 -1
  41. siliconcompiler/tools/openroad/scripts/apr/sc_power_grid.tcl +1 -1
  42. siliconcompiler/tools/openroad/scripts/apr/sc_repair_design.tcl +1 -1
  43. siliconcompiler/tools/openroad/scripts/apr/sc_repair_timing.tcl +54 -8
  44. siliconcompiler/tools/openroad/scripts/apr/sc_write_data.tcl +1 -1
  45. siliconcompiler/tools/openroad/scripts/common/procs.tcl +19 -1
  46. siliconcompiler/tools/openroad/scripts/common/reports.tcl +18 -7
  47. siliconcompiler/tools/openroad/scripts/sc_rcx.tcl +1 -1
  48. siliconcompiler/tools/openroad/scripts/sc_rdlroute.tcl +1 -1
  49. siliconcompiler/tools/openroad/scripts/sc_show.tcl +1 -1
  50. siliconcompiler/tools/opensta/__init__.py +1 -1
  51. siliconcompiler/tools/opensta/scripts/sc_check_library.tcl +1 -1
  52. siliconcompiler/tools/opensta/scripts/sc_procs.tcl +16 -0
  53. siliconcompiler/tools/opensta/scripts/sc_report_libraries.tcl +1 -1
  54. siliconcompiler/tools/opensta/scripts/sc_timing.tcl +35 -7
  55. siliconcompiler/tools/opensta/timing.py +6 -2
  56. siliconcompiler/tools/slang/__init__.py +7 -8
  57. siliconcompiler/tools/sv2v/sv2v.py +4 -1
  58. siliconcompiler/tools/yosys/__init__.py +4 -36
  59. siliconcompiler/tools/yosys/lec.py +3 -4
  60. siliconcompiler/tools/yosys/{syn_asic.tcl → sc_synth_asic.tcl} +87 -0
  61. siliconcompiler/tools/yosys/{syn_fpga.tcl → sc_synth_fpga.tcl} +78 -0
  62. siliconcompiler/tools/yosys/syn_asic.py +36 -11
  63. siliconcompiler/tools/yosys/syn_fpga.py +23 -16
  64. siliconcompiler/toolscripts/_tools.json +23 -9
  65. siliconcompiler/toolscripts/rhel8/install-chisel.sh +2 -0
  66. siliconcompiler/toolscripts/rhel8/install-icarus.sh +1 -0
  67. siliconcompiler/toolscripts/rhel8/install-klayout.sh +2 -0
  68. siliconcompiler/toolscripts/rhel8/install-magic.sh +1 -2
  69. siliconcompiler/toolscripts/rhel8/install-netgen.sh +1 -1
  70. siliconcompiler/toolscripts/rhel8/install-slang.sh +2 -0
  71. siliconcompiler/toolscripts/rhel8/install-surelog.sh +3 -1
  72. siliconcompiler/toolscripts/rhel8/install-sv2v.sh +1 -0
  73. siliconcompiler/toolscripts/rhel8/install-verible.sh +2 -0
  74. siliconcompiler/toolscripts/rhel8/install-verilator.sh +1 -0
  75. siliconcompiler/toolscripts/rhel8/install-xyce.sh +2 -0
  76. siliconcompiler/toolscripts/rhel9/install-chisel.sh +2 -0
  77. siliconcompiler/toolscripts/rhel9/install-ghdl.sh +1 -0
  78. siliconcompiler/toolscripts/rhel9/install-gtkwave.sh +2 -1
  79. siliconcompiler/toolscripts/rhel9/install-icarus.sh +1 -0
  80. siliconcompiler/toolscripts/rhel9/install-klayout.sh +2 -0
  81. siliconcompiler/toolscripts/rhel9/install-magic.sh +1 -2
  82. siliconcompiler/toolscripts/rhel9/install-netgen.sh +1 -1
  83. siliconcompiler/toolscripts/rhel9/install-openroad.sh +2 -0
  84. siliconcompiler/toolscripts/rhel9/install-opensta.sh +76 -0
  85. siliconcompiler/toolscripts/rhel9/install-slang.sh +3 -1
  86. siliconcompiler/toolscripts/rhel9/install-surelog.sh +2 -1
  87. siliconcompiler/toolscripts/rhel9/install-sv2v.sh +1 -0
  88. siliconcompiler/toolscripts/rhel9/install-verible.sh +2 -0
  89. siliconcompiler/toolscripts/rhel9/install-verilator.sh +1 -0
  90. siliconcompiler/toolscripts/rhel9/install-vpr.sh +31 -0
  91. siliconcompiler/toolscripts/rhel9/install-xdm.sh +2 -0
  92. siliconcompiler/toolscripts/rhel9/install-xyce.sh +2 -0
  93. siliconcompiler/toolscripts/rhel9/install-yosys-moosic.sh +2 -0
  94. siliconcompiler/toolscripts/rhel9/install-yosys-parmys.sh +61 -0
  95. siliconcompiler/toolscripts/rhel9/install-yosys-slang.sh +3 -1
  96. siliconcompiler/toolscripts/rhel9/install-yosys.sh +2 -0
  97. siliconcompiler/toolscripts/ubuntu20/install-bambu.sh +2 -0
  98. siliconcompiler/toolscripts/ubuntu20/install-bluespec.sh +2 -0
  99. siliconcompiler/toolscripts/ubuntu20/install-chisel.sh +2 -0
  100. siliconcompiler/toolscripts/ubuntu20/install-ghdl.sh +2 -0
  101. siliconcompiler/toolscripts/ubuntu20/install-gtkwave.sh +2 -0
  102. siliconcompiler/toolscripts/ubuntu20/install-icarus.sh +2 -0
  103. siliconcompiler/toolscripts/ubuntu20/install-icepack.sh +2 -0
  104. siliconcompiler/toolscripts/ubuntu20/install-klayout.sh +2 -0
  105. siliconcompiler/toolscripts/ubuntu20/install-magic.sh +2 -0
  106. siliconcompiler/toolscripts/ubuntu20/install-netgen.sh +2 -0
  107. siliconcompiler/toolscripts/ubuntu20/install-nextpnr.sh +1 -3
  108. siliconcompiler/toolscripts/ubuntu20/install-openroad.sh +2 -0
  109. siliconcompiler/toolscripts/ubuntu20/install-opensta.sh +72 -0
  110. siliconcompiler/toolscripts/ubuntu20/install-slang.sh +3 -1
  111. siliconcompiler/toolscripts/ubuntu20/install-slurm.sh +2 -0
  112. siliconcompiler/toolscripts/ubuntu20/install-surelog.sh +3 -1
  113. siliconcompiler/toolscripts/ubuntu20/install-sv2v.sh +1 -1
  114. siliconcompiler/toolscripts/ubuntu20/install-verible.sh +2 -0
  115. siliconcompiler/toolscripts/ubuntu20/install-verilator.sh +2 -0
  116. siliconcompiler/toolscripts/ubuntu20/install-vpr.sh +2 -0
  117. siliconcompiler/toolscripts/ubuntu20/install-xdm.sh +2 -0
  118. siliconcompiler/toolscripts/ubuntu20/install-xyce.sh +2 -0
  119. siliconcompiler/toolscripts/ubuntu20/install-yosys-moosic.sh +2 -0
  120. siliconcompiler/toolscripts/ubuntu20/install-yosys-parmys.sh +61 -0
  121. siliconcompiler/toolscripts/ubuntu20/install-yosys.sh +2 -0
  122. siliconcompiler/toolscripts/ubuntu22/install-bambu.sh +2 -0
  123. siliconcompiler/toolscripts/ubuntu22/install-bluespec.sh +27 -2
  124. siliconcompiler/toolscripts/ubuntu22/install-chisel.sh +2 -0
  125. siliconcompiler/toolscripts/ubuntu22/install-ghdl.sh +4 -2
  126. siliconcompiler/toolscripts/ubuntu22/install-gtkwave.sh +2 -0
  127. siliconcompiler/toolscripts/ubuntu22/install-icarus.sh +2 -0
  128. siliconcompiler/toolscripts/ubuntu22/install-icepack.sh +2 -0
  129. siliconcompiler/toolscripts/ubuntu22/install-klayout.sh +2 -0
  130. siliconcompiler/toolscripts/ubuntu22/install-magic.sh +2 -0
  131. siliconcompiler/toolscripts/ubuntu22/install-netgen.sh +2 -0
  132. siliconcompiler/toolscripts/ubuntu22/install-nextpnr.sh +1 -2
  133. siliconcompiler/toolscripts/ubuntu22/install-openroad.sh +2 -0
  134. siliconcompiler/toolscripts/ubuntu22/install-opensta.sh +72 -0
  135. siliconcompiler/toolscripts/ubuntu22/install-slang.sh +3 -1
  136. siliconcompiler/toolscripts/ubuntu22/install-slurm.sh +2 -0
  137. siliconcompiler/toolscripts/ubuntu22/install-surelog.sh +3 -1
  138. siliconcompiler/toolscripts/ubuntu22/install-sv2v.sh +1 -1
  139. siliconcompiler/toolscripts/ubuntu22/install-verible.sh +2 -0
  140. siliconcompiler/toolscripts/ubuntu22/install-verilator.sh +2 -0
  141. siliconcompiler/toolscripts/ubuntu22/install-vpr.sh +2 -0
  142. siliconcompiler/toolscripts/ubuntu22/install-xdm.sh +2 -0
  143. siliconcompiler/toolscripts/ubuntu22/install-xyce.sh +2 -0
  144. siliconcompiler/toolscripts/ubuntu22/install-yosys-moosic.sh +2 -0
  145. siliconcompiler/toolscripts/ubuntu22/install-yosys-parmys.sh +61 -0
  146. siliconcompiler/toolscripts/ubuntu22/install-yosys-slang.sh +3 -1
  147. siliconcompiler/toolscripts/ubuntu22/install-yosys.sh +2 -0
  148. siliconcompiler/toolscripts/ubuntu24/install-bambu.sh +2 -0
  149. siliconcompiler/toolscripts/ubuntu24/install-bluespec.sh +2 -0
  150. siliconcompiler/toolscripts/ubuntu24/install-chisel.sh +2 -0
  151. siliconcompiler/toolscripts/ubuntu24/install-ghdl.sh +4 -2
  152. siliconcompiler/toolscripts/ubuntu24/install-gtkwave.sh +2 -0
  153. siliconcompiler/toolscripts/ubuntu24/install-icarus.sh +2 -0
  154. siliconcompiler/toolscripts/ubuntu24/install-icepack.sh +2 -0
  155. siliconcompiler/toolscripts/ubuntu24/install-klayout.sh +2 -0
  156. siliconcompiler/toolscripts/ubuntu24/install-magic.sh +2 -0
  157. siliconcompiler/toolscripts/ubuntu24/install-netgen.sh +2 -0
  158. siliconcompiler/toolscripts/ubuntu24/install-nextpnr.sh +1 -3
  159. siliconcompiler/toolscripts/ubuntu24/install-openroad.sh +2 -0
  160. siliconcompiler/toolscripts/ubuntu24/install-opensta.sh +72 -0
  161. siliconcompiler/toolscripts/ubuntu24/install-slang.sh +3 -1
  162. siliconcompiler/toolscripts/ubuntu24/install-slurm.sh +2 -0
  163. siliconcompiler/toolscripts/ubuntu24/install-surelog.sh +3 -1
  164. siliconcompiler/toolscripts/ubuntu24/install-sv2v.sh +1 -1
  165. siliconcompiler/toolscripts/ubuntu24/install-verible.sh +2 -0
  166. siliconcompiler/toolscripts/ubuntu24/install-verilator.sh +2 -0
  167. siliconcompiler/toolscripts/ubuntu24/install-vpr.sh +2 -0
  168. siliconcompiler/toolscripts/ubuntu24/install-xdm.sh +2 -0
  169. siliconcompiler/toolscripts/ubuntu24/install-xyce.sh +2 -0
  170. siliconcompiler/toolscripts/ubuntu24/install-yosys-moosic.sh +2 -0
  171. siliconcompiler/toolscripts/ubuntu24/install-yosys-parmys.sh +61 -0
  172. siliconcompiler/toolscripts/ubuntu24/install-yosys-slang.sh +3 -1
  173. siliconcompiler/toolscripts/ubuntu24/install-yosys.sh +2 -0
  174. siliconcompiler/utils/__init__.py +4 -1
  175. siliconcompiler/utils/logging.py +88 -34
  176. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info}/METADATA +14 -10
  177. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info}/RECORD +185 -175
  178. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info}/WHEEL +1 -1
  179. siliconcompiler/tools/yosys/sc_syn.tcl +0 -87
  180. siliconcompiler/toolscripts/ubuntu20/install-yosys-slang.sh +0 -22
  181. /siliconcompiler/report/dashboard/{components → web/components}/flowgraph.py +0 -0
  182. /siliconcompiler/report/dashboard/{state.py → web/state.py} +0 -0
  183. /siliconcompiler/report/dashboard/{utils → web/utils}/__init__.py +0 -0
  184. /siliconcompiler/report/dashboard/{utils → web/utils}/file_utils.py +0 -0
  185. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info}/entry_points.txt +0 -0
  186. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info/licenses}/LICENSE +0 -0
  187. {siliconcompiler-0.32.1.dist-info → siliconcompiler-0.32.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,788 @@
1
+ import os
2
+ import threading
3
+ import logging
4
+ import time
5
+
6
+ from collections import deque
7
+ from dataclasses import dataclass, field
8
+ from typing import List, Dict
9
+
10
+ from rich import box
11
+ from rich.theme import Theme
12
+ from rich.live import Live
13
+ from rich.table import Table
14
+ from rich.progress import Progress, BarColumn, TextColumn, MofNCompleteColumn
15
+ from rich.console import Console
16
+ from rich.console import Group
17
+ from rich.padding import Padding
18
+
19
+ from siliconcompiler import SiliconCompilerError, NodeStatus
20
+ from siliconcompiler.report.dashboard import AbstractDashboard
21
+ from siliconcompiler.flowgraph import nodes_to_execute, _get_flowgraph_execution_order, \
22
+ _get_flowgraph_node_inputs, _get_flowgraph_entry_nodes
23
+
24
+
25
+ class LogBufferHandler(logging.Handler):
26
+ def __init__(self, n=50, event=None):
27
+ """
28
+ Initializes the handler.
29
+
30
+ Args:
31
+ n (int): Maximum number of lines to keep.
32
+ event (threading.Event): Optional event to trigger on every log line.
33
+ """
34
+ super().__init__()
35
+ self.buffer = deque(maxlen=n)
36
+ self.event = event
37
+ self._lock = threading.Lock()
38
+
39
+ def emit(self, record):
40
+ """
41
+ Processes a log record.
42
+
43
+ Args:
44
+ record (logging.LogRecord): The log record to process.
45
+ """
46
+ log_entry = self.format(record)
47
+ with self._lock:
48
+ self.buffer.append(log_entry)
49
+ if self.event:
50
+ self.event.set()
51
+
52
+ def get_lines(self, lines=None):
53
+ """
54
+ Retrieves the last logged lines.
55
+
56
+ Returns:
57
+ list: A list of the last logged lines.
58
+ """
59
+ with self._lock:
60
+ buffer_list = list(self.buffer)
61
+ if lines is None or lines > len(buffer_list):
62
+ return buffer_list
63
+ return buffer_list[-lines:]
64
+
65
+
66
+ @dataclass
67
+ class JobData:
68
+ total: int = 0
69
+ success: int = 0
70
+ error: int = 0
71
+ skipped: int = 0
72
+ finished: int = 0
73
+ jobname: str = ""
74
+ design: str = ""
75
+ runtime: float = 0.0
76
+ nodes: List[dict] = field(default_factory=list)
77
+
78
+
79
+ @dataclass
80
+ class SessionData:
81
+ total: int = 0
82
+ success: int = 0
83
+ error: int = 0
84
+ skipped: int = 0
85
+ finished: int = 0
86
+ runtime: float = 0.0
87
+ jobs: Dict[str, JobData] = field(default_factory=dict)
88
+
89
+
90
+ @dataclass
91
+ class Layout:
92
+ """
93
+ Layout class represents the configuration for a dashboard layout.
94
+
95
+ Attributes:
96
+ height (int): The total height of the layout.
97
+ width (int): The total width of the layout.
98
+ job_board_min (int): The minimum height allocated for the job board.
99
+ job_board_max (int): The maximum height allocated for the job board.
100
+ log_max (int): The maximum height allocated for the log section.
101
+ log_min (int): The minimum height allocated for the log section.
102
+ progress_bar_min (int): The minimum height allocated for the progress bar.
103
+ progress_bar_max (int): The maximum height allocated for the progress bar.
104
+ job_board_show_log (bool): A flag indicating whether to show the log in the job board.
105
+
106
+ __reserved (int): Reserved space for table headings and extra padding.
107
+
108
+ Methods:
109
+ available_height():
110
+ Calculates and returns the available height for other components in the layout
111
+ after accounting for reserved space, job board, and log sections.
112
+ Returns 0 if the total height is not set.
113
+ """
114
+
115
+ height: int = 0
116
+ width: int = 0
117
+
118
+ log_height = 0
119
+ job_board_height = 0
120
+ progress_bar_height = 0
121
+
122
+ job_board_show_log: bool = True
123
+ job_board_v_limit: int = 120
124
+
125
+ __progress_bar_height_default = 1
126
+ padding_log = 2
127
+ padding_progress_bar = 1
128
+ padding_job_board = 1
129
+ padding_job_board_header = 1
130
+
131
+ def update(self, height, width, visible_jobs, visible_bars):
132
+ self.height = height
133
+ self.width = width
134
+
135
+ min_required = (
136
+ max(visible_bars, self.__progress_bar_height_default)
137
+ + self.padding_progress_bar
138
+ )
139
+ if self.height < min_required:
140
+ self.progress_bar_height = 0
141
+ self.job_board_height = 0
142
+ self.log_height = 0
143
+ return
144
+
145
+ remaining_height = self.height
146
+
147
+ # Allocate progress bar space (highest priority)
148
+ self.progress_bar_height = max(visible_bars, self.__progress_bar_height_default)
149
+ if self.progress_bar_height > 0:
150
+ remaining_height -= self.progress_bar_height + self.padding_progress_bar
151
+
152
+ # Calculate job board requirements
153
+ job_board_min_space = self.padding_job_board_header + self.padding_job_board
154
+ job_board_max_nodes = remaining_height // 2
155
+ visible_jobs = min(visible_jobs, job_board_max_nodes)
156
+ if visible_jobs > 0:
157
+ job_board_full_space = visible_jobs + job_board_min_space
158
+ else:
159
+ job_board_full_space = 0
160
+
161
+ # Allocate job board space (second priority)
162
+ if remaining_height <= job_board_min_space:
163
+ self.job_board_height = 0
164
+ self.log_height = 0
165
+ elif remaining_height <= job_board_full_space:
166
+ self.job_board_height = remaining_height - job_board_min_space
167
+ self.log_height = 0
168
+ elif visible_jobs == 0:
169
+ self.job_board_height = 0
170
+ self.log_height = remaining_height
171
+ else:
172
+ self.job_board_height = visible_jobs
173
+ self.log_height = remaining_height - job_board_full_space - self.padding_log
174
+
175
+ if self.width < self.job_board_v_limit:
176
+ self.job_board_show_log = False
177
+
178
+
179
+ class CliDashboard(AbstractDashboard):
180
+ __status_color_map = {
181
+ NodeStatus.PENDING: "blue",
182
+ NodeStatus.QUEUED: "blue",
183
+ NodeStatus.RUNNING: "orange4",
184
+ NodeStatus.SUCCESS: "green",
185
+ NodeStatus.ERROR: "red",
186
+ NodeStatus.SKIPPED: "bright_black",
187
+ NodeStatus.TIMEOUT: "red",
188
+ }
189
+ __theme = Theme(
190
+ {
191
+ # Text colors
192
+ "text.primary": "white",
193
+ "text.secondary": "cyan",
194
+ # Background colors
195
+ "background.primary": "grey15",
196
+ "background.secondary": "dark_blue",
197
+ # Highlight and accent colors
198
+ "highlight": "green",
199
+ "accent": " cyan",
200
+ # Status colors
201
+ "error": "red",
202
+ "warning": "yellow",
203
+ "success": "green",
204
+ # Node status colors
205
+ **{f"node.{status}": color for status, color in __status_color_map.items()},
206
+ # Custom style for headers
207
+ "header": "bold underline cyan",
208
+ }
209
+ )
210
+
211
+ __JOB_BOARD_HEADER = True
212
+
213
+ __JOB_BOARD_BOX = box.SIMPLE_HEAD
214
+
215
+ def __init__(self, chip):
216
+ super().__init__(chip)
217
+
218
+ self._render_event = threading.Event()
219
+ self._render_stop_event = threading.Event()
220
+ self._render_thread = None
221
+
222
+ self._render_data = SessionData()
223
+ self._render_data_lock = threading.Lock()
224
+
225
+ self._console = Console(theme=CliDashboard.__theme)
226
+ self._layout = Layout()
227
+
228
+ self.__logger_console = None
229
+
230
+ if not self.__JOB_BOARD_HEADER:
231
+ self._layout.padding_job_board_header = 0
232
+
233
+ self._logger = chip.logger
234
+
235
+ self._metrics = ("warnings", "errors")
236
+
237
+ def set_logger(self, logger):
238
+ """
239
+ Sets the logger for the dashboard.
240
+
241
+ Args:
242
+ logger (logging.Logger): The logger to set.
243
+ """
244
+ self._logger = logger
245
+ if self._logger:
246
+ self.__log_handler = LogBufferHandler(n=120, event=self._render_event)
247
+ # Hijack the console
248
+ self._logger.removeHandler(self._chip.logger._console)
249
+ self.__logger_console = self._chip.logger._console
250
+ self._chip.logger._console = self.__log_handler
251
+ self._logger.addHandler(self.__log_handler)
252
+ self._chip._init_logger_formats()
253
+
254
+ def open_dashboard(self):
255
+ """Starts the dashboard rendering thread if it is not already running."""
256
+
257
+ if not self.is_running():
258
+ self.set_logger(self._logger)
259
+ self._update_render_data()
260
+
261
+ self._render_thread = threading.Thread(target=self._render, daemon=True)
262
+ self._render_event.clear()
263
+ self._render_stop_event.clear()
264
+
265
+ self._render_thread.start()
266
+
267
+ def update_manifest(self, payload=None):
268
+ """
269
+ Updates the manifest file with the latest data from the chip object.
270
+ This ensures that the dashboard reflects the current state of the chip.
271
+ """
272
+ starttimes = None
273
+ if payload and "starttimes" in payload:
274
+ starttimes = payload["starttimes"]
275
+ self._update_render_data(starttimes=starttimes)
276
+ self._render_event.set()
277
+
278
+ def update_graph_manifests(self):
279
+ """Placeholder method for updating graph manifests. Currently not implemented."""
280
+ pass
281
+
282
+ def is_running(self):
283
+ """Returns True to indicate that the dashboard is running."""
284
+ if not self._render_thread:
285
+ return False
286
+
287
+ return self._render_thread.is_alive()
288
+
289
+ def end_of_run(self):
290
+ """
291
+ Stops the dashboard rendering thread and ensures all rendering operations are completed.
292
+ """
293
+ self.stop()
294
+
295
+ def stop(self):
296
+ """
297
+ Stops the dashboard rendering thread and ensures all rendering operations are completed.
298
+ """
299
+ if not self.is_running():
300
+ return
301
+
302
+ self._render_stop_event.set()
303
+ self._render_event.set()
304
+ # Wait for rendering to finish
305
+ self.wait()
306
+
307
+ # Restore logger
308
+ if self.__logger_console:
309
+ self._logger.removeHandler(self.__log_handler)
310
+ self._chip.logger._console = self.__logger_console
311
+ self._logger.addHandler(self.__logger_console)
312
+ self._chip._init_logger_formats()
313
+ self.__logger_console = None
314
+
315
+ def wait(self):
316
+ """Waits for the dashboard rendering thread to finish."""
317
+ if not self.is_running():
318
+ return
319
+
320
+ self._render_thread.join()
321
+
322
+ @staticmethod
323
+ def format_status(status: str):
324
+ """
325
+ Formats the status of a node for display in the dashboard.
326
+
327
+ Args:
328
+ status (str): The status of the node (e.g., 'running', 'success', 'error').
329
+
330
+ Returns:
331
+ str: A formatted string with the status styled for display.
332
+ """
333
+ return f"[node.{status.lower()}]{status.upper()}[/]"
334
+
335
+ @staticmethod
336
+ def format_node(design, jobname, step, index) -> str:
337
+ """
338
+ Formats a node's information for display in the dashboard.
339
+
340
+ Args:
341
+ design (str): The design name.
342
+ jobname (str): The job name.
343
+ step (str): The step name.
344
+ index (int): The step index.
345
+
346
+ Returns:
347
+ str: A formatted string with the node's information styled for display.
348
+ """
349
+ return f"{design}/{jobname}/{step}/{index}"
350
+
351
+ def _render_log(self, layout):
352
+ if not self._logger or layout.log_height == 0:
353
+ return None
354
+
355
+ table = Table(box=None)
356
+ table.add_column(overflow="ellipsis", no_wrap=True, vertical="bottom")
357
+ table.show_edge = False
358
+ table.show_lines = False
359
+ table.show_footer = False
360
+ table.show_header = False
361
+ for line in self.__log_handler.get_lines(layout.log_height):
362
+ table.add_row(f"[bright_black]{line}[/]")
363
+ while table.row_count < layout.log_height:
364
+ table.add_row("")
365
+
366
+ return Group(table, Padding("", (0, 0)))
367
+
368
+ def _render_job_dashboard(self, layout):
369
+ """
370
+ Creates a table of jobs and their statuses for display in the dashboard.
371
+
372
+ Returns:
373
+ Group: A Rich Group object containing tables for each job.
374
+ """
375
+ # Don't render anything if there is not enough space
376
+ if layout.job_board_height == 0:
377
+ return None
378
+
379
+ with self._render_data_lock:
380
+ job_data = self._render_data.jobs.copy() # Access jobs from SessionData
381
+
382
+ if self.__JOB_BOARD_HEADER:
383
+ table_box = self.__JOB_BOARD_BOX
384
+ else:
385
+ table_box = None
386
+
387
+ table = Table(box=table_box, pad_edge=False)
388
+ table.show_edge = False
389
+ table.show_lines = False
390
+ table.show_footer = False
391
+ table.show_header = self.__JOB_BOARD_HEADER
392
+ table.add_column("Status")
393
+ table.add_column("Node")
394
+ table.add_column("Time", justify="right")
395
+ for metric in self._metrics:
396
+ table.add_column(metric.capitalize(), justify="right")
397
+ if layout.job_board_show_log:
398
+ table.add_column("Log")
399
+
400
+ table_data = []
401
+
402
+ for jobname, job in job_data.items():
403
+ if not job.nodes:
404
+ continue
405
+
406
+ for node in job.nodes:
407
+ if (
408
+ layout.job_board_show_log
409
+ and os.path.exists(node["log"])
410
+ ):
411
+ log_file = "[bright_black]{}[/]".format(node['log'])
412
+ else:
413
+ log_file = None
414
+
415
+ if node["time"]["duration"] is not None:
416
+ duration = f'{node["time"]["duration"]:.1f}s'
417
+ elif node["time"]["start"] is not None:
418
+ duration = f'{time.time() - node["time"]["start"]:.1f}s'
419
+ else:
420
+ duration = ""
421
+
422
+ table_data.append((node["status"], node["step"], node["index"], (
423
+ CliDashboard.format_status(node["status"]),
424
+ CliDashboard.format_node(
425
+ job.design, job.jobname, node["step"], node["index"]
426
+ ),
427
+ duration,
428
+ *node["metrics"],
429
+ log_file
430
+ )))
431
+
432
+ def job_data_fits(table_data):
433
+ return len(table_data) <= layout.job_board_height
434
+
435
+ def remove_pending(table_data, keep_nodes):
436
+ if not keep_nodes:
437
+ keep_nodes = set()
438
+ for n in range(len(table_data)):
439
+ if NodeStatus.is_waiting(table_data[-n][0]):
440
+ if (table_data[-n][1], table_data[-n][2]) not in keep_nodes:
441
+ table_data.pop(-n)
442
+ return table_data
443
+ return table_data
444
+
445
+ def remove_success(table_data, keep_nodes):
446
+ if not keep_nodes:
447
+ keep_nodes = set()
448
+ for n in range(len(table_data)):
449
+ if NodeStatus.is_success(table_data[n][0]):
450
+ if (table_data[n][1], table_data[n][2]) not in keep_nodes:
451
+ table_data.pop(n)
452
+ return table_data
453
+ return table_data
454
+
455
+ def count_table_data(table_data):
456
+ pending = 0
457
+ done = 0
458
+ for status, _, _, _ in table_data:
459
+ if NodeStatus.is_done(status):
460
+ done += 1
461
+ elif NodeStatus.is_waiting(status):
462
+ pending += 1
463
+ return pending, done
464
+
465
+ running_nodes = set([
466
+ (step, index) for status, step, index, _ in table_data
467
+ if NodeStatus.is_running(status)])
468
+
469
+ done_nodes = set([
470
+ (step, index) for status, step, index, _ in table_data
471
+ if NodeStatus.is_done(status)])
472
+
473
+ flow = self._chip.get('option', 'flow')
474
+ entry_nodes = set([node for node in _get_flowgraph_entry_nodes(self._chip, flow)
475
+ if node not in running_nodes and node not in done_nodes])
476
+
477
+ input_nodes = set()
478
+ for step, index in running_nodes:
479
+ input_nodes.update(_get_flowgraph_node_inputs(self._chip, flow, (step, index)))
480
+ input_nodes.update(entry_nodes)
481
+
482
+ output_nodes = set()
483
+ for step, index in nodes_to_execute(self._chip):
484
+ for in_node in self._chip.get('flowgraph', flow, step, index, 'input'):
485
+ if in_node in running_nodes:
486
+ output_nodes.add((step, index))
487
+ output_nodes.update(entry_nodes)
488
+
489
+ # order:
490
+ # loop:
491
+ # remove pending, 1+ removed from running
492
+ # remove success, 1+ removed from running
493
+ # loop:
494
+ # remove pending, any
495
+ # remove success, any
496
+ # trim running to fit
497
+
498
+ while True:
499
+ if job_data_fits(table_data):
500
+ break
501
+ start_len = len(table_data)
502
+ pending, done = count_table_data(table_data)
503
+ if pending >= done:
504
+ table_data = remove_pending(table_data, output_nodes)
505
+ else:
506
+ table_data = remove_success(table_data, input_nodes)
507
+ if len(table_data) == start_len:
508
+ break
509
+
510
+ while True:
511
+ if job_data_fits(table_data):
512
+ break
513
+ start_len = len(table_data)
514
+ pending, done = count_table_data(table_data)
515
+ if pending >= done:
516
+ table_data = remove_pending(table_data, None)
517
+ else:
518
+ table_data = remove_success(table_data, None)
519
+ if len(table_data) == start_len:
520
+ break
521
+
522
+ if not job_data_fits(table_data):
523
+ # trim to fit
524
+ table_data = table_data[0:layout.job_board_height]
525
+
526
+ for _, _, _, row_data in table_data:
527
+ table.add_row(*row_data)
528
+
529
+ if table.row_count == 0:
530
+ return None
531
+
532
+ if self.__JOB_BOARD_HEADER:
533
+ return Group(table, Padding("", (0, 0)))
534
+ return Group(Padding("", (0, 0)), table, Padding("", (0, 0)))
535
+
536
+ def _render_progress_bar(self, layout):
537
+ """
538
+ Creates progress bars showing job completion for display in the dashboard.
539
+
540
+ Returns:
541
+ Group: A Rich Group object containing progress bars for each job.
542
+ """
543
+ with self._render_data_lock:
544
+ job_data = self._render_data.jobs.copy()
545
+ done = self._render_data.finished > 0 \
546
+ and self._render_data.total == self._render_data.finished \
547
+ and self._render_data.success == self._render_data.total
548
+
549
+ if done:
550
+ return None
551
+
552
+ progress = Progress(
553
+ TextColumn("[progress.description]{task.description}"),
554
+ MofNCompleteColumn(),
555
+ BarColumn(bar_width=60),
556
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%")
557
+ )
558
+ nodes = 0
559
+ for _, job in job_data.items():
560
+ nodes += len(job.nodes)
561
+ progress.add_task(
562
+ f"[text.primary]Progress ({job.design}/{job.jobname}):",
563
+ total=job.total,
564
+ completed=job.success,
565
+ )
566
+
567
+ if nodes == 0:
568
+ return Padding("", (0, 0))
569
+
570
+ return Group(progress, Padding("", (0, 0)))
571
+
572
+ def _render_final(self, layout):
573
+ """
574
+ Creates a summary of the final results, including runtime, passed, and failed jobs.
575
+
576
+ Returns:
577
+ Padding: A Rich Padding object containing the summary text.
578
+ """
579
+ with self._render_data_lock:
580
+ success = self._render_data.success
581
+ error = self._render_data.error
582
+ total = self._render_data.total
583
+ finished = self._render_data.finished
584
+ runtime = self._render_data.runtime
585
+
586
+ if finished != 0 and finished == total:
587
+ return Padding(
588
+ f"[text.primary]Results {runtime:.2f}s\n"
589
+ f" [success]{success} passed[/]\n"
590
+ f" [error]{error} failed[/]\n"
591
+ )
592
+
593
+ return self._render_log(layout)
594
+
595
+ def _render(self):
596
+ """
597
+ Main rendering method for the TUI. Continuously updates the dashboard
598
+ with the latest data until the stop event is set.
599
+ """
600
+ live = None
601
+ try:
602
+ live = Live(
603
+ self._get_rendable(),
604
+ console=self._console,
605
+ screen=False,
606
+ # transient=True,
607
+ auto_refresh=True,
608
+ # refresh_per_second=60,
609
+ )
610
+ live.start()
611
+
612
+ while not self._render_stop_event.is_set():
613
+ if self._render_event.wait(timeout=0.2):
614
+ self._render_event.clear()
615
+
616
+ if self._render_stop_event.is_set():
617
+ break
618
+
619
+ live.update(self._get_rendable(), refresh=True)
620
+ finally:
621
+ try:
622
+ if live:
623
+ live.update(self._get_rendable(), refresh=True)
624
+ live.stop()
625
+ else:
626
+ self._console.print(self._get_rendable())
627
+ finally:
628
+ # Restore the prompt
629
+ print("\033[?25h", end="")
630
+
631
+ def _update_layout(self):
632
+ with self._render_data_lock:
633
+ visible_progress_bars = len(self._render_data.jobs)
634
+ visible_jobs_count = self._render_data.total - self._render_data.skipped
635
+
636
+ self._layout.update(
637
+ self._console.height,
638
+ self._console.width,
639
+ visible_jobs_count,
640
+ visible_progress_bars,
641
+ )
642
+
643
+ return self._layout
644
+
645
+ def _get_rendable(self):
646
+ """
647
+ Combines all dashboard components (job table, progress bars, final summary)
648
+ into a single renderable group.
649
+
650
+ Returns:
651
+ Group: A Rich Group object containing all dashboard components.
652
+ """
653
+
654
+ layout = self._update_layout()
655
+
656
+ new_table = self._render_job_dashboard(layout)
657
+ new_bar = self._render_progress_bar(layout)
658
+ footer = self._render_final(layout)
659
+
660
+ items = []
661
+ if new_table:
662
+ items.extend([new_table])
663
+
664
+ if new_bar:
665
+ items.extend([new_bar])
666
+
667
+ if footer:
668
+ items.extend([footer])
669
+
670
+ return Group(*items)
671
+
672
+ def _update_render_data(self, starttimes=None):
673
+ """
674
+ Updates the render data with the latest job and node information from the chip object.
675
+ This data is used to populate the dashboard.
676
+ """
677
+
678
+ job_data = self._get_job(starttimes=starttimes)
679
+
680
+ with self._render_data_lock:
681
+ self._render_data.jobs[self._chip] = job_data
682
+ self._render_data.total = sum(
683
+ job.total for job in self._render_data.jobs.values()
684
+ )
685
+ self._render_data.success = sum(
686
+ job.success for job in self._render_data.jobs.values()
687
+ )
688
+ self._render_data.error = sum(
689
+ job.error for job in self._render_data.jobs.values()
690
+ )
691
+ self._render_data.skipped = sum(
692
+ job.skipped for job in self._render_data.jobs.values()
693
+ )
694
+ self._render_data.finished = sum(
695
+ job.finished for job in self._render_data.jobs.values()
696
+ )
697
+ self._render_data.runtime = max(
698
+ job.runtime for job in self._render_data.jobs.values()
699
+ )
700
+
701
+ def _get_job(self, chip=None, starttimes=None) -> JobData:
702
+ chip = chip or self._chip
703
+
704
+ if not starttimes:
705
+ starttimes = {}
706
+
707
+ nodes = []
708
+ try:
709
+ flow = chip.get("option", "flow")
710
+ if not flow:
711
+ raise SiliconCompilerError("dummy error")
712
+ execnodes = nodes_to_execute(chip)
713
+ for nodeset in _get_flowgraph_execution_order(chip, flow):
714
+ for node in nodeset:
715
+ if node not in execnodes:
716
+ continue
717
+ nodes.append(node)
718
+ except SiliconCompilerError:
719
+ pass
720
+
721
+ design = chip.get("design")
722
+ jobname = chip.get("option", "jobname")
723
+
724
+ job_data = JobData()
725
+ job_data.jobname = jobname
726
+ job_data.design = design
727
+ totaltimes = [
728
+ self._chip.get("metric", "totaltime", step=step, index=index) or 0
729
+ for step, index in nodes
730
+ ]
731
+ if not totaltimes:
732
+ totaltimes = [0]
733
+ job_data.runtime = max(totaltimes)
734
+
735
+ for step, index in nodes:
736
+ status = self._chip.get("record", "status", step=step, index=index)
737
+ if not status:
738
+ status = NodeStatus.PENDING
739
+
740
+ job_data.total += 1
741
+ if NodeStatus.is_error(status):
742
+ job_data.error += 1
743
+ if NodeStatus.is_success(status):
744
+ job_data.success += 1
745
+ if NodeStatus.is_done(status):
746
+ job_data.finished += 1
747
+
748
+ if status == NodeStatus.SKIPPED:
749
+ job_data.skipped += 1
750
+ continue
751
+
752
+ starttime = None
753
+ duration = None
754
+ if NodeStatus.is_done(status):
755
+ duration = self._chip.get("metric", "tasktime", step=step, index=index)
756
+ if (step, index) in starttimes:
757
+ starttime = starttimes[(step, index)]
758
+
759
+ node_metrics = []
760
+ for metric in self._metrics:
761
+ value = self._chip.get('metric', metric,
762
+ step=step, index=index)
763
+ if value is None:
764
+ node_metrics.append("")
765
+ else:
766
+ node_metrics.append(str(value))
767
+
768
+ job_data.nodes.append(
769
+ {
770
+ "step": step,
771
+ "index": index,
772
+ "status": status,
773
+ "time": {
774
+ "start": starttime,
775
+ "duration": duration
776
+ },
777
+ "metrics": node_metrics,
778
+ "log": os.path.join(
779
+ os.path.relpath(
780
+ self._chip.getworkdir(step=step, index=index),
781
+ self._chip.cwd,
782
+ ),
783
+ f"{step}.log",
784
+ ),
785
+ }
786
+ )
787
+
788
+ return job_data