Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added custom progress bar for get data #361

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/autolabel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
from string import Formatter
from typing import Any, Dict, Iterable, List, Optional, Sequence, Union
import shutil

import regex
import wget
Expand Down Expand Up @@ -260,6 +261,11 @@ def get_data(dataset_name: str, force: bool = False):
if false then downloads onlyif the files are not present locally
"""

def download_bar(current, total, width = 80):
"""custom progress bar for downloading data """
width = shutil.get_terminal_size()[0]//2
print(f"{current//total*100}% [{'.' * (current//total * int(width))}] [{current}/{total}] bytes",end='\r')

def download(url: str) -> None:
"""Downloads the data given an url"""
file_name = os.path.basename(url)
Expand All @@ -269,7 +275,8 @@ def download(url: str) -> None:

if not os.path.exists(file_name):
print(f"Downloading example dataset from {url} to {file_name}...")
wget.download(url)
wget.download(url, bar = download_bar)


if dataset_name not in EXAMPLE_DATASETS:
logger.error(
Expand Down