Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86868172
sgeCoat.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Oct 9, 02:32
Size
2 KB
Mime Type
text/x-python
Expires
Fri, Oct 11, 02:32 (2 d)
Engine
blob
Format
Raw Data
Handle
21495921
Attached To
R3127 blackdynamite
sgeCoat.py
View Options
#!/usr/bin/env python
from
BlackDynamite
import
*
import
os
,
stat
import
subprocess
import
re
import
socket
import
shlex
admissible_params
=
{
"walltime"
:
str
,
"email"
:
str
,
"nproc"
:
int
,
"sge_option"
:[
str
],
"module"
:[
str
]}
#default_params = {"walltime":"00:05:00"}
help
=
{
"walltime"
:
"Specify the wall time for the runs"
,
"email"
:
"Specify the email to notify"
,
"nproc"
:
"Force the number of processors and update the run"
,
"sge_option"
:
"Allow to provide additional SGE options"
,
"module"
:
"List of module to load"
}
def
launch
(
run
,
params
):
_exec
=
run
.
getExecFile
()
if
(
"walltime"
not
in
params
):
raise
Exception
(
"walltime not set for this job {0}"
.
format
(
run
.
id
))
head
=
\
"""#!/bin/bash
#$ -S /bin/sh
#$ -cwd
#$ -j y
#$ -notify
#$ -l walltime={0}
"""
.
format
(
params
[
"walltime"
])
if
(
"email"
in
params
):
head
+=
"#$ -m eas -M {0}
\n
"
.
format
(
params
[
"email"
])
sge_head_name
=
"#$ -N "
+
"run"
+
str
(
run
.
id
)
+
"-"
+
run
[
"run_name"
]
+
"
\n
"
sge_head_name
=
sge_head_name
.
replace
(
":"
,
"_"
)
head
+=
sge_head_name
run
[
"state"
]
=
"SGE submit"
if
(
"nproc"
in
params
):
run
[
"nproc"
]
=
params
[
"nproc"
]
nproc
=
run
[
"nproc"
]
if
(
nproc
%
12
==
0
and
nproc
%
8
==
0
):
head
+=
"#$ -pe orte* "
+
str
(
nproc
)
+
"
\n
"
elif
(
nproc
%
12
==
0
):
head
+=
"#$ -pe orte12 "
+
str
(
nproc
)
+
"
\n
"
elif
(
nproc
%
8
==
0
):
head
+=
"#$ -pe orte8 "
+
str
(
nproc
)
+
"
\n
"
if
(
"sge_option"
in
params
):
for
i
in
params
[
"sge_option"
]:
head
+=
"#$ {0}
\n
"
.
format
(
i
)
if
(
"module"
in
params
):
for
i
in
params
[
"module"
]:
head
+=
"module load {0}
\n
"
.
format
(
i
)
run
.
update
()
head
+=
"""
export BLACKDYNAMITE_HOST=__BLACKDYNAMITE__dbhost__
export BLACKDYNAMITE_SCHEMA=__BLACKDYNAMITE__study__
export BLACKDYNAMITE_STUDY=__BLACKDYNAMITE__study__
export BLACKDYNAMITE_RUN_ID=__BLACKDYNAMITE__run_id__
export BLACKDYNAMITE_USER="""
+
params
[
"user"
]
+
"""
on_kill()
{
updateRuns.py --updates \"state = SGE killed\" --truerun
exit 0
}
on_stop()
{
updateRuns.py --updates \"state = SGE stopped\" --truerun
exit 0
}
# Execute function on_die() receiving TERM signal
#
trap on_stop SIGUSR1
trap on_kill SIGUSR2
"""
_exec
[
"file"
]
=
run
.
replaceBlackDynamiteVariables
(
head
)
+
_exec
[
"file"
]
f
=
open
(
_exec
[
"filename"
],
'w'
)
f
.
write
(
_exec
[
"file"
])
f
.
close
()
# os.chmod(_exec["filename"], stat.S_IRWXU)
print
(
"execute qsub ./"
+
_exec
[
"filename"
])
print
(
"in dir "
)
subprocess
.
call
(
"pwd"
)
if
(
params
[
"truerun"
]
==
True
):
ret
=
subprocess
.
call
(
"qsub "
+
_exec
[
"filename"
],
shell
=
True
)
Event Timeline
Log In to Comment