s365b.jobs.progress

Live progress of a running job, saved on the job run for the web UI.

The runner reports what it is doing to a ProgressTracker; the tracker keeps it in memory and writes a snapshot to job_run.progress every few seconds, so a busy backup does not write to the database for every item.

Percent and time left are estimates. When the module can estimate the items each object will process (Exchange counts the messages in folders not yet backed up), progress is by items; otherwise it is by objects.

Attributes

Classes

ProgressTracker

Collects progress for one job run and saves it periodically.

Module Contents

s365b.jobs.progress.log[source]
s365b.jobs.progress.MIN_ITEMS_FOR_ITEM_PROGRESS = 200[source]
s365b.jobs.progress.MIN_FRACTION_FOR_ETA = 0.02[source]
s365b.jobs.progress.MIN_SECONDS_FOR_ETA = 20.0[source]
class s365b.jobs.progress.ProgressTracker(db: s365b.db.session.Database, run_id: int, modules_total: int, interval: float = 3.0, stop: asyncio.Event | None = None)[source]

Collects progress for one job run and saves it periodically.

Parameters:
  • db – Database.

  • run_id – The job run.

  • modules_total – Number of modules in the job.

  • interval – Seconds between saves.

db[source]
stop[source]
stopped_by: str | None = None[source]
run_id[source]
interval = 3.0[source]
phase = 'starting'[source]
modules_total[source]
modules_done = 0[source]
module = ''[source]
module_name = ''[source]
noun: tuple[str, str] = ('object', 'objects')[source]
objects_total = 0[source]
objects_done = 0[source]
objects_failed = 0[source]
items_expected: int | None = None[source]
module_items = 0[source]
module_started[source]
totals[source]
active: dict[int, _Active][source]
expected: dict[int, int | None][source]
started_at[source]
start_module(module_id: str, name: str, noun: tuple[str, str], objects_total: int) → None[source]

A module starts: discovery is done, objects are known.

set_phase(phase: str) → None[source]

Set the phase: discovering, estimating, backing_up (or restoring), finishing.

set_estimates(estimates: dict[int, int | None]) → None[source]

Record per-object item estimates (None where unknown).

object_started(key: int, name: str) → None[source]

An object’s backup started.

object_progress(key: int, *, done: int = 0, total: int | None = None, message: str = '', unit: str = '', **_: Any) → None[source]

The module reported progress within an object (ctx.progress).

object_stats(key: int, stats: s365b.core.catalog.VersionStats) → None[source]

Items stored for an object since the last report.

object_finished(key: int, failed: bool) → None[source]

An object’s backup ended.

finish_module() → None[source]

A module’s objects are all done.

fraction() → float | None[source]

Estimated share of the current module that is done (0 to 1).

snapshot() → dict[str, Any][source]

The progress document saved on the job run.

async save() → None[source]

Write the current snapshot to the job run; notice stop requests.