tomato package
- tomato.set_loglevel(loglevel: int)
- tomato.parse_args(parser, verbose, is_tomato=False)
- tomato.run_tomato()
- tomato.run_ketchup()
- tomato.run_passata()
Subpackages
- tomato.daemon: Functions and modules comprising the tomato daemon
setup_logging()tomato_daemon()- Submodules
- tomato.daemon.cmd: command parsing for tomato daemon
status()stop()reload()- tomato.daemon.crates: functions for creating RO-crates
RepositoryObject()Profile()to_rocrate()- tomato.daemon.db: shared functions using
sqlite3 connect_db()setup_db()- tomato.daemon.driver: the driver manager of tomato daemon
tomato_driver_bootstrap()perform_idle_measurements()stop_tomato_driver()kill_tomato_driver()tomato_driver()manager()- tomato.daemon.drvdb: the sqlite database for drivers in tomato
insert_drv()update_drv()get_drv()get_drvs_where()del_drv()- tomato.daemon.io: functions for storing job data
merge_netcdfs()data_to_pickle()- tomato.daemon.job: the job manager of tomato daemon
method_validate()find_matching_pipelines()kill_tomato_job()manage_running()check_queued()action_queued()manager()tomato_job()job_thread()job_main_loop()- tomato.daemon.jobdb: the sqlite database for jobs in tomato
insert_job()update_job_id()get_job_id()get_jobs_where()- tomato.daemon.lpp: a lazy pirate pattern implementation
comm()- tomato.daemon.pip: the pipeline manager of tomato daemon
manager()- tomato.daemon.pipdb: the sqlite database for pipelines in tomato
insert_pip()update_pip()get_pip()get_pips_where()
- tomato.DriverInterface: version 2.0
in_devmap()to_reply()log_errors()AttrModelInterfaceModelInterface.versionModelInterface.idle_measurement_intervalModelInterface.devmapModelInterface.constantsModelInterface.settingsModelInterface.DeviceFactory()ModelInterface.cmp_register()ModelInterface.cmp_teardown()ModelInterface.cmp_reset()ModelInterface.cmp_set_attr()ModelInterface.cmp_get_attr()ModelInterface.cmp_status()ModelInterface.cmp_capabilities()ModelInterface.cmp_attrs()ModelInterface.cmp_constants()ModelInterface.cmp_last_data()ModelInterface.cmp_measure()ModelInterface.task_start()ModelInterface.task_status()ModelInterface.task_stop()ModelInterface.task_data()ModelInterface.task_validate()ModelInterface.status()ModelInterface.quit()ModelInterface.reset()
ModelDeviceModelDevice.driverModelDevice.keyModelDevice.task_listModelDevice.threadModelDevice.dataModelDevice.last_dataModelDevice.runningModelDevice.datalockModelDevice.constantsModelDevice.run()ModelDevice.measure()ModelDevice.task_runner()ModelDevice.meas_runner()ModelDevice.prepare_task()ModelDevice.do_task()ModelDevice.do_measure()ModelDevice.stop_task()ModelDevice.set_attr()ModelDevice.get_attr()ModelDevice.get_data()ModelDevice.get_last_data()ModelDevice.attrs()ModelDevice.capabilities()ModelDevice.status()ModelDevice.reset()
- tomato.DriverInterface: version 2.1
AttrModelInterfaceModelInterface.versionModelInterface.idle_measurement_intervalModelInterface.devmapModelInterface.constantsModelInterface.settingsModelInterface.retriesModelInterface.DeviceFactory()ModelInterface.cmp_register()ModelInterface.cmp_teardown()ModelInterface.cmp_reset()ModelInterface.cmp_set_attr()ModelInterface.cmp_get_attr()ModelInterface.cmp_status()ModelInterface.cmp_capabilities()ModelInterface.cmp_attrs()ModelInterface.cmp_constants()ModelInterface.cmp_last_data()ModelInterface.cmp_measure()ModelInterface.task_start()ModelInterface.task_status()ModelInterface.task_stop()ModelInterface.task_data()ModelInterface.task_validate()ModelInterface.status()ModelInterface.quit()ModelInterface.reset()
ModelDeviceModelDevice.driverModelDevice.keyModelDevice.task_listModelDevice.threadModelDevice.dataModelDevice.last_dataModelDevice.runningModelDevice.datalockModelDevice.constantsModelDevice.task_runner()ModelDevice.prepare_task()ModelDevice.do_task()ModelDevice.do_measure()ModelDevice.stop_task()ModelDevice.set_attr()ModelDevice.get_attr()ModelDevice.get_data()ModelDevice.get_last_data()ModelDevice.attrs()ModelDevice.capabilities()ModelDevice.status()ModelDevice.reset()
- Submodules
- tomato.ketchup: CLI and API for the tomato job queue
- tomato.passata: CLI and API for tomato drivers and components
- tomato.tomato: CLI and API for the tomato daemon
Submodules
tomato.drivers: Shim interfacing with tomato driver packages
Code author: Peter Kraus
- tomato.drivers.driver_to_interface(drivername: str) None | ModelInterface | ModelInterface
tomato.models: Pydantic models for internal tomato use
Code author: Peter Kraus
- pydantic model tomato.models.Component
Bases:
BaseModelShow JSON schema
{ "title": "Component", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "device": { "title": "Device", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channel": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Channel" } }, "required": [ "name", "device", "driver", "address" ] }
- field name: str [Required]
- field device: str [Required]
- field driver: str [Required]
- field address: str [Required]
- field channel: str | None = None
- pydantic model tomato.models.Daemon
Bases:
BaseModelShow JSON schema
{ "title": "Daemon", "type": "object", "properties": { "status": { "enum": [ "bootstrap", "running", "stop" ], "title": "Status", "type": "string" }, "port": { "title": "Port", "type": "integer" }, "verbosity": { "title": "Verbosity", "type": "integer" }, "appdir": { "title": "Appdir", "type": "string" }, "settings": { "additionalProperties": true, "title": "Settings", "type": "object" }, "devicefile": { "$ref": "#/$defs/DeviceFile" } }, "$defs": { "Component": { "properties": { "name": { "title": "Name", "type": "string" }, "device": { "title": "Device", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channel": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Channel" } }, "required": [ "name", "device", "driver", "address" ], "title": "Component", "type": "object" }, "Device": { "properties": { "name": { "title": "Name", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channels": { "items": { "type": "string" }, "title": "Channels", "type": "array" }, "pollrate": { "default": 1, "title": "Pollrate", "type": "integer" } }, "required": [ "name", "driver", "address", "channels" ], "title": "Device", "type": "object" }, "DeviceFile": { "properties": { "filename": { "format": "path", "title": "Filename", "type": "string" }, "components": { "additionalProperties": { "$ref": "#/$defs/Component" }, "title": "Components", "type": "object" }, "devices": { "additionalProperties": { "$ref": "#/$defs/Device" }, "title": "Devices", "type": "object" }, "drivers": { "additionalProperties": { "$ref": "#/$defs/Driver" }, "title": "Drivers", "type": "object" }, "pipelines": { "additionalProperties": { "$ref": "#/$defs/Pipeline" }, "title": "Pipelines", "type": "object" } }, "required": [ "filename" ], "title": "DeviceFile", "type": "object" }, "Driver": { "properties": { "name": { "title": "Name", "type": "string" }, "settings": { "additionalProperties": true, "title": "Settings", "type": "object" } }, "required": [ "name" ], "title": "Driver", "type": "object" }, "Pipeline": { "properties": { "name": { "title": "Name", "type": "string" }, "components": { "additionalProperties": { "type": "string" }, "title": "Components", "type": "object" } }, "required": [ "name", "components" ], "title": "Pipeline", "type": "object" } }, "required": [ "status", "port", "verbosity", "appdir" ] }
- Config:
arbitrary_types_allowed: bool = True
validate_assignment: bool = True
- Validators:
device_settings»all fieldspopulate_devicefile»all fieldspopulate_settings»all fields
- field status: Literal['bootstrap', 'running', 'stop'] [Required]
- Validated by:
- field port: int [Required]
- Validated by:
- field verbosity: int [Required]
- Validated by:
- field appdir: str [Required]
- Validated by:
- field settings: dict [Optional]
- Validated by:
- field devicefile: DeviceFile [Optional]
- Validated by:
- validator populate_devicefile » all fields
- validator populate_settings » all fields
- validator device_settings » all fields
- pydantic model tomato.models.Device
Bases:
BaseModelShow JSON schema
{ "title": "Device", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channels": { "items": { "type": "string" }, "title": "Channels", "type": "array" }, "pollrate": { "default": 1, "title": "Pollrate", "type": "integer" } }, "required": [ "name", "driver", "address", "channels" ] }
- field name: str [Required]
- field driver: str [Required]
- field address: str [Required]
- field channels: Sequence[str] [Required]
- field pollrate: int = 1
- pydantic model tomato.models.DeviceFile
Bases:
BaseModelShow JSON schema
{ "title": "DeviceFile", "type": "object", "properties": { "filename": { "format": "path", "title": "Filename", "type": "string" }, "components": { "additionalProperties": { "$ref": "#/$defs/Component" }, "title": "Components", "type": "object" }, "devices": { "additionalProperties": { "$ref": "#/$defs/Device" }, "title": "Devices", "type": "object" }, "drivers": { "additionalProperties": { "$ref": "#/$defs/Driver" }, "title": "Drivers", "type": "object" }, "pipelines": { "additionalProperties": { "$ref": "#/$defs/Pipeline" }, "title": "Pipelines", "type": "object" } }, "$defs": { "Component": { "properties": { "name": { "title": "Name", "type": "string" }, "device": { "title": "Device", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channel": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Channel" } }, "required": [ "name", "device", "driver", "address" ], "title": "Component", "type": "object" }, "Device": { "properties": { "name": { "title": "Name", "type": "string" }, "driver": { "title": "Driver", "type": "string" }, "address": { "title": "Address", "type": "string" }, "channels": { "items": { "type": "string" }, "title": "Channels", "type": "array" }, "pollrate": { "default": 1, "title": "Pollrate", "type": "integer" } }, "required": [ "name", "driver", "address", "channels" ], "title": "Device", "type": "object" }, "Driver": { "properties": { "name": { "title": "Name", "type": "string" }, "settings": { "additionalProperties": true, "title": "Settings", "type": "object" } }, "required": [ "name" ], "title": "Driver", "type": "object" }, "Pipeline": { "properties": { "name": { "title": "Name", "type": "string" }, "components": { "additionalProperties": { "type": "string" }, "title": "Components", "type": "object" } }, "required": [ "name", "components" ], "title": "Pipeline", "type": "object" } }, "required": [ "filename" ] }
- Validators:
populate_attrs»all fields
- field filename: Path [Required]
- Constraints:
func = <class ‘str’>
return_type = PydanticUndefined
when_used = always
- Validated by:
- validator populate_attrs » all fields
- pydantic model tomato.models.Driver
Bases:
BaseModelShow JSON schema
{ "title": "Driver", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "settings": { "additionalProperties": true, "title": "Settings", "type": "object" } }, "required": [ "name" ] }
- field name: str [Required]
- field settings: dict [Optional]
- pydantic model tomato.models.DrvState
Bases:
BaseModelShow JSON schema
{ "title": "DrvState", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "port": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Port" }, "pid": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Pid" }, "version": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Version" }, "spawn_time": { "default": 0.0, "title": "Spawn Time", "type": "number" }, "spawn_count": { "default": 0, "title": "Spawn Count", "type": "integer" }, "heartbeat_time": { "default": 0.0, "title": "Heartbeat Time", "type": "number" } }, "required": [ "name" ] }
- field name: str [Required]
- field port: int | None = None
- field pid: int | None = None
- field version: str | None = None
- field spawn_time: float = 0.0
- field spawn_count: int = 0
- field heartbeat_time: float = 0.0
- pydantic model tomato.models.Job
Bases:
BaseModelShow JSON schema
{ "title": "Job", "type": "object", "properties": { "id": { "title": "Id", "type": "integer" }, "payload": { "$ref": "#/$defs/Payload" }, "jobname": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Jobname" }, "pid": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Pid" }, "status": { "default": "q", "enum": [ "q", "qw", "r", "rd", "c", "cd", "ce" ], "title": "Status", "type": "string" }, "submitted_at": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Submitted At" }, "launched_at": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Launched At" }, "connected_at": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Connected At" }, "completed_at": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Completed At" }, "jobpath": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Jobpath" }, "respath": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Respath" }, "snappath": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Snappath" } }, "$defs": { "Output": { "additionalProperties": false, "description": "Provide the ``path`` and ``prefix`` for the final FAIR-data archive of the *job*.", "properties": { "path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Path" }, "prefix": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Prefix" }, "repositories": { "default": [ "default" ], "items": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "title": "Repositories", "type": "array" } }, "title": "Output", "type": "object" }, "Payload": { "additionalProperties": false, "properties": { "version": { "const": "2.2", "title": "Version", "type": "string" }, "settings": { "$ref": "#/$defs/Settings" }, "user": { "$ref": "#/$defs/User" }, "sample": { "$ref": "#/$defs/Sample" }, "method": { "items": { "$ref": "#/$defs/Task" }, "title": "Method", "type": "array" } }, "required": [ "version", "user", "sample", "method" ], "title": "Payload", "type": "object" }, "Sample": { "additionalProperties": true, "description": "Additional attributes for each :class:`Sample` may be required, depending on the\nmethod within the payload.", "properties": { "identifier": { "title": "Identifier", "type": "string" }, "sample_is_parent": { "default": true, "title": "Sample Is Parent", "type": "boolean" } }, "required": [ "identifier" ], "title": "Sample", "type": "object" }, "Settings": { "additionalProperties": false, "description": "Specification of *job* configuration for tomato.", "properties": { "unlock_when_done": { "default": false, "title": "Unlock When Done", "type": "boolean" }, "verbosity": { "default": "WARNING", "enum": [ "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL" ], "title": "Verbosity", "type": "string" }, "output": { "$ref": "#/$defs/Output" }, "snapshot": { "anyOf": [ { "$ref": "#/$defs/Snapshot" }, { "type": "null" } ], "default": null } }, "title": "Settings", "type": "object" }, "Snapshot": { "additionalProperties": false, "description": "Provide the ``interval``, ``path`` and ``prefix`` to configure\nthe snapshotting functionality of tomato.", "properties": { "path": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Path" }, "prefix": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Prefix" }, "interval": { "default": 3600.0, "title": "Interval", "type": "number" } }, "title": "Snapshot", "type": "object" }, "Task": { "additionalProperties": false, "description": "The :class:`Task` is a driver/device-independent abstraction describing the\nmeasurement steps. The driver-specific information for the :class:`Task` can be\nprovided via the :obj:`technique_name` and :obj:`task_params` parameters.", "properties": { "component_role": { "title": "Component Role", "type": "string" }, "max_duration": { "title": "Max Duration", "type": "number" }, "sampling_interval": { "title": "Sampling Interval", "type": "number" }, "polling_interval": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Polling Interval" }, "technique_name": { "title": "Technique Name", "type": "string" }, "task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Task Name" }, "task_params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "title": "Task Params" }, "start_with_task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Start With Task Name" }, "stop_with_task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stop With Task Name" } }, "required": [ "component_role", "max_duration", "sampling_interval", "technique_name" ], "title": "Task", "type": "object" }, "User": { "additionalProperties": true, "description": "Additional attributes for each :class:`Sample` may be required, depending on the\nmethod within the payload.", "properties": { "identifier": { "title": "Identifier", "type": "string" } }, "required": [ "identifier" ], "title": "User", "type": "object" } }, "required": [ "id", "payload" ] }
- Validators:
- field id: int [Required]
- field jobname: str | None = None
- field pid: int | None = None
- field status: Literal['q', 'qw', 'r', 'rd', 'c', 'cd', 'ce'] = 'q'
- field submitted_at: str | None = None
- field launched_at: str | None = None
- field connected_at: str | None = None
- field completed_at: str | None = None
- field jobpath: str | None = None
- field respath: str | None = None
- field snappath: str | None = None
- pydantic model tomato.models.PipState
Bases:
BaseModelShow JSON schema
{ "title": "PipState", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "ready": { "default": false, "title": "Ready", "type": "boolean" }, "jobid": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Jobid" }, "sampleid": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Sampleid" } }, "required": [ "name" ] }
- field name: str [Required]
- field ready: bool = False
- field jobid: int | None = None
- field sampleid: str | None = None
- pydantic model tomato.models.Pipeline
Bases:
BaseModelShow JSON schema
{ "title": "Pipeline", "type": "object", "properties": { "name": { "title": "Name", "type": "string" }, "components": { "additionalProperties": { "type": "string" }, "title": "Components", "type": "object" } }, "required": [ "name", "components" ] }
- field name: str [Required]
- field components: dict[str, str] [Required]
Mapping of component roles to names.
- pydantic model tomato.models.Reply
Bases:
BaseModelShow JSON schema
{ "title": "Reply", "type": "object", "properties": { "success": { "title": "Success", "type": "boolean" }, "msg": { "title": "Msg", "type": "string" }, "data": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Data" } }, "required": [ "success", "msg" ] }
- field success: bool [Required]
- field msg: str [Required]
- field data: Any | None = None
- pydantic model tomato.models.Task
Bases:
BaseModelThe
Taskis a driver/device-independent abstraction describing the measurement steps. The driver-specific information for theTaskcan be provided via thetechnique_nameandtask_paramsparameters.Show JSON schema
{ "title": "Task", "description": "The :class:`Task` is a driver/device-independent abstraction describing the\nmeasurement steps. The driver-specific information for the :class:`Task` can be\nprovided via the :obj:`technique_name` and :obj:`task_params` parameters.", "type": "object", "properties": { "component_role": { "title": "Component Role", "type": "string" }, "max_duration": { "title": "Max Duration", "type": "number" }, "sampling_interval": { "title": "Sampling Interval", "type": "number" }, "polling_interval": { "anyOf": [ { "type": "number" }, { "type": "null" } ], "default": null, "title": "Polling Interval" }, "technique_name": { "title": "Technique Name", "type": "string" }, "task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Task Name" }, "task_params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "title": "Task Params" }, "start_with_task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Start With Task Name" }, "stop_with_task_name": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Stop With Task Name" } }, "additionalProperties": false, "required": [ "component_role", "max_duration", "sampling_interval", "technique_name" ] }
- Config:
extra: str = forbid
- Validators:
- field component_role: str [Required]
role of the pipeline component on which this
Taskshould run- Validated by:
- field sampling_interval: float [Required]
the interval between measurements, in seconds
- Validated by:
- field polling_interval: float | None = None
the interval between polling for data by the
tomato-jobprocess, in seconds; defaults to the value in driver settings- Validated by:
- field technique_name: str [Required]
the name of the technique; has to match one of the capabilities of the component on which this
Taskwill be executed- Validated by:
- field task_name: str | None = None
the (optional) name of the current
Task; can be used for triggering otherTaskin parallel to this one viastart_with_task_name- Validated by:
- field task_params: Dict[str, Any] | None [Optional]
a
dictof any additional parameters required to specify the experimental technique; the key-value pairs of thisdictwill be used as attr-val pairs by theset_attr()method of the component executing thisTask- Validated by:
- field start_with_task_name: str | None = None
the
task_nameof theTaskthat thisTaskshould be started in parallel with; when set, thisTaskwill wait for execution until aTaskwith the matchingtask_nameis started- Validated by:
- field stop_with_task_name: str | None = None
the
task_nameof theTaskthat, when started, will stop the execution of thisTask; when set, thisTaskwill execute normally, but if a aTaskwith the matchingtask_nameis started, thisTaskwill be stopped- Validated by:
- validator task_names_cannot_be_same » all fields
- validator convert_str_to_seconds » polling_interval, sampling_interval, max_duration
- tomato.utils.spawn_cmd(cmd: list[str], logger: Logger) None
- tomato.utils.load_device_file(yamlpath: Path, logger: Logger) dict
- tomato.utils.get_pid() int