Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CTDAS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tsurata, Aki
CTDAS
Commits
180b6ef9
Commit
180b6ef9
authored
14 years ago
by
Peters, Wouter
Browse files
Options
Downloads
Patches
Plain Diff
baseclass to contain job control object class PlatForm
parent
2499ceb7
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
da/baseclasses/jobcontrol.py
+95
-0
95 additions, 0 deletions
da/baseclasses/jobcontrol.py
with
95 additions
and
0 deletions
da/baseclasses/jobcontrol.py
0 → 100755
+
95
−
0
View file @
180b6ef9
#!/usr/bin/env python
# jobcontrol.py
"""
Author : peters
Revision History:
File created on 06 Sep 2010.
"""
import
sys
import
os
import
logging
import
subprocess
class
PlatForm
(
object
):
"""
This specifies platform dependent options under generic object calls. A platform object is used to control and submit jobs
"""
def
__init__
(
self
):
self
.
Identifier
=
'
iPad
'
# the identifier gives the plaform name
self
.
Version
=
'
1.0
'
# the platform version used
print
self
def
__str__
(
self
):
msg1
=
'
%s object initialized
'
%
self
.
Identifier
;
logging
.
debug
(
msg1
)
msg2
=
'
%s version: %s
'
%
(
self
.
Identifier
,
self
.
Version
)
;
logging
.
debug
(
msg2
)
return
msg1
+
'
\n
'
+
msg2
def
GetJobTemplate
(
self
,
joboptions
=
{}):
"""
Return the job template for a given computing system, and fill it with options from the dictionary provided as argument
"""
template
=
"""
##
\n
"""
+
\
"""
## This is a set of dummy names, to be replaced by values from the dictionary
\n
"""
+
\
"""
## Please make your own platform specific template with your own keys and place it in a subfolder of the da package.
\n
"""
+
\
"""
##
\n
"""
+
\
"""
\n
"""
+
\
"""
#$ jobname
\n
"""
+
\
"""
#$ jobaccount
\n
"""
+
\
"""
#$ jobnodes
\n
"""
+
\
"""
#$ jobtime
\n
"""
+
\
"""
#$ jobshell
\n
"""
+
\
"""
\n
"""
for
k
,
v
in
joboptions
.
iteritems
():
while
k
in
template
:
template
=
template
.
replace
(
k
,
v
)
return
template
def
WriteJob
(
self
,
DaCycle
,
template
,
jobid
):
"""
This method writes a jobfile to the exec dir
"""
#
# Done, write jobfile
#
targetdir
=
os
.
path
.
join
(
DaCycle
.
da_settings
[
'
dir.exec
'
])
jobfile
=
os
.
path
.
join
(
targetdir
,
'
jb.%s.jb
'
%
jobid
)
f
=
open
(
jobfile
,
'
w
'
)
dummy
=
f
.
write
(
template
)
dummy
=
f
.
close
()
dummy
=
os
.
chmod
(
jobfile
,
477
)
msg
=
"
A job file was created (%s)
"
%
jobfile
;
logging
.
debug
(
msg
)
return
jobfile
def
SubmitJob
(
self
,
jobfile
):
"""
This method submits a jobfile to the queue, and returns the queue ID
"""
cmd
=
[
'
sh
'
,
jobfile
]
jobid
=
subprocess
.
call
(
cmd
)
return
jobid
def
KillJob
(
self
,
jobid
):
"""
This method kills a running job
"""
output
=
subprocess
.
Popen
([
'
qdel
'
,
jobid
],
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
;
logging
.
info
(
output
)
return
output
def
StatJob
(
self
,
jobid
):
"""
This method gets the status of a running job
"""
import
subprocess
output
=
subprocess
.
Popen
([
'
qstat
'
,
jobid
],
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
;
logging
.
info
(
output
)
return
output
if
__name__
==
"
__main__
"
:
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment