Commit 2b2f068e authored by Wout De Nolf's avatar Wout De Nolf

[oarresource] add host

parent c15e5ecf
......@@ -94,7 +94,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -103,14 +103,19 @@
"text": [
"Initial request:\n",
" \n",
"\n",
"Wanted resources:\n",
" -l \"{(gpu='YES') AND type = 'default'}/host=1,walltime=24:0:0\" \n",
"\n",
"Properties:\n",
" ((((desktop_computing = 'NO') AND cluster = 'NICE') AND opsys = 'debian8') AND interactive = 'MIXED') AND drain='NO'\n",
"\n",
"Job resource:\n",
" -l walltime=24:00:00 -p gpu='YES'\n",
"\n",
"Job definition:\n",
" -n sample_031_tero --project pyhst2 -d /data/visitor/ma3931/id15/data/absct/sample_031_tero -O OAR.%jobname%.%jobid%.stdout -E OAR.%jobname%.%jobid%.stderr -l walltime=24:00:00 -p gpu='YES' \"./sample_031_tero.oar sample_031_tero0001.par\"\n"
" -n sample_031_tero --project pyhst2 -d /data/visitor/ma3931/id15/data/absct/sample_031_tero -O OAR.%jobname%.%jobid%.stdout -E OAR.%jobname%.%jobid%.stderr -l walltime=24:00:00 -p gpu='YES' \"./sample_031_tero.oar sample_031_tero0001.par\"\n",
"\n"
]
}
],
......@@ -119,11 +124,11 @@
"\n",
"job = oarjob.Job(110327)\n",
"jobdef = job.definition\n",
"print('Initial request:\\n {}'.format(job.stats['initial_request']))\n",
"print('Wanted resources:\\n {}'.format(job.stats['wanted_resources']))\n",
"print('Properties:\\n {}'.format(job.stats['properties']))\n",
"print('Job resource:\\n {}'.format(jobdef.resource))\n",
"print('Job definition:\\n {}'.format(jobdef))"
"print('Initial request:\\n {}\\n'.format(job.stats['initial_request']))\n",
"print('Wanted resources:\\n {}\\n'.format(job.stats['wanted_resources']))\n",
"print('Properties:\\n {}\\n'.format(job.stats['properties']))\n",
"print('Job resource:\\n {}\\n'.format(jobdef.resource))\n",
"print('Job definition:\\n {}\\n'.format(jobdef))"
]
},
{
......
......@@ -36,10 +36,11 @@ def str2walltime(s):
class Resource(object):
def __init__(self,nodes=None,cpu=None,core=None,gpu=False,
def __init__(self,host=None,nodes=None,cpu=None,core=None,gpu=False,
walltime=None,mem_core_mb=None):
"""
Args:
host(Optional(int)): number of hosts to be used
nodes(Optional(int)): number of nodes to be used
cpu(Optional(int)): number of cpu's per node
core(Optional(int)): number of cores per cpu
......@@ -48,6 +49,7 @@ class Resource(object):
dict keys: days, seconds, microseconds, milliseconds, minutes, hours, weeks
mem_core_mb(Optional(int)): required memory per core in MB
"""
self.host = host
self.nodes = nodes
self.cpu = cpu
self.core = core
......@@ -76,7 +78,7 @@ class Resource(object):
@property
def cores(self):
n = 1
for m in [self.nodes,self.cpu,self.core]:
for m in [self.host,self.nodes,self.cpu,self.core]:
if m:
n *= m
return n
......@@ -84,6 +86,8 @@ class Resource(object):
@property
def _cli_resource(self):
resources = []
if self.host:
resources.append('host={}'.format(self.host))
if self.nodes:
resources.append('nodes={}'.format(self.nodes))
if self.cpu:
......@@ -131,7 +135,7 @@ class Resource(object):
arg = oarshell._cli_getarg(cli_arguments,'-l')
if arg:
for key in ['nodes','cpu','core']:
for key in ['host','nodes','cpu','core']:
match = re.search('{}=(\d+)'.format(key),arg)
if match:
kwargs[key] = match.groups()[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment