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

[doc]

parent d7adc5cf
......@@ -32,7 +32,15 @@ See documentation for more fine-grained control with the JobFactory and Resource
Search
~~~~~~
Find the job started above (not all arguments are absolutely necessary in this case):
Find a job in case you know the job ID:
.. code-block:: python
from oarpy.oarjob import Job
job = Job(1130922)
print(job)
Find a job in case you do not know the job ID (not all arguments are necessary):
.. code-block:: python
......@@ -42,6 +50,6 @@ Find the job started above (not all arguments are absolutely necessary in this c
owner = os.getlogin()
start = timeutils.add(timeutils.now(),minutes=-10)
jobs = search(owner=owner, start=start, name='helloworld',
jobs = search(owner=owner, start=start, name='quickstart',
project='oarpy', state='Terminated')
print(jobs)
\ No newline at end of file
......@@ -84,9 +84,9 @@
"from oarpy import oarjob\n",
"from oarpy.oarresource import Resource\n",
"\n",
"resource = Resource(core=1,walltime={'hours':1,'minutes':30},gpu=False)\n",
"jobdef = oarjob.JobFactory(name='helloworld',project='oarpy',\n",
" command='echo \"Hello word\"',resource=resource)\n",
"resource = Resource(core=1, walltime={'hours':1,'minutes':30}, gpu=False)\n",
"jobdef = oarjob.JobFactory(name='helloworld', project='oarpy',\n",
" command='echo \"Hello word\"', resource=resource)\n",
"\n",
"job = jobdef.submit(hold=True)\n",
"print(job)\n",
......@@ -131,10 +131,10 @@
"from oarpy import oarjob\n",
"from oarpy import timeutils\n",
"\n",
"start = timeutils.add(timeutils.now(),minutes=-1)\n",
"start = timeutils.add(timeutils.now(), minutes=-1)\n",
"jobs = oarjob.search(start=start)\n",
"print(sorted(jobs))\n",
"print(set([(job['owner'],job.status) for job in jobs]))"
"print(set([(job['owner'], job.status) for job in jobs]))"
]
},
{
......@@ -199,7 +199,7 @@
"outputs": [],
"source": [
"from oarpy import oarjob\n",
"jobs = oarjob.search(owner='testuser',project='oarpy',state='Terminated')\n",
"jobs = oarjob.search(owner='testuser', project='oarpy', state='Terminated')\n",
"for job in jobs:\n",
" job.remove_logs()"
]
......
......@@ -180,7 +180,7 @@
"\n",
"end = timeutils.now()\n",
"start = timeutils.add(end,minutes=-10)\n",
"jobs = oarjob.search(start=start,end=end)\n",
"jobs = oarjob.search(start=start, end=end)\n",
"\n",
"print(str(len(jobs))+' jobs found')\n",
"\n",
......@@ -245,7 +245,7 @@
}
],
"source": [
"jobdef = oarjob.JobFactory(name='test',project='oarpy',command='ls')\n",
"jobdef = oarjob.JobFactory(name='test', project='oarpy', command='ls')\n",
"print(jobdef)"
]
},
......@@ -270,8 +270,8 @@
}
],
"source": [
"jobdef = oarjob.JobFactory(name='test',project='oarpy',command='ls',\n",
" working_directory='/tmp/oarpy',log_directory='/tmp/oarpy/log')\n",
"jobdef = oarjob.JobFactory(name='test', project='oarpy', command='ls',\n",
" working_directory='/tmp/oarpy', log_directory='/tmp/oarpy/log')\n",
"print(jobdef)"
]
},
......@@ -307,8 +307,8 @@
],
"source": [
"resource = Resource(nodes=1,core=8,walltime={'minutes':1})\n",
"jobdef = oarjob.JobFactory(name='test',project='oarpy',\n",
" command='ls',resource=resource)\n",
"jobdef = oarjob.JobFactory(name='test', project='oarpy',\n",
" command='ls', resource=resource)\n",
"print(jobdef)"
]
},
......@@ -329,8 +329,8 @@
"def definition(seconds):\n",
" command = 'python -c \"from time import sleep\\nfor i in range({}):\\n print(i)\\n sleep(1)\"'\n",
" resource = Resource(core=1,walltime={'seconds':seconds*3})\n",
" return oarjob.JobFactory(name='test{}'.format(seconds),project='oarpy',\n",
" resource=resource,command=command.format(seconds))"
" return oarjob.JobFactory(name='test{}'.format(seconds), project='oarpy',\n",
" resource=resource, command=command.format(seconds))"
]
},
{
......
......@@ -57,7 +57,38 @@
"source": [
"## Search\n",
"\n",
"Find the job started above (not all arguments are absolutely necessary in this case):"
"Find the job started above in case you know the job ID:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Job(1130922)\n",
" name = quickstart\n",
" project = oarpy\n",
" state = Terminated\n",
" owner = denolf\n",
" runtime = 0:00:16\n"
]
}
],
"source": [
"from oarpy.oarjob import Job\n",
"job = Job(1130922)\n",
"print(job)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Find the job started above in case you do not know the job ID (not all arguments are necessary):"
]
},
{
......@@ -79,7 +110,7 @@
"import os\n",
"\n",
"owner = os.getlogin()\n",
"start = timeutils.add(timeutils.now(),minutes=-10)\n",
"start = timeutils.add(timeutils.now(), minutes=-10)\n",
"jobs = search(owner=owner, start=start, name='quickstart',\n",
" project='oarpy', state='Terminated')\n",
"print(jobs)"
......
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