-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from brianhlin/sw2256_slurm
Copy blahp SLURM scripts from Condor (SOFTWARE-2256)
- Loading branch information
Showing
8 changed files
with
381 additions
and
1 deletion.
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
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,60 @@ | ||
#!/bin/bash | ||
|
||
# File: slurm_cancel.sh | ||
# Author: Jaime Frey ([email protected]) | ||
# Based on code by David Rebatto ([email protected]) | ||
# | ||
# Copyright (c) Members of the EGEE Collaboration. 2004. | ||
# Copyright (c) HTCondor Team, Computer Sciences Department, | ||
# University of Wisconsin-Madison, WI. 2015. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
|
||
. `dirname $0`/blah_load_config.sh | ||
|
||
if [ -z "$slurm_binpath" ] ; then | ||
slurm_binpath=/usr/bin | ||
fi | ||
|
||
jnr=0 | ||
jc=0 | ||
for job in $@ ; do | ||
jnr=$(($jnr+1)) | ||
done | ||
for job in $@ ; do | ||
requested=`echo $job | sed 's/^.*\///'` | ||
cmdout=`${slurm_binpath}/scancel $requested 2>&1` | ||
retcode=$? | ||
# If the job is already completed or no longer in the queue, | ||
# treat it as successfully deleted. | ||
if echo "$cmdout" | grep -q 'Invalid job id specified' ; then | ||
retcode=0 | ||
if [ "$retcode" == "0" ] ; then | ||
if [ "$jnr" == "1" ]; then | ||
echo " 0 No\\ error" | ||
else | ||
echo .$jc" 0 No\\ error" | ||
fi | ||
else | ||
escaped_cmdout=`echo $cmdout|sed "s/ /\\\\\ /g"` | ||
if [ "$jnr" == "1" ]; then | ||
echo " $retcode $escaped_cmdout" | ||
else | ||
echo .$jc" $retcode $escaped_cmdout" | ||
fi | ||
fi | ||
jc=$(($jc+1)) | ||
done | ||
|
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,46 @@ | ||
#!/bin/bash | ||
|
||
# File: slurm_hold.sh | ||
# Author: Jaime Frey ([email protected]) | ||
# Based on code by David Rebatto ([email protected]) | ||
# | ||
# Copyright (c) Members of the EGEE Collaboration. 2004. | ||
# Copyright (c) HTCondor Team, Computer Sciences Department, | ||
# University of Wisconsin-Madison, WI. 2015. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
|
||
. `dirname $0`/blah_load_config.sh | ||
|
||
if [ -z "$slurm_binpath" ] ; then | ||
slurm_binpath=/usr/bin | ||
fi | ||
|
||
requested=`echo $1 | sed 's/^.*\///'` | ||
|
||
cmdout=`${slurm_binpath}/scontrol hold $requested 2>&1` | ||
retcode=$? | ||
if echo "$cmdout" | grep -q 'Job is no longer pending execution' ; then | ||
cmdout=`${slurm_binpath}/scontrol requeuehold $requested 2>&1` | ||
retcode=$? | ||
fi | ||
|
||
if [ "$retcode" == "0" ] ; then | ||
echo " 0 No\\ error" | ||
exit 0 | ||
else | ||
echo " 1 Error" | ||
exit 1 | ||
fi |
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,40 @@ | ||
#!/bin/bash | ||
|
||
# File: slurm_resume.sh | ||
# Author: Jaime Frey ([email protected]) | ||
# Based on code by David Rebatto ([email protected]) | ||
# | ||
# Copyright (c) Members of the EGEE Collaboration. 2004. | ||
# Copyright (c) HTCondor Team, Computer Sciences Department, | ||
# University of Wisconsin-Madison, WI. 2015. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
. `dirname $0`/blah_load_config.sh | ||
|
||
if [ -z "$slurm_binpath" ] ; then | ||
slurm_binpath=/usr/bin | ||
fi | ||
|
||
requested=`echo $1 | sed 's/^.*\///'` | ||
${slurm_binpath}/scontrol release $requested >&/dev/null | ||
|
||
if [ "$?" == "0" ]; then | ||
echo " 0 No\\ error" | ||
exit 0 | ||
else | ||
echo " 1 Error" | ||
exit 1 | ||
fi | ||
|
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,120 @@ | ||
#!/bin/bash | ||
|
||
# File: slurm_status.sh | ||
# Author: Jaime Frey ([email protected]) | ||
# Based on code by David Rebatto ([email protected]) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
. `dirname $0`/blah_load_config.sh | ||
|
||
if [ -z "$slurm_binpath" ] ; then | ||
slurm_binpath=/usr/bin | ||
fi | ||
|
||
usage_string="Usage: $0 [-w] [-n]" | ||
|
||
#echo $0 "$@" >>~/slurm.debug | ||
|
||
############################################################### | ||
# Parse parameters | ||
############################################################### | ||
|
||
while getopts "wn" arg | ||
do | ||
case "$arg" in | ||
w) getwn="yes" ;; | ||
n) ;; | ||
|
||
-) break ;; | ||
?) echo $usage_string | ||
exit 1 ;; | ||
esac | ||
done | ||
|
||
shift `expr $OPTIND - 1` | ||
|
||
pars=$* | ||
proxy_dir=~/.blah_jobproxy_dir | ||
|
||
for reqfull in $pars ; do | ||
reqjob=`echo $reqfull | sed -e 's/^.*\///'` | ||
|
||
staterr=/tmp/${reqjob}_staterr | ||
|
||
#echo "running: ${slurm_binpath}/scontrol show job $reqjob" >>~/slurm.debug | ||
result=`${slurm_binpath}/scontrol show job $reqjob 2>$staterr` | ||
stat_exit_code=$? | ||
#echo "stat_exit_code=$stat_exit_code" >>~/slurm.debug | ||
result=`echo "$result" | awk -v job_id=$reqjob -v proxy_dir=$proxy_dir ' | ||
BEGIN { | ||
blah_status = 4 | ||
slurm_status = "" | ||
exit_code = "0" | ||
} | ||
/JobState=/ { | ||
slurm_status = substr( $1, index( $1, "=" ) + 1 ) | ||
} | ||
/ExitCode=/ { | ||
if ( split( $4, tmp, "[=:]" ) == 3 ) { | ||
exit_code = tmp[2] | ||
} | ||
} | ||
END { | ||
if ( slurm_status ~ "BOOT_FAIL" ) { blah_status = 4 } | ||
if ( slurm_status ~ "CANCELLED" ) { blah_status = 3 } | ||
if ( slurm_status ~ "COMPLETED" ) { blah_status = 4 } | ||
if ( slurm_status ~ "CONFIGURING" ) { blah_status = 1 } | ||
if ( slurm_status ~ "COMPLETING" ) { blah_status = 2 } | ||
if ( slurm_status ~ "FAILED" ) { blah_status = 4 } | ||
if ( slurm_status ~ "NODE_FAIL" ) { blah_status = 4 } | ||
if ( slurm_status ~ "PENDING" ) { blah_status = 1 } | ||
if ( slurm_status ~ "PREEMPTED" ) { blah_status = 4 } | ||
if ( slurm_status ~ "RUNNING" ) { blah_status = 2 } | ||
if ( slurm_status ~ "SPECIAL_EXIT" ) { blah_status = 4 } | ||
if ( slurm_status ~ "STOPPED" ) { blah_status = 2 } | ||
if ( slurm_status ~ "SUSPENDED" ) { blah_status = 2 } | ||
print "[BatchJobId=\"" job_id "\";JobStatus=" blah_status ";" | ||
if ( blah_status == 4 ) { | ||
print "ExitCode=" exit_code ";" | ||
} | ||
print "]\n" | ||
if ( blah_status == 3 || blah_status == 4 ) { | ||
#system( "rm " proxy_dir "/" job_id ".proxy 2>/dev/null" ) | ||
} | ||
} | ||
' | ||
` | ||
#echo result=$result >>~/slurm.debug | ||
errout=`cat $staterr` | ||
rm -f $staterr 2>/dev/null | ||
|
||
if echo "$errout" | grep -q "Invalid job id specified" ; then | ||
stat_exit_code=0 | ||
fi | ||
if [ $stat_exit_code -eq 0 ] ; then | ||
echo 0${result} | ||
#echo 0${result} >>~/slurm.debug | ||
else | ||
echo 1Error: ${errout} | ||
#echo 1Error: ${errout} >>~/slurm.debug | ||
fi | ||
|
||
done | ||
|
||
exit 0 |
Oops, something went wrong.