Skip to content

Commit

Permalink
Merge pull request #110 from HECBioSim/issue108
Browse files Browse the repository at this point in the history
Rest of the output directives added
  • Loading branch information
jimboid committed Aug 6, 2018
2 parents 70d1290 + dd7d29e commit 4e71d05
Show file tree
Hide file tree
Showing 24 changed files with 417 additions and 13 deletions.
12 changes: 6 additions & 6 deletions longbow/schedulers/lsf.py
Expand Up @@ -129,22 +129,22 @@ def prepare(job):
jobfile.write("#BSUB -n " + job["cores"] + "\n")

# Redirect stdout
if job["stdout"] == "":
if job["stdout"] != "":

jobfile.write("#BSUB -o %J.out")
jobfile.write("#BSUB -o " + job["stdout"] + "\n")

else:

jobfile.write("#BSUB -o " + job["stdout"])
jobfile.write("#BSUB -o %J.out" + "\n")

# Redirect stderr
if job["stderr"] == "":
if job["stderr"] != "":

jobfile.write("#BSUB -e %J.err")
jobfile.write("#BSUB -e " + job["stderr"] + "\n")

else:

jobfile.write("#BSUB -e " + job["stderr"])
jobfile.write("#BSUB -e %J.err" + "\n")

# Load any custom scripts.
if job["scripts"] != "":
Expand Down
10 changes: 10 additions & 0 deletions longbow/schedulers/pbs.py
Expand Up @@ -160,6 +160,16 @@ def prepare(job):
jobfile.write("#PBS -J 1-" + job["replicates"] + "\n")
jobfile.write("#PBS -r y\n")

# Redirect stdout
if job["stdout"] != "":

jobfile.write("#PBS -o " + job["stdout"] + "\n")

# Redirect stderr
if job["stderr"] != "":

jobfile.write("#PBS -e " + job["stderr"] + "\n")

