Download tabula_nova/progress.py from mirgedw/tabula-nova-157m: direct link, hf CLI and curl.
- Browser
- Download file 900 Bytes
-
https://huggingface.co/mirgedw/tabula-nova-157m/resolve/main/tabula_nova/progress.py
- Command line
-
hf download hf://mirgedw/tabula-nova-157m/tabula_nova/progress.py
-
curl -L -o progress.py https://huggingface.co/mirgedw/tabula-nova-157m/resolve/main/tabula_nova/progress.py
900 Bytes
| """Terminal progress without changing machine-readable stdout or GPU execution.""" | |
| import os | |
| import sys | |
| from tqdm import tqdm | |
| def progress_enabled(): | |
| setting = os.environ.get('TABULA_PROGRESS', 'auto').strip().lower() | |
| if setting in ('1', 'true', 'yes', 'on'): | |
| return True | |
| if setting in ('0', 'false', 'no', 'off'): | |
| return False | |
| return bool(getattr(sys.stderr, 'isatty', lambda: False)()) | |
| def progress(iterable=None, **options): | |
| options.setdefault('disable', not progress_enabled()) | |
| options.setdefault('file', sys.stderr) | |
| options.setdefault('dynamic_ncols', True) | |
| options.setdefault('mininterval', 0.5) | |
| options.setdefault('delay', 0.5) | |
| return tqdm(iterable, **options) | |
| def progress_write(message): | |
| # Clear/repaint any active bars around a normal stdout status message. | |
| tqdm.write(message, file=sys.stdout) | |
| sys.stdout.flush() | |