status_renderers
This module handles creating a formatted task-by-task status display
MerlinDefaultRenderer
Bases: BaseStatusRenderer
This class handles the default status formatting for task-by-task display. It will separate the display on a step-by-step basis, similar to Maestro's 'narrow' status display.
Attributes:
| Name | Type | Description |
|---|---|---|
disable_theme |
bool
|
Flag to disable theming for the display. |
disable_pager |
bool
|
Flag to disable pager functionality for the display. |
_theme_dict |
Dict[str, str]
|
A dictionary containing the theme settings for various status types. |
_status_table |
Table
|
A Table object that contains the formatted status information. |
Methods:
| Name | Description |
|---|---|
create_param_table |
Creates the parameter section of the display. |
create_step_table |
Creates each step entry in the display. |
create_task_details_table |
Creates the task details section of the display. |
layout |
Sets up the overall layout of the display. |
render |
Performs the actual printing of the status table with optional theme customization. |
Source code in merlin/study/status_renderers.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
__init__(*args, **kwargs)
Initializes the MerlinDefaultRenderer instance, which handles the default status formatting
for task-by-task display, with optional theming and pager functionality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
List
|
Positional arguments passed to the superclass ( |
()
|
**kwargs
|
Dict
|
Keyword arguments used to configure the renderer. Supported keys include:
|
{}
|
Source code in merlin/study/status_renderers.py
create_param_table(parameters)
Create the parameter section of the display.
This method generates a formatted table for the parameters associated with each command type. Each command type (e.g., "cmd", "restart") will have its own sub-table displaying the tokens and their corresponding values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Dict[str, Dict[str, str]]
|
A dictionary where each key is a command type (e.g., "cmd", "restart")
and each value is another dictionary containing token-value pairs.
Example format: |
required |
Returns:
| Type | Description |
|---|---|
Columns
|
A rich Columns object containing the formatted parameter tables, arranged side-by-side. |
Source code in merlin/study/status_renderers.py
create_step_table(step_name, parameters, task_queue=None, workers=None)
Create each step entry in the display.
This method constructs a formatted table entry for a specific step in the process, including relevant details such as the step name, associated task queue, worker(s), and any parameters related to the step. Each parameter set will be displayed in a sub-table format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_name
|
str
|
The name of the step for which the layout is being created. |
required |
parameters
|
Dict[str, Dict[str, str]]
|
A dictionary of parameters associated with the step, where each key is a parameter type and each value is a dictionary of token-value pairs. |
required |
task_queue
|
str
|
The name of the task queue associated with this step, if provided. |
None
|
workers
|
str
|
The name(s) of the worker(s) that executed this step, if provided. |
None
|
Returns:
| Type | Description |
|---|---|
Table
|
A rich Table object containing the formatted information for the specified step, including its parameters and any associated task queue or worker details. |
Source code in merlin/study/status_renderers.py
create_task_details_table(task_statuses)
Create the task details section of the display.
This method constructs a formatted table that displays detailed information about various tasks, including their statuses, return codes, elapsed times, run times, restarts, and associated workers. Each task is represented as a row in the table, with specific styling applied based on the task's status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
task_statuses
|
Dict
|
A dictionary containing task statuses, where each key represents a step workspace and each value is another dictionary with details such as status, return code, elapsed time, run time, restarts, and workers. |
required |
Returns:
| Type | Description |
|---|---|
Table
|
A rich Table object containing the formatted task details, structured for easy readability and visual distinction based on task status. |
Source code in merlin/study/status_renderers.py
layout(status_data, study_title=None, status_time=None)
Setup the overall layout of the display.
This method configures the main display layout for the status data, including setting up the title with optional study information and timestamp. It organizes the status data into a structured table format, displaying each step's details along with associated task information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_data
|
Dict
|
A dictionary containing status data to be displayed, where each key represents a step and its associated information. |
required |
study_title
|
str
|
A title for the study to be displayed at the top of the output. |
None
|
status_time
|
str
|
A timestamp to be included in the title, indicating when the status data was captured. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in merlin/study/status_renderers.py
render(theme=None)
Do the actual printing of the status table.
This method is responsible for rendering the status table to the console, applying any specified theme settings for visual customization. It handles the enabling or disabling of themes and manages the output display, either using a pager for long outputs or printing directly to the console.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme
|
Dict[str, str]
|
A dictionary of theme settings that define the appearance of the output. The keys and
values should correspond to the layout defined in |
None
|
Source code in merlin/study/status_renderers.py
MerlinFlatRenderer
Bases: FlatStatusRenderer
This class handles the flat status formatting for task-by-task display. It will not separate the display on a step-by-step basis and instead group all statuses together in a single table, similar to Maestro's 'flat' status display.
Attributes:
| Name | Type | Description |
|---|---|---|
disable_theme |
bool
|
A flag indicating whether to disable theme customization for the output. |
disable_pager |
bool
|
A flag indicating whether to disable the use of a pager for long outputs. |
Methods:
| Name | Description |
|---|---|
layout |
Sets up the layout of the display, formatting the status data and study title. |
render |
Renders the status table to the console, applying any specified theme settings and managing the output display. |
Source code in merlin/study/status_renderers.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | |
layout(status_data, study_title=None)
Set up the layout of the display for the status information.
This method processes the provided status data by removing unnecessary parameters, capitalizing the column labels, and preparing the data for display. It also allows for an optional study title to be displayed at the top of the output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_data
|
Dict[str, List[Union[str, int]]]
|
A dictionary containing status information to be displayed. The keys represent the status categories, and the values are lists of corresponding status values. |
required |
study_title
|
str
|
The title of the study to display at the top of the output. If provided, it will be included in the layout. |
None
|
Source code in merlin/study/status_renderers.py
render(theme=None)
Render the status table to the console.
This method is responsible for displaying the formatted status information
in the console. It applies any specified theme settings to customize the
appearance of the output. If the theme is disabled, it sets all theme
attributes to 'none'. The method also handles the output display, either
printing directly to the console or using a pager for long outputs based
on the disable_pager attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theme
|
Dict[str, str]
|
A dictionary of theme settings that customize the appearance of the output. The keys represent the theme attributes, and the values are the corresponding settings. If not provided, the default theme settings will be used. |
None
|
Source code in merlin/study/status_renderers.py
MerlinStatusRendererFactory
Bases: StatusRendererFactory
This class keeps track of all available status layouts for Merlin.
The MerlinStatusRendererFactory is responsible for managing different
status layout renderers used in the Merlin application. It provides a
method to retrieve the appropriate renderer based on the specified layout
type and user preferences regarding theme and pager usage.
Attributes:
| Name | Type | Description |
|---|---|---|
_layouts |
Dict[str, BaseStatusRenderer]
|
A dictionary mapping layout names to their corresponding renderer
classes. Currently includes "table" for
|
Methods:
| Name | Description |
|---|---|
get_renderer |
Retrieves an instance of the specified layout renderer, applying user preferences for theme and pager settings. |
Source code in merlin/study/status_renderers.py
get_renderer(layout, disable_theme, disable_pager)
Get handle for specific layout renderer to instantiate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout
|
str
|
A string denoting the name of the layout renderer to use. |
required |
disable_theme
|
bool
|
True if the user wants to disable themes when displaying status; False otherwise. |
required |
disable_pager
|
bool
|
True if the user wants to disable the pager when displaying status; False otherwise. |
required |
Returns:
| Type | Description |
|---|---|
BaseStatusRenderer
|
The status renderer class to use for displaying the output. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the specified layout is not found in the available layouts. |
Source code in merlin/study/status_renderers.py
format_label(label_to_format, delimiter='_')
Format a string by replacing a specified delimiter with spaces and capitalizing each word.
This function takes a string that uses a specific delimiter to separate words and returns a more readable version of that string, where the words are separated by spaces and each word is capitalized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label_to_format
|
str
|
The string to format. |
required |
delimiter
|
str
|
The character that separates words in |
'_'
|
Returns:
| Type | Description |
|---|---|
str
|
A formatted string where the delimiter is replaced with spaces and each word is capitalized. |