s365b.jobs.progress =================== .. py:module:: s365b.jobs.progress .. autoapi-nested-parse:: Live progress of a running job, saved on the job run for the web UI. The runner reports what it is doing to a :class:`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 ---------- .. autoapisummary:: s365b.jobs.progress.log s365b.jobs.progress.MIN_ITEMS_FOR_ITEM_PROGRESS s365b.jobs.progress.MIN_FRACTION_FOR_ETA s365b.jobs.progress.MIN_SECONDS_FOR_ETA Classes ------- .. autoapisummary:: s365b.jobs.progress.ProgressTracker Module Contents --------------- .. py:data:: log .. py:data:: MIN_ITEMS_FOR_ITEM_PROGRESS :value: 200 .. py:data:: MIN_FRACTION_FOR_ETA :value: 0.02 .. py:data:: MIN_SECONDS_FOR_ETA :value: 20.0 .. py:class:: ProgressTracker(db: s365b.db.session.Database, run_id: int, modules_total: int, interval: float = 3.0, stop: asyncio.Event | None = None) Collects progress for one job run and saves it periodically. :param db: Database. :param run_id: The job run. :param modules_total: Number of modules in the job. :param interval: Seconds between saves. .. py:attribute:: db .. py:attribute:: stop .. py:attribute:: stopped_by :type: str | None :value: None .. py:attribute:: run_id .. py:attribute:: interval :value: 3.0 .. py:attribute:: phase :value: 'starting' .. py:attribute:: modules_total .. py:attribute:: modules_done :value: 0 .. py:attribute:: module :value: '' .. py:attribute:: module_name :value: '' .. py:attribute:: noun :type: tuple[str, str] :value: ('object', 'objects') .. py:attribute:: objects_total :value: 0 .. py:attribute:: objects_done :value: 0 .. py:attribute:: objects_failed :value: 0 .. py:attribute:: items_expected :type: int | None :value: None .. py:attribute:: module_items :value: 0 .. py:attribute:: module_started .. py:attribute:: totals .. py:attribute:: active :type: dict[int, _Active] .. py:attribute:: expected :type: dict[int, int | None] .. py:attribute:: started_at .. py:method:: start_module(module_id: str, name: str, noun: tuple[str, str], objects_total: int) -> None A module starts: discovery is done, objects are known. .. py:method:: set_phase(phase: str) -> None Set the phase: discovering, estimating, backing_up (or restoring), finishing. .. py:method:: set_estimates(estimates: dict[int, int | None]) -> None Record per-object item estimates (``None`` where unknown). .. py:method:: object_started(key: int, name: str) -> None An object's backup started. .. py:method:: object_progress(key: int, *, done: int = 0, total: int | None = None, message: str = '', unit: str = '', **_: Any) -> None The module reported progress within an object (``ctx.progress``). .. py:method:: object_stats(key: int, stats: s365b.core.catalog.VersionStats) -> None Items stored for an object since the last report. .. py:method:: object_finished(key: int, failed: bool) -> None An object's backup ended. .. py:method:: finish_module() -> None A module's objects are all done. .. py:method:: fraction() -> float | None Estimated share of the current module that is done (0 to 1). .. py:method:: snapshot() -> dict[str, Any] The progress document saved on the job run. .. py:method:: save() -> None :async: Write the current snapshot to the job run; notice stop requests.