diff options
| author | avi robusta <avi@robusta.dev> | 2023-05-17 16:05:35 +0300 |
|---|---|---|
| committer | avi robusta <avi@robusta.dev> | 2023-05-17 16:05:35 +0300 |
| commit | 179e94aea96f69fc147b8d3337f521be704d53a2 (patch) | |
| tree | cfc7a1916294aead41140172ff0450922e3bfcf0 /robusta_krr/utils/progress_bar.py | |
| parent | 1f417d684417dda2b00763325f6a3869c86809e4 (diff) | |
added loading bar
Diffstat (limited to 'robusta_krr/utils/progress_bar.py')
| -rw-r--r-- | robusta_krr/utils/progress_bar.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/robusta_krr/utils/progress_bar.py b/robusta_krr/utils/progress_bar.py new file mode 100644 index 0000000..cd5038c --- /dev/null +++ b/robusta_krr/utils/progress_bar.py @@ -0,0 +1,24 @@ +from robusta_krr.utils.configurable import Configurable +from alive_progress import alive_bar +from robusta_krr.core.models.config import Config + + +class ProgressBar(Configurable): + def __init__(self, config: Config, **kwargs) -> None: + super().__init__(config) + self.show_bar = self.echo_active + if self.show_bar: + self.alive_bar = alive_bar(**kwargs) + + def __enter__(self): + if self.show_bar: + self.bar = self.alive_bar.__enter__() + return self + + def progress(self): + if self.show_bar: + self.bar() + + def __exit__(self, *args): + if self.show_bar: + self.alive_bar.__exit__(*args)
\ No newline at end of file |
