Skip to content
Snippets Groups Projects
Commit 24ab0b73 authored by Corné Lukken's avatar Corné Lukken
Browse files

L2SS-1574: PyTango 9.5.0 compatability

parent 98222bdc
No related branches found
No related tags found
1 merge request!767L2SS-1574: PyTango 9.5.0 compatability
...@@ -139,6 +139,7 @@ Next change the version in the following places: ...@@ -139,6 +139,7 @@ Next change the version in the following places:
# Release Notes # Release Notes
* 0.24.2 Ensure code base is PyTango 9.5 compatible
* 0.24.1 Let all devices emit basic prometheus metrics * 0.24.1 Let all devices emit basic prometheus metrics
* 0.24.0 Allow multiple antenna fields to be used in single observation, * 0.24.0 Allow multiple antenna fields to be used in single observation,
This renames the `Observation` device to `ObservationField`. This renames the `Observation` device to `ObservationField`.
......
...@@ -14,9 +14,10 @@ from tango import ( ...@@ -14,9 +14,10 @@ from tango import (
Database, Database,
DeviceProxy, DeviceProxy,
CmdArgType as ArgType, CmdArgType as ArgType,
utils,
AttrDataFormat, AttrDataFormat,
DevState, DevState,
DevFailed, DevFailed, AttributeInfo,
) )
logger = logging.getLogger() logger = logging.getLogger()
...@@ -110,28 +111,18 @@ class CustomCollector(object): ...@@ -110,28 +111,18 @@ class CustomCollector(object):
self.policy = ArchiverPolicy(config) self.policy = ArchiverPolicy(config)
self.proxy_timeout = proxy_timeout self.proxy_timeout = proxy_timeout
def _to_metric(self, dev, attr_info, x, y, idx, value): def _to_metric(self, dev, attr_info: AttributeInfo, x, y, idx, value):
"""Convert the given values to a (labels, value) pair, used to construct a Metric.""" """Convert the given values to a (labels, value) pair, used to construct a Metric."""
if attr_info.data_type in [ if utils.is_numerical_type(attr_info.data_type):
ArgType.DevShort,
ArgType.DevLong,
ArgType.DevUShort,
ArgType.DevULong,
ArgType.DevLong64,
ArgType.DevULong64,
ArgType.DevInt,
ArgType.DevFloat,
ArgType.DevDouble,
]:
data_type = "float" data_type = "float"
str_value = "" str_value = ""
float_value = float(value) float_value = float(value)
elif attr_info.data_type == ArgType.DevBoolean: elif utils.is_bool_type(attr_info.data_type):
data_type = "bool" data_type = "bool"
str_value = "" str_value = ""
float_value = int(value) float_value = int(value)
elif attr_info.data_type == ArgType.DevString: elif utils.is_str_type(attr_info.data_type):
data_type = "string" data_type = "string"
str_value = str(value) str_value = str(value)
float_value = len(str_value) float_value = len(str_value)
...@@ -162,13 +153,13 @@ class CustomCollector(object): ...@@ -162,13 +153,13 @@ class CustomCollector(object):
float_value, float_value,
) )
def metrics_scalar(self, dev, attr_info, attr_value): def metrics_scalar(self, dev, attr_info: AttributeInfo, attr_value):
"""Return all metrics for a given SCALAR attribute.""" """Return all metrics for a given SCALAR attribute."""
new_metric = self._to_metric(dev, attr_info, 0, 0, 0, attr_value.value) new_metric = self._to_metric(dev, attr_info, 0, 0, 0, attr_value.value)
return [new_metric] if new_metric else [] return [new_metric] if new_metric else []
def metrics_spectrum(self, dev, attr_info, attr_value): def metrics_spectrum(self, dev, attr_info: AttributeInfo, attr_value):
"""Return all metrics for a given SPECTRUM attribute.""" """Return all metrics for a given SPECTRUM attribute."""
metrics = [] metrics = []
...@@ -178,7 +169,7 @@ class CustomCollector(object): ...@@ -178,7 +169,7 @@ class CustomCollector(object):
return metrics return metrics
def metrics_image(self, dev, attr_info, attr_value): def metrics_image(self, dev, attr_info: AttributeInfo, attr_value):
"""Return all metrics for a given IMAGE attribute.""" """Return all metrics for a given IMAGE attribute."""
metrics = [] metrics = []
...@@ -199,7 +190,7 @@ class CustomCollector(object): ...@@ -199,7 +190,7 @@ class CustomCollector(object):
return metrics return metrics
def metrics(self, dev, attr_info, attr_value): def metrics(self, dev, attr_info: AttributeInfo, attr_value):
"""Return all metrics for a given attribute.""" """Return all metrics for a given attribute."""
if attr_info.data_format == AttrDataFormat.SCALAR: if attr_info.data_format == AttrDataFormat.SCALAR:
......
0.24.1 0.24.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment