job
¶
Submodules¶
Package Contents¶
Classes¶
Handle a single Job. |
|
A job which does nothing. |
|
Specialized version of Job that spawn processes. |
Attributes¶
- job.NotifyEndType¶
- job.logger¶
- job.JobTimingInfo¶
- class job.Job(uid: str, data: Any, notify_end: NotifyEndType)¶
Handle a single Job.
- Variables:
slot (int) – number associated with the job during its execution. At a given time only one job have a given slot number.
start_time (datetime.datetime) – time at which job execution started or None if never started
stop_time (datetime.datetime) – time at which job execution ended or None if either the job was never run or if the job is still running
should_skip – indicator for the scheduler that the job should not be executed
interrupted – if True it means that job has been interrupted. Can be consequence of timeout or Ctrl-C pressed
queue_name – name of the queue in which the job has been placed
tokens – number of tokens (i.e: resources) consumed during the job execution
index – global index indicating the order in which jobs have been created. The index is used to implement the default ordering function needed to sort Jobs. In the context of
e3.job.scheduler.Scheduler
this means that by default jobs that are created first will have a higher priority.
- Vartype:
bool
- Vartype:
bool
- Vartype:
str
- Vartype:
int
- Vartype:
int
- property priority: int¶
Return job priority.
This is used in
e3.job.scheduler.Scheduler
.
- property timing_info: JobTimingInfo¶
Retrieve some job’s timing information.
- Returns:
a JobTimingInfo object
- property status: e3.anod.status.ReturnValue¶
Return he job’s status.
This is made a property because users of this class should not be allowed to set or change it value. The job’s status is … a property of the job!
- lock¶
- index_counter = 0¶
- record_start_time() None ¶
Log the starting time of a job.
- record_stop_time() None ¶
Log the stopping time of a job.
- start(slot: int) None ¶
Launch the job.
- Parameters:
slot – slot number
- abstract run() None ¶
Job activity.
- interrupt() bool ¶
Interrupt current job.
- Returns:
True if interrupted, False if already interrupted
- on_start(scheduler: e3.job.scheduler.Scheduler) None ¶
Call whenever a job is started.
This allow the user to do some logging on job startup
- on_finish(scheduler: e3.job.scheduler.Scheduler) None ¶
Call whenever a job is finished.
This allow the user to do some logging on job termination
- class job.EmptyJob(uid: str, data: Any, notify_end: collections.abc.Callable[[str], None], status: e3.anod.status.ReturnValue)¶
Bases:
Job
A job which does nothing.
- property status: e3.anod.status.ReturnValue¶
See Job.status’ description.
- run() None ¶
Job activity.
- class job.ProcessJob(uid: str, data: Any, notify_end: collections.abc.Callable[[str], None])¶
Bases:
Job
Specialized version of Job that spawn processes.
- Variables:
proc_handle (e3.os.process.Run | None) – None when an object of this class is initialized. An e3.os.process.Run object after the “run” method is called.
- property status: e3.anod.status.ReturnValue¶
See Job.status’ description.
- property cmd_options: dict¶
Process options.
Important note: don’t use PIPE for output or error parameters this can cause locking error in case the process is interrupted. The default redirect output and error to the console.
The pipe behavior can easily be emulated by writing to a file and modifying the run method to read the file content when the process finish.
- Returns:
options for e3.os.process.Run as a dict
- run() None ¶
Run the job.
- abstract cmdline() list[str] ¶
Return the command line of the process to be spawned.
- Returns:
the command line
- interrupt() bool ¶
Kill running process tree.