Module enrgdaq.daq.alert.models

Classes

class DAQAlertInfo (message: str,
severity: DAQAlertSeverity)
Expand source code
class DAQAlertInfo(Struct):
    message: str
    severity: DAQAlertSeverity

A base class for defining efficient serializable objects.

Fields are defined using type annotations. Fields may optionally have default values, which result in keyword parameters to the constructor.

Structs automatically define __init__, __eq__, __repr__, and __copy__ methods. Additional methods can be defined on the class as needed. Note that __init__/__new__ cannot be overridden, but other methods can. A tuple of the field names is available on the class via the __struct_fields__ attribute if needed.

Additional class options can be enabled by passing keywords to the class definition (see example below). These configuration options may also be inspected at runtime through the __struct_config__ attribute.

Configuration

frozen: bool, default False Whether instances of this type are pseudo-immutable. If true, attribute assignment is disabled and a corresponding __hash__ is defined. order: bool, default False If True, __lt__, `le, gt, and ge`` methods will be generated for this type. eq: bool, default True If True (the default), an __eq__ method will be generated for this type. Set to False to compare based on instance identity alone. kw_only: bool, default False If True, all fields will be treated as keyword-only arguments in the generated __init__ method. Default is False. omit_defaults: bool, default False Whether fields should be omitted from encoding if the corresponding value is the default for that field. Enabling this may reduce message size, and often also improve encoding & decoding performance. forbid_unknown_fields: bool, default False If True, an error is raised if an unknown field is encountered while decoding structs of this type. If False (the default), no error is raised and the unknown field is skipped. tag: str, int, bool, callable, or None, default None Used along with tag_field for configuring tagged union support. If either are non-None, then the struct is considered "tagged". In this case, an extra field (the tag_field) and value (the tag) are added to the encoded message, which can be used to differentiate message types during decoding.

Set tag=True to enable the default tagged configuration (tag_field is "type", tag is the class name). Alternatively, you can provide a string (or less commonly int) value directly to be used as the tag (e.g. tag="my-tag-value").tag can also be passed a callable that takes the class qualname and returns a valid tag value (e.g. tag=str.lower). See the docs for more information. tag_field: str or None, default None The field name to use for tagged union support. If tag is non-None, then this defaults to "type". See the tag docs above for more information. rename: str, mapping, callable, or None, default None Controls renaming the field names used when encoding/decoding the struct. May be one of "lower", "upper", "camel", "pascal", or "kebab" to rename in lowercase, UPPERCASE, camelCase, PascalCase, or kebab-case respectively. May also be a mapping from field names to the renamed names (missing fields are not renamed). Alternatively, may be a callable that takes the field name and returns a new name or None to not rename that field. Default is None for no field renaming. repr_omit_defaults: bool, default False Whether fields should be omitted from the generated repr if the corresponding value is the default for that field. array_like: bool, default False If True, this struct type will be treated as an array-like type during encoding/decoding, rather than a dict-like type (the default). This may improve performance, at the cost of a more inscrutable message encoding. gc: bool, default True Whether garbage collection is enabled for this type. Disabling this may help reduce GC pressure, but will prevent reference cycles composed of only gc=False from being collected. It is the user's responsibility to ensure that reference cycles don't occur when setting gc=False. weakref: bool, default False Whether instances of this type support weak references. Defaults to False. dict: bool, default False Whether instances of this type will include a __dict__. Setting this to True will allow adding additional undeclared attributes to a struct instance, which may be useful for holding private runtime state. Defaults to False. cache_hash: bool, default False If enabled, the hash of a frozen struct instance will be computed at most once, and then cached on the instance for further reuse. For expensive hash values this can improve performance at the cost of a small amount of memory usage.

Examples

Here we define a new Struct type for describing a dog. It has three fields; two required and one optional.

>>> class Dog(Struct):
...     name: str
...     breed: str
...     is_good_boy: bool = True
...
>>> Dog('snickers', breed='corgi')
Dog(name='snickers', breed='corgi', is_good_boy=True)

Additional struct options can be set as part of the class definition. Here we define a new Struct type for a frozen Point object.

>>> class Point(Struct, frozen=True):
...     x: float
...     y: float
...
>>> {Point(1.5, 2.0): 1}  # frozen structs are hashable
{Point(x=1.5, y=2.0): 1}

Ancestors

  • msgspec.Struct
  • msgspec._core._StructMixin

Instance variables

var message : str
Expand source code
class DAQAlertInfo(Struct):
    message: str
    severity: DAQAlertSeverity
var severityDAQAlertSeverity
Expand source code
class DAQAlertInfo(Struct):
    message: str
    severity: DAQAlertSeverity
class DAQAlertSeverity (*args, **kwds)
Expand source code
class DAQAlertSeverity(str, Enum):
    INFO = "info"
    WARNING = "warning"
    ERROR = "error"

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

Ancestors

  • builtins.str
  • enum.Enum

Class variables

var ERROR
var INFO
var WARNING
class DAQJobMessageAlert (date: datetime.datetime,
alert_info: DAQAlertInfo,
originated_supervisor_id: str,
*,
id: str | None = <factory>,
timestamp: datetime.datetime | None = <factory>,
is_remote: bool = False,
daq_job_info: DAQJobInfo | None = None,
remote_config: DAQRemoteConfig = <factory>)
Expand source code
class DAQJobMessageAlert(DAQJobMessage):
    date: datetime
    alert_info: DAQAlertInfo
    originated_supervisor_id: str

DAQJobMessage is the base class for messages sent between DAQJobs.

Attributes

id : Optional[str]
The unique identifier for the message. Defaults to a UUID.
timestamp : Optional[datetime]
The timestamp for the message. Defaults to the current datetime.
is_remote : bool
Whether the message is sent by a remote DAQJob. Defaults to False.
daq_job_info : Optional[DAQJobInfo]
The information about the DAQJob that sent the message. Defaults to None.
remote_config : DAQRemoteConfig
The remote configuration for the DAQ job. Defaults to an instance of DAQRemoteConfig.

Ancestors

Instance variables

var alert_infoDAQAlertInfo
Expand source code
class DAQJobMessageAlert(DAQJobMessage):
    date: datetime
    alert_info: DAQAlertInfo
    originated_supervisor_id: str
var date : datetime.datetime
Expand source code
class DAQJobMessageAlert(DAQJobMessage):
    date: datetime
    alert_info: DAQAlertInfo
    originated_supervisor_id: str
var originated_supervisor_id : str
Expand source code
class DAQJobMessageAlert(DAQJobMessage):
    date: datetime
    alert_info: DAQAlertInfo
    originated_supervisor_id: str