Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
pan14001 committed Mar 20, 2017
0 parents commit 620a1d7
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aliases-functions/job-aliases.csh
@@ -0,0 +1,3 @@
alias job-cpu 'sacct -o jobid,jobname,ncpus,elapsed,mincpu,cputime%12 -j'
alias job-disk 'sacct -o jobid,jobname,elapsed,maxdiskread,maxdiskwrite -j'
alias job-mem 'sacct -o jobid,jobname,maxvmsize,maxrss,averss,maxpages -j'
3 changes: 3 additions & 0 deletions aliases-functions/job-aliases.sh
@@ -0,0 +1,3 @@
alias job-cpu='sacct -o jobid,jobname,ncpus,elapsed,mincpu,cputime%12 -j'
alias job-disk='sacct -o jobid,jobname,elapsed,maxdiskread,maxdiskwrite -j'
alias job-mem='sacct -o jobid,jobname,maxvmsize,maxrss,averss,maxpages -j'
47 changes: 47 additions & 0 deletions aliases-functions/stail
@@ -0,0 +1,47 @@
#!/bin/csh

# Validate input.
if ($# < 1) then
echo "Usage: $argv[0] SLURM_SUBMISSION_FILE"
exit 1
else if (! -e $argv[1]) then
echo "Usage: $argv[0] SLURM_SUBMISSION_FILE"
exit 1
endif
# Submit job using `sbatch`.
set sbatch_out = `sbatch $argv[1]`
# Exit if submission is unsuccessful.
if (-z "$sbatch_out") then
exit 1
endif
echo $sbatch_out
# Grab job metadata.
set job_id = `echo $sbatch_out | awk '{ print $NF }'`
set out_file = `scontrol -ao show job $job_id | sed -E 's#.* StdOut=([^ ]+).*#\1#'`
# Wait for the job to start running or fail.
set message = "Waiting for job $job_id"
foreach i (`seq 1 120`)
set state = `\sacct -PXnj $job_id -o state`
if ("$state" == "PENDING") then
if ("$message" != "") then
echo "$message"
set message = ""
endif
else if ("$state" == "RUNNING") then
echo "Job $job_id is running. Showing output file $out_file (hit Ctrl + C to exit):\
"
tail -f $out_file
break
else if ("$state" == "FAILED") then
echo "Error: Job $job_id failed. Showing end of output file $out_file :\
"
tail $out_file
break
else if ("$state" == "COMPLETED") then
echo "Job $job_id completed. Showing end of output file $out_file :\
"
tail $out_file
break
endif
sleep 1
end
44 changes: 44 additions & 0 deletions aliases-functions/watch-sbatch.sh
@@ -0,0 +1,44 @@
function stail() {
# Validate input.
if ! [[ -e "$1" ]]; then
echo "Usage: ${FUNCNAME} SLURM_SUBMISSION_FILE"
return 1
fi
# Submit job using `sbatch`.
sbatch_out=$(sbatch $1)
# Exit if submission is unsuccessful.
if [[ -z "$sbatch_out" ]]; then
return 1
fi
echo $sbatch_out
# Grab job metadata.
job_id=${sbatch_out##* }
out_file=$(scontrol -ao show job $job_id | sed -E 's#.* StdOut=([^ ]+).*#\1#')
# Wait for the job to start running or fail.
message="Waiting for job $job_id"
for i in {1..120}; do
state=$(command sacct -PXnj $job_id -o state)
if [[ "$state" == "PENDING" ]]; then
if ! [[ -z "$message" ]]; then
echo "$message"
message=
fi
elif [[ "$state" == "RUNNING" ]]; then
echo "Job $job_id is running. Showing output file $out_file (hit Ctrl + C to exit):
"
tail -f $out_file
break
elif [[ "$state" == "FAILED" ]]; then
echo "Error: Job $job_id failed. Showing end of output file $out_file :
"
tail $out_file
break
elif [[ "$state" == "COMPLETED" ]]; then
echo "Job $job_id completed. Showing end of output file $out_file :
"
tail $out_file
break
fi
sleep 1
done
}
7 changes: 7 additions & 0 deletions install-apps/R-commands.R
@@ -0,0 +1,7 @@
# The usual `install.packages("rPython")` doesn't work because we also
# need to interactively at least once tell R to use the user library
# and to select a mirror.

dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
.libPaths(Sys.getenv("R_LIBS_USER"))
install.packages("rPython", repos = "http://cran.us.r-project.org")
5 changes: 5 additions & 0 deletions install-apps/R-example
@@ -0,0 +1,5 @@
source /etc/profile.d/modules.sh # Needed for bash
module purge
module load r/3.1.1
Rscript R-commands.R
# Then we will setup the paths
5 changes: 5 additions & 0 deletions install-apps/python-example
@@ -0,0 +1,5 @@
source /etc/profile.d/modules.sh # Needed for bash
module purge
module load python/2.7.6
pip install --user cutadapt
# Then we will setup the paths
7 changes: 7 additions & 0 deletions slurm-troubleshooting/bash-debug.slurm
@@ -0,0 +1,7 @@
#!/bin/bash -x
# Submit a 1 minute job.
#SBATCH --partition=phi
#SBATCH --time=1:00

scontrol show job $SLURM_JOB_ID
hostname
6 changes: 6 additions & 0 deletions slurm-troubleshooting/bash-fail.slurm
@@ -0,0 +1,6 @@
#!/bin /bash
# Submit a 1 minute job.
#SBATCH --partition=phi
#SBATCH --time=1:00

hostname
6 changes: 6 additions & 0 deletions slurm-troubleshooting/bash-pending.slurm
@@ -0,0 +1,6 @@
#!/bin/bash
# Submit a 1 hour job.
#SBATCH --partition=debug
#SBATCH --time=1:00:00

hostname
6 changes: 6 additions & 0 deletions slurm-troubleshooting/bash-success.slurm
@@ -0,0 +1,6 @@
#!/bin/bash
# Submit a 1 minute job.
#SBATCH --partition=phi
#SBATCH --time=1:00

hostname

0 comments on commit 620a1d7

Please sign in to comment.