120 def read(self, query_range, query, *, regex=False):
122 Read the relevant data from pBeast for this variable, and convert them to COOL-like format
124 partition, className, attribute, path = query.split(
'.', 3)
126 log.info(f
"Querying pBeast object{'s using regex' if regex else ''} {query}")
128 since, until = query_range
129 since, until = TDAQC_Variable.timeCOOL2PBeast(since), TDAQC_Variable.timeCOOL2PBeast(until)
131 query_data = pbeast.get_data(partition, className, attribute, path, regex, since, until)
132 data = dict.fromkeys(self.mapping.
keys())
if self.force_mapping
else dict()
134 data.update(query_data[0].data)
136 def instantiate(since, until, channel, value):
137 if isinstance(value, list):
139 return PBeastIOV(TDAQC_Variable.timePBeast2COOL(since), TDAQC_Variable.timePBeast2COOL(until), channel, value)
142 for channel, entries
in data.items():
144 iovs.append(
PBeastIOV(*query_range, channel, self.empty_value))
149 for point
in entries:
150 if point.value == value:
152 iovs.append(instantiate(since, point.ts, channel, value))
156 iovs.append(instantiate(since, last.ts, channel, value))
157 iovs = IOVSet(iovs, iov_type=PBeastIOV, origin=query)
159 if log.isEnabledFor(logging.INFO):
160 input_hash =
hash(iovs)
161 self.input_hashes.
append(input_hash)
162 log.info(
" -> Input hash: % 09x (len=%i)", input_hash, len(iovs))