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 (
Connection
) – the cluster on which to send the jobname (
str
) – given name of the jobpool (
Pool
or None) – which Pool to submit the job in,shortname (
str
) – userfriendly job nameuse_dependencies (
bool
) – allow dependencies between tasks in this joblogger (
logging.Logger
) – which job to attach the task to
- property auto_update
- Type:
- 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.
- property update_cache_time
- Type:
- Getter:
Returns this job’s auto update state
- Setter:
Sets this job’s auto update state
Cache expiration time, default to 5s
- property state
- Type:
- 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.
- property tasks
- Type:
List of
Task
- Getter:
Returns this job tasks
The tasks submitted in this job.
Note
The tasks need to be actually submitted with
Task.submit()
to be recognized and displayed by the methodtasks()
- property use_dependencies
- Type:
- Getter:
task’s job can have dependencies
- Setter:
Set if there is task’s job dependencies
Can be set until
submit()
is called.
- property uuid
- Type:
- Getter:
Returns this job’s uuid
The job’s uuid.
Automatically set when a job is submitted.
- property name
- Type:
- Getter:
Returns this job’s name
- Setter:
Sets this job’s name
The job’s name.
Can be set until job is submitted.
- property shortname
- Type:
- 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.
- property creation_date
- Type:
- Getter:
Returns this job’s creation date
Creation date of the job (UTC Time)
- property max_wall_time
- Type:
- 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
orhh:mm:ss
Can be set until job is submitted.
- property pool
- Type:
- 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:
QarnotGenericException – API general error, see message for details
MaxJobException – Job quota reached
NotEnoughCreditsException – Not enough credits
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:
QarnotGenericException – API general error, see message for details
UnauthorizedException – invalid credentials
MissingJobException – job does not exist
- terminate()[source]
Terminate this job on the server and abort all remaining tasks in the job.
- Raises:
QarnotGenericException – API general error, see message for details
UnauthorizedException – invalid credentials
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:
QarnotGenericException – API general error, see message for details
UnauthorizedException – invalid credentials
UnauthorizedException – job still contains running tasks
MissingJobException – job does not exist
- property 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:
- 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
- property 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:
- Setter:
Sets this job’s this job’s completed time to live.
- Type:
- 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
orhh:mm:ss
)
- property tags
- Type:
:class:list(str)
- Getter:
Returns this job’s tags
- Setter:
Sets this job’s tags
Custom tags.
- property state_transition_time
- Type:
- Getter:
Returns the running job’s transition state time
job state transition time (UTC Time)