Commit 8fcb13c8 authored by Joubert, Wayne's avatar Joubert, Wayne
Browse files

Modifications to uptime_monitor, now runs correctly on crest, titan.

parent aa9869dc
CXX = mpCC
ifeq ($(CRAYPE_VERSION),)
CXX = mpCC
else
CXX = CC
endif
CFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
LFLAGS = -g -DMPI_PROTOCOL -DMPICH_IGNORE_CXX_SEEK
......
#!/usr/bin/env python
"""
-------------------------------------------------------------------------------
File: build_executable.x
Author: Arnold Tharrington (arnoldt@ornl.gov)
Modified: Veronica G. Vergara Larrea, Wayne Joubert
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import getopt
import sys
import os
import argparse
import shutil
#import popen2
import subprocess
#
# Author: Arnold Tharrington
# Email: arnoldt@ornl.gov
# National Center for Computational Sciences, Scientific Computing Group.
#
# Modified by: Veronica G. Vergara Larrea
# National Center for Computational Sciences, User Assistance Group.
#
# This build the simple fortran program.
#
#import subprocess
#------------------------------------------------------------------------------
def process_command_line_args():
"""Get the command line arguments."""
command_description = (
'A driver program that builds the binary for the test.')
p_help = (
'The absolute path to the workspace. This path must have the '
'appropiate permissions to permit the user of the test to r, w, and x.')
i_help = (
'The test id string. The build program uses this string to make a '
'unique directory within path_to_workspace. We don\'t want concurrent '
'builds to clobber each other. The submit program uses this string '
'to write the job schedule id to Status/<test_id_string>/job_id.txt')
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main():
"""Main program for building the executable."""
#
# Get the command line arguments.
#
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
if opts == []:
usage()
sys.exit()
for o, a in opts:
if o == "-p":
path_to_workspace = a
elif o == "-i":
test_id_string = a
elif o in ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
args = process_command_line_args()
path_to_workspace = args.p
#test_id = args.i
# Create the temporary workspace.
# Save the tempoary workspace for the submit executable.
#
create_tmp_workspace(path_to_workspace)
#
#--Making the binary.
#
# Make the binary.
make_exit_status = make_binary(path_to_workspace)
if make_exit_status == 0:
make_exit_value = 0
else:
......@@ -67,67 +69,52 @@ def main():
return make_exit_value
#------------------------------------------------------------------------------
def make_binary(path_to_workspace):
"""Execute the make."""
#
# Get the current working directory.
#
cwd = os.getcwd()
#
# Get the 2 tail paths in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
(dir_head2, dir_tail2) = os.path.split(dir_head1)
#
dir_head1, dir_tail1 = os.path.split(cwd)
dir_head2, dir_tail2 = os.path.split(dir_head1)
# Get the path to the Source directory for the application.
#
path_to_source = os.path.join(dir_head2,"Source")
#
path_to_source = os.path.join(dir_head2, "Source")
# Now make the path to the build directory.
#
path_to_build_directory = os.path.join(path_to_workspace,"build_directory")
#
#Copy Source to build directory.
#
shutil.copytree(path_to_source,path_to_build_directory)
path_to_build_directory = os.path.join(path_to_workspace, "build_directory")
# Copy Source to build directory.
shutil.copytree(path_to_source, path_to_build_directory)
#
# Change back to build directory.
#
os.chdir(path_to_build_directory)
# Make executable.
make_command = "./make.sh"
make_exit_status = os.system(make_command)
return make_exit_status
def usage():
print("Usage: build_executable.x [-h|--help] -p <path_to_worspace> -i <test_id_string>")
print("A driver program that the build the binary for the test.")
print()
print("-h, --help Prints usage information.")
print("-p The absolute path to the workspace. This path ")
print(" must have the appropiate permissions to permit ")
print(" the user of the test to r,w, and x. ")
print("-i The test id string. The build program ")
print(" uses this string to make a unique directory ")
print(" within path_to_workspace. We don't want ")
print(" concurrent builds to clobber each other. ")
#------------------------------------------------------------------------------
def create_tmp_workspace(path1):
#
# Fisrt check to see if the path1 does not already exist.
#
"""Create the workspace dir."""
os.makedirs(path1)
if __name__ == "__main__" :
#------------------------------------------------------------------------------
if __name__ == '__main__':
main()
#------------------------------------------------------------------------------
#! /usr/bin/env python
"""
-------------------------------------------------------------------------------
File: check_executable.x
Author: Arnold Tharrington (arnoldt@ornl.gov)
Modified: Veronica G. Vergara Larrea, Wayne Joubert
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import sys
import os
import getopt
import filecmp
import argparse
import re
#------------------------------------------------------------------------------
def process_command_line_args():
"""Get the command line arguments."""
command_description = (
'A program that checks the results located at <path_to_results>. '
'The check executable must write the status of the results to the '
'file Status/<test_id_string>/job_status.txt')
p_help = 'The absoulte path to the results of a test.'
i_help = 'The test id string.'
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main():
#
"""Main program for check operation. Check the correctness of
the run results and report back.
"""
# Get the command line arguments.
#
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
except getopt.GetoptError:
usage()
sys.exit(2)
#
# Parse the command line arguments.
#
for o, a in opts:
if o == "-p":
path_to_results = a
elif o == "-i":
test_id_string = a
elif o == ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
#
# Get path to the correct results.
#
path_to_correct_results = get_path_to_correct_results()
#
# Compare the results.
#
jstatus = check_results(path_to_results)
#
# Write the statis of the results to job data file.
#
write_to_job_data(path_to_results,jstatus)
def get_path_to_correct_results():
cwd = os.getcwd()
args = process_command_line_args()
path_to_results = args.p
#test_id = args.i
# Compare the results.
#
# Get the head path in the cwd.
#
(dir_head1, dir_tail1) = os.path.split(cwd)
is_passing = check_results(path_to_results)
#
# This is the path to the correct results.
#
crslts = os.path.join(dir_head1,"Correct_Results")
return crslts
# Write the status of the results to job data file.
write_to_job_status_file(path_to_results, is_passing)
#------------------------------------------------------------------------------
def check_results(path_to_results):
#-----------------------------------------------------
#Define good and bad results.
# -
#-----------------------------------------------------
GOOD_RESULTS=1
BAD_RESULTS=0
#
"""
"""
# Define good and bad results.
passing_yes = 1
passing_no = 0
# Make the file name paths to numbers squared.
#
file1 = os.path.join(path_to_results,"std.out.txt")
file_obj = open(file1,"r")
alllines = file_obj.readlines()
file_obj.close()
num_failures = -1
file_path = os.path.join(path_to_results, "std.out.txt")
lastline = alllines[-1]
if not os.path.exists(file_path):
return passing_no
# Check to make sure job completed
match = re.search('FINAL',lastline)
file_ = open(file_path, "r")
lines = file_.readlines()
file_.close()
# And if it did, retrieve the number of failures
if match:
match_failures = re.search('num_failures (\d+)',lastline)
if match_failures:
num_failures = int(match_failures.group(1))
for line in lines:
match = re.search('^Success$', line)
if match:
return passing_yes
if num_failures == 0:
ival = GOOD_RESULTS
else:
ival = BAD_RESULTS
return ival
return passing_no
def write_to_job_data(path_to_results,jstatus):
#------------------------------------------------------------------------------
(dir_head1, dir_tail1) = os.path.split(path_to_results)
(dir_head2, dir_tail2) = os.path.split(dir_head1)
def write_to_job_status_file(path_to_results, is_passing):
"""Write the status of the results to job data file."""
file1 = os.path.join(dir_head2,"Status",dir_tail1,"job_status.txt")
file1_obj = open(file1,"w")
# Get path.
# Set the string to write to the job_status.txt file.
if jstatus == 0:
pf = "1"
elif jstatus == 1:
pf = "0"
elif jstatus >= 2:
pf = "2"
string1 = "%s\n" % (pf)
dir_head1, dir_tail1 = os.path.split(path_to_results)
dir_head2, dir_tail2 = os.path.split(dir_head1)
file_path = os.path.join(dir_head2, 'Status', dir_tail1, 'job_status.txt')
file1_obj.write(string1)
file1_obj.close()
file_ = open(file_path, 'w')
# Create the the string to write.
if is_passing == 0:
indicator = '1'
elif is_passing == 1:
indicator = '0'
elif is_passing >= 2:
indicator = '2'
string_ = '%s\n' % (indicator)
def usage():
print("Usage: check_executable.x [-h|--help] [-i <test_id_string>] [-p <path_to_results>]")
print("A program that checks the results located at <path_to_results>")
print("The check executable must write the status of the results to the file")
print("Status/<test_id_string>/job_status.txt'.")
print("")
print("-h, --help Prints usage information.")
print("-p <path_to_results> The absoulte path to the results of a test.")
print("-i <test_id_string> The test string unique id.")
# Write the string.
file_.write(string_)
file_.close()
#------------------------------------------------------------------------------
if __name__ == "__main__":
if __name__ == '__main__':
main()
#------------------------------------------------------------------------------
#! /bin/bash -l
#------------------------------------------------------------------------------
#BSUB -q __batchqueue__
#BSUB -J __jobname__
#BSUB -o __jobname__.o%J
......@@ -84,13 +85,15 @@ cd $STARTINGDIRECTORY
# Copy the results back to the $RESULTSDIR -
# -
#-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR
cp -rf $WORKDIR"/"* $RESULTSDIR ### && rm -rf $WORKDIR
#-----------------------------------------------------
# Move the batch file name to $RESULTSDIR -
# -
#-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR
if [ -e __batchfilename__ ] ; then
mv __batchfilename__ $RESULTSDIR
fi
#-----------------------------------------------------
# Check the final results. -
......@@ -111,3 +114,4 @@ case __resubmitme__ in
echo "No resubmit";;
esac
#------------------------------------------------------------------------------
#! /bin/bash -l
#------------------------------------------------------------------------------
#PBS -e __resultsdir__
#PBS -o __resultsdir__
......@@ -27,7 +28,7 @@ RESULTSDIR="__resultsdir__"
UNIQUE_ID_STRING="__unique_id_string__"
#-----------------------------------------------------
# Enusre that we are in the correct starting -
# Ensure that we are in the correct starting -
# directory. -
# -
#-----------------------------------------------------
......@@ -78,13 +79,15 @@ cd $STARTINGDIRECTORY
# Copy the results back to the $RESULTSDIR -
# -
#-----------------------------------------------------
cp -rf $WORKDIR/* $RESULTSDIR # && rm -rf $WORKDIR
cp -rf $WORKDIR"/"* $RESULTSDIR ### && rm -rf $WORKDIR
#-----------------------------------------------------
# Move the batch file name to $RESULTSDIR -
# -
#-----------------------------------------------------
mv __batchfilename__ $RESULTSDIR
if [ -e __batchfilename__ ] ; then
mv __batchfilename__ $RESULTSDIR
fi
#-----------------------------------------------------
# Check the final results. -
......@@ -104,3 +107,5 @@ case __resubmitme__ in
1)
echo "No resubmit";;
esac
#------------------------------------------------------------------------------
#!/usr/bin/env python
#==============================================================================
"""
-------------------------------------------------------------------------------
File: report_executable.x
Author: Wayne Joubert (joubert@ornl.gov)
Modified: Wayne Joubert
National Center for Computational Sciences, Scientific Computing Group.
Oak Ridge National Laboratory
Copyright (C) 2016 Oak Ridge National Laboratory, UT-Battelle, LLC.
-------------------------------------------------------------------------------
"""
import sys
import os
import getopt
import argparse
import re
import datetime
from subprocess import Popen, PIPE
# NOTE: use here of harness code, somewhat against original intent for this
# to be a standalone script.
from libraries.status_file import StatusFile
#==============================================================================
#------------------------------------------------------------------------------
def main():
def process_command_line_args():
"""Get the command line arguments."""
command_description = (
'Script used by app to report arbitrary user-defined results '
'from a run back to the harness.')
p_help = (
'The absolute path to the results. This path must have the '
'appropiate permissions to permit the user of the test to r, w, and x.')
#---Get command line arguments.
i_help = ('The test id string.')
try:
opts,args = getopt.getopt(sys.argv[1:],"hi:p:")
parser = argparse.ArgumentParser(description=command_description)
parser.add_argument('-p', help=p_help, required=True)
parser.add_argument('-i', help=i_help, required=True)
except getopt.GetoptError:
usage()
sys.exit(2)
args = parser.parse_args()
return args
#------------------------------------------------------------------------------
def main():
"""Main program for report operation. Extracts information from
the run and stores in files and sends to the logger.
"""
#---Parse command line arguments.
# Get the command line arguments.
for o, a in opts:
if o == "-p":
path_to_results = a
elif o == "-i":
test_id = a
elif o == ("-h", "--help"):
usage()
sys.exit()
else:
usage()
sys.exit()
args = process_command_line_args()
path_to_results = args.p
test_id = args.i
#
# Extract info from scheduler.
status_file = StatusFile(test_id, StatusFile.MODE_OLD)
scheduler = 'lsf' if 'LSF_BINDIR' in os.environ else 'pbs'