Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90891751
pbsCoat.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
Tue, Nov 5, 17:32
Size
3 KB
Mime Type
text/x-python
Expires
Thu, Nov 7, 17:32 (2 d)
Engine
blob
Format
Raw Data
Handle
22153930
Attached To
R3127 blackdynamite
pbsCoat.py
View Options
#!/usr/bin/env python
from
BlackDynamite
import
*
import
os
,
stat
import
subprocess
import
re
import
socket
admissible_params
=
{
"walltime"
:
str
,
"email"
:
str
,
"nproc"
:
int
,
"pbs_option"
:
[
str
],
"module"
:
[
str
],
"mpiprocs"
:
int
,
"ncpus"
:
int
,
"cwd"
:
bool
}
default_params
=
{
"walltime"
:
"48:00:00"
,
"cwd"
:
True
}
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"
,
"pbs_option"
:
"Allow to provide additional PBS options"
,
"module"
:
"List of module to load"
,
"ncpus"
:
"Number of cpus per nodes"
,
"mpiprocs"
:
"Number of mpi processus per nodes"
,
"cwd"
:
"Run by default in the run folder"
}
def
launch
(
run
,
params
):
_exec
=
run
.
getExecFile
()
head
=
\
"""#!/bin/bash
#PBS -l walltime={0}
"""
.
format
(
params
[
"walltime"
])
if
(
"email"
in
params
):
head
+=
"#PBS -m abe
\n
"
head
+=
"#PBS -M {0}
\n
"
.
format
(
params
[
"email"
])
pbs_head_name
=
"#PBS -N {0}_{1}
\n
"
.
format
(
run
[
"run_name"
],
run
.
id
)
head
+=
pbs_head_name
run
[
"state"
]
=
"PBS submit"
if
(
"nproc"
in
params
):
run
[
"nproc"
]
=
params
[
"nproc"
]
nproc
=
run
[
"nproc"
]
if
(
"mpiprocs"
in
params
or
"npcus"
in
params
):
args
=
[]
if
"ncpus"
in
params
:
npernode
=
params
[
"ncpus"
]
args
.
append
(
"ncpus={0}"
.
format
(
npernode
))
if
"mpiprocs"
in
params
:
npernode
=
min
(
params
[
"mpiprocs"
],
nproc
)
args
.
append
(
"mpiprocs={0}"
.
format
(
npernode
))
select
=
max
(
1
,
nproc
/
npernode
)
args
.
insert
(
0
,
"#PBS -l select={0}"
.
format
(
select
))
select_str
=
":"
.
join
(
args
)
print
select_str
head
+=
select_str
+
"
\n
"
else
:
head
+=
"#PBS -l nodes="
+
str
(
nproc
)
+
"
\n
"
if
(
"pbs_option"
in
params
):
for
i
in
params
[
"pbs_option"
]:
head
+=
"#PBS {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 = PBS killed\" --truerun
exit 0
}
on_stop()
{
updateRuns.py --updates \"state = PBS stopped\" --truerun
exit 0
}
# Execute function on_die() receiving TERM signal
#
trap on_stop SIGUSR1
trap on_stop SIGTERM
trap on_kill SIGUSR2
trap on_kill SIGKILL
"""
if
(
params
[
"cwd"
]):
head
+=
"""
cd __BLACKDYNAMITE__run_path__
"""
_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