client
client
¶
Async Unix domain socket client for Marianne daemon IPC.
Provides DaemonClient with two call patterns:
call(method, params): send a JSON-RPC request, await a single response. Uses aConnectionPoolto reuse connections across calls.stream(method, params): send a request, yield streaming notifications, and return the final result when the stream ends.
Plus typed convenience methods (status, submit_job, etc.) that wrap
call with Pydantic model serialization for type safety at the CLI layer.
Attributes¶
Classes¶
ConnectionPool
¶
ConnectionPool(socket_path, *, max_size=_DEFAULT_POOL_SIZE, max_idle_seconds=_DEFAULT_MAX_IDLE_SECONDS, connect_timeout=_DEFAULT_CONNECT_TIMEOUT, acquire_timeout=30.0)
LIFO connection pool for Unix domain sockets.
Internal implementation detail — not exported. Manages a bounded set
of reusable (reader, writer) pairs so DaemonClient.call() does
not pay the cost of opening a fresh socket for every RPC.
Parameters¶
socket_path: Unix domain socket to connect to. max_size: Maximum number of connections (checked-out + idle combined). max_idle_seconds: Connections idle longer than this are discarded on next acquire. connect_timeout: Seconds to wait when opening a new connection. acquire_timeout: Seconds to wait for the pool semaphore when all slots are busy.
Source code in src/marianne/daemon/ipc/client.py
Attributes¶
Functions¶
acquire
async
¶
Acquire a connection from the pool.
Tries idle connections first (LIFO), skipping stale or broken ones. Opens a new connection if no idle connection is available.
Raises:
| Type | Description |
|---|---|
DaemonNotRunningError
|
if the pool is closed or connection fails. |
TimeoutError
|
if the pool semaphore cannot be acquired in time. |
Source code in src/marianne/daemon/ipc/client.py
release
¶
Return a healthy connection to the idle stack.
Source code in src/marianne/daemon/ipc/client.py
discard
¶
Discard a broken connection and release its semaphore slot.
close
async
¶
Close the pool and all idle connections. Idempotent.
Source code in src/marianne/daemon/ipc/client.py
DaemonClient
¶
Async client for the Marianne daemon Unix socket IPC.
Parameters¶
socket_path:
Path to the Unix domain socket created by DaemonServer.
timeout:
Seconds to wait for a response before raising TimeoutError.
pool_size:
Maximum number of pooled connections for call().
Source code in src/marianne/daemon/ipc/client.py
Functions¶
close
async
¶
call
async
¶
Send a JSON-RPC request and return the result.
Uses the connection pool. If a pooled connection is stale (server closed it, daemon restarted), discards it and retries once with a fresh connection.
Raises:
| Type | Description |
|---|---|
DaemonNotRunningError
|
socket unreachable |
DaemonError(subclass)
|
server returned an error response |
TimeoutError
|
no response within |
Source code in src/marianne/daemon/ipc/client.py
stream
async
¶
Send a JSON-RPC request and yield streaming notifications.
Notifications (no id) are yielded as dicts. The final
response (with id) terminates the iteration.
If the final response contains an error, raises the
corresponding DaemonError.
Source code in src/marianne/daemon/ipc/client.py
is_daemon_running
async
¶
Check if daemon is running by performing a lightweight health RPC.
Uses daemon.health instead of bare socket connect so stale
sockets left by crashed daemons are properly detected.
Short-circuits immediately if the socket path doesn't exist,
consistent with _connect()'s guard.
Source code in src/marianne/daemon/ipc/client.py
status
async
¶
submit_job
async
¶
get_job_status
async
¶
Get status of a specific job.
pause_job
async
¶
Pause a running job. Returns {"paused": bool}.
Source code in src/marianne/daemon/ipc/client.py
resume_job
async
¶
Resume a paused job. Returns a JobResponse dict.
Source code in src/marianne/daemon/ipc/client.py
cancel_job
async
¶
Cancel a running or paused job. Returns {"cancelled": bool}.
Source code in src/marianne/daemon/ipc/client.py
list_jobs
async
¶
clear_jobs
async
¶
Clear terminal jobs from the daemon registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
statuses
|
list[str] | None
|
Status filter (defaults to terminal statuses). |
None
|
older_than_seconds
|
float | None
|
Only clear jobs older than this. |
None
|
job_ids
|
list[str] | None
|
Only clear these specific job IDs. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with "deleted" count. |
Source code in src/marianne/daemon/ipc/client.py
config
async
¶
health
async
¶
readiness
async
¶
get_errors
async
¶
Get errors for a specific job.
Source code in src/marianne/daemon/ipc/client.py
diagnose
async
¶
Get diagnostic data for a specific job.
Source code in src/marianne/daemon/ipc/client.py
get_execution_history
async
¶
Get execution history for a specific job.
Source code in src/marianne/daemon/ipc/client.py
recover_job
async
¶
Request recovery data for a specific job.
Source code in src/marianne/daemon/ipc/client.py
rate_limits
async
¶
learning_patterns
async
¶
Get recent learning patterns from the global store.