diff --git a/README.md b/README.md index 8762b1d5ef79a8761b71d8fcd3c6115d60f3b0a3..ff2cba2c69f490843440cd497921e5b9d9a91849 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ Next change the version in the following places: # 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.0 Allow multiple antenna fields to be used in single observation, This renames the `Observation` device to `ObservationField`. diff --git a/docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py b/docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py index fdb80e699e4bd6bbb2b453ac16ebdfae4bcf0baa..a2553cad2b6590767504a04bd1d4207aae76ea6c 100644 --- a/docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py +++ b/docker-compose/tango-prometheus-exporter/code/tango-prometheus-client.py @@ -14,9 +14,10 @@ from tango import ( Database, DeviceProxy, CmdArgType as ArgType, + utils, AttrDataFormat, DevState, - DevFailed, + DevFailed, AttributeInfo, ) logger = logging.getLogger() @@ -110,28 +111,18 @@ class CustomCollector(object): self.policy = ArchiverPolicy(config) 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.""" - if attr_info.data_type in [ - ArgType.DevShort, - ArgType.DevLong, - ArgType.DevUShort, - ArgType.DevULong, - ArgType.DevLong64, - ArgType.DevULong64, - ArgType.DevInt, - ArgType.DevFloat, - ArgType.DevDouble, - ]: + if utils.is_numerical_type(attr_info.data_type): data_type = "float" str_value = "" float_value = float(value) - elif attr_info.data_type == ArgType.DevBoolean: + elif utils.is_bool_type(attr_info.data_type): data_type = "bool" str_value = "" float_value = int(value) - elif attr_info.data_type == ArgType.DevString: + elif utils.is_str_type(attr_info.data_type): data_type = "string" str_value = str(value) float_value = len(str_value) @@ -162,13 +153,13 @@ class CustomCollector(object): 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.""" new_metric = self._to_metric(dev, attr_info, 0, 0, 0, attr_value.value) 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.""" metrics = [] @@ -178,7 +169,7 @@ class CustomCollector(object): 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.""" metrics = [] @@ -199,7 +190,7 @@ class CustomCollector(object): 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.""" if attr_info.data_format == AttrDataFormat.SCALAR: diff --git a/tangostationcontrol/VERSION b/tangostationcontrol/VERSION index 48b91fd89c0759b898d563d1141cc93ef25e16fe..8b95abd9483e5ec2c932da88c141b56dc1f2b550 100644 --- a/tangostationcontrol/VERSION +++ b/tangostationcontrol/VERSION @@ -1 +1 @@ -0.24.1 +0.24.2