aind_behavior_services package

Subpackages

Submodules

aind_behavior_services.base module

pydantic model aind_behavior_services.base.SchemaVersionedModel[source]

Bases: BaseModel

Show JSON schema
{
   "title": "SchemaVersionedModel",
   "type": "object",
   "properties": {
      "aind_behavior_services_pkg_version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "aind_behavior_services package version",
         "type": "string"
      },
      "version": {
         "description": "schema version",
         "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
         "title": "Version",
         "type": "string"
      }
   },
   "required": [
      "version"
   ]
}

Fields:
Validators:
field aind_behavior_services_pkg_version: Literal['0.13.0-rc2'] = '0.13.0-rc2'[source]
Constraints:
  • pattern = ^(0|[1-9]d*).(0|[1-9]d*).(0|[1-9]d*)(?:-((?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*)(?:.(?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

Validated by:
field version: str [Required][source]

schema version

Constraints:
  • pattern = ^(0|[1-9]d*).(0|[1-9]d*).(0|[1-9]d*)(?:-((?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*)(?:.(?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

Validated by:
validator coerce_version  »  aind_behavior_services_pkg_version, version[source]
Parameters:

v (str)

Return type:

str

aind_behavior_services.base.coerce_schema_version(cls, v, version_string='version')[source]
Parameters:
  • cls (type[BaseModel])

  • v (str)

  • version_string (str)

Return type:

str

aind_behavior_services.common module

pydantic model aind_behavior_services.common.Circle[source]

Bases: BaseModel

Represents a circle defined by its center point and radius.

Show JSON schema
{
   "title": "Circle",
   "description": "Represents a circle defined by its center point and radius.",
   "type": "object",
   "properties": {
      "center": {
         "$ref": "#/$defs/Point2f",
         "default": {
            "x": 0.0,
            "y": 0.0
         },
         "description": "Center of the circle (px)"
      },
      "radius": {
         "default": 1,
         "description": "Radius of the circle (px)",
         "minimum": 0,
         "title": "Radius",
         "type": "number"
      }
   },
   "$defs": {
      "Point2f": {
         "description": "Represents a 2D point with float coordinates.",
         "properties": {
            "x": {
               "description": "X coordinate of the point (px)",
               "title": "X",
               "type": "number"
            },
            "y": {
               "description": "Y coordinate of the point (px)",
               "title": "Y",
               "type": "number"
            }
         },
         "required": [
            "x",
            "y"
         ],
         "title": "Point2f",
         "type": "object"
      }
   }
}

Fields:
field center: Point2f = Point2f(x=0.0, y=0.0)[source]

Center of the circle (px)

field radius: float = 1[source]

Radius of the circle (px)

Constraints:
  • ge = 0

pydantic model aind_behavior_services.common.Point2f[source]

Bases: BaseModel

Represents a 2D point with float coordinates.

Show JSON schema
{
   "title": "Point2f",
   "description": "Represents a 2D point with float coordinates.",
   "type": "object",
   "properties": {
      "x": {
         "description": "X coordinate of the point (px)",
         "title": "X",
         "type": "number"
      },
      "y": {
         "description": "Y coordinate of the point (px)",
         "title": "Y",
         "type": "number"
      }
   },
   "required": [
      "x",
      "y"
   ]
}

Fields:
field x: float [Required][source]

X coordinate of the point (px)

field y: float [Required][source]

Y coordinate of the point (px)

pydantic model aind_behavior_services.common.Rect[source]

Bases: BaseModel

Represents a rectangle defined by its top-left corner, width, and height.

Show JSON schema
{
   "title": "Rect",
   "description": "Represents a rectangle defined by its top-left corner, width, and height.",
   "type": "object",
   "properties": {
      "x": {
         "default": 0,
         "description": "X coordinate of the top-left corner",
         "minimum": 0,
         "title": "X",
         "type": "integer"
      },
      "y": {
         "default": 0,
         "description": "Y coordinate of the top-left corner",
         "minimum": 0,
         "title": "Y",
         "type": "integer"
      },
      "width": {
         "default": 0,
         "description": "Width of the rectangle",
         "minimum": 0,
         "title": "Width",
         "type": "integer"
      },
      "height": {
         "default": 0,
         "description": "Height of the rectangle",
         "minimum": 0,
         "title": "Height",
         "type": "integer"
      }
   }
}

Fields:
field height: int = 0[source]

Height of the rectangle

Constraints:
  • ge = 0

field width: int = 0[source]

Width of the rectangle

Constraints:
  • ge = 0

field x: int = 0[source]

X coordinate of the top-left corner

Constraints:
  • ge = 0

field y: int = 0[source]

Y coordinate of the top-left corner

Constraints:
  • ge = 0

pydantic model aind_behavior_services.common.Vector3[source]

Bases: BaseModel

Represents a 3D vector with float coordinates.

Show JSON schema
{
   "title": "Vector3",
   "description": "Represents a 3D vector with float coordinates.",
   "type": "object",
   "properties": {
      "x": {
         "default": 0,
         "description": "X coordinate of the vector",
         "title": "X",
         "type": "number"
      },
      "y": {
         "default": 0,
         "description": "Y coordinate of the vector",
         "title": "Y",
         "type": "number"
      },
      "z": {
         "default": 0,
         "description": "Z coordinate of the vector",
         "title": "Z",
         "type": "number"
      }
   }
}

Fields:
field x: float = 0[source]

X coordinate of the vector

field y: float = 0[source]

Y coordinate of the vector

field z: float = 0[source]

Z coordinate of the vector

aind_behavior_services.data_types module

class aind_behavior_services.data_types.DataType(*values)[source]

Bases: StrEnum

ARRAY = 'array'[source]
BOOLEAN = 'boolean'[source]
NULL = 'null'[source]
NUMBER = 'number'[source]
OBJECT = 'object'[source]
STRING = 'string'[source]
pydantic model aind_behavior_services.data_types.DataTypes[source]

Bases: SchemaVersionedModel

Show JSON schema
{
   "title": "DataTypes",
   "type": "object",
   "properties": {
      "aind_behavior_services_pkg_version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "aind_behavior_services package version",
         "type": "string"
      },
      "version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "Version",
         "type": "string"
      },
      "software_event": {
         "$ref": "#/$defs/SoftwareEvent"
      },
      "render_synch_state": {
         "$ref": "#/$defs/RenderSynchState"
      }
   },
   "$defs": {
      "DataType": {
         "enum": [
            "string",
            "number",
            "object",
            "array",
            "null",
            "boolean"
         ],
         "title": "DataType",
         "type": "string"
      },
      "RenderSynchState": {
         "properties": {
            "sync_quad_value": {
               "anyOf": [
                  {
                     "maximum": 1,
                     "minimum": 0,
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The synchronization quad value",
               "title": "Sync Quad Value"
            },
            "frame_index": {
               "anyOf": [
                  {
                     "minimum": 0,
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The frame index of the event",
               "title": "Frame Index"
            },
            "frame_timestamp": {
               "anyOf": [
                  {
                     "minimum": 0,
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The timestamp of the frame",
               "title": "Frame Timestamp"
            }
         },
         "title": "RenderSynchState",
         "type": "object"
      },
      "SoftwareEvent": {
         "description": "A software event is a generic event that can be used to track any event that occurs in the software.",
         "properties": {
            "name": {
               "description": "The name of the event",
               "title": "Name",
               "type": "string"
            },
            "timestamp": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The timestamp of the event",
               "title": "Timestamp"
            },
            "timestamp_source": {
               "$ref": "#/$defs/TimestampSource",
               "default": "null",
               "description": "The source of the timestamp"
            },
            "frame_index": {
               "anyOf": [
                  {
                     "minimum": 0,
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The frame index of the event",
               "title": "Frame Index"
            },
            "frame_timestamp": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The timestamp of the frame",
               "title": "Frame Timestamp"
            },
            "data": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The data of the event",
               "title": "Data"
            },
            "data_type": {
               "$ref": "#/$defs/DataType",
               "default": "null",
               "description": "The data type of the event"
            },
            "data_type_hint": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The data type hint of the event",
               "title": "Data Type Hint"
            }
         },
         "required": [
            "name"
         ],
         "title": "SoftwareEvent",
         "type": "object"
      },
      "TimestampSource": {
         "enum": [
            "null",
            "harp",
            "render"
         ],
         "title": "TimestampSource",
         "type": "string"
      }
   },
   "required": [
      "software_event",
      "render_synch_state"
   ],
   "x-abstract": "True"
}

Config:
  • json_schema_extra: dict = {‘x-abstract’: ‘True’}

Fields:
Validators:
field render_synch_state: RenderSynchState [Required][source]
field software_event: SoftwareEvent [Required][source]
field version: Literal['0.13.0-rc2'] = '0.13.0-rc2'[source]
Validated by:
pydantic model aind_behavior_services.data_types.RenderSynchState[source]

Bases: BaseModel

Show JSON schema
{
   "title": "RenderSynchState",
   "type": "object",
   "properties": {
      "sync_quad_value": {
         "anyOf": [
            {
               "maximum": 1,
               "minimum": 0,
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The synchronization quad value",
         "title": "Sync Quad Value"
      },
      "frame_index": {
         "anyOf": [
            {
               "minimum": 0,
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The frame index of the event",
         "title": "Frame Index"
      },
      "frame_timestamp": {
         "anyOf": [
            {
               "minimum": 0,
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The timestamp of the frame",
         "title": "Frame Timestamp"
      }
   }
}

Fields:
field frame_index: int | None = None[source]

The frame index of the event

Constraints:
  • ge = 0

field frame_timestamp: float | None = None[source]

The timestamp of the frame

Constraints:
  • ge = 0

field sync_quad_value: float | None = None[source]

The synchronization quad value

Constraints:
  • ge = 0

  • le = 1

pydantic model aind_behavior_services.data_types.SoftwareEvent[source]

Bases: BaseModel, Generic[TData]

A software event is a generic event that can be used to track any event that occurs in the software.

Show JSON schema
{
   "title": "SoftwareEvent",
   "description": "A software event is a generic event that can be used to track any event that occurs in the software.",
   "type": "object",
   "properties": {
      "name": {
         "description": "The name of the event",
         "title": "Name",
         "type": "string"
      },
      "timestamp": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The timestamp of the event",
         "title": "Timestamp"
      },
      "timestamp_source": {
         "$ref": "#/$defs/TimestampSource",
         "default": "null",
         "description": "The source of the timestamp"
      },
      "frame_index": {
         "anyOf": [
            {
               "minimum": 0,
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The frame index of the event",
         "title": "Frame Index"
      },
      "frame_timestamp": {
         "anyOf": [
            {
               "type": "number"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The timestamp of the frame",
         "title": "Frame Timestamp"
      },
      "data": {
         "anyOf": [
            {},
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The data of the event",
         "title": "Data"
      },
      "data_type": {
         "$ref": "#/$defs/DataType",
         "default": "null",
         "description": "The data type of the event"
      },
      "data_type_hint": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The data type hint of the event",
         "title": "Data Type Hint"
      }
   },
   "$defs": {
      "DataType": {
         "enum": [
            "string",
            "number",
            "object",
            "array",
            "null",
            "boolean"
         ],
         "title": "DataType",
         "type": "string"
      },
      "TimestampSource": {
         "enum": [
            "null",
            "harp",
            "render"
         ],
         "title": "TimestampSource",
         "type": "string"
      }
   },
   "required": [
      "name"
   ]
}

Fields:
field data: Annotated[TData | None, SerializeAsAny()] = None[source]

The data of the event

field data_type: DataType = DataType.NULL[source]

The data type of the event

field data_type_hint: str | None = None[source]

The data type hint of the event

field frame_index: int | None = None[source]

The frame index of the event

Constraints:
  • ge = 0

field frame_timestamp: float | None = None[source]

The timestamp of the frame

field name: str [Required][source]

The name of the event

field timestamp: float | None = None[source]

The timestamp of the event

field timestamp_source: TimestampSource = TimestampSource.NULL[source]

The source of the timestamp

class aind_behavior_services.data_types.TimestampSource(*values)[source]

Bases: StrEnum

HARP = 'harp'[source]
NULL = 'null'[source]
RENDER = 'render'[source]

aind_behavior_services.message_protocol module

pydantic model aind_behavior_services.message_protocol.HeartbeatPayload[source]

Bases: BaseModel

Payload for heartbeat messages indicating system health status.

Heartbeat messages are used to monitor the health and availability of system components. They include a status indicator and optional context information.

context[source]

Optional additional data about the system state

status[source]

Current health status of the component

Examples

```python heartbeat = HeartbeatPayload(

status=HeartbeatStatus.OK, context={“cpu_usage”: 0.25, “memory_usage”: 0.60}

) print(heartbeat.status) # HeartbeatStatus.OK

warning_heartbeat = HeartbeatPayload(

status=HeartbeatStatus.WARNING, context={“disk_space_low”: True}

)

Show JSON schema
{
   "title": "HeartbeatPayload",
   "description": "Payload for heartbeat messages indicating system health status.\n\nHeartbeat messages are used to monitor the health and availability\nof system components. They include a status indicator and optional\ncontext information.\n\nAttributes:\n    context: Optional additional data about the system state\n    status: Current health status of the component\n\nExamples:\n    ```python\n    heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.OK,\n        context={\"cpu_usage\": 0.25, \"memory_usage\": 0.60}\n    )\n    print(heartbeat.status)  # HeartbeatStatus.OK\n\n    warning_heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.WARNING,\n        context={\"disk_space_low\": True}\n    )\n    ```",
   "type": "object",
   "properties": {
      "payload_type": {
         "const": "HeartbeatPayload",
         "default": "HeartbeatPayload",
         "title": "Payload Type",
         "type": "string"
      },
      "context": {
         "anyOf": [
            {},
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Additional context for the heartbeat message.",
         "title": "Context"
      },
      "status": {
         "$ref": "#/$defs/HeartbeatStatus",
         "description": "The status of the heartbeat message"
      }
   },
   "$defs": {
      "HeartbeatStatus": {
         "description": "Enumeration of possible heartbeat status values.\n\nRepresents the health status of a system component,\nwith higher values indicating more severe issues.\n\nExamples:\n    ```python\n    HeartbeatStatus.OK                            # <HeartbeatStatus.OK: 0>\n    HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING  # True\n    int(HeartbeatStatus.ERROR)                    # 2\n    ```",
         "enum": [
            0,
            1,
            2,
            3
         ],
         "title": "HeartbeatStatus",
         "type": "integer"
      }
   },
   "required": [
      "status"
   ]
}

Fields:
field context: Annotated[Any | None, SerializeAsAny()] = None[source]

Additional context for the heartbeat message.

field payload_type: Literal['HeartbeatPayload'] = 'HeartbeatPayload'[source]
field status: HeartbeatStatus [Required][source]

The status of the heartbeat message

class aind_behavior_services.message_protocol.HeartbeatStatus(*values)[source]

Bases: IntEnum

Enumeration of possible heartbeat status values.

Represents the health status of a system component, with higher values indicating more severe issues.

Examples

`python HeartbeatStatus.OK                            # <HeartbeatStatus.OK: 0> HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING  # True int(HeartbeatStatus.ERROR)                    # 2 `

CRITICAL = 3[source]
ERROR = 2[source]
OK = 0[source]
WARNING = 1[source]
class aind_behavior_services.message_protocol.LogLevel(*values)[source]

Bases: IntEnum

Enumeration of log levels for the logging system.

Follows standard Python logging levels with integer values that allow for easy comparison and filtering.

Examples

`python LogLevel.ERROR > LogLevel.WARNING  # True LogLevel.DEBUG.value               # 10 str(LogLevel.INFO)                 # 'LogLevel.INFO' `

CRITICAL = 50[source]
DEBUG = 10[source]
ERROR = 40[source]
INFO = 20[source]
NOTSET = 0[source]
WARNING = 30[source]
pydantic model aind_behavior_services.message_protocol.LogPayload[source]

Bases: BaseModel

Payload for log messages containing logging information.

This payload carries log data including the message content, severity level, optional context, and application version.

message[source]

The actual log message text

level[source]

Severity level of the log entry

context[source]

Optional additional data related to the log

application_version[source]

Version of the application generating the log

Examples

```python log_payload = LogPayload(

message=”System startup complete”, level=LogLevel.INFO, context={“operator”: “John Doe”}, application_version=”1.0.0”

) print(log_payload.level) # LogLevel.INFO ```

Show JSON schema
{
   "title": "LogPayload",
   "description": "Payload for log messages containing logging information.\n\nThis payload carries log data including the message content,\nseverity level, optional context, and application version.\n\nAttributes:\n    message: The actual log message text\n    level: Severity level of the log entry\n    context: Optional additional data related to the log\n    application_version: Version of the application generating the log\n\nExamples:\n    ```python\n    log_payload = LogPayload(\n        message=\"System startup complete\",\n        level=LogLevel.INFO,\n        context={\"operator\": \"John Doe\"},\n        application_version=\"1.0.0\"\n    )\n    print(log_payload.level)  # LogLevel.INFO\n    ```",
   "type": "object",
   "properties": {
      "payload_type": {
         "const": "LogPayload",
         "default": "LogPayload",
         "title": "Payload Type",
         "type": "string"
      },
      "message": {
         "description": "The message of the log",
         "title": "Message",
         "type": "string"
      },
      "level": {
         "$ref": "#/$defs/LogLevel",
         "default": 10,
         "description": "The level of the log message"
      },
      "context": {
         "anyOf": [
            {},
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Additional context for the log message",
         "title": "Context"
      },
      "application_version": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The version of the application",
         "title": "Application Version"
      }
   },
   "$defs": {
      "LogLevel": {
         "description": "Enumeration of log levels for the logging system.\n\nFollows standard Python logging levels with integer values\nthat allow for easy comparison and filtering.\n\nExamples:\n    ```python\n    LogLevel.ERROR > LogLevel.WARNING  # True\n    LogLevel.DEBUG.value               # 10\n    str(LogLevel.INFO)                 # 'LogLevel.INFO'\n    ```",
         "enum": [
            50,
            40,
            30,
            20,
            10,
            0
         ],
         "title": "LogLevel",
         "type": "integer"
      }
   },
   "required": [
      "message"
   ]
}

Fields:
field application_version: str | None = None[source]

The version of the application

field context: Annotated[Any, SerializeAsAny()] | None = None[source]

Additional context for the log message

field level: LogLevel = LogLevel.DEBUG[source]

The level of the log message

field message: str [Required][source]

The message of the log

field payload_type: Literal['LogPayload'] = 'LogPayload'[source]
pydantic model aind_behavior_services.message_protocol.Message[source]

Bases: RootModel

Show JSON schema
{
   "title": "Message",
   "$defs": {
      "MessageType": {
         "description": "Enumeration of possible message types in the protocol.\n\nExamples:\n    ```python\n    MessageType.REQUEST  # 'request'\n    MessageType.REPLY    # 'reply'\n    MessageType.EVENT    # 'event'\n    ```",
         "enum": [
            "request",
            "reply",
            "event"
         ],
         "title": "MessageType",
         "type": "string"
      },
      "_Message_Any_": {
         "properties": {
            "message_type": {
               "$ref": "#/$defs/MessageType"
            },
            "protocol_version": {
               "const": 0,
               "default": 0,
               "title": "Protocol Version",
               "type": "integer"
            },
            "timestamp": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "The timestamp of the message",
               "title": "Timestamp"
            },
            "payload": {
               "description": "The payload of the message",
               "title": "Payload"
            },
            "process_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Process that created the message",
               "title": "Process Id"
            },
            "hostname": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Hostname that created the message",
               "title": "Hostname"
            },
            "rig_name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Rig name that created the message",
               "title": "Rig Name"
            }
         },
         "required": [
            "message_type",
            "timestamp",
            "payload",
            "process_id",
            "hostname",
            "rig_name"
         ],
         "title": "_Message[Any]",
         "type": "object"
      }
   },
   "$ref": "#/$defs/_Message_Any_"
}

Fields:
field root: _Message[Any] [Required][source]
pydantic model aind_behavior_services.message_protocol.MessageProtocol[source]

Bases: BaseModel

Container for the complete message protocol including all registered message types.

Show JSON schema
{
   "title": "MessageProtocol",
   "description": "Container for the complete message protocol including all registered message types.",
   "type": "object",
   "properties": {
      "registered_message": {
         "$ref": "#/$defs/RegisteredMessages"
      },
      "message": {
         "$ref": "#/$defs/Message"
      }
   },
   "$defs": {
      "HeartbeatPayload": {
         "description": "Payload for heartbeat messages indicating system health status.\n\nHeartbeat messages are used to monitor the health and availability\nof system components. They include a status indicator and optional\ncontext information.\n\nAttributes:\n    context: Optional additional data about the system state\n    status: Current health status of the component\n\nExamples:\n    ```python\n    heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.OK,\n        context={\"cpu_usage\": 0.25, \"memory_usage\": 0.60}\n    )\n    print(heartbeat.status)  # HeartbeatStatus.OK\n\n    warning_heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.WARNING,\n        context={\"disk_space_low\": True}\n    )\n    ```",
         "properties": {
            "payload_type": {
               "const": "HeartbeatPayload",
               "default": "HeartbeatPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the heartbeat message.",
               "title": "Context"
            },
            "status": {
               "$ref": "#/$defs/HeartbeatStatus",
               "description": "The status of the heartbeat message"
            }
         },
         "required": [
            "status"
         ],
         "title": "HeartbeatPayload",
         "type": "object"
      },
      "HeartbeatStatus": {
         "description": "Enumeration of possible heartbeat status values.\n\nRepresents the health status of a system component,\nwith higher values indicating more severe issues.\n\nExamples:\n    ```python\n    HeartbeatStatus.OK                            # <HeartbeatStatus.OK: 0>\n    HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING  # True\n    int(HeartbeatStatus.ERROR)                    # 2\n    ```",
         "enum": [
            0,
            1,
            2,
            3
         ],
         "title": "HeartbeatStatus",
         "type": "integer"
      },
      "LogLevel": {
         "description": "Enumeration of log levels for the logging system.\n\nFollows standard Python logging levels with integer values\nthat allow for easy comparison and filtering.\n\nExamples:\n    ```python\n    LogLevel.ERROR > LogLevel.WARNING  # True\n    LogLevel.DEBUG.value               # 10\n    str(LogLevel.INFO)                 # 'LogLevel.INFO'\n    ```",
         "enum": [
            50,
            40,
            30,
            20,
            10,
            0
         ],
         "title": "LogLevel",
         "type": "integer"
      },
      "LogPayload": {
         "description": "Payload for log messages containing logging information.\n\nThis payload carries log data including the message content,\nseverity level, optional context, and application version.\n\nAttributes:\n    message: The actual log message text\n    level: Severity level of the log entry\n    context: Optional additional data related to the log\n    application_version: Version of the application generating the log\n\nExamples:\n    ```python\n    log_payload = LogPayload(\n        message=\"System startup complete\",\n        level=LogLevel.INFO,\n        context={\"operator\": \"John Doe\"},\n        application_version=\"1.0.0\"\n    )\n    print(log_payload.level)  # LogLevel.INFO\n    ```",
         "properties": {
            "payload_type": {
               "const": "LogPayload",
               "default": "LogPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "message": {
               "description": "The message of the log",
               "title": "Message",
               "type": "string"
            },
            "level": {
               "$ref": "#/$defs/LogLevel",
               "default": 10,
               "description": "The level of the log message"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the log message",
               "title": "Context"
            },
            "application_version": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The version of the application",
               "title": "Application Version"
            }
         },
         "required": [
            "message"
         ],
         "title": "LogPayload",
         "type": "object"
      },
      "Message": {
         "$ref": "#/$defs/_Message_Any_",
         "title": "Message"
      },
      "MessageType": {
         "description": "Enumeration of possible message types in the protocol.\n\nExamples:\n    ```python\n    MessageType.REQUEST  # 'request'\n    MessageType.REPLY    # 'reply'\n    MessageType.EVENT    # 'event'\n    ```",
         "enum": [
            "request",
            "reply",
            "event"
         ],
         "title": "MessageType",
         "type": "string"
      },
      "RegisteredMessages": {
         "properties": {
            "message_type": {
               "$ref": "#/$defs/MessageType"
            },
            "protocol_version": {
               "const": 0,
               "default": 0,
               "title": "Protocol Version",
               "type": "integer"
            },
            "timestamp": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "The timestamp of the message",
               "title": "Timestamp"
            },
            "payload": {
               "$ref": "#/$defs/RegisteredPayload",
               "description": "The payload of the message"
            },
            "process_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Process that created the message",
               "title": "Process Id"
            },
            "hostname": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Hostname that created the message",
               "title": "Hostname"
            },
            "rig_name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Rig name that created the message",
               "title": "Rig Name"
            }
         },
         "required": [
            "message_type",
            "timestamp",
            "payload",
            "process_id",
            "hostname",
            "rig_name"
         ],
         "title": "RegisteredMessages",
         "type": "object"
      },
      "RegisteredPayload": {
         "discriminator": {
            "mapping": {
               "HeartbeatPayload": "#/$defs/HeartbeatPayload",
               "LogPayload": "#/$defs/LogPayload"
            },
            "propertyName": "payload_type"
         },
         "oneOf": [
            {
               "$ref": "#/$defs/LogPayload"
            },
            {
               "$ref": "#/$defs/HeartbeatPayload"
            }
         ],
         "title": "RegisteredPayload",
         "x-abstract": true
      },
      "_Message_Any_": {
         "properties": {
            "message_type": {
               "$ref": "#/$defs/MessageType"
            },
            "protocol_version": {
               "const": 0,
               "default": 0,
               "title": "Protocol Version",
               "type": "integer"
            },
            "timestamp": {
               "anyOf": [
                  {
                     "format": "date-time",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "The timestamp of the message",
               "title": "Timestamp"
            },
            "payload": {
               "description": "The payload of the message",
               "title": "Payload"
            },
            "process_id": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Process that created the message",
               "title": "Process Id"
            },
            "hostname": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Hostname that created the message",
               "title": "Hostname"
            },
            "rig_name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "Rig name that created the message",
               "title": "Rig Name"
            }
         },
         "required": [
            "message_type",
            "timestamp",
            "payload",
            "process_id",
            "hostname",
            "rig_name"
         ],
         "title": "_Message[Any]",
         "type": "object"
      }
   },
   "required": [
      "registered_message",
      "message"
   ],
   "x-abstract": true
}

Config:
  • json_schema_extra: dict = {‘x-abstract’: True}

Fields:
field message: Message [Required][source]
field registered_message: RegisteredMessages [Required][source]
class aind_behavior_services.message_protocol.MessageType(*values)[source]

Bases: StrEnum

Enumeration of possible message types in the protocol.

Examples

`python MessageType.REQUEST  # 'request' MessageType.REPLY    # 'reply' MessageType.EVENT    # 'event' `

EVENT = 'event'[source]
REPLY = 'reply'[source]
REQUEST = 'request'[source]
pydantic model aind_behavior_services.message_protocol.RegisteredMessages[source]

Bases: _Message[RegisteredPayload]

Show JSON schema
{
   "title": "RegisteredMessages",
   "type": "object",
   "properties": {
      "message_type": {
         "$ref": "#/$defs/MessageType"
      },
      "protocol_version": {
         "const": 0,
         "default": 0,
         "title": "Protocol Version",
         "type": "integer"
      },
      "timestamp": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "The timestamp of the message",
         "title": "Timestamp"
      },
      "payload": {
         "$ref": "#/$defs/RegisteredPayload",
         "description": "The payload of the message"
      },
      "process_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "Process that created the message",
         "title": "Process Id"
      },
      "hostname": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "Hostname that created the message",
         "title": "Hostname"
      },
      "rig_name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "description": "Rig name that created the message",
         "title": "Rig Name"
      }
   },
   "$defs": {
      "HeartbeatPayload": {
         "description": "Payload for heartbeat messages indicating system health status.\n\nHeartbeat messages are used to monitor the health and availability\nof system components. They include a status indicator and optional\ncontext information.\n\nAttributes:\n    context: Optional additional data about the system state\n    status: Current health status of the component\n\nExamples:\n    ```python\n    heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.OK,\n        context={\"cpu_usage\": 0.25, \"memory_usage\": 0.60}\n    )\n    print(heartbeat.status)  # HeartbeatStatus.OK\n\n    warning_heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.WARNING,\n        context={\"disk_space_low\": True}\n    )\n    ```",
         "properties": {
            "payload_type": {
               "const": "HeartbeatPayload",
               "default": "HeartbeatPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the heartbeat message.",
               "title": "Context"
            },
            "status": {
               "$ref": "#/$defs/HeartbeatStatus",
               "description": "The status of the heartbeat message"
            }
         },
         "required": [
            "status"
         ],
         "title": "HeartbeatPayload",
         "type": "object"
      },
      "HeartbeatStatus": {
         "description": "Enumeration of possible heartbeat status values.\n\nRepresents the health status of a system component,\nwith higher values indicating more severe issues.\n\nExamples:\n    ```python\n    HeartbeatStatus.OK                            # <HeartbeatStatus.OK: 0>\n    HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING  # True\n    int(HeartbeatStatus.ERROR)                    # 2\n    ```",
         "enum": [
            0,
            1,
            2,
            3
         ],
         "title": "HeartbeatStatus",
         "type": "integer"
      },
      "LogLevel": {
         "description": "Enumeration of log levels for the logging system.\n\nFollows standard Python logging levels with integer values\nthat allow for easy comparison and filtering.\n\nExamples:\n    ```python\n    LogLevel.ERROR > LogLevel.WARNING  # True\n    LogLevel.DEBUG.value               # 10\n    str(LogLevel.INFO)                 # 'LogLevel.INFO'\n    ```",
         "enum": [
            50,
            40,
            30,
            20,
            10,
            0
         ],
         "title": "LogLevel",
         "type": "integer"
      },
      "LogPayload": {
         "description": "Payload for log messages containing logging information.\n\nThis payload carries log data including the message content,\nseverity level, optional context, and application version.\n\nAttributes:\n    message: The actual log message text\n    level: Severity level of the log entry\n    context: Optional additional data related to the log\n    application_version: Version of the application generating the log\n\nExamples:\n    ```python\n    log_payload = LogPayload(\n        message=\"System startup complete\",\n        level=LogLevel.INFO,\n        context={\"operator\": \"John Doe\"},\n        application_version=\"1.0.0\"\n    )\n    print(log_payload.level)  # LogLevel.INFO\n    ```",
         "properties": {
            "payload_type": {
               "const": "LogPayload",
               "default": "LogPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "message": {
               "description": "The message of the log",
               "title": "Message",
               "type": "string"
            },
            "level": {
               "$ref": "#/$defs/LogLevel",
               "default": 10,
               "description": "The level of the log message"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the log message",
               "title": "Context"
            },
            "application_version": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The version of the application",
               "title": "Application Version"
            }
         },
         "required": [
            "message"
         ],
         "title": "LogPayload",
         "type": "object"
      },
      "MessageType": {
         "description": "Enumeration of possible message types in the protocol.\n\nExamples:\n    ```python\n    MessageType.REQUEST  # 'request'\n    MessageType.REPLY    # 'reply'\n    MessageType.EVENT    # 'event'\n    ```",
         "enum": [
            "request",
            "reply",
            "event"
         ],
         "title": "MessageType",
         "type": "string"
      },
      "RegisteredPayload": {
         "discriminator": {
            "mapping": {
               "HeartbeatPayload": "#/$defs/HeartbeatPayload",
               "LogPayload": "#/$defs/LogPayload"
            },
            "propertyName": "payload_type"
         },
         "oneOf": [
            {
               "$ref": "#/$defs/LogPayload"
            },
            {
               "$ref": "#/$defs/HeartbeatPayload"
            }
         ],
         "title": "RegisteredPayload",
         "x-abstract": true
      }
   },
   "required": [
      "message_type",
      "timestamp",
      "payload",
      "process_id",
      "hostname",
      "rig_name"
   ]
}

Fields:

pydantic model aind_behavior_services.message_protocol.RegisteredPayload[source]

Bases: RootModel

Show JSON schema
{
   "title": "RegisteredPayload",
   "$defs": {
      "HeartbeatPayload": {
         "description": "Payload for heartbeat messages indicating system health status.\n\nHeartbeat messages are used to monitor the health and availability\nof system components. They include a status indicator and optional\ncontext information.\n\nAttributes:\n    context: Optional additional data about the system state\n    status: Current health status of the component\n\nExamples:\n    ```python\n    heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.OK,\n        context={\"cpu_usage\": 0.25, \"memory_usage\": 0.60}\n    )\n    print(heartbeat.status)  # HeartbeatStatus.OK\n\n    warning_heartbeat = HeartbeatPayload(\n        status=HeartbeatStatus.WARNING,\n        context={\"disk_space_low\": True}\n    )\n    ```",
         "properties": {
            "payload_type": {
               "const": "HeartbeatPayload",
               "default": "HeartbeatPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the heartbeat message.",
               "title": "Context"
            },
            "status": {
               "$ref": "#/$defs/HeartbeatStatus",
               "description": "The status of the heartbeat message"
            }
         },
         "required": [
            "status"
         ],
         "title": "HeartbeatPayload",
         "type": "object"
      },
      "HeartbeatStatus": {
         "description": "Enumeration of possible heartbeat status values.\n\nRepresents the health status of a system component,\nwith higher values indicating more severe issues.\n\nExamples:\n    ```python\n    HeartbeatStatus.OK                            # <HeartbeatStatus.OK: 0>\n    HeartbeatStatus.CRITICAL > HeartbeatStatus.WARNING  # True\n    int(HeartbeatStatus.ERROR)                    # 2\n    ```",
         "enum": [
            0,
            1,
            2,
            3
         ],
         "title": "HeartbeatStatus",
         "type": "integer"
      },
      "LogLevel": {
         "description": "Enumeration of log levels for the logging system.\n\nFollows standard Python logging levels with integer values\nthat allow for easy comparison and filtering.\n\nExamples:\n    ```python\n    LogLevel.ERROR > LogLevel.WARNING  # True\n    LogLevel.DEBUG.value               # 10\n    str(LogLevel.INFO)                 # 'LogLevel.INFO'\n    ```",
         "enum": [
            50,
            40,
            30,
            20,
            10,
            0
         ],
         "title": "LogLevel",
         "type": "integer"
      },
      "LogPayload": {
         "description": "Payload for log messages containing logging information.\n\nThis payload carries log data including the message content,\nseverity level, optional context, and application version.\n\nAttributes:\n    message: The actual log message text\n    level: Severity level of the log entry\n    context: Optional additional data related to the log\n    application_version: Version of the application generating the log\n\nExamples:\n    ```python\n    log_payload = LogPayload(\n        message=\"System startup complete\",\n        level=LogLevel.INFO,\n        context={\"operator\": \"John Doe\"},\n        application_version=\"1.0.0\"\n    )\n    print(log_payload.level)  # LogLevel.INFO\n    ```",
         "properties": {
            "payload_type": {
               "const": "LogPayload",
               "default": "LogPayload",
               "title": "Payload Type",
               "type": "string"
            },
            "message": {
               "description": "The message of the log",
               "title": "Message",
               "type": "string"
            },
            "level": {
               "$ref": "#/$defs/LogLevel",
               "default": 10,
               "description": "The level of the log message"
            },
            "context": {
               "anyOf": [
                  {},
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Additional context for the log message",
               "title": "Context"
            },
            "application_version": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The version of the application",
               "title": "Application Version"
            }
         },
         "required": [
            "message"
         ],
         "title": "LogPayload",
         "type": "object"
      }
   },
   "discriminator": {
      "mapping": {
         "HeartbeatPayload": "#/$defs/HeartbeatPayload",
         "LogPayload": "#/$defs/LogPayload"
      },
      "propertyName": "payload_type"
   },
   "oneOf": [
      {
         "$ref": "#/$defs/LogPayload"
      },
      {
         "$ref": "#/$defs/HeartbeatPayload"
      }
   ],
   "x-abstract": true
}

Fields:
field root: HeartbeatPayload, FieldInfo(annotation=NoneType, required=True, discriminator='payload_type', json_schema_extra={'x-abstract': True})] [Required][source]

aind_behavior_services.utils module

aind_behavior_services.utils.format_datetime(value, is_tz_strict=False)[source]
Parameters:
  • value (datetime)

  • is_tz_strict (bool)

Return type:

str

aind_behavior_services.utils.get_commit_hash(repository=None)[source]

Get the commit hash of the repository.

Parameters:

repository (PathLike | None)

Return type:

str

aind_behavior_services.utils.get_fields_of_type(searchable, target_type, *, recursive=True, stop_recursion_on_type=True)[source]
Parameters:
  • searchable (BaseModel | Dict | List)

  • target_type (Type[T])

  • recursive (bool)

  • stop_recursion_on_type (bool)

Return type:

List[Tuple[str | None, T]]

aind_behavior_services.utils.model_from_json_file(json_path, model)[source]
Parameters:
  • json_path (PathLike | str)

  • model (type[TModel])

Return type:

TModel

aind_behavior_services.utils.now()[source]

Returns the current time as a timezone unaware datetime.

Return type:

datetime

aind_behavior_services.utils.open_bonsai_process(workflow_file, bonsai_exe='bonsai/bonsai.exe', is_editor_mode=True, is_start_flag=True, layout=None, additional_properties=None, log_file_name=None, cwd=None, creation_flags=None, print_cmd=False)[source]
Parameters:
  • workflow_file (PathLike | str)

  • bonsai_exe (PathLike | str)

  • is_editor_mode (bool)

  • is_start_flag (bool)

  • layout (PathLike | str | None)

  • additional_properties (Dict[str, str] | None)

  • log_file_name (str | None)

  • cwd (PathLike | str | None)

  • creation_flags (int | None)

  • print_cmd (bool)

Return type:

Popen

aind_behavior_services.utils.pascal_to_snake_case(s)[source]

Converts a PascalCase string to snake_case.

Parameters:

s (str) – The PascalCase string to be converted.

Returns:

The snake_case string.

Return type:

str

aind_behavior_services.utils.run_bonsai_process(workflow_file, bonsai_exe='bonsai/bonsai.exe', is_editor_mode=True, is_start_flag=True, layout=None, additional_properties=None, cwd=None, timeout=None, print_cmd=False)[source]
Parameters:
  • workflow_file (PathLike | str)

  • bonsai_exe (PathLike | str)

  • is_editor_mode (bool)

  • is_start_flag (bool)

  • layout (PathLike | str | None)

  • additional_properties (Dict[str, str] | None)

  • cwd (PathLike | str | None)

  • timeout (float | None)

  • print_cmd (bool)

Return type:

CompletedProcess

aind_behavior_services.utils.screaming_snake_case_to_pascal_case(s)[source]

Converts a SCREAMING_SNAKE_CASE string to PascalCase.

Parameters:

s (str) – The SCREAMING_SNAKE_CASE string to be converted.

Returns:

The PascalCase string.

Return type:

str

aind_behavior_services.utils.snake_to_pascal_case(s)[source]

Converts a snake_case string to PascalCase.

Parameters:

s (str) – The snake_case string to be converted.

Returns:

The PascalCase string.

Return type:

str

aind_behavior_services.utils.tznow()[source]

Returns the current time as a timezone aware datetime in the local timezone.

Return type:

datetime

aind_behavior_services.utils.utcnow()[source]

Returns the current time as a timezone aware datetime in UTC.

Return type:

datetime

Module contents

class aind_behavior_services.BonsaiSgenSerializers(*values)[source]

Bases: Enum

JSON = 'json'[source]
NONE = 'None'[source]
YAML = 'yaml'[source]
pydantic model aind_behavior_services.Rig[source]

Bases: SchemaVersionedModel

Base model for rig configuration. All rig configurations should derive from this base class.

Show JSON schema
{
   "title": "Rig",
   "description": "Base model for rig configuration. All rig configurations should derive from this base class.",
   "type": "object",
   "properties": {
      "aind_behavior_services_pkg_version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "aind_behavior_services package version",
         "type": "string"
      },
      "version": {
         "description": "schema version",
         "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
         "title": "Version",
         "type": "string"
      },
      "computer_name": {
         "description": "Computer name",
         "title": "Computer Name",
         "type": "string"
      },
      "rig_name": {
         "description": "Rig name",
         "title": "Rig Name",
         "type": "string"
      },
      "data_directory": {
         "description": "Directory where data will be saved to",
         "format": "path",
         "title": "Data Directory",
         "type": "string"
      }
   },
   "required": [
      "version",
      "computer_name",
      "rig_name",
      "data_directory"
   ]
}

Fields:
  • computer_name (str)

  • data_directory (pathlib.Path)

  • rig_name (str)

Validators:

field computer_name: str [Required][source]

Computer name

field data_directory: Path [Required][source]

Directory where data will be saved to

field rig_name: str [Required][source]

Rig name

pydantic model aind_behavior_services.SchemaVersionedModel[source]

Bases: BaseModel

Show JSON schema
{
   "title": "SchemaVersionedModel",
   "type": "object",
   "properties": {
      "aind_behavior_services_pkg_version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "aind_behavior_services package version",
         "type": "string"
      },
      "version": {
         "description": "schema version",
         "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
         "title": "Version",
         "type": "string"
      }
   },
   "required": [
      "version"
   ]
}

Fields:
Validators:
field aind_behavior_services_pkg_version: Literal['0.13.0-rc2'] = '0.13.0-rc2'[source]
Constraints:
  • pattern = ^(0|[1-9]d*).(0|[1-9]d*).(0|[1-9]d*)(?:-((?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*)(?:.(?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

Validated by:
field version: str [Required][source]

schema version

Constraints:
  • pattern = ^(0|[1-9]d*).(0|[1-9]d*).(0|[1-9]d*)(?:-((?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*)(?:.(?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

Validated by:
validator coerce_version  »  aind_behavior_services_pkg_version, version[source]
Parameters:

v (str)

Return type:

str

pydantic model aind_behavior_services.Session[source]

Bases: SchemaVersionedModel

Show JSON schema
{
   "title": "Session",
   "type": "object",
   "properties": {
      "aind_behavior_services_pkg_version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "aind_behavior_services package version",
         "type": "string"
      },
      "version": {
         "const": "0.13.0-rc2",
         "default": "0.13.0-rc2",
         "title": "Version",
         "type": "string"
      },
      "experiment": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Name of the experiment",
         "title": "Experiment"
      },
      "experimenter": {
         "default": [],
         "description": "Name of the experimenter",
         "items": {
            "type": "string"
         },
         "title": "Experimenter",
         "type": "array"
      },
      "date": {
         "description": "Date of the experiment",
         "format": "date-time",
         "title": "Date",
         "type": "string"
      },
      "session_name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Name of the session. This will be used to create a folder in the root path. If not provided, it will be generated using subject and date.",
         "title": "Session Name"
      },
      "subject": {
         "description": "Name of the subject",
         "title": "Subject",
         "type": "string"
      },
      "notes": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Notes about the experiment",
         "title": "Notes"
      },
      "commit_hash": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Commit hash of the repository",
         "title": "Commit Hash"
      },
      "allow_dirty_repo": {
         "default": false,
         "description": "Allow running from a dirty repository",
         "title": "Allow Dirty Repo",
         "type": "boolean"
      },
      "skip_hardware_validation": {
         "default": false,
         "description": "Skip hardware validation",
         "title": "Skip Hardware Validation",
         "type": "boolean"
      }
   },
   "required": [
      "subject"
   ]
}

Fields:
Validators:
field allow_dirty_repo: bool = False[source]

Allow running from a dirty repository

Validated by:
field commit_hash: str | None = None[source]

Commit hash of the repository

Validated by:
field date: Annotated[AwareDatetime, WrapValidator(func=_add_default_tz, json_schema_input_type=PydanticUndefined), FieldInfo(annotation=NoneType, required=True, validate_default=True)] [Optional][source]

Date of the experiment

Constraints:
  • func = <function _add_default_tz at 0x7f76749f39c0>

  • json_schema_input_type = PydanticUndefined

Validated by:
field experiment: str | None = None[source]

Name of the experiment

Validated by:
field experimenter: List[str] = [][source]

Name of the experimenter

Validated by:
field notes: str | None = None[source]

Notes about the experiment

Validated by:
field session_name: str | None = None[source]

Name of the session. This will be used to create a folder in the root path. If not provided, it will be generated using subject and date.

Validated by:
field skip_hardware_validation: bool = False[source]

Skip hardware validation

Validated by:
field subject: str [Required][source]

Name of the subject

Validated by:
field version: Literal['0.13.0-rc2'] = '0.13.0-rc2'[source]
Validated by:
validator generate_session_name_default  »  all fields[source]
Return type:

Self

pydantic model aind_behavior_services.Task[source]

Bases: Task

Base class for task schemas.

Show JSON schema
{
   "title": "Task",
   "description": "Base class for task schemas.",
   "type": "object",
   "properties": {
      "name": {
         "description": "Name of the task.",
         "title": "Name",
         "type": "string"
      },
      "description": {
         "default": "",
         "description": "Description of the task.",
         "title": "Description",
         "type": "string"
      },
      "task_parameters": {
         "$ref": "#/$defs/TaskParameters",
         "description": "Parameters of the task"
      },
      "version": {
         "description": "task schema version",
         "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$",
         "title": "Version",
         "type": "string"
      },
      "stage_name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Optional stage name the `Task` object instance represents.",
         "title": "Stage Name"
      }
   },
   "$defs": {
      "TaskParameters": {
         "additionalProperties": true,
         "description": "Base class for storing parameters for the task.",
         "properties": {
            "rng_seed": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Seed of the random number generator",
               "title": "Rng Seed"
            },
            "aind_behavior_services_pkg_version": {
               "const": "0.13.0-rc2",
               "default": "0.13.0-rc2",
               "title": "aind_behavior_services package version",
               "type": "string"
            }
         },
         "title": "TaskParameters",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "name",
      "task_parameters",
      "version"
   ]
}

Config:
  • extra: str = forbid

  • validate_assignment: bool = True

  • validate_default: bool = True

  • strict: bool = True

  • str_strip_whitespace: bool = True

Fields:
Validators:
field task_parameters: TaskParameters [Required][source]

Parameters of the task

field version: str [Required][source]

task schema version

Constraints:
  • pattern = ^(0|[1-9]d*).(0|[1-9]d*).(0|[1-9]d*)(?:-((?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*)(?:.(?:0|[1-9]d*|d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:+([0-9a-zA-Z-]+(?:.[0-9a-zA-Z-]+)*))?$

Validated by:
validator coerce_version  »  version[source]
Parameters:

v (str)

Return type:

str

aind_behavior_services.convert_pydantic_to_bonsai(model, *, model_name=None, json_schema_output_dir=PosixPath('src/DataSchemas'), cs_output_dir=PosixPath('src/Extensions'), cs_namespace='DataSchema', cs_serializer=None, json_schema_export_kwargs=None, root_element=None)[source]
Parameters:
  • model (Type[BaseModel])

  • model_name (str | None)

  • json_schema_output_dir (PathLike)

  • cs_output_dir (PathLike | None)

  • cs_namespace (str)

  • cs_serializer (List[BonsaiSgenSerializers] | None)

  • json_schema_export_kwargs (Dict[str, Any] | None)

  • root_element (str | None)

Return type:

CompletedProcess | None