job_monitor_helper
Helper class for Job Monitor MCP tools.
This module contains the non-MCP business logic used by JobMonitorServer so
the server can delegate execution through BaseMCPServer.run_tool() while
keeping the tool-registration layer thin.
JobMonitorHelper
Encapsulate Job Monitor tool implementations behind the run_tool contract.
Attributes:
| Name | Type | Description |
|---|---|---|
tail_bytes |
Maximum number of bytes to read from the end of each log file. |
|
status_depth |
Optional future-facing status-history depth setting stored alongside the helper configuration. |
Methods:
| Name | Description |
|---|---|
read_logs |
Read tailed stdout and stderr content for a job run. |
summarize_status |
Build a structured status payload with failure classification data. |
Source code in src/mada_tools/monitor/job_monitor/job_monitor_helper.py
__init__(tail_bytes=50000, status_depth=None)
Initialize the helper with log-tail configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tail_bytes
|
int
|
Maximum number of bytes to read from the end of each log file. |
50000
|
status_depth
|
Optional[int]
|
Optional status-history depth value retained for compatibility with server-level configuration. |
None
|
Source code in src/mada_tools/monitor/job_monitor/job_monitor_helper.py
read_logs(run_location, stdout_file, stderr_file)
Return tailed stdout and stderr logs for a job.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_location
|
str
|
Path to the directory containing the log files. |
required |
stdout_file
|
str
|
Name of the stdout log file. |
required |
stderr_file
|
str
|
Name of the stderr log file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
A |
str
|
|
tuple[bool, str]
|
tails. |
Source code in src/mada_tools/monitor/job_monitor/job_monitor_helper.py
summarize_status(run_location, stdout_file, stderr_file, exit_code=None)
Return a structured status summary including failure classification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_location
|
str
|
Path to the directory containing the log files. |
required |
stdout_file
|
str
|
Name of the stdout log file. |
required |
stderr_file
|
str
|
Name of the stderr log file. |
required |
exit_code
|
Optional[int]
|
Optional scheduler or application exit code to include in the returned summary. |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
A |
str
|
|
tuple[bool, str]
|
and detected failure classifications. |