atef.check.DynamicValue
- class atef.check.DynamicValue(value: str | int | bool | float | None = None, reduce_period: int | float | None = None, reduce_method: ReduceMethod = ReduceMethod.average, string: bool | None = None)[source]
A primitive value from an external source that may change over time. This necessarily picks up a runtime performance cost and getting the value is not guaranteed to be successful. If unsuccessful, this will raise a DynamicValueError from the original exception.
Includes settings for reduction of multiple samples.
Value will be cached on preparation, and this value used for comparisons
- Attributes:
- reduce_period
- string
- value
Methods
get
()Return the cached value from
prepare
, or raise aDynamicValueError
if there is no such value.prepare
(cache)Implement in child class to get the current value from source.
Methods
- __init__(value: str | int | bool | float | None = None, reduce_period: int | float | None = None, reduce_method: ReduceMethod = ReduceMethod.average, string: bool | None = None) None
- get() str | int | bool | float [source]
Return the cached value from
prepare
, or raise aDynamicValueError
if there is no such value.
- async prepare(cache: DataCache) None [source]
Implement in child class to get the current value from source. Should set the self.value
Attributes
- reduce_method: ReduceMethod = 'average'
Reduce collected samples by this reduce method