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

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: BaseModel

Show 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: BaseModel

Show 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:
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: BaseModel

Show 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: BaseModel

Show 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:
field filename: Path [Required]
Constraints:
  • func = <class ‘str’>

  • return_type = PydanticUndefined

  • when_used = always

Validated by:
field components: dict[str, Component] [Optional]
Validated by:
field devices: dict[str, Device] [Optional]
Validated by:
field drivers: dict[str, Driver] [Optional]
Validated by:
field pipelines: dict[str, Pipeline] [Optional]
Validated by:
validator coerce_filename  »  filename
validator filename_exists  »  filename
validator populate_attrs  »  all fields
pydantic model tomato.models.Driver

Bases: BaseModel

Show 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: BaseModel

Show 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: BaseModel

Show 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 payload: Payload [Required]
Validated by:
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
validator coerce_payload  »  payload
pydantic model tomato.models.PipState

Bases: BaseModel

Show 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: BaseModel

Show 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: BaseModel

Show 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: BaseModel

The Task is a driver/device-independent abstraction describing the measurement steps. The driver-specific information for the Task can be provided via the technique_name and task_params parameters.

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 Task should run

Validated by:
field max_duration: float [Required]

the maximum duration of this Task, in seconds

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-job process, 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 Task will be executed

Validated by:
field task_name: str | None = None

the (optional) name of the current Task; can be used for triggering other Task in parallel to this one via start_with_task_name

Validated by:
field task_params: Dict[str, Any] | None [Optional]

a dict of any additional parameters required to specify the experimental technique; the key-value pairs of this dict will be used as attr-val pairs by the set_attr() method of the component executing this Task

Validated by:
field start_with_task_name: str | None = None

the task_name of the Task that this Task should be started in parallel with; when set, this Task will wait for execution until a Task with the matching task_name is started

Validated by:
field stop_with_task_name: str | None = None

the task_name of the Task that, when started, will stop the execution of this Task; when set, this Task will execute normally, but if a a Task with the matching task_name is started, this Task will 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