luna.util.progress_tracker module¶
- class ProgressData(input_data, proc_time, output_data=None, exception=None, func=None)[source]¶
Bases:
object
Custom data structure to store data generated during the execution of a single task.
- Parameters
input_data (any) – The input data of the executed task.
proc_time (float) – How long a task took to be executed.
output_data (any, optional) – The output data produced by a given task. The data type is the same as the executed function’s return.
exception (
Exception
, optional) – If an exception was raised, thenexception
stores an Exception object. Otherwise,exception
will be set to None.func (function, optional) – The executed function for reference.
- class ProgressResult(results=None)[source]¶
Bases:
object
Custom iterable class to store
ProgressData
objects as they are produced during the execution of a set of tasks.This class implements append() and __iter__() by default.
- Parameters
results (list, optional) – A pre-populated list of
ProgressData
objects.- Variables
~ProgressResult.results (list) – The list of
ProgressData
objects.
- append(r)[source]¶
Add a new
ProgressData
object toresults
- property errors¶
Errors from each
ProgressData
object stored inresults
. Each tuple contains the input and the exception raised during the execution of a task with that input.- Type
list of tuple
- property inputs¶
Inputs from each
ProgressData
object stored inresults
.- Type
- property outputs¶
Outputs from each
ProgressData
object stored inresults
. Each tuple contains the input and the output produced for that input.- Type
list of tuple
- class ProgressTracker(ntasks, queue, task_name=None)[source]¶
Bases:
object
A progress tracker for tasks queued in
queue
.- Parameters
ntasks (int) – The number of tasks to be executed.
queue (
Queue
) – A queue to track the tasks’ progress.task_name (str, optional) – A name to identify the set of tasks.
- Variables
~ProgressTracker.ntasks (int) – The number of tasks to be executed.
~ProgressTracker.queue (
Queue
) – The queue to track the tasks’ progress from.~ProgressTracker.task_name (str, optional) – The name to identify the set of tasks.
~ProgressTracker.results (ProgressResult) – Store results and any errors found during the tasks’ processing.
~ProgressTracker.nerrors (int) – Number of errors.