Multiprocessing related classes (tomographer.multiproc)

Classes and utilities for handling parallel tasks and for status reporting.

class tomographer.multiproc.FullStatusReport

Bases: pybind11_builtins.pybind11_object

A full status report of running tasks. This is typically passed on to a callback for displaying progressive status reports.

See also

This Python class interfaces the C++ class Tomographer::MultiProc::FullStatusReport.

There is a slight difference between the C++ and Python API’s on how the individual workers’ running/idle are reported: here, we don’t expose any workers_running list, rather, if a worker is idle, the corresponding object in workers is None.

All attributes of this class are read-only.

num_completed

The number of task instances that have already been entirely completed.

num_total_runs

The total number of task instances that we have to run

elapsed

How many seconds have elapsed since starting to run tasks

total_fraction_done

The total fraction of the tasks completed

workers

A list of individual reports for each running worker. The length of this list is the number of workers which can handle running tasks (e.g. parallel threads). Each item of the list is either None if the worker is idle, or a WorkerStatusReport instance providing the worker’s current status report.

getHumanReport()

A convenience function which formats the data contained in this structure in a human-readable form, providing an overview of the current status of the tasks. The report is suitable to be displayed in a terminal, for example.

The formatted report is returned as a string.

class tomographer.multiproc.WorkerStatusReport

Bases: pybind11_builtins.pybind11_object

Provides a summary of the current status of a worker processing a task.

This Python class is a wrapper for a corresponding C++ subclass class of Tomographer::MultiProc::TaskStatusReport, for example Tomographer::MHRWTasks::MHRandomWalkTask::StatusReport. Note that the data is rearranged from the C++ API; only the attributes fraction_done and msg are exposed directly; the remaining data is exposed via a general-purpose dictionary data.

worker_id

The identification number for this worker, typically the thread number.

fraction_done

The estimated fraction of the current task which is completed, given as a real number between 0 and 1.

msg

A message (provided as a string) which summarizes the currents status of the task

data

Additional data which is available, depending on the task type.

Functions which provide status reports using FullStatusReport and WorkerStatusReport should properly document which additional information is available in the data attribute. (See, for example, tomographer.tomorun.tomorun().)