mantidimaging.core.utility.progress_reporting.progress module#

class mantidimaging.core.utility.progress_reporting.progress.Progress(num_steps: int = 1, task_name: str = 'Task')[source]#

Bases: object

Class used to perform basic progress monitoring and reporting.

add_estimated_steps(num_steps)[source]#

Increments the number of steps this task is expected to take to complete.

add_progress_handler(handler: ProgressHandler)[source]#

Adds a handler to receiver progress updates. :param handler: Instance of a progress handler

static calculate_mean_time(progress_history: list[ProgressHistory]) float[source]#
cancel(msg='cancelled')[source]#

Mark the task tree that uses this progress instance for cancellation.

Task should either periodically inspect should_cancel or have suitably many calls to update() to be cancellable.

completion()[source]#

Gets the completion of the task in the range of 0.0 - 1.0

static ensure_instance(p: Progress | None = None, *args, num_steps: int | None = None, **kwargs) Progress[source]#

Helper function used to select either a non-None Progress instance as a parameter, or simply create and configure a new one.

execution_time()[source]#

Gets the total time this task has been executing.

Total time is measured from the timestamp of the first progress message to the timestamp of the last progress message.

is_completed()[source]#

Checks if the task has been marked as completed.

is_started()[source]#

Checks if the task has been started.

A task starts when it reports it’s first progress update.

last_status_message()[source]#

Gets the message from the last progress update.

mark_complete(msg='complete')[source]#

Marks the task as completed.

set_estimated_steps(num_steps: int)[source]#

Sets the number of steps this task is expected to take to complete.

property should_cancel#

Checks if the task should be cancelled.

update(steps: int = 1, msg: str = '', force_continue: bool = False, extra_info: dict | None = None) None[source]#

Updates the progress of the task.

Parameters:
  • steps – Number of steps that have been completed since last call to this function

  • msg – Message describing current step

  • force_continue – Prevent cancellation of the async progress

class mantidimaging.core.utility.progress_reporting.progress.ProgressHandler[source]#

Bases: object

progress_update()[source]#
class mantidimaging.core.utility.progress_reporting.progress.ProgressHistory(time, step, msg, extra_info)#

Bases: NamedTuple

extra_info: dict | None#

Alias for field number 3

msg: str#

Alias for field number 2

step: int#

Alias for field number 1

time: float#

Alias for field number 0