-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(progress): progress bar wrapper of
rich.progress
- Loading branch information
Showing
4 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from typing import Iterable, Sequence, Union | ||
|
||
from rich.progress import ( | ||
BarColumn, | ||
MofNCompleteColumn, | ||
Progress, | ||
TextColumn, | ||
TimeElapsedColumn, | ||
TimeRemainingColumn, | ||
) | ||
|
||
|
||
def log_progress(iterable: Union[Iterable, Sequence]): | ||
""" | ||
Log an iterable or sequence using a progress bar. | ||
Wraps `rich.progress.Progress.track`. | ||
### Parameters | ||
---------- | ||
`iterable`: the iterable whose progress to log. | ||
### Returns | ||
------- | ||
The tracked iterable. | ||
""" | ||
|
||
bar = Progress( | ||
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"), | ||
BarColumn(), | ||
MofNCompleteColumn(), | ||
TextColumn("•"), | ||
TimeElapsedColumn(), | ||
TextColumn("•"), | ||
TimeRemainingColumn(), | ||
) | ||
bar.__enter__() | ||
return bar.track(iterable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "mloggers" | ||
version = "1.0.2" | ||
version = "1.1.0" | ||
authors = [ | ||
{ name = "Sergio Hernandez Gutierrez", email = "[email protected]" }, | ||
] | ||
|
@@ -16,7 +16,7 @@ classifiers = [ | |
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
] | ||
dependencies = ["aenum", "numpy", "omegaconf", "termcolor", "wandb"] | ||
dependencies = ["aenum", "numpy", "omegaconf", "termcolor", "wandb", "rich"] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/serhez/mloggers" | ||
|