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.
- 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_started()[source]#
Checks if the task has been started.
A task starts when it reports it’s first progress update.
- 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