feat: oxidized progress bars
Metadata
Current evaluation
Merged into main in canonical/craft-cli#426, implementing the redesigned Emitter.progress_bar API and oxidized progress-bar output for CRAFT-4983.
Resolution: closed resolved
Reason: The feature PR itself was approved and merged, adding the new Emitter.progress_bar API and its supporting implementation, tests, and documentation.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the guidelines for contributing?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `make lint && make test`?
---
Implements the `progress_bar` method for the emitter. This one has an entirely different API from the existing one, but comes with far more content.
The exact appearance of the progress bar doesn't need much review, as the design team and I have not landed on an approved appearance yet.
I strongly recommend reviewing per-commit.
Here's a script that showcases some of the new behavior and gives a good starting point for testing by hand:
```py
import logging
from time import sleep
from craft_cli import Emitter, Verbosity
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
e = Emitter(Verbosity.BRIEF, "blah.log", "Hello", streaming_brief=True)
logger.info("Testing")
TOTAL_NUMBERS = 50
with e.progress_bar("Crunching the numbers", TOTAL_NUMBERS, show_progress=True, show_percentage=True) as prog:
# An overflow just keeps counting over the total.
for i in range(TOTAL_NUMBERS + 10):
prog.tick()
sleep(0.1)
if i % 25 == 0:
logger.warning("⚠️ Booping imminent ⚠️")
sleep(0.1)
prog.println("Boop")
# Can't increment with a negative
try:
prog.inc(-1)
except OverflowError as err:
prog.println(f"Caught: {err}")
prog.println("Phew, that was close.")
# Can't use emitter methods while progress bar is active
try:
e.message("MOM SAID IT'S MY TURN WITH THE TTY")
except RuntimeError as err:
prog.println(f"Caught: {err}")
prog.println("I get one more CPU cycle!")
e.message("Done")
```
CRAFT-4983
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged into main in canonical/craft-cli#426, implementing the redesigned Emitter.progress_bar API and oxidized progress-bar output for CRAFT-4983. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged in craft-cli#426, adding the redesigned Emitter progress_bar API and oxidized progress-bar output. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged. Implements a new progress_bar method for the emitter. Author addressed reviewer feedback on error handling, fixing immediate issues and deferring thread-safety to a follow-up ticket. Approved by two reviewers. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #428 feat: support units for progress bars | craft-cli | merged | PR #428 by bepri merged (commit bca0d66), adding a `units` parameter to Emitter.progress_bar so progress bars can label units; shipped in craft-cli 3.4.0. | |
| #7 Added the 'progress' method to send progress messages (CRAFT-98). | craft-cli | merged | Merged PR #7 added Emitter.progress() for progress messages (CRAFT-98) in commit 079c538; merge commit: 77a34cc. |