diagnose
diagnose
¶
Diagnostic commands for Marianne CLI.
This module implements commands for inspecting job state and debugging issues:
- logs: View and follow log files
- errors: List errors for a job with filtering
- diagnose: Generate comprehensive diagnostic reports
★ Insight ─────────────────────────────────────
1. Layered debugging approach: The three commands form a debugging hierarchy:
logs for real-time streaming, errors for filtered error lists, and
diagnose for comprehensive reports. Users typically progress through
these as they narrow down issues.
-
Synthetic error records: When older state files lack error_history, the commands synthesize ErrorRecord objects from sheet-level error_message fields. This maintains backward compatibility with pre-history state files.
-
Error type inference: The
infer_error_typefunction categorizes errors into permanent/transient/rate_limit based on error_category strings. This enables appropriate color-coding and helps users understand retry behavior. ─────────────────────────────────────────────────
Attributes¶
Classes¶
LogFollower
¶
Parse, filter, and display structured log entries.
Extracted from the logs() command closures to enable unit testing
of log parsing, filtering, and formatting independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_path
|
Path
|
Path to the log file. |
required |
job_id
|
str | None
|
Optional job ID filter (None = show all). |
None
|
min_level
|
int
|
Minimum log level (0=DEBUG, 1=INFO, 2=WARNING, 3=ERROR, 4=CRITICAL). |
0
|
json_output
|
bool
|
If True, output raw JSON instead of formatted lines. |
False
|
Source code in src/marianne/cli/commands/diagnose.py
Methods:¶
parse_line
¶
Parse a JSON log line, returning None if blank.
Source code in src/marianne/cli/commands/diagnose.py
should_include
¶
Check if a log entry passes the configured filters.
Source code in src/marianne/cli/commands/diagnose.py
format_entry
¶
Format a log entry for Rich console display.
Source code in src/marianne/cli/commands/diagnose.py
read_lines
¶
Read lines from the log file (handles .gz compression).
Source code in src/marianne/cli/commands/diagnose.py
display
¶
Display filtered log entries.
Source code in src/marianne/cli/commands/diagnose.py
follow
¶
Follow log file for new entries (like tail -f).
Source code in src/marianne/cli/commands/diagnose.py
Functions:¶
logs
¶
logs(job_id=Argument(None, help="The score's run id (job id) to filter logs for (optional, shows all if not specified)"), workspace=Option(None, '--workspace', '-w', help='Workspace directory to find logs (debug override)', hidden=True), log_file=Option(None, '--file', '-f', help='Specific log file path (overrides workspace default)'), follow=Option(False, '--follow', '-F', help='Follow the log file for new entries (like tail -f)'), lines=Option(50, '--lines', '-n', help='Number of lines to show (0 for all)'), level=Option(None, '--level', '-l', help='Filter by minimum log level (DEBUG, INFO, WARNING, ERROR)'), json_output=Option(False, '--json', '-j', help='Output raw JSON log entries'))
Show or tail log files for a score.
Displays log entries from Marianne log files. Supports both current log files and compressed rotated logs (.gz).
Examples:
mzt logs # Show recent logs mzt logs my-job # Filter by job ID mzt logs --follow # Follow log file (like tail -f) mzt logs --lines 100 # Show last 100 lines mzt logs --level ERROR # Show only ERROR and above mzt logs --json # Output raw JSON entries
Note
Daemon-managed logs live under the conductor logging root by default. Use --file only for explicit offline/debug log files.
Source code in src/marianne/cli/commands/diagnose.py
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 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
errors
¶
errors(job_id=Argument(..., help="The score's run id (job id) to show errors for"), sheet=Option(None, '--sheet', '-b', help='Filter errors by specific sheet number'), error_type=Option(None, '--type', '-t', help='Filter by error type: transient, rate_limit, or permanent'), error_code=Option(None, '--code', '-c', help='Filter by error code (e.g., E001, E101)'), verbose=Option(False, '--verbose', '-V', help='Show full stdout/stderr tails for each error'), workspace=Option(None, '--workspace', '-w', help='Workspace directory to search for score state (debug override)', hidden=True), json_output=Option(False, '--json', '-j', help='Output errors as JSON'))
List all errors for a score with detailed information.
Displays errors grouped by sheet, with color-coding by error type: - Red: Permanent errors (non-retriable, fatal) - Yellow: Transient errors (retriable with backoff) - Blue: Rate limit errors (retriable after wait)
Examples:
mzt errors my-job # Show all errors mzt errors my-job --sheet 3 # Errors for sheet 3 only mzt errors my-job --type transient # Only transient errors mzt errors my-job --code E001 # Only timeout errors mzt errors my-job --verbose # Show stdout/stderr details
Source code in src/marianne/cli/commands/diagnose.py
diagnose
¶
diagnose(job_id=Argument(..., help="The score's run id (job id) to diagnose"), workspace=Option(None, '--workspace', '-w', help='Workspace directory (for scores not in conductor registry)'), json_output=Option(False, '--json', '-j', help='Output diagnostic report as JSON'), include_logs=Option(False, '--include-logs', help='Inline the last 50 lines from each sheet/hook log file in the output'), resources=Option(False, '--resources', help='Include resource profile (peak memory, CPU-time, syscalls, anomalies)'))
Generate a comprehensive diagnostic report for a score.
The diagnostic report includes: - Score overview and current status - Preflight warnings from all sheets - Prompt metrics (token counts, line counts) - Execution timeline with timing information - All errors with full context and output tails - Log file locations, sizes, and modification times - (with --include-logs) Inline log content from each log file - (with --resources) Resource profile from profiler data
This command is particularly useful for debugging failed scores or understanding why a score is running slowly.
Examples:
mzt diagnose my-job # Full diagnostic report mzt diagnose my-job --json # Machine-readable output mzt diagnose my-job --include-logs # Include inline log content mzt diagnose my-job --resources # Include resource profile
Source code in src/marianne/cli/commands/diagnose.py
history
¶
history(job_id=Argument(..., help="The score's run id (job id) to show execution history for"), sheet=Option(None, '--sheet', '-b', help='Filter by specific sheet number'), limit=Option(50, '--limit', '-n', help='Maximum number of records to show'), workspace=Option(None, '--workspace', '-w', help='Workspace directory to search for score state (debug override)', hidden=True), json_output=Option(False, '--json', '-j', help='Output history as JSON'))
Show execution history for a score.
One row per attempt, newest first: sheet, attempt, instrument and model, outcome, exit code, duration, timestamp, and the redacted cause of a failure. Read from the score's checkpoint (the last 50 attempts per sheet), so it survives completion and conductor restarts.
Examples:
mzt history my-job # Show all history mzt history my-job --sheet 3 # History for sheet 3 only mzt history my-job --limit 100 # Show more records mzt history my-job --json # Machine-readable output