Skip to content
Snippets Groups Projects
Commit 28b26ede authored by Sevda Esen's avatar Sevda Esen
Browse files

make sure stream names are unique, add get stream function

parent 77d2c895
No related branches found
No related tags found
1 merge request!2736Draft: clean up and simplify the config
......@@ -117,13 +117,21 @@ class Streams(object):
"""
def __init__(self, streams):
self.streams = list(
filter(lambda stream: len(stream.lines) > 0,
sorted(streams, key=lambda stream: stream.name)))
self.streams = self._streams(streams)
self.lines = self._lines()
self.physics_lines = self._physics_lines()
self.lumi_lines = self._lumi_lines()
def _streams(self, streams):
streams = list(
filter(lambda stream: len(stream.lines) > 0,
sorted(streams, key=lambda stream: stream.name)))
names = [stream.name for stream in streams]
assert len(streams) == len(
unique(names)), "Multiple streams with same name found in streams."
return streams
def _lines(self):
"""Function to return flat list of DecisionLines from streams"""
lines = []
......@@ -171,6 +179,17 @@ class Streams(object):
print(" lumi_lines: ", [l.name for l in stream.lumi_lines])
print(" raw_banks: ", stream.raw_banks)
def get(self, stream_name):
filtered = list(filter(lambda s: s.name is stream_name, self.streams))
if len(filtered) == 1:
return filtered[0]
elif len(filtered) == 0:
raise ConfigurationError(f"{stream_name} not found in streams.")
else:
raise ConfigurationError(
f"Multiple streams with name {stream_name} found in streams.")
def make_default_streams(lines):
stream = Stream(name="default", lines=lines, detectors=DETECTORS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment