README.rst 1.5 KB
Newer Older
1 2 3
oarpy: OAR job management in python
===================================

Wout De Nolf's avatar
Wout De Nolf committed
4 5 6 7 8 9 10 11 12 13
Installation
------------

.. code-block:: bash

    pip install oarpy

Documentation
-------------

Wout De Nolf's avatar
Wout De Nolf committed
14
The documentation of the latest release is available at: http://oarpy.readthedocs.io/en/latest/
Wout De Nolf's avatar
Wout De Nolf committed
15

16 17 18
Getting started
---------------

Wout De Nolf's avatar
Wout De Nolf committed
19 20 21
Submit
~~~~~~

Wout De Nolf's avatar
Wout De Nolf committed
22
Run an OAR job that prints "Hello world":
23 24 25

.. code-block:: python

Wout De Nolf's avatar
Wout De Nolf committed
26 27 28
    from oarpy.oarjob import submit

    job = submit(command='echo "Hello word"', name='helloword',
Wout De Nolf's avatar
Wout De Nolf committed
29
                 project='oarpy', core=1, gpu=False, walltime={'hours':2})
Wout De Nolf's avatar
Wout De Nolf committed
30
    print(job)
31
    job.wait()
Wout De Nolf's avatar
Wout De Nolf committed
32

33 34 35 36 37 38
    if job.exit_code:
        print('Failed:\n{}'.format(job.stderr))
    elif job.exit_code is None:
        print('Interrupted:\n{}'.format(job.stdout))
    else:
        print('Succes:\n{}'.format(job.stdout))
Wout De Nolf's avatar
Wout De Nolf committed
39

40
    job.remove_logs()
41

Wout De Nolf's avatar
Wout De Nolf committed
42
Only "command" is required, all other arguments are optional. See documentation for more fine-grained control with the JobFactory and Resource classes.
Wout De Nolf's avatar
Wout De Nolf committed
43
 
Wout De Nolf's avatar
Wout De Nolf committed
44 45
Search
~~~~~~
46

Wout De Nolf's avatar
Wout De Nolf committed
47 48 49 50 51 52 53 54 55
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):
56 57 58

.. code-block:: python

Wout De Nolf's avatar
Wout De Nolf committed
59
    from oarpy.oarjob import search
60
    from oarpy import timeutils
Wout De Nolf's avatar
Wout De Nolf committed
61 62 63 64
    import os

    owner = os.getlogin()
    start = timeutils.add(timeutils.now(),minutes=-10)
Wout De Nolf's avatar
Wout De Nolf committed
65
    jobs = search(owner=owner, start=start, name='helloword',
Wout De Nolf's avatar
Wout De Nolf committed
66
                  project='oarpy', state='Terminated')
Wout De Nolf's avatar
Wout De Nolf committed
67 68 69
    print(jobs)