Skip to content

Commit d602756

Browse files
committed
Its ridiculous to slow down experiments on every platform for problem on one platform. Already introduced "delay" as an argument for test monitoring; use this to control delay and only make it one minute on Derecho
1 parent 97c61d0 commit d602756

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

tests/WE2E/monitor_jobs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def monitor_jobs(expts_dict: dict, monitor_file: str = '', procs: int = 1,
5555

5656
if procs > 1:
5757
print(f'Starting experiments in parallel with {procs} processes')
58-
expts_dict = update_expt_status_parallel(expts_dict, procs, True, debug)
58+
expts_dict = update_expt_status_parallel(expts_dict, procs, True, delay, debug)
5959
else:
6060
for expt in expts_dict:
6161
logging.info(f"Starting experiment {expt} running")
62-
expts_dict[expt] = update_expt_status(expts_dict[expt], expt, True, debug)
62+
expts_dict[expt] = update_expt_status(expts_dict[expt], expt, True, delay, debug)
6363

6464
write_monitor_file(monitor_file,expts_dict)
6565

@@ -79,10 +79,10 @@ def monitor_jobs(expts_dict: dict, monitor_file: str = '', procs: int = 1,
7979
while running_expts:
8080
i += 1
8181
if procs > 1:
82-
expts_dict = update_expt_status_parallel(expts_dict, procs)
82+
expts_dict = update_expt_status_parallel(expts_dict, procs, False, delay)
8383
else:
8484
for expt in running_expts.copy():
85-
expts_dict[expt] = update_expt_status(expts_dict[expt], expt)
85+
expts_dict[expt] = update_expt_status(expts_dict[expt], expt, False, delay)
8686

8787
for expt in running_expts.copy():
8888
running_expts[expt] = expts_dict[expt]
@@ -121,8 +121,6 @@ def monitor_jobs(expts_dict: dict, monitor_file: str = '', procs: int = 1,
121121

122122
logging.debug(f"Finished loop {i}")
123123
logging.debug(f"Walltime so far is {str(total_walltime)}")
124-
#Slow things down just a tad between loops so experiments behave better
125-
time.sleep(delay)
126124

127125
logging.info(f'All {len(expts_dict)} experiments finished')
128126
logging.info('Calculating core-hour usage and printing final summary')

tests/WE2E/utils.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ def print_WE2E_summary(expts_dict: dict, debug: bool = False):
106106
for line in expt_details:
107107
f.write(f"{line}\n")
108108

109-
def create_expts_dict(expt_dir: str):
109+
def create_expts_dict(expt_dir: str, delay: int):
110110
"""
111111
Takes in a directory, searches that directory for subdirectories containing
112112
experiments, and creates a skeleton dictionary that can be filled out by ``update_expt_status()``
113113
114114
Args:
115115
expt_dir (str): Experiment directory name
116-
116+
delay (int): [optional] Delay in seconds between calls to rocotorun.
117117
Returns:
118118
(summary_file, expts_dict): A tuple including the name of the summary file (``WE2E_tests_YYYYMMDDHHmmSS.yaml``) and the experiment dictionary
119119
"""
@@ -141,7 +141,7 @@ def create_expts_dict(expt_dir: str):
141141
continue
142142
#Update the experiment dictionary
143143
logging.debug(f"Reading status of experiment {item}")
144-
update_expt_status(expts_dict[item],item,True,False,False)
144+
update_expt_status(expts_dict[item],item,True,delay,False,False)
145145
summary_file = f'WE2E_tests_{datetime.now().strftime("%Y%m%d%H%M%S")}.yaml'
146146

147147
return summary_file, expts_dict
@@ -222,8 +222,8 @@ def write_monitor_file(monitor_file: str, expts_dict: dict):
222222
raise
223223

224224

225-
def update_expt_status(expt: dict, name: str, refresh: bool = False, debug: bool = False,
226-
submit: bool = True) -> dict:
225+
def update_expt_status(expt: dict, name: str, refresh: bool = False, delay: int = 5,
226+
debug: bool = False, submit: bool = True) -> dict:
227227
"""
228228
This function reads the dictionary for a given experiment, runs the ``rocotorun`` command to update the experiment (by running new jobs and updating the status of previously submitted ones), and reads the Rocoto database (``.db``) file to update the status of each job in the experiment dictionary. The function then uses a simple set of rules to combine the statuses of every task into a useful summary status for the whole experiment and returns the updated experiment dictionary.
229229
@@ -245,13 +245,19 @@ def update_expt_status(expt: dict, name: str, refresh: bool = False, debug: bool
245245
expt (dict): A dictionary containing the information for an individual experiment, as described in the main ``monitor_jobs()`` function.
246246
name (str): Name of the experiment; used for logging only
247247
refresh (bool): If True, this flag will check an experiment status even if it is listed as DEAD, ERROR, or COMPLETE. Used for initial checks for experiments that may have been restarted.
248+
delay (int): [optional] Delay in seconds between calls to rocotorun.
248249
debug (bool): Will capture all output from ``rocotorun``. This will allow information such as job cards and job submit messages to appear in the log files, but turning on this option can drastically slow down the testing process.
249250
submit (bool): In addition to reading the Rocoto database (``.db``) file, the script will advance the workflow by calling ``rocotorun``. If simply generating a report, set this to False.
250251
251252
Returns:
252253
expt: The updated experiment dictionary
253254
"""
254255

256+
# Derecho requires long delay between calls to rocotorun due to system-level cacheing of
257+
# job statuses
258+
if expt["user"]["MACHINE"]=="DERECHO":
259+
if delay < 60:
260+
delay=60
255261
#If we are no longer tracking this experiment, return unchanged
256262
if (expt["status"] in ['DEAD','ERROR','COMPLETE']) and not refresh:
257263
return expt
@@ -267,16 +273,20 @@ def update_expt_status(expt: dict, name: str, refresh: bool = False, debug: bool
267273
stderr=subprocess.STDOUT, text=True)
268274
logging.debug(p.stdout)
269275

270-
#Run rocotorun again to get around rocotobqserver proliferation issue
271-
time.sleep(60)
276+
# Run rocotorun again to get around rocotobqserver proliferation issue
277+
# Delay prevents problems with frequent calls to rocotorun, seen with very large
278+
# experiments and on some systems such as Derecho
279+
time.sleep(delay)
272280
p = subprocess.run(rocotorun_cmd, stdout=subprocess.PIPE,
273281
stderr=subprocess.STDOUT, text=True)
274282
logging.debug(p.stdout)
275283
else:
276284
rocotorun_cmd = ["rocotorun", f"-w {rocoto_xml}", f"-d {rocoto_db}"]
277285
subprocess.run(rocotorun_cmd)
278-
#Run rocotorun again to get around rocotobqserver proliferation issue
279-
time.sleep(60)
286+
# Run rocotorun again to get around rocotobqserver proliferation issue
287+
# Delay prevents problems with frequent calls to rocotorun, seen with very large
288+
# experiments and on some systems such as Derecho
289+
time.sleep(delay)
280290
subprocess.run(rocotorun_cmd)
281291

282292
logging.debug(f"Reading database for experiment {name}, updating experiment dictionary")
@@ -369,7 +379,7 @@ def update_expt_status(expt: dict, name: str, refresh: bool = False, debug: bool
369379
return expt
370380

371381
def update_expt_status_parallel(expts_dict: dict, procs: int, refresh: bool = False,
372-
debug: bool = False) -> dict:
382+
delay: int = 5, debug: bool = False) -> dict:
373383
"""
374384
This function updates an entire set of experiments in parallel, drastically speeding up
375385
the testing if given enough parallel processes. Given a dictionary of experiments, it will
@@ -380,6 +390,7 @@ def update_expt_status_parallel(expts_dict: dict, procs: int, refresh: bool = Fa
380390
expts_dict (dict): A dictionary containing information for all experiments
381391
procs (int): The number of parallel processes
382392
refresh (bool): "Refresh" flag to pass to ``update_expt_status()``. If True, this flag will check an experiment status even if it is listed as DEAD, ERROR, or COMPLETE. Used for initial checks for experiments that may have been restarted.
393+
delay (int): [optional] Delay in seconds between calls to rocotorun.
383394
debug (bool): Will capture all output from ``rocotorun``. This will allow information such as job cards and job submit messages to appear in the log files, but can drastically slow down the testing process.
384395
385396
Returns:
@@ -389,7 +400,7 @@ def update_expt_status_parallel(expts_dict: dict, procs: int, refresh: bool = Fa
389400
args = []
390401
# Define a tuple of arguments to pass to starmap
391402
for expt in expts_dict:
392-
args.append( (expts_dict[expt],expt,refresh,debug) )
403+
args.append( (expts_dict[expt],expt,refresh,delay,debug) )
393404

394405
# call update_expt_status() in parallel
395406
with Pool(processes=procs) as pool:

0 commit comments

Comments
 (0)