Commit 3b7e0f97 authored by Melesse Vergara, Veronica's avatar Melesse Vergara, Veronica
Browse files

modified test to use the machine factory

parent b308b12e
......@@ -8,10 +8,12 @@ import re
import time
import subprocess
import shlex
from machine_types.factories.machine_factory import MachineFactory
#
# Author: Arnold Tharrington
# Email: arnoldt@ornl.gov
# National Center of Computational Science, Scientifc Computing Group.
# National Center for Computational Sciences, Scientific Computing Group.
#
......@@ -55,36 +57,37 @@ def main():
#
# Make the batch script.
#
scheduler = "lsf"
batchfilename = make_batch_script(batch_recursive_mode,path_to_workspace,test_id_string,scheduler)
mymachine = MachineFactory.create_machine()
#
# Submit the batch file to the scheduler.
#
sched_job_id = send_to_scheduler(batchfilename,scheduler)
print ("Job id =" + str(sched_job_id))
batchfilename = make_batch_script(batch_recursive_mode,path_to_workspace,test_id_string,mymachine)
#==##
#==## Submit the batch file to the scheduler.
#==##
#==#sched_job_id = send_to_scheduler(batchfilename,scheduler)
#==#print("Job id =" + str(sched_job_id))
#
#Write pbs job id to job_id.txt in the Status dir.
#
write_job_id_to_status(sched_job_id,test_id_string)
#==##
#==##Write pbs job id to job_id.txt in the Status dir.
#==##
#==#write_job_id_to_status(sched_job_id,test_id_string)
def make_batch_script(batch_recursive_mode,path_to_workspace,test_id_string,scheduler):
def make_batch_script(batch_recursive_mode,path_to_workspace,test_id_string,mymachine):
#
# Define the batch file names.
#
if scheduler == "pbs":
print "Using PBS scheduler syntax"
if mymachine.get_scheduler_type() == "PBS":
print("Using PBS scheduler syntax")
batchtemplatefilename = "pbs.template.x"
sched_id = 0
elif scheduler == "lsf":
print "Using LSF scheduler syntax"
elif mymachine.get_scheduler_type() == "lsf":
print("Using LSF scheduler syntax")
batchtemplatefilename = "lsf.template.x"
sched_id = 1
else:
print "Scheduler " + scheduler + " is not supported"
print("Scheduler " + mymachine.get_scheduler_type() + " is not supported")
sched_id = -1
batchfilename = "run_helloWorld.sh"
......@@ -113,7 +116,7 @@ def make_batch_script(batch_recursive_mode,path_to_workspace,test_id_string,sche
walltime = "300"
joblaunchcommand = "poe $EXECUTABLE 1> std.out.txt 2> std.err.txt"
else:
print "Executing on current node"
print("Executing on current node")
joblaunchcommand = "$EXECUTABLE 1> std.out.txt 2> std.err.txt"
rg_array = [
......@@ -209,13 +212,13 @@ def send_to_scheduler(batchfilename,scheduler):
my_stderr = open(t2,"w")
if scheduler == "pbs":
print "Using PBS scheduler syntax to submit job"
print("Using PBS scheduler syntax to submit job")
sched_id = 0
elif scheduler == "lsf":
print "Using LSF scheduler syntax to submit job"
print("Using LSF scheduler syntax to submit job")
sched_id = 1
else:
print "Scheduler " + scheduler + " is not supported"
print("Scheduler " + scheduler + " is not supported")
sched_id = -1
......@@ -227,12 +230,12 @@ def send_to_scheduler(batchfilename,scheduler):
submit_command = "bsub "
qcommand = submit_command
else:
print "Unsupported scheduler (sched_id = " + str(sched_id) + ")"
print("Unsupported scheduler (sched_id = " + str(sched_id) + ")")
# Split the arguments for the command
args = shlex.split(qcommand)
print "args = "
print args
print("args = ")
print(args)
# Execute the command as a subprocess
if sched_id == 0:
......@@ -242,7 +245,7 @@ def send_to_scheduler(batchfilename,scheduler):
p = subprocess.Popen(args,stdout=my_stdout,stderr=my_stderr,stdin=my_jobfile)
my_jobfile.close()
else:
print "Unsupported scheduler (sched_id = " + str(sched_id) + ")"
print("Unsupported scheduler (sched_id = " + str(sched_id) + ")")
p.wait()
......@@ -251,8 +254,8 @@ def send_to_scheduler(batchfilename,scheduler):
my_stdout = open(t1,"r")
records = my_stdout.readlines()
print "records = "
print records
print("records = ")
print(records)
jobid = extract_jobid(records,sched_id)
my_stdout.close()
......@@ -261,18 +264,18 @@ def send_to_scheduler(batchfilename,scheduler):
def extract_jobid(records,sched_id):
if sched_id == 0:
print "Extracting PBS jobID"
print("Extracting PBS jobID")
jobid = records[0].strip()
elif sched_id == 1:
print "Extracting LSF jobID"
print("Extracting LSF jobID")
m = re.compile('\d+')
print "m = "
print m
print "m.findall = "
print("m = ")
print(m)
print("m.findall = ")
jobid = m.findall(records[0])[0]
print jobid
print(jobid)
else:
print "Non-supported scheduler requested"
print("Non-supported scheduler requested")
return jobid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment