-
Notifications
You must be signed in to change notification settings - Fork 3
Use tqdm for operations with longer durations #324
Copy link
Copy link
Open
Labels
featureProduct featureProduct feature
Description
And display a nice progress bar
Proposed use cases
- build docker container
- upload to BucketFS
Sample implementation:
import contextlib
from pathlib import Path
import exasol.bucketfs as bfs
import tqdm
def upload_file_to_bucketfs(bfs_file: bfs.path.PathLike, file: Path) -> None:
"""
If leave is False, then hide progress bar after upload.
If leave is not specified (default), then progress bar remains
visible after upload is completed.
"""
print(f'Uploading {file.name} to bucketfs:/{bfs_file.parent}')
size = file.stat().st_size
with contextlib.ExitStack() as stack:
fd = stack.enter_context(file.open("rb"))
progress = stack.enter_context(
tqdm.tqdm.wrapattr(
fd,
"read",
total=size,
unit='B',
unit_scale=True,
unit_divisor=1024,
colour="green",
leave=False, # see above
)
)
bfs_file.write(progress)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureProduct featureProduct feature