Skip to content
Snippets Groups Projects
Commit 260b6626 authored by Jeremy Auguste's avatar Jeremy Auguste
Browse files

Added way to specify multiple hosts (and ignore hosts)

parent 5bb2a115
No related branches found
No related tags found
No related merge requests found
Pipeline #998 failed
......@@ -23,8 +23,10 @@ def argparser():
help="If True, reserves only cores with GPUs")
parser.add_argument('-c', '--core', default=1, type=int,
help="Number of cores to reserve")
parser.add_argument('-H', '--host',
help="Name of the host (SQL LIKE syntax accepted)")
parser.add_argument('-H', '--host', nargs="+", default=[],
help="Name of the hosts (SQL 'LIKE' syntax accepted)")
parser.add_argument('-I', '--ignore-host', nargs="+", default=[],
help="Name of the hosts to ignore (SQL 'NOT LIKE' syntax accepted)")
parser.add_argument('-i', '--interactive', action="store_true",
help="Launch job in interactive mode")
parser.add_argument('-C', '--checkpoint', type=int, metavar="SECONDS",
......@@ -95,7 +97,7 @@ def load_jobs(yaml_in, args):
yaml_jobs = yaml.load(yaml_in)
var_names, var_tuples = load_variables(yaml_jobs["variables"])
constants = yaml_jobs["constants"]
constants = yaml_jobs["constants"] if "constants" in yaml_jobs else {}
flags = load_flags(yaml_jobs["flags"], args)
try:
precommand = yaml_jobs["environment"]["precommand"]
......@@ -142,6 +144,7 @@ def main():
anterior = anteriors.pop()
oar_command = oargen.prepare_oarsub(args.gpu, args.host, args.core, args.time,
ignore_hosts=args.ignore_host,
command=job, name=job_name,
output_directory=args.directory,
besteffort=args.besteffort,
......
......@@ -27,8 +27,10 @@ def argparser():
help="If True, reserves only cores with GPUs")
parser.add_argument('-c', '--core', default=1, type=int,
help="Number of cores to reserve")
parser.add_argument('-H', '--host',
help="Name of the host (SQL LIKE syntax accepted)")
parser.add_argument('-H', '--host', nargs="+", default=[],
help="Name of the hosts (SQL 'LIKE' syntax accepted)")
parser.add_argument('-I', '--ignore-host', nargs="+", default=[],
help="Name of the hosts to ignore (SQL 'NOT LIKE' syntax accepted)")
parser.add_argument('-i', '--interactive', action="store_true",
help="Launch job in interactive mode")
parser.add_argument('-C', '--checkpoint', type=int, metavar="SECONDS",
......@@ -42,7 +44,8 @@ def argparser():
return args
def prepare_oarsub(gpu, host, core, time,
def prepare_oarsub(gpu, hosts, core, time,
ignore_hosts=[],
command=None,
interactive=False,
name=None, output_directory=None,
......@@ -55,8 +58,12 @@ def prepare_oarsub(gpu, host, core, time,
properties += "(gpu IS NOT NULL)"
else:
properties += "(gpu IS NULL)"
if host is not None:
if hosts:
for host in hosts:
properties += " AND host LIKE '{}'".format(host)
if ignore_hosts:
for host in ignore_hosts:
properties += " AND host NOT LIKE '{}'".format(host)
properties += ""
oar_cmd.append(properties)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment