Skip to content

progress.reporters

What renders the activities of a run: a bar, a log line, an event.

The activities of a run, see sbmlsim.progress.core, are rendered by three reporters, and resolve chooses between them:

  • BarReporter draws a rich bar per activity on the console, nested by its depth, with the steps, the elapsed time and the estimate of the time which is left. It needs a terminal.
  • LogReporter writes a line per activity every 30 seconds, so a run in a log file, in a pipe or in continuous integration says how far it is.
  • EventReporter records the progress in the events of the run, see sbmlsim.events, so something outside the process (simrun, an agent) follows the run by reading progress.jsonl.

Every rendering says what of the machine the run uses, the cores, the CPU and the memory of sbmlsim.progress.resources: the bar of the outermost activity, the end of every line and the field resources of every event.

The rendering is chosen by --progress auto|bar|log|none of the run, by the environment variable SBMLSIM_PROGRESS or by the argument of a function which takes one, e.g. show_progress of a fit. auto draws bars on a terminal and writes lines without one. The events are recorded whatever is chosen, they cost a line in a file and nothing on the console.

ResourcesColumn

Bases: ProgressColumn

What of the machine the run uses, on the outermost activity only.

The resources are those of the process, not of the activity, so one line carries them and the bars of the activities inside stay readable, see sbmlsim.progress.resources.

render

render(task)

Render the resources of the run on an outermost task.

RemainingColumn

Bases: ProgressColumn

The estimate of the time which is left, eta H:MM:SS.

The estimate is the one of the activity, see Activity.remaining, which is corrected for the steps its workers process at once. The rate of rich is not used, it is measured over a window of seconds and a step of a run takes minutes.

render

render(task)

Render the estimate of a task.

BarReporter

BarReporter(console=None)

Draw a bar per activity on the console of the package.

An activity which runs in another one is indented by its depth and its bar is removed when it ends; the outermost activities stay until the run ends.

Create the reporter and its display, which is started on demand.

Parameters:

Name Type Description Default
console Console | None

the console of the bars, by default the one of the package.

None

started

started(activity)

Add the bar of an activity, and start the display with the first.

advanced

advanced(activity)

Update the bar of an activity.

finished

finished(activity, error)

Complete the bar of an activity, and stop the display with the last.

LogReporter

LogReporter(interval=None, *, target=None, now=_now)

Write a line per activity, every interval and at its end.

A run without a terminal (a log file, a pipe, continuous integration) says how far it is this way. The interval keeps the file short: the first line of an activity is written when it is older than the interval, so the activities which are over in a moment, e.g. the scans of a fit, write no line at all, and two lines are an interval apart whatever runs, so the workers of a run cannot fill the file between them. The line of an activity which failed is always written.

Create the reporter.

Parameters:

Name Type Description Default
interval float | None

the seconds between two lines of an activity, LOG_INTERVAL by default.

None
target Logger | None

what writes the lines, by default the logger of the progress.

None
now object

the monotonic clock, for the tests.

_now

started

started(activity)

Note the start of an activity, whose line comes after the interval.

advanced

advanced(activity)

Write the line of an activity, at most every interval.

finished

finished(activity, error)

Write the last line of an activity which wrote one, took a while or failed.

EventReporter

EventReporter(throttle=EVENT_THROTTLE, *, now=_now)

Record the progress of the activities in the events of the run.

Something outside the process follows the run by reading progress.jsonl: one progress event when an activity starts, one at most every second while it runs and one when it ends. Outside of a recording the events cost a lookup, see sbmlsim.events.emit.

Create the reporter.

Parameters:

Name Type Description Default
throttle float

the seconds between two events of an activity.

EVENT_THROTTLE
now object

the monotonic clock, for the tests.

_now

started

started(activity)

Record that an activity started.

advanced

advanced(activity)

Record what an activity is at, at most every throttle.

finished

finished(activity, error)

Record that an activity ended, and what it ended by.

MultiReporter

MultiReporter(reporters)

Report to several reporters, a failing one is dropped, see report.

Attributes:

Name Type Description
reporters list[Reporter]

what renders the activities, in the order they are called.

Create the reporter of several reporters.

started

started(activity)

Report the start of an activity to every reporter.

advanced

advanced(activity)

Report a step of an activity to every reporter.

finished

finished(activity, error)

Report the end of an activity to every reporter.

resolve

resolve(setting=None, console=None)

Get the reporter of a setting of the progress.

The events are recorded whatever is chosen, see EventReporter; none means that nothing is rendered for a human.

Parameters:

Name Type Description Default
setting str | bool | None

auto, bar, log, none, True for auto, False for none or None for the environment variable SBMLSIM_PROGRESS.

None
console Console | None

the console of the bars, by default the one of the package.

None

Returns:

Type Description
MultiReporter

The reporter, which is installed with sbmlsim.progress.reporter.