Job¶
Module to handle a job.
-
class
qarnot.job.
Job
(connection, name, pool=None, shortname=None, use_dependencies=False)[source]¶ Bases:
object
Represents a Qarnot job.
Note
A
Job
must be created withqarnot.connection.Connection.create_job()
or retrieved withqarnot.connection.Connection.jobs()
orqarnot.connection.Connection.retrieve_job()
.-
__init__
(connection, name, pool=None, shortname=None, use_dependencies=False)[source]¶ Create a new
Job
.Parameters: - connection (
qarnot.connection.Connection
) – the cluster on which to send the job - name (
str
) – given name of the job - pool (
Pool
or None) – which Pool to submit the job in, - shortname (
str
) – userfriendly job name - use_dependencies – allow dependencies between tasks in this job
- connection (
-
auto_update
¶ Type: bool
Getter: Returns this job’s auto update state Setter: Sets this job’s auto update state Auto update state, default to True When auto update is disabled properties will always return cached value for the object and a call to
update()
will be required to get latest values from the REST Api.
-
update_cache_time
¶ Type: int
Getter: Returns this job’s auto update state Setter: Sets this job’s auto update state Cache expiration time, default to 5s
-
state
¶ Type: str
Getter: return this job’s state State of the job.
- Value is in
- UnSubmitted
- Active,
- Terminating,
- Completed,
- Deleting
Warning
this is the state of the job when the object was retrieved, call
update()
for up to date value.
-
use_dependencies
¶ Type: bool
Getter: task’s job can have dependencies Setter: Set if there is task’s job dependencies Can be set until
submit()
is called.
-
uuid
¶ Type: str
Getter: Returns this job’s uuid The job’s uuid.
Automatically set when a job is submitted.
-
name
¶ Type: str
Getter: Returns this job’s name Setter: Sets this job’s name The job’s name.
Can be set until job is submitted.
-
shortname
¶ Type: str
Getter: Returns this job’s shortname Setter: Sets this job’s shortname The job’s shortname, must be DNS compliant and unique, if not provided, will default to
uuid
.Can be set until job is submitted.
-
max_wall_time
¶ Type: str
Getter: Returns this job’s maximum wall time Setter: Sets this job’s maximum wall time The job’s maximum wall time. It is a time span string. Format example: ‘d.hh:mm:ss’ or ‘hh:mm:ss’
Can be set until job is submitted.
-
pool
¶ Type: Pool
Getter: Returns this job’s pool Setter: Sets this job’s pool The pool to run the job in.
Can be set until
submit()
is called.
-
classmethod
from_json
(connection, payload)[source]¶ Create a Job object from a json job.
Parameters: - connection (qarnot.connection.Connection) – the cluster connection
- json_job (dict) – Dictionary representing the job
Returns: The created
Job
.
-
submit
()[source]¶ Submit job to the cluster if it is not already submitted.
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.MaxJobException – Job quota reached
- qarnot.exceptions.NotEnoughCreditsException – Not enough credits
- qarnot.exceptions.UnauthorizedException – invalid credentials
-
update
(flushcache=False)[source]¶ Update the job object from the REST Api. The flushcache parameter can be used to force the update, otherwise a cached version of the object will be served when accessing properties of the object. Cache behavior is configurable with
auto_update
andupdate_cache_time
.Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.MissingJobException – job does not exist
-
terminate
()[source]¶ Terminate this job on the server and abort all remaining tasks in the job.
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.MissingJobException – job does not exist
-
delete
(forceAbort=False)[source]¶ Delete this job on the server.
The forceAbort parameter can be used to force running task in the job to be aborted,
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.UnauthorizedException – job still contains running tasks
- qarnot.exceptions.MissingJobException – job does not exist
-
auto_delete
¶ Autodelete this job if it is finished and your max number of job is reach
Can be set until
submit()
is called.Type: bool
Getter: Returns is this job must autodelete Setter: Sets this job’s autodelete Default_value: “False” Raises: AttributeError – if you try to reset the auto_delete after the job is submit
-
completion_ttl
¶ The job will be auto delete completion_ttl after it is finished
Can be set until
submit()
is called.Getter: Returns this job’s completed time to live. Type: str
Setter: Sets this job’s this job’s completed time to live. Type: str
ordatetime.timedelta
Default_value: “” Raises: AttributeError – if you try to set it after the job is submitted The completion_ttl must be a timedelta or a time span format string (example: ‘d.hh:mm:ss’ or ‘hh:mm:ss’)
-