question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to directly access one of the fields in tasks.fields in a Progress Bar?

See original GitHub issue

Hi, first of all this library is really really great, thank you for the great work.

As for the subject of this post, I currently have a progress bar defined by:

progress_bar = Progress(
    "[blue]{task.description}",
    BarColumn(),
    "[progress.percentage]{task.percentage:>3.0f}%",
    TimeRemainingColumn(),
    "[yellow]{task.fields}",  # <-- relevant part
)
task = self.progress_bar.add_task(label, total=total_frames)

I am updating it with bar.update(self.task, advance=1, fps=f"{fps:.2f}") and it runs just fine, with the progress bar displaying my fps as part of a dict, which would look something like {'fps': '6.60'} at the end of the progress bar. This is a bit unsightly in my opinion, as I’d really prefer not to print it as a dict, with all its {s and 's. I would prefer to be able to chose exactly in what format my fields get printed in the progress bar.

Is there a way to chose exactly which field to show and with what format, without printing as a dict? I tried things like "[yellow]{task.fields.fps}fps" or "[yellow]{task.fields['fps']}fps" but it doesn’t work.

If this is not the case of me missing something obvious, it would be great to have this as a feature as it would allow us to chose how our custom fields look like.

Thanks for the awesome library by the way!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
joaqocommented, Aug 4, 2020

Perfect, that fixed it, thanks a lot again! I don’t think I’ve ever seen a dev answer so quickly on such a large open source project, kudos!

PD: For anyone reading this issue, if you want ipdb or pdb to work with progress bars set:

redirect_stderr=False
redirect_stdout=False
auto_refresh=False

in your Progress() constructor, and refresh your progress bar manually in your update method by setting refresh=True there.

1reaction
willmcgugancommented, Aug 4, 2020

Both are writing to stdout, so it might be a problem.

Possibly the refresh thread is making it worse. Try setting auto_refresh=False for testing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to directly access one of the fields in tasks.fields ...
in your Progress() constructor, and refresh your progress bar manually in your update method by setting refresh=True there.
Read more >
Progress Display — Rich 12.6.0 documentation
Rich progress display supports multiple tasks, each with a bar and progress information. You can use this to track concurrent tasks where the...
Read more >
Display rollup progress or totals in Azure Boards
Rollup columns allow you to view progress bars or totals of numeric fields for descendant items within a hierarchy.
Read more >
Display a Custom Progress Bar in Microsoft Access Forms ...
Learn how to use the Microsoft ActiveX ProgressBar control that comes with Microsoft Access. I don't like using external controls, however.
Read more >
Progress Bar 2: Show Completion Progress of a Form with a ...
Learn how to use a Progress Bar to show the completion progress of a form with a large number of fields on it.LEVEL:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found