# Set some environment variables for PBS.
jobfile.write(
"\n" + "export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)\n"
Expand Down
10 changes: 10 additions & 0 deletions longbow/schedulers/sge.py
Expand Up @@ -126,6 +126,16 @@ def prepare(job):
jobfile.write("#$ -pe " + job["sge-peflag"] + " " +
job["cores"] + "\n\n")

# Redirect stdout
if job["stdout"] != "":

jobfile.write("#$ -o " + job["stdout"] + "\n")

# Redirect stderr
if job["stderr"] != "":

jobfile.write("#$ -e " + job["stderr"] + "\n\n")

# Load any custom scripts.
if job["scripts"] != "":

Expand Down
10 changes: 10 additions & 0 deletions longbow/schedulers/slurm.py
Expand Up @@ -137,6 +137,16 @@ def prepare(job):
# Walltime for job
jobfile.write("#SBATCH -t " + job["maxtime"] + ":00\n\n")

# Redirect stdout
if job["stdout"] != "":

jobfile.write("#SBATCH -o " + job["stdout"] + "\n")

# Redirect stderr
if job["stderr"] != "":

jobfile.write("#SBATCH -e " + job["stderr"] + "\n\n")

# Load any custom scripts.
if job["scripts"] != "":

Expand Down
10 changes: 10 additions & 0 deletions longbow/schedulers/soge.py
Expand Up @@ -150,6 +150,16 @@ def prepare(job):

jobfile.write("#$ -pe ib " + cores + "\n\n")

# Redirect stdout
if job["stdout"] != "":

jobfile.write("#$ -o " + job["stdout"] + "\n")

# Redirect stderr
if job["stderr"] != "":

jobfile.write("#$ -e " + job["stderr"] + "\n\n")

# Load any custom scripts.
if job["scripts"] != "":

Expand Down
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case1.txt
Expand Up @@ -3,7 +3,9 @@
#BSUB -q debug
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
11 changes: 11 additions & 0 deletions tests/standards/lsf_submitfiles/case10.txt
@@ -0,0 +1,11 @@
#!/bin/bash --login
#BSUB -J testjob
#BSUB -q debug
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o test.log
#BSUB -e test.err

module load amber

mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case2.txt
Expand Up @@ -3,8 +3,10 @@
#BSUB -q debug
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

cd rep${LSB_JOBINDEX}/
mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case3.txt
Expand Up @@ -4,7 +4,9 @@
#BSUB -m cluster1
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case4.txt
Expand Up @@ -4,7 +4,9 @@
#BSUB -P accno1234
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case5.txt
Expand Up @@ -4,7 +4,9 @@
#BSUB -F accno1234
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case6.txt
Expand Up @@ -5,7 +5,9 @@
#BSUB -u test.email@server.com
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
4 changes: 3 additions & 1 deletion tests/standards/lsf_submitfiles/case7.txt
Expand Up @@ -3,10 +3,12 @@
#BSUB -q debug
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

ls /dir
cd /dir

module load amber

mpirun -lsf pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
2 changes: 2 additions & 0 deletions tests/standards/lsf_submitfiles/case8.txt
Expand Up @@ -3,6 +3,8 @@
#BSUB -q debug
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

Expand Down
2 changes: 2 additions & 0 deletions tests/standards/lsf_submitfiles/case9.txt
Expand Up @@ -4,6 +4,8 @@
#BSUB -R "rusage[mem=10G]"
#BSUB -W 24:00
#BSUB -n 24
#BSUB -o %J.out
#BSUB -e %J.err

module load amber

Expand Down
15 changes: 15 additions & 0 deletions tests/standards/pbs_submitfiles/case10.txt
@@ -0,0 +1,15 @@
#!/bin/bash --login
#PBS -N testjob
#PBS -q debug
#PBS -l select=1:ncpus=24:mpiprocs=24
#PBS -l walltime=24:00:00
#PBS -o test.log
#PBS -e test.err

export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
cd $PBS_O_WORKDIR
export OMP_NUM_THREADS=1

module load amber

mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
13 changes: 13 additions & 0 deletions tests/standards/sge_submitfiles/case9.txt
@@ -0,0 +1,13 @@
#!/bin/bash --login
#$ -cwd -V
#$ -N testjob
#$ -q debug
#$ -l h_rt=24:00:00
#$ -pe mpi 24

#$ -o test.log
#$ -e test.err

module load amber

mpirun -n 24 pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
13 changes: 13 additions & 0 deletions tests/standards/slurm_submitfiles/case9.txt
@@ -0,0 +1,13 @@
#!/bin/bash --login
#SBATCH -J testjob
#SBATCH -p debug
#SBATCH -n 24
#SBATCH -N 1
#SBATCH -t 24:00:00

#SBATCH -o test.log
#SBATCH -e test.err

module load amber

mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
14 changes: 14 additions & 0 deletions tests/standards/soge_submitfiles/case9.txt
@@ -0,0 +1,14 @@
#!/bin/bash --login
#$ -cwd -V
#$ -N testjob
#$ -q debug
#$ -l h_rt=24:00:00
#$ -l nodes=1
#$ -pe ib 24

#$ -o test.log
#$ -e test.err

module load amber

mpirun pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out
55 changes: 55 additions & 0 deletions tests/unit/schedulers_lsf/test_lsf_prepare.py
Expand Up @@ -59,6 +59,8 @@ def test_prepare_case1():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -94,6 +96,8 @@ def test_prepare_case2():
"modules": "amber",
"queue": "debug",
"replicates": "5",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -127,6 +131,8 @@ def test_prepare_case3():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -161,6 +167,8 @@ def test_prepare_case4():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -195,6 +203,8 @@ def test_prepare_case5():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -229,6 +239,8 @@ def test_prepare_case6():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -263,6 +275,8 @@ def test_prepare_case7():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "ls /dir, cd /dir",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -297,6 +311,8 @@ def test_prepare_case8():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand Down Expand Up @@ -331,6 +347,8 @@ def test_prepare_case9():
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "",
"stderr": "",
"scripts": "",
"upload-include": "file1, file2"
}
Expand All @@ -341,3 +359,40 @@ def test_prepare_case9():
os.path.join(
os.getcwd(),
"tests/standards/lsf_submitfiles/case9.txt"), "rb").read()


def test_prepare_case10():

"""
Stdout and stderr check
"""

job = {
"account": "",
"cores": "24",
"executableargs": "pmemd.MPI -O -i e.in -c e.min -p e.top -o e.out",
"handler": "mpirun",
"email-address": "",
"email-flags": "",
"jobname": "testjob",
"localworkdir": "/tmp",
"lsf-cluster": "",
"maxtime": "24:00",
"memory": "",
"modules": "amber",
"queue": "debug",
"replicates": "1",
"stdout": "test.log",
"stderr": "test.err",
"scripts": "",
"upload-include": "file1, file2"
}

prepare(job)

assert job["subfile"] == "submit.lsf"
assert job["upload-include"] == "file1, file2, submit.lsf"
assert open("/tmp/submit.lsf", "rb").read() == open(
os.path.join(
os.getcwd(),
"tests/standards/lsf_submitfiles/case10.txt"), "rb").read()

0 comments on commit 4e71d05

Please sign in to comment.