Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Jeremy Auguste
oar
Commits
b44989bc
Commit
b44989bc
authored
7 years ago
by
Jeremy Auguste
Browse files
Options
Downloads
Patches
Plain Diff
Added anterior argument and made code more modular
parent
a54cee34
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
oargen.py
+58
-41
58 additions, 41 deletions
oargen.py
with
58 additions
and
41 deletions
oargen.py
+
58
−
41
View file @
b44989bc
...
@@ -5,16 +5,15 @@ from __future__ import print_function
...
@@ -5,16 +5,15 @@ from __future__ import print_function
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
argparse
import
argparse
# import logging
import
subprocess
import
subprocess
def
argparser
():
def
argparser
():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
command
'
,
nargs
=
'
?
'
,
# parser.add_argument('command', nargs='?',
# help="Command to use for the job (in passive mode)")
parser
.
add_argument
(
'
command
'
,
nargs
=
argparse
.
REMAINDER
,
help
=
"
Command to use for the job (in passive mode)
"
)
help
=
"
Command to use for the job (in passive mode)
"
)
parser
.
add_argument
(
'
argument
'
,
nargs
=
argparse
.
REMAINDER
,
help
=
"
Arguments of the command (in passive mode)
"
)
parser
.
add_argument
(
'
-n
'
,
'
--name
'
,
parser
.
add_argument
(
'
-n
'
,
'
--name
'
,
help
=
"
Name to give to the job
"
)
help
=
"
Name to give to the job
"
)
parser
.
add_argument
(
'
-b
'
,
'
--besteffort
'
,
action
=
"
store_true
"
,
parser
.
add_argument
(
'
-b
'
,
'
--besteffort
'
,
action
=
"
store_true
"
,
...
@@ -33,65 +32,83 @@ def argparser():
...
@@ -33,65 +32,83 @@ def argparser():
help
=
"
Enable checkpoint signals with the given delay (in seconds)
"
)
help
=
"
Enable checkpoint signals with the given delay (in seconds)
"
)
parser
.
add_argument
(
'
-r
'
,
'
--run
'
,
action
=
"
store_true
"
,
parser
.
add_argument
(
'
-r
'
,
'
--run
'
,
action
=
"
store_true
"
,
help
=
"
Run the command
"
)
help
=
"
Run the command
"
)
# parser.add_argument('-l', '--logger', default='INFO',
parser
.
add_argument
(
'
-a
'
,
'
--anterior
'
,
# choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
help
=
"
Anterior job id that must be terminated to start this new one
"
)
# help="Logging level: DEBUG, INFO (default), WARNING, ERROR")
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# numeric_level = getattr(logging, args.logger.upper(), None)
# if not isinstance(numeric_level, int):
# raise ValueError("Invalid log level: {}".format(args.logger))
# logging.basicConfig(level=numeric_level)
return
args
return
args
def
main
():
def
prepare_oarsub
(
gpu
,
host
,
core
,
time
,
args
=
argparser
()
command
=
None
,
argument
=
None
,
interactive
=
False
,
command
=
[
"
oarsub
"
]
name
=
None
,
besteffort
=
False
,
command
.
append
(
"
-p
"
)
checkpoint
=
None
,
anterior
=
None
,
command_is_string
=
False
):
oar_cmd
=
[
"
oarsub
"
]
oar_cmd
.
append
(
"
-p
"
)
properties
=
""
properties
=
""
if
args
.
gpu
:
if
gpu
:
properties
+=
"
(gpu IS NOT NULL)
"
properties
+=
"
(gpu IS NOT NULL)
"
else
:
else
:
properties
+=
"
(gpu IS NULL)
"
properties
+=
"
(gpu IS NULL)
"
if
args
.
host
is
not
None
:
if
host
is
not
None
:
properties
+=
"
AND host LIKE
'
{}
'"
.
format
(
args
.
host
)
properties
+=
"
AND host LIKE
'
{}
'"
.
format
(
host
)
properties
+=
""
properties
+=
""
comman
d
.
append
(
properties
)
oar_cm
d
.
append
(
properties
)
comman
d
.
append
(
"
-l
"
)
oar_cm
d
.
append
(
"
-l
"
)
time
=
args
.
time
.
split
(
'
:
'
)
time
=
time
.
split
(
'
:
'
)
hour
=
time
[
0
]
hour
=
time
[
0
]
minutes
=
time
[
1
]
if
len
(
time
)
>=
2
else
"
00
"
minutes
=
time
[
1
]
if
len
(
time
)
>=
2
else
"
00
"
seconds
=
time
[
2
]
if
len
(
time
)
>=
3
else
"
00
"
seconds
=
time
[
2
]
if
len
(
time
)
>=
3
else
"
00
"
ressources
=
"
core={},walltime={}:{}:{}
"
.
format
(
args
.
core
,
hour
,
minutes
,
seconds
)
ressources
=
"
core={},walltime={}:{}:{}
"
.
format
(
core
,
hour
,
minutes
,
seconds
)
command
.
append
(
ressources
)
oar_cmd
.
append
(
ressources
)
if
name
is
not
None
:
oar_cmd
.
append
(
"
-n
"
)
oar_cmd
.
append
(
name
)
oar_cmd
.
append
(
"
-O
"
)
oar_cmd
.
append
(
"
{}.%jobid%.stdout
"
.
format
(
name
))
oar_cmd
.
append
(
"
-E
"
)
oar_cmd
.
append
(
"
{}.%jobid%.stderr
"
.
format
(
name
))
if
args
.
name
is
not
None
:
if
besteffort
:
command
.
append
(
"
-n
"
)
oar_cmd
.
extend
([
"
-t
"
,
"
besteffort
"
,
"
-t
"
,
"
idempotent
"
])
command
.
append
(
args
.
name
)
command
.
append
(
"
-O
"
)
command
.
append
(
"
{}.%jobid%.stdout
"
.
format
(
args
.
name
))
command
.
append
(
"
-E
"
)
command
.
append
(
"
{}.%jobid%.stderr
"
.
format
(
args
.
name
))
if
args
.
besteffort
:
if
checkpoint
is
not
None
:
comman
d
.
extend
([
"
-
t
"
,
"
besteffort
"
,
"
-t
"
,
"
idempote
nt
"
])
oar_cm
d
.
extend
([
"
-
-checkpoint
"
,
checkpoi
nt
])
if
a
rgs
.
checkpoint
is
not
None
:
if
a
nterior
is
not
None
:
comman
d
.
extend
([
"
-
-checkpoint
"
,
args
.
checkpoint
])
oar_cm
d
.
extend
([
"
-
a
"
,
anterior
])
if
args
.
interactive
:
if
interactive
:
comman
d
.
append
(
'
-I
'
)
oar_cm
d
.
append
(
'
-I
'
)
else
:
else
:
job_command
=
[
args
.
command
]
+
args
.
argument
job_command
=
command
if
command_is_string
else
"
"
.
join
(
command
)
command
.
append
(
"
"
.
join
(
job_command
))
oar_cmd
.
append
(
"
"
.
join
(
job_command
))
def
run_oarsub
(
command
,
print_cmd
=
False
,
fake_run
=
False
,
return_output
=
False
):
print
(
subprocess
.
list2cmdline
(
command
))
print
(
subprocess
.
list2cmdline
(
command
))
if
args
.
run
:
if
fake_run
:
return
None
if
not
return_output
:
subprocess
.
call
(
command
)
subprocess
.
call
(
command
)
return
None
return
subprocess
.
check_output
(
command
)
def
main
():
args
=
argparser
()
oar_command
=
prepare_oarsub
(
args
.
gpu
,
args
.
host
,
args
.
core
,
args
.
time
,
command
=
args
.
command
,
argument
=
args
.
argument
,
interactive
=
args
.
interactive
,
name
=
args
.
name
,
besteffort
=
args
.
besteffort
,
checkpoint
=
args
.
checkpoint
,
anterior
=
args
.
anterior
)
run_oarsub
(
oar_command
,
print_cmd
=
True
,
fake_run
=
not
args
.
run
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
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