Skip to content
Snippets Groups Projects
Commit 4800240b authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-630: fix statistics client functions

parent 167c8c9e
Branches
Tags
1 merge request!296Resolve L2SS-630 "Refactor functions graded c"
......@@ -97,7 +97,7 @@ class StatisticsClient(AsyncCommClient):
# redirect to right object. this works as long as the parameter names are unique among them.
if annotation["type"] == "statistics":
def read_function():
process_statistics_annotation(annotation, attribute, parameter)
return _process_statistics_annotation()
elif annotation["type"] == "udp":
def read_function():
return self.udp.parameters[parameter]
......@@ -111,17 +111,10 @@ class StatisticsClient(AsyncCommClient):
else:
raise ValueError(f"Unknown queue parameter requested: {parameter}")
elif annotation["type"] == "replicator":
parameters_dict = {"clients": numpy.array(self.tcp.clients(),dtype=numpy.str),
"nof_bytes_sent": numpy.uint64(self.tcp.nof_bytes_sent),
"nof_packets_sent": numpy.uint64(self.tcp.nof_packets_sent),
"nof_tasks_pending": numpy.uint64(self.tcp.nof_tasks_pending)}
for k,v in parameters_dict.items():
if parameter == k:
def read_function():
return v
raise ValueError(f"Unknown replicator parameter requested: {parameter}")
return _process_replicator_annotation()
def process_statistics_annotation(annotation, attribute, parameter):
def _process_statistics_annotation():
if annotation.get("reshape", False):
# force array into the shape of the attribute
if attribute.dim_y > 1:
......@@ -131,6 +124,16 @@ class StatisticsClient(AsyncCommClient):
else:
return self.collector.parameters[parameter]
def _process_replicator_annotation():
parameters_dict = {"clients": numpy.array(self.tcp.clients(),dtype=numpy.str),
"nof_bytes_sent": numpy.uint64(self.tcp.nof_bytes_sent),
"nof_packets_sent": numpy.uint64(self.tcp.nof_packets_sent),
"nof_tasks_pending": numpy.uint64(self.tcp.nof_tasks_pending)}
for k,v in parameters_dict.items():
if parameter == k:
return v
raise ValueError(f"Unknown replicator parameter requested: {parameter}")
def write_function(value):
"""
Not used here
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment