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

fix test failures #364

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions src/autolabel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,14 @@ 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_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 @@ -275,8 +278,7 @@ 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, bar = download_bar)

wget.download(url, bar=download_bar)

if dataset_name not in EXAMPLE_DATASETS:
logger.error(
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test utils"""
from typing import Optional, Any

import tempfile
import os
Expand All @@ -24,7 +25,9 @@ def assert_text_remove(file_name_: str, text: str):
assert file_content == text
os.remove(file_name)

def generate_tempfile_with_content(input_url: str) -> None:
def generate_tempfile_with_content(
input_url: str, bar: Optional[Any] = None
) -> None:
"""Generate a Temporary file with dummy content"""
with tempfile.NamedTemporaryFile(dir="./", delete=False) as tmp_file:
file_name = os.path.basename(input_url)
Expand Down