clabe.daemon ¶
The clabe daemon: one per PC, it lists experiment repositories, runs an experiment in its repository's own
environment, and serves it (proxied under /run/) so each rig has one stable URL.
AttachBody ¶
Bases: BaseModel
A run started on this machine outside the daemon (e.g. from a terminal), announcing itself.
Host ¶
Host(
settings: DaemonSettings,
*,
leased_by: Callable[[], str | None] = lambda: None,
)
Lists the configured repositories and runs one experiment at a time.
A run is started as clabe run <file> --frontend headless --serve in the repository's own environment
(settings.command), bound to localhost with a token only the host knows; the daemon proxies it.
Source code in src/clabe/daemon/_host.py
repository ¶
repository(name: str) -> RepositoryConfig
The repository called name.
Source code in src/clabe/daemon/_host.py
experiments ¶
experiments(name: str) -> ExperimentListing
The experiments a repository offers, listed in its own environment (clabe list --json).
Source code in src/clabe/daemon/_host.py
launch ¶
launch(body: LaunchBody) -> RunInfo
Starts body's experiment; refused while another run is going.
Source code in src/clabe/daemon/_host.py
current ¶
attach ¶
attach(body: AttachBody) -> RunInfo
Follows a run started outside the daemon on this machine; refused while another run is going.
Source code in src/clabe/daemon/_host.py
stop ¶
Stops the current run's process (prefer aborting it through its API: it cleans up).
Source code in src/clabe/daemon/_host.py
info ¶
info() -> HostInfo
Who the host is and what it runs.
Source code in src/clabe/daemon/_host.py
HostError ¶
HostInfo ¶
Bases: BaseModel
Who the host is and whether it is busy.
LaunchBody ¶
Bases: BaseModel
Which experiment to run.
RepositoryInfo ¶
Bases: BaseModel
A configured repository.
RunInfo ¶
Bases: BaseModel
The run the host launched last.
DaemonSettings ¶
Bases: EnvSettings
Settings of clabe daemon run, from environment variables only (DAEMON_CLABE_<FIELD>, e.g.
DAEMON_CLABE_TOKEN). Every setting has a default; a rig usually needs none.
Repositories are found under repository_roots: every folder right under a root with a main.py and a
pyproject.toml depending on aind-clabe. List others (any layout) in repositories. Lists are written
a;b or as JSON:
setx DAEMON_CLABE_REPOSITORY_ROOTS "C:/git;D:/experiments"
setx DAEMON_CLABE_REPOSITORIES "C:/somewhere/else/Aind.Experiment.Special"
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Keyword arguments, then the environment, then a .env file when the class names one.
Source code in src/clabe/settings.py
reports_path ¶
reports_path() -> Path
Where this machine's issue reports wait for the hub (reports_directory, else reports_dir).
find_repositories ¶
find_repositories() -> list[RepositoryConfig]
The listed repositories, then those found under the roots (sorted); a name is used once.
Source code in src/clabe/daemon/_settings.py
RepositoryConfig ¶
Worker ¶
Worker(
settings: DaemonSettings,
*,
busy: Callable[[], bool] = lambda: False,
)
Jobs, files and the lease of the worker role.
Source code in src/clabe/daemon/_worker.py
lease ¶
lease() -> Lease | None
The current lease, if it has not expired.
Source code in src/clabe/daemon/_worker.py
take ¶
take(request: LeaseRequest) -> Lease
Takes the worker for a run, or renews the lease it holds.
Source code in src/clabe/daemon/_worker.py
release ¶
Gives the worker back; stop_jobs stops the jobs still running (e.g. the run was aborted).
Source code in src/clabe/daemon/_worker.py
check_lease ¶
check_lease(given: str | None) -> None
Refuses a request that does not carry the current lease (when there is one).
Source code in src/clabe/daemon/_worker.py
repository ¶
repository(name: str | None) -> RepositoryConfig | None
The repository called name (by default the first one offered).
Source code in src/clabe/daemon/_worker.py
info ¶
info(repository: str | None) -> WorkerInfo
The worker, as seen for repository.
Source code in src/clabe/daemon/_worker.py
submit ¶
submit(submission: JobSubmission) -> JobResult
Starts a job in the background.
Source code in src/clabe/daemon/_worker.py
output ¶
A job's output lines after line after (the last OUTPUT_LINES are kept).
Source code in src/clabe/daemon/_worker.py
result ¶
A job's state; a finished job is forgotten once its result is read (its last output lines are kept a little longer, for whoever follows them).
Source code in src/clabe/daemon/_worker.py
stop ¶
Stops a job's process: asks it to exit, then kills it.
Source code in src/clabe/daemon/_worker.py
jobs_of ¶
jobs_of(run_id: str) -> list[JobSummary]
The jobs of run run_id not yet collected (running, or finished with an unread result).
Source code in src/clabe/daemon/_worker.py
jobs ¶
The jobs, running and finished (but not yet read).
Source code in src/clabe/daemon/_worker.py
upload ¶
Writes a file to the transfer directory.
Source code in src/clabe/daemon/_worker.py
download ¶
A file of the transfer directory, to send back.
files ¶
delete_all ¶
Deletes every file of the transfer directory; returns their names.
Source code in src/clabe/daemon/_worker.py
create_daemon ¶
create_daemon(
settings: DaemonSettings, *, token: str | None = None
) -> FastAPI
The daemon's app with both roles: the host (runs started here) and the worker (jobs for runs elsewhere).
Source code in src/clabe/daemon/_app.py
create_daemon_app ¶
create_daemon_app(
host: Host,
*,
token: str | None = None,
static_dir: Path | None = STATIC_DIR,
worker: Worker | None = None,
) -> FastAPI
Builds the daemon's app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
Host
|
The host role (repositories and runs). |
required |
token
|
str | None
|
When set, every API call (the daemon's and the proxied run's) must carry it. |
None
|
worker
|
Worker | None
|
The worker role (jobs and files for runs hosted elsewhere), served under |
None
|
static_dir
|
Path | None
|
The web UI, served at |
STATIC_DIR
|
Source code in src/clabe/daemon/_app.py
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 | |