Skip to content

Commit 3221595

Browse files
authored
Merge pull request #166 from art-daq/eflumerf/BroadcastFragmentCount
Correct accounting for multiple art processes per EventBuilder
2 parents 578923a + 1a35a1a commit 3221595

8 files changed

Lines changed: 118 additions & 275 deletions

File tree

rc/control/bookkeeping.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,12 @@ def sends_to_via_RootNetOutput(proc1, proc2):
11791179

11801180
return False
11811181

1182+
def art_analyzer_count(procinfo):
1183+
res = re.search(r"\s*art_analyzer_count\s*:\s*([0-9\.e]+)", procinfo.fhicl_used)
1184+
if res:
1185+
return int(float(res.group(1)))
1186+
return 1
1187+
11821188
for subsystem_id, subsystem in self.subsystems.items():
11831189

11841190
init_fragment_counts = {}
@@ -1200,7 +1206,7 @@ def sends_to_via_RootNetOutput(proc1, proc2):
12001206
if sends_to_via_RootNetOutput(
12011207
possible_sender_procinfo, procinfo
12021208
):
1203-
init_fragment_count += 1
1209+
init_fragment_count += art_analyzer_count(possible_sender_procinfo)
12041210
elif procinfo.name == "DataLogger":
12051211
for possible_sender_procinfo in [
12061212
pi
@@ -1211,7 +1217,7 @@ def sends_to_via_RootNetOutput(proc1, proc2):
12111217
if sends_to_via_RootNetOutput(
12121218
possible_sender_procinfo, procinfo
12131219
):
1214-
init_fragment_count += 1
1220+
init_fragment_count += art_analyzer_count(possible_sender_procinfo)
12151221
elif procinfo.name == "Dispatcher":
12161222
for possible_sender_procinfo in [
12171223
pi
@@ -1222,7 +1228,7 @@ def sends_to_via_RootNetOutput(proc1, proc2):
12221228
if sends_to_via_RootNetOutput(
12231229
possible_sender_procinfo, procinfo
12241230
):
1225-
init_fragment_count += 1
1231+
init_fragment_count += art_analyzer_count(possible_sender_procinfo)
12261232
if (
12271233
init_fragment_count == 0
12281234
): # Dispatcher will _always_ receive init Fragments, this probably means we're running without DataLoggers
@@ -1235,7 +1241,7 @@ def sends_to_via_RootNetOutput(proc1, proc2):
12351241
if sends_to_via_RootNetOutput(
12361242
possible_sender_procinfo, procinfo
12371243
):
1238-
init_fragment_count += 1
1244+
init_fragment_count += art_analyzer_count(possible_sender_procinfo)
12391245

12401246
init_fragment_counts[procinfo.name] = init_fragment_count
12411247

rc/control/daqinterface.py

Lines changed: 48 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from rc.control.utilities import reformat_fhicl_documents
5252
from rc.control.utilities import fhicl_writes_root_file
5353
from rc.control.utilities import get_setup_commands
54+
from rc.control.utilities import get_build_info
5455
from rc.control.utilities import kill_tail_f
5556
from rc.control.utilities import obtain_messagefacility_fhicl
5657
from rc.control.utilities import record_directory_info
@@ -66,8 +67,9 @@
6667

6768
messagefacility_fhicl_filename = obtain_messagefacility_fhicl(True)
6869
if (
69-
not "ARTDAQ_LOG_FHICL" in os.environ
70-
#or os.environ["ARTDAQ_LOG_FHICL"] != messagefacility_fhicl_filename
70+
not "ARTDAQ_LOG_FHICL"
71+
in os.environ
72+
# or os.environ["ARTDAQ_LOG_FHICL"] != messagefacility_fhicl_filename
7173
):
7274
raise Exception(
7375
make_paragraph(
@@ -868,7 +870,6 @@ def read_settings(self):
868870
self.record_directory = None
869871
self.package_hashes_to_save = []
870872
self.package_versions = {}
871-
self.productsdir_for_bash_scripts = None
872873
self.max_fragment_size_bytes = None
873874

874875
self.boardreader_timeout = 30
@@ -892,7 +893,6 @@ def read_settings(self):
892893
self.max_num_launch_procs_checks = 20
893894
self.launch_procs_wait_time = 40
894895

895-
self.productsdir = None
896896
self.spackdir = None
897897

898898
for line in inf.readlines():
@@ -912,11 +912,6 @@ def read_settings(self):
912912
self.log_directory = line.split()[-1].strip()
913913
elif "record_directory" in line or "record directory" in line:
914914
self.record_directory = line.split()[-1].strip()
915-
elif (
916-
"productsdir_for_bash_scripts" in line
917-
or "productsdir for bash scripts" in line
918-
):
919-
self.productsdir = line.split()[-1].strip()
920915
elif (
921916
"spack_root_for_bash_scripts" in line
922917
or "spack root for bash scripts" in line
@@ -1106,11 +1101,17 @@ def read_settings(self):
11061101
self.data_directory_override = self.data_directory_override + "/"
11071102
elif "transfer_plugin_to_use" in line or "transfer plugin to use" in line:
11081103
self.default_transfer = line.split()[-1].strip()
1109-
elif "transfer_plugin_from_brs" in line or "transfer plugin from brs" in line:
1104+
elif (
1105+
"transfer_plugin_from_brs" in line or "transfer plugin from brs" in line
1106+
):
11101107
self.br_transfer = line.split()[-1].strip()
1111-
elif "transfer_plugin_from_ebs" in line or "transfer plugin from ebs" in line:
1108+
elif (
1109+
"transfer_plugin_from_ebs" in line or "transfer plugin from ebs" in line
1110+
):
11121111
self.eb_transfer = line.split()[-1].strip()
1113-
elif "transfer_plugin_from_dls" in line or "transfer plugin from dls" in line:
1112+
elif (
1113+
"transfer_plugin_from_dls" in line or "transfer plugin from dls" in line
1114+
):
11141115
self.dl_transfer = line.split()[-1].strip()
11151116
elif "allowed_processors" in line or "allowed processors" in line:
11161117
self.allowed_processors = line.split()[-1].strip()
@@ -1138,8 +1139,8 @@ def read_settings(self):
11381139
if self.record_directory is None:
11391140
missing_vars.append("record_directory")
11401141

1141-
if self.productsdir is None and self.spackdir is None:
1142-
missing_vars.append("productsdir_for_bash_scripts or spack_root_for_bash_scripts")
1142+
if self.spackdir is None:
1143+
missing_vars.append("spack_root_for_bash_scripts")
11431144

11441145
if not self.advanced_memory_usage and self.max_fragment_size_bytes is None:
11451146
missing_vars.append("max_fragment_size_bytes")
@@ -1303,11 +1304,9 @@ def have_artdaq_mfextensions(self):
13031304
return self.artdaq_mfextensions_booleans[self.daq_setup_script]
13041305

13051306
cmds = []
1306-
cmds += get_setup_commands(self.productsdir, self.spackdir)
1307+
cmds += get_setup_commands(self.spackdir)
13071308
cmds.append(". %s for_running" % (self.daq_setup_script))
1308-
cmds.append(
1309-
'type -P "msgviewer" && true || false'
1310-
)
1309+
cmds.append('type -P "msgviewer" && true || false')
13111310

13121311
checked_cmd = construct_checked_command(cmds)
13131312

@@ -1326,33 +1325,6 @@ def have_artdaq_mfextensions(self):
13261325

13271326
return self.artdaq_mfextensions_booleans[self.daq_setup_script]
13281327

1329-
def artdaq_mfextensions_info(self):
1330-
1331-
assert self.have_artdaq_mfextensions()
1332-
1333-
cmds = []
1334-
cmds += get_setup_commands(self.productsdir, self.spackdir)
1335-
cmds.append(". %s for_running" % (self.daq_setup_script))
1336-
cmds.append(
1337-
'if [ -n "$SETUP_ARTDAQ_MFEXTENSIONS" ]; then printenv SETUP_ARTDAQ_MFEXTENSIONS; else echo "artdaq_mfextensions $ARTDAQ_MFEXTENSIONS_VERSION $MRB_QUALS";fi'
1338-
)
1339-
1340-
proc = Popen(
1341-
";".join(cmds),
1342-
executable="/bin/bash",
1343-
shell=True,
1344-
stdout=subprocess.PIPE,
1345-
stderr=subprocess.STDOUT,
1346-
)
1347-
1348-
proclines = proc.stdout.readlines()
1349-
1350-
printenv_line = proclines[-1].decode("utf-8")
1351-
version = printenv_line.split()[1]
1352-
qualifiers = printenv_line.split()[-1]
1353-
1354-
return (version, qualifiers)
1355-
13561328
# WK 8/31/21
13571329
# refactor out launching the message viewer into a function
13581330
# and make that function run in the background
@@ -1364,11 +1336,12 @@ def launch_msgviewer(self):
13641336
self.partition_number,
13651337
os.environ["USER"],
13661338
)
1367-
cmds += get_setup_commands(self.productsdir, self.spackdir)
1339+
cmds += get_setup_commands(self.spackdir)
13681340
cmds.append(". %s for_running" % (self.daq_setup_script))
13691341
cmds.append("which msgviewer")
13701342
cmds.append(
1371-
"cp `find ${FHICL_FILE_PATH//:/\/ } -name 'msgviewer.fcl' 2>/dev/null|head -1` %s" % (msgviewer_fhicl)
1343+
"cp `find ${FHICL_FILE_PATH//:/\/ } -name 'msgviewer.fcl' 2>/dev/null|head -1` %s"
1344+
% (msgviewer_fhicl)
13721345
)
13731346
cmds.append(
13741347
'res=$( grep -l "port: %d" %s )' % (port_to_replace, msgviewer_fhicl)
@@ -2020,7 +1993,10 @@ def softlink_logfiles(self):
20201993
link_logfile_cmd = "; ".join(softlink_commands_to_run_on_host[host])
20211994

20221995
if not host_is_local(host):
2023-
link_logfile_cmd = "ssh -o BatchMode=yes %s '%s'" % (host, link_logfile_cmd)
1996+
link_logfile_cmd = "ssh -o BatchMode=yes %s '%s'" % (
1997+
host,
1998+
link_logfile_cmd,
1999+
)
20242000

20252001
proc = Popen(
20262002
link_logfile_cmd,
@@ -2056,8 +2032,9 @@ def fill_package_versions(self, packages):
20562032

20572033
if self.spackdir != None:
20582034
cmd = (
2059-
"%s ; . %s; spack find --loaded | sed -r -n 's/^(%s)@(\\S+).*/\\1 \\2/p'" % (
2060-
";".join(get_setup_commands(self.productsdir, self.spackdir)),
2035+
"%s ; . %s; spack find | sed -r -n 's/^(%s)@(\\S+).*/\\1 \\2/p'"
2036+
% (
2037+
";".join(get_setup_commands(self.spackdir)),
20612038
self.daq_setup_script,
20622039
"|".join(needed_packages),
20632040
)
@@ -2618,12 +2595,10 @@ def archive_documents(self, labeled_fhicl_documents):
26182595
3,
26192596
)
26202597
try:
2621-
self.procinfos[
2622-
procinfo_index
2623-
].lastreturned = self.procinfos[
2624-
procinfo_index
2625-
].server.daq.add_config_archive_entry(
2626-
label, contents
2598+
self.procinfos[procinfo_index].lastreturned = (
2599+
self.procinfos[
2600+
procinfo_index
2601+
].server.daq.add_config_archive_entry(label, contents)
26272602
)
26282603
except:
26292604
self.print_log("d", traceback.format_exc(), 2)
@@ -2775,37 +2750,9 @@ def create_setup_fhiclcpp_if_needed(self):
27752750
),
27762751
)
27772752
with open(os.environ["DAQINTERFACE_SETUP_FHICLCPP"], "w") as outf:
2778-
outf.write("\n".join(get_setup_commands(self.productsdir, self.spackdir)))
2753+
outf.write("\n".join(get_setup_commands(self.spackdir)))
27792754
outf.write("\n\n")
2780-
if self.productsdir != None:
2781-
lines = Popen(
2782-
'%s;ups list -aK+ fhiclcpp | sort -n'
2783-
% (";".join(get_setup_commands(self.productsdir, self.spackdir))),
2784-
executable="/bin/bash",
2785-
shell=True,
2786-
stdout=subprocess.PIPE,
2787-
stderr=subprocess.STDOUT,
2788-
).stdout.readlines()
2789-
if len(lines) > 0:
2790-
fhiclcpp_to_setup_line = lines[-1].decode("utf-8")
2791-
else:
2792-
os.unlink(os.environ["DAQINTERFACE_SETUP_FHICLCPP"])
2793-
raise Exception(
2794-
make_paragraph(
2795-
'Unable to find fhiclcpp ups product in products directory "%s" provided in the DAQInterface settings file, "%s"'
2796-
% (self.productsdir, os.environ["DAQINTERFACE_SETTINGS"])
2797-
)
2798-
)
2799-
2800-
outf.write(
2801-
"setup %s %s -q %s\n"
2802-
% (
2803-
fhiclcpp_to_setup_line.split()[0],
2804-
fhiclcpp_to_setup_line.split()[1],
2805-
fhiclcpp_to_setup_line.split()[3],
2806-
)
2807-
)
2808-
elif self.spackdir != None:
2755+
if self.spackdir != None:
28092756
outf.write("spack load --first fhicl-cpp")
28102757

28112758
if os.path.exists(os.environ["DAQINTERFACE_SETUP_FHICLCPP"]):
@@ -3050,15 +2997,13 @@ def revert_failed_boot(failed_action):
30502997
)
30512998

30522999
elif self.have_artdaq_mfextensions():
3053-
version, qualifiers = self.artdaq_mfextensions_info()
30543000

30553001
self.print_log(
30563002
"i",
30573003
make_paragraph(
3058-
"artdaq_mfextensions %s, %s, appears to be available; "
3004+
"artdaq_mfextensions appears to be available; "
30593005
"if windowing is supported on your host you should see the "
30603006
"messageviewer window pop up momentarily"
3061-
% (version, qualifiers)
30623007
),
30633008
)
30643009

@@ -3116,7 +3061,7 @@ def revert_failed_boot(failed_action):
31163061
# self.print_log("d", "\n", random_node_source_debug_level)
31173062

31183063
cmd = "%s ; . %s for_running" % (
3119-
";".join(get_setup_commands(self.productsdir, self.spackdir)),
3064+
";".join(get_setup_commands(self.spackdir)),
31203065
self.daq_setup_script,
31213066
)
31223067

@@ -3250,7 +3195,10 @@ def revert_failed_boot(failed_action):
32503195
cmds = []
32513196
cmds.append(
32523197
"if [[ -z $( command -v fhicl-dump ) ]]; then %s; source %s; fi"
3253-
% (";".join(get_setup_commands(self.productsdir, self.spackdir)), os.environ["DAQINTERFACE_SETUP_FHICLCPP"])
3198+
% (
3199+
";".join(get_setup_commands(self.spackdir)),
3200+
os.environ["DAQINTERFACE_SETUP_FHICLCPP"],
3201+
)
32543202
)
32553203
cmds.append(
32563204
"if [[ $FHICLCPP_VERSION =~ v4_1[01]|v4_0|v[0123] ]]; then dump_arg=0;else dump_arg=none;fi"
@@ -4302,9 +4250,9 @@ def send_recover_command(command):
43024250

43034251
for procinfo in self.procinfos:
43044252
if name in procinfo.name:
4305-
priorities_used[
4306-
procinfo.priority
4307-
] = "We only care about the key in the dict"
4253+
priorities_used[procinfo.priority] = (
4254+
"We only care about the key in the dict"
4255+
)
43084256

43094257
for priority in sorted(priorities_used.keys(), reverse=True):
43104258
for procinfo in self.procinfos:
@@ -4345,27 +4293,13 @@ def send_recover_command(command):
43454293
# transition "in the queue" despite DAQInterface being in the
43464294
# Stopped state after we've finished this recover
43474295

4348-
self.__do_boot = (
4349-
self.__do_shutdown
4350-
) = (
4351-
self.__do_config
4352-
) = (
4353-
self.__do_recover
4354-
) = (
4296+
self.__do_boot = self.__do_shutdown = self.__do_config = self.__do_recover = (
43554297
self.__do_start_running
4356-
) = (
4357-
self.__do_stop_running
4358-
) = (
4359-
self.__do_terminate
4360-
) = (
4361-
self.__do_pause_running
4362-
) = (
4298+
) = self.__do_stop_running = self.__do_terminate = self.__do_pause_running = (
43634299
self.__do_resume_running
4364-
) = (
4365-
self.__do_enable
4366-
) = (
4367-
self.__do_disable
4368-
) = self.do_trace_get_boolean = self.do_trace_set_boolean = False
4300+
) = self.__do_enable = self.__do_disable = self.do_trace_get_boolean = (
4301+
self.do_trace_set_boolean
4302+
) = False
43694303

43704304
self.complete_state_change(self.name, "recovering")
43714305

@@ -4414,7 +4348,6 @@ def artdaq_process_info(self, name, quiet=False):
44144348
# 5/30/14, called every 1s by control.py
44154349

44164350
def runner(self):
4417-
44184351
"""
44194352
Component "ops" loop. Called at threading hearbeat frequency,
44204353
currently 1/sec.
@@ -4625,7 +4558,7 @@ def main(): # no-coverage
46254558
shell=True,
46264559
stdout=subprocess.PIPE,
46274560
stderr=subprocess.STDOUT,
4628-
encoding="UTF-8"
4561+
encoding="UTF-8",
46294562
)
46304563
.stdout.readlines()[0]
46314564
.strip()

rc/control/manage_processes_direct.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def launch_procs_base(self):
208208
cmds = []
209209
cmds.append(
210210
"if [[ -z $( command -v fhicl-dump ) ]]; then %s; source %s; fi"
211-
% (";".join(get_setup_commands(self.productsdir, self.spackdir)), os.environ["DAQINTERFACE_SETUP_FHICLCPP"])
211+
% (";".join(get_setup_commands(self.spackdir)), os.environ["DAQINTERFACE_SETUP_FHICLCPP"])
212212
)
213213
cmds.append(
214214
"if [[ $FHICLCPP_VERSION =~ v4_1[01]|v4_0|v[0123] ]]; then dump_arg=0;else dump_arg=none;fi"
@@ -310,7 +310,7 @@ def launch_procs_base(self):
310310
launch_commands_to_run_on_host[procinfo.host].append(
311311
"echo > %s" % (self.launch_attempt_files[procinfo.host])
312312
)
313-
launch_commands_to_run_on_host[procinfo.host] += get_setup_commands(self.productsdir, self.spackdir,self.launch_attempt_files[procinfo.host])
313+
launch_commands_to_run_on_host[procinfo.host] += get_setup_commands(self.spackdir,self.launch_attempt_files[procinfo.host])
314314
launch_commands_to_run_on_host[procinfo.host].append(
315315
"source %s for_running >> %s 2>&1 "
316316
% (self.daq_setup_script, self.launch_attempt_files[procinfo.host])

0 commit comments

Comments
 (0)