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.

__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 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 (bool) – allow dependencies between tasks in this job

  • logger (logging.Logger) – which job to attach the task to

property 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.

property 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

property 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.

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 method tasks()

property 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.

property uuid
Type

str

Getter

Returns this job’s uuid

The job’s uuid.

Automatically set when a job is submitted.

property 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.

property 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.

property creation_date
Type

str

Getter

Returns this job’s creation date

Creation date of the job (UTC Time)

property 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.

property 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
Returns

The created Job.

submit()[source]

Submit job to the cluster if it is not already submitted.

Raises
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 and update_cache_time.

Raises
terminate()[source]

Terminate this job on the server and abort all remaining tasks in the job.

Raises
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
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

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

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

str

Setter

Sets this job’s this job’s completed time to live.

Type

str or datetime.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 )

property tags
Type

:class:list(str)

Getter

Returns this job’s tags

Setter

Sets this job’s tags

Custom tags.

property previous_state
Type

str

Getter

Returns the running job’s previous state

property state_transition_time
Type

str

Getter

Returns the running job’s transition state time

job state transition time (UTC Time)

property previous_state_transition_time
Type

str

Getter

Returns the running job’s previous transition state time

job previous state transition time (UTC Time)