Progress#
Live progress display for orchestrator drains.
A drain runs a queue of jobs. On an interactive terminal it can show how far the sweep has got, the elapsed time and an estimated time remaining. The estimate is based on the jobs that actually executed, so a sweep that mostly reuses cached results does not overstate how long is left.
The display degrades gracefully. rich is used when it is importable, a
plain ANSI line otherwise, and nothing at all when the output is not a
terminal. There is no hard dependency on any third-party package.
- class krum.orchestration.progress.Failure(key: str, params: Mapping[str, Any], error: str, path: Path | None = None)[source]#
Bases:
objectWhat a failed job needs to be diagnosed from the console.
Carries the job’s identity, the parameters it ran with, the folder its traceback was written to, and the traceback itself.
- class krum.orchestration.progress.NullProgress[source]#
Bases:
objectA progress display that renders nothing.
- class krum.orchestration.progress.Progress(*args, **kwargs)[source]#
Bases:
ProtocolA live progress display for a single drain.
- advance(*, ran: bool, rerun: bool = False, duration: float = 0.0, description: str = '') None[source]#
Record one completed job.
- Parameters:
ran – Whether the job actually executed, as opposed to being reused from the cache.
rerun – Whether the job is being retried after a previous failed attempt.
duration – How long the job took to execute, in seconds. Ignored when
ranis false.description – A short label for the job just finished.
- krum.orchestration.progress.describe_params(params: Mapping[str, Any], limit: int | None = 80) str[source]#
Render a job’s parameters as a
k=v · k=vstring.Class values are shortened to their qualified name, and the whole string is capped so a wide sweep does not fill the terminal. Pass
limit=Noneto keep every parameter, which is what a failure report does.
- krum.orchestration.progress.make_progress(total: int, runs_total: int, *, stream: TextIO | None = None) Progress[source]#
Build the best display writing to
stream, or a no-op without one.- Parameters:
total – The number of jobs in the drain.
runs_total – How many of them will actually execute, the rest being reused from the cache.
stream – The stream to draw on, as returned by
progress_stream().Nonedisables the display.
- Returns:
A no-op without a stream, a rich bar when ``rich`` is importable, and a
plain ANSI line otherwise.
- krum.orchestration.progress.progress_stream(enabled: bool | TextIO) TextIO | None[source]#
The stream a display would draw on, or None when it would draw nothing.
Truemeans the default stream, standard error, and only when it is a terminal: a sweep whose output is redirected gets no escape codes. A stream passed explicitly is always drawn on, since asking for one is the point.