tomato.tomato: CLI and API for the tomato daemon
Code author: Peter Kraus
Module of functions to interact with tomato. Includes basic tomato daemon functions:
status()to query the status of the tomato daemonstart()to start a new tomato daemonstop()to stop a running tomato daemoninit()to create a defaultsettings.tomlfilereload()to process thesettings.tomlanddevices.ymlfiles again
Also includes the following pipeline management functions:
pipeline_load()to load a sample into a pipelinepipeline_eject()to eject any sample from a pipelinepipeline_ready()to mark a pipeline as ready
- tomato.tomato.set_loglevel(delta: int)
- tomato.tomato.make_padded_lines(data: dict, keys: list) list
- tomato.tomato.format_msg(msg: str, objs: str, yml: bool, keys: list[str], data: dict) str
- tomato.tomato.status(*, port: int, timeout: int, stgrp: str = 'tomato', yaml: bool = True, **_: dict) Reply
Get status of the tomato daemon.
Examples
>>> # Status with a running daemon >>> tomato status Success: tomato running on port 1234
>>> # Status without a running daemon >>> tomato status Failure: tomato not running on port 1234
>>> # Status of a running daemon with yaml data >>> tomato status -y data: appdir: .config/tomato/2.2rc3 devicefile: components: [...] devices: [...] drivers: [...] pipelines: [...] filename: .config/tomato/2.2rc3/devices.yml port: 1234 settings: datadir: .config/tomato/2.2rc3/ devices: config: .config/tomato/2.2rc3/devices.yml drivers: [...] jobs: dbpath: .config/tomato/2.2rc3/Jobs/dbpath.sqlite storage: .config/tomato/2.2rc3/Jobs/ logdir: .config/tomato/2.2rc3/ repositories: {} status: running verbosity: 20 msg: tomato running on port 1234 success: true
>>> # Status of all configured pipelines >>> tomato status pipelines Success: tomato running on port 1234 with the following pipelines: name:pip-counter ready:False sampleid:counter_1_0.1 jobid:None
>>> # Status of all configured drivers >>> tomato status drivers Success: tomato running on port 1234 with the following drivers: name:example_counter port:34747 pid:192318 version: 2.1 heartbeat: 4.4 s
>>> # Status of all configured devices >>> tomato status devices Success: tomato running on port 1234 with the following devices: name:dev-counter driver:example_counter address:example-addr channels:['1']
>>> # Status of all configured components: >>> tomato status components Success: tomato running on port 1234 with the following components: name:example_counter:(example-addr,1) driver:example_counter device:dev-counter capabilities:{'random', 'count'}
- tomato.tomato.start(*, port: int, timeout: int, appdir: str | Path, verbosity: int, **_: dict) Reply
Start the tomato daemon.
Examples
>>> # Start tomato >>> tomato start Success: tomato on port 1234 reloaded with settings from /home/kraus/.config/tomato/1.0rc2.dev2
>>> # Start tomato with a custom port >>> tomato start -p 1235 Success: tomato on port 1235 reloaded with settings from /home/kraus/.config/tomato/1.0rc2.dev2
>>> # Start tomato with another tomato running >>> tomato start Failure: required port 1234 is already in use, choose a different one
- tomato.tomato.stop(*, port: int, timeout: int, **_: dict) Reply
Stop a running tomato daemon.
Will not stop the daemon if any jobs are running. Will create a state snapshot.
Examples
>>> # Stop tomato daemon without running jobs >>> tomato stop Success: tomato on port 1234 closed successfully
>>> # Attempt to stop tomato daemon with running jobs >>> tomato stop Failure: jobs are running
>>> # Attempt to stop tomato daemon which is not running >>> tomato stop -p 1235 Failure: tomato not running on port 1235
- tomato.tomato.init(*, appdir: str | Path, datadir: str | Path, logdir: str | Path, **_: dict) Reply
Create a default settings.toml file.
Will overwrite any existing settings.toml file.
Examples
>>> tomato init Success: wrote default settings into /home/kraus/.config/tomato/1.0rc2.dev2/settings.toml
- tomato.tomato.reload(*, port: int, timeout: int, appdir: str | Path, **_: dict) Reply
Reload settings.toml and devices.yaml files and reconfigure tomato daemon.
Examples
>>> # Reload with compatible changes >>> tomato reload Success: tomato on port 1234 reloaded with settings from /home/kraus/.config/tomato/1.0rc2.dev2
- tomato.tomato.pipeline_load(*, port: int, timeout: int, pipeline: str, sampleid: str, **_: dict) Reply
Load a sample into a pipeline. Usage:
tomato pipeline load <pipeline> <sampleid>