-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
363 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
# Run this script between each repeated local run of the Balsam | ||
# job_control_hworld_balsam test in the base libensemble directory. | ||
# Besides ensuring that postgres and the generated Balsam db have the proper | ||
# permissions, this script flushes previous apps and jobs in the db before | ||
# submitting the test_balsam app/job script. | ||
# | ||
# Most of this comes from scaling_tests/forces/balsam_local.sh | ||
|
||
# Can't run this line in calling Python file. Balsam installation hasn't been | ||
# noticed by the Python runtime yet. | ||
python -c 'from libensemble.tests.regression_tests.common import modify_Balsam_pyCoverage; modify_Balsam_pyCoverage()' | ||
export EXE=$PWD/libensemble/tests/regression_tests/script_test_balsam.py | ||
export NUM_WORKERS=2 | ||
export WORKFLOW_NAME=libe_test-balsam | ||
export LIBE_WALLCLOCK=3 | ||
export THIS_DIR=$PWD | ||
export SCRIPT_BASENAME=script_test_balsam | ||
|
||
# Set proper permissions, initialize Balsam DB, activate DB | ||
export BALSAM_DB_PATH='~/test-balsam' | ||
sudo chown -R postgres:postgres /var/run/postgresql | ||
sudo chmod a+w /var/run/postgresql | ||
balsam init ~/test-balsam | ||
sudo chmod -R 700 ~/test-balsam/balsamdb | ||
source balsamactivate test-balsam | ||
|
||
# Refresh DB | ||
balsam rm apps --all --force | ||
balsam rm jobs --all --force | ||
|
||
# Submit script_test_balsam as app | ||
balsam app --name $SCRIPT_BASENAME.app --exec $EXE --desc "Run $SCRIPT_BASENAME" | ||
|
||
# Submit job based on script_test_balsam app | ||
balsam job --name job_$SCRIPT_BASENAME --workflow $WORKFLOW_NAME --application $SCRIPT_BASENAME.app --wall-time-minutes $LIBE_WALLCLOCK --num-nodes 1 --ranks-per-node $((NUM_WORKERS+1)) --url-out="local:/$THIS_DIR" --stage-out-files="*.out *.txt *.log" --url-in="local:/$THIS_DIR/*" --yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /usr/bin/env python | ||
|
||
# Installing Balsam consists of both cloning and pip installing the latest version | ||
# of Balsam from source but also moving the Balsam-relevant test to the regression_tests | ||
# directory. This way, run-tests won't run a non-relevant test if Balsam isn't | ||
# installed or the necessary Python version isn't installed. | ||
|
||
import sys | ||
import os | ||
import subprocess | ||
|
||
|
||
balsamclone = 'git clone https://github.com/balsam-alcf/balsam.git ../balsam' | ||
|
||
if int(sys.version[2]) >= 6: # Balsam only supports Python 3.6+ | ||
subprocess.check_call(balsamclone.split()) | ||
os.chdir('../balsam') | ||
subprocess.check_call('pip install -e .'.split()) | ||
os.chdir('../libensemble') | ||
if not os.path.isfile('./libensemble/tests/regression_tests/test_balsam.py'): | ||
os.rename('./conda/test_balsam.py', | ||
'./libensemble/tests/regression_tests/test_balsam.py') | ||
subprocess.run('./conda/configure-balsam-test.sh'.split()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import subprocess | ||
import os | ||
import time | ||
import sys | ||
import libensemble | ||
from libensemble.tests.regression_tests.common import parse_args, modify_Balsam_worker | ||
|
||
# TESTSUITE_COMMS: local | ||
# TESTSUITE_NPROCS: 3 | ||
|
||
# This test is NOT submitted as a job to Balsam. That would be script_test_balsam.py | ||
# This test executes that job through the 'runstr' line defined further down. | ||
|
||
nworkers, is_master, libE_specs, _ = parse_args() # None used. Bug-prevention | ||
|
||
# Set libensemble base directory to environment variable for Balsam coverage | ||
# orientation purposes. Otherwise coverage in the Balsam data directory is | ||
# (unsuccessfully) collected. | ||
libepath = os.path.dirname(libensemble.__file__) | ||
os.environ['LIBE_PATH'] = libepath | ||
|
||
# Balsam is meant for HPC systems that commonly distribute jobs across many | ||
# nodes. For our purposes, we append (hack) ten workers to Balsam's WorkerGroup | ||
print("Currently in {}. Beginning Balsam worker modification".format(os.getcwd())) | ||
modify_Balsam_worker() | ||
|
||
# By this point, script_test_balsam.py has been submitted as an app and job to Balsam | ||
# This line launches the queued job in the Balsam database | ||
runstr = 'balsam launcher --consume-all --job-mode=mpi --num-transition-threads=1' | ||
print('Executing Balsam job with command: {}'.format(runstr)) | ||
subprocess.Popen(runstr.split()) | ||
|
||
# Location of Balsam DB location defined in configure-balsam-test.sh | ||
basedb = os.path.expanduser('~/test-balsam/data/libe_test-balsam') | ||
|
||
# Periodically wait for Workflow and Job directory within Balsam DB | ||
sleeptime = 0 | ||
print('{}: Waiting for Workflow directory'.format(sleeptime)) | ||
while not os.path.isdir(basedb) and sleeptime < 58: | ||
sleeptime += 1 | ||
print('{}'.format(sleeptime), end=" ") | ||
sys.stdout.flush() | ||
time.sleep(1) | ||
|
||
print('{}: Waiting for Job Directory'.format(sleeptime)) | ||
while len(os.listdir(basedb)) == 0 and sleeptime < 58: | ||
sleeptime += 1 | ||
print('{}'.format(sleeptime), end=" ") | ||
sys.stdout.flush() | ||
time.sleep(1) | ||
|
||
# Job directory now exists | ||
jobdirname = os.listdir(basedb)[0] | ||
jobdir = os.path.join(basedb, jobdirname) | ||
outscript = os.path.join(jobdir, 'job_script_test_balsam.out') | ||
|
||
# Periodically wait for Balsam Job output | ||
print('{}: Checking for Balsam output file: {}'.format(sleeptime, outscript)) | ||
while not os.path.isfile(outscript) and sleeptime < 58: | ||
sleeptime += 2 | ||
print('{}'.format(sleeptime), end=" ") | ||
sys.stdout.flush() | ||
time.sleep(2) | ||
|
||
# Print sections of Balsam output to screen every second until complete | ||
print('{}: Output file exists. Waiting for Balsam Job Output.'.format(sleeptime)) | ||
lastposition = 0 | ||
lastlines = ['Job 4 done on worker 1\n', 'Job 4 done on worker 2\n'] | ||
while sleeptime < 58: | ||
with open(outscript, 'r') as f: | ||
f.seek(lastposition) # (should) prevent outputting already printed sections | ||
new = f.read() | ||
lastposition = f.tell() | ||
if len(new) > 0: | ||
print(new) | ||
sys.stdout.flush() | ||
if any(new.endswith(line) for line in lastlines): | ||
break | ||
print('{}'.format(sleeptime), end=" ") | ||
time.sleep(1) | ||
sleeptime += 1 | ||
|
||
print('{}: Importing any coverage from Balsam.'.format(sleeptime)) | ||
here = os.getcwd() | ||
|
||
# Move coverage files from Balsam DB to ./regression_tests (for concatenation) | ||
covname = '.cov_reg_out.' | ||
for file in os.listdir(jobdir): | ||
if file.startswith(covname): | ||
balsam_cov = os.path.join(jobdir, file) | ||
here_cov = os.path.join(here, file) | ||
print('Moved {} from {} to {}'.format(file, jobdir, here)) | ||
os.rename(balsam_cov, here_cov) | ||
|
||
print('Test complete.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[run] | ||
source = $LIBE_PATH | ||
|
||
omit = | ||
*/tests/* | ||
*/unit_tests/* | ||
*/unit_tests_nompi/* | ||
*/regression_tests/* | ||
*/branin_*/* | ||
|
||
branch = true | ||
|
||
data_file = .cov_reg_out | ||
|
||
parallel = true | ||
|
||
[report] | ||
omit = | ||
*/__init__.py/* | ||
*/setup.py/* | ||
*/tests/* | ||
*/unit_tests/* | ||
*/unit_tests_nompi/* | ||
*/regression_tests/* | ||
|
||
exclude_lines = | ||
if __name__ == .__main__.: | ||
|
||
[html] | ||
directory = cov_reg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.