job_service
job_service
¶
Core job execution service — decoupled from CLI.
Extracted from CLI commands to enable both CLI and daemon usage. The CLI becomes a thin wrapper around this service.
The service encapsulates the run/resume/pause/status lifecycle without any dependency on Rich, Typer, or CLI-level globals. All user-facing output goes through OutputProtocol.
Classes¶
JobService
¶
JobService(*, output=None, global_learning_store=None, rate_limit_callback=None, event_callback=None, state_publish_callback=None, registry=None, token_warning_threshold=None, token_error_threshold=None, pgroup_manager=None)
Core job execution service.
Encapsulates the logic from CLI run/resume/pause commands into a reusable service that can be called from CLI, daemon, dashboard, or MCP server.
All user-facing output goes through the OutputProtocol abstraction, allowing different frontends (Rich console, structlog, SSE, null) to receive execution events without code changes.
Source code in src/marianne/daemon/job_service.py
Attributes¶
notifications_degraded
property
¶
Whether notification delivery is degraded.
Returns True after _NOTIFICATION_DEGRADED_THRESHOLD consecutive
notification failures. Readable by HealthChecker.readiness()
to signal degraded notification capability to operators.
Functions¶
pause_job
async
¶
Pause a running job via signal file.
Mirrors the logic in cli/commands/pause.py::_pause_job(): Creates a pause signal file that the runner polls at sheet boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
Job identifier to pause. |
required |
workspace
|
Path
|
Workspace directory containing job state. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if pause signal was created successfully. |
Raises:
| Type | Description |
|---|---|
JobSubmissionError
|
If job not found or not in a pausable state. |
Source code in src/marianne/daemon/job_service.py
get_status
async
¶
Get job status from state backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job_id
|
str
|
Job identifier. |
required |
workspace
|
Path
|
Workspace directory containing job state. |
required |
backend_type
|
str
|
State backend type (default "sqlite" for daemon). |
'sqlite'
|
Returns:
| Type | Description |
|---|---|
CheckpointState | None
|
CheckpointState if found, None if job doesn't exist. |