Skip to content

Commit

Permalink
⬇️ remove tqdm from requirements, add disable progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
lalmei committed Jan 31, 2021
1 parent 4bc5f17 commit e113c14
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/whylogs/app/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import datetime
import hashlib
import json
import logging
from typing import List, Optional, Dict, Union, Callable, AnyStr
from typing.io import IO
from pathlib import Path


from tqdm import tqdm
import pandas as pd


from whylogs.app.writers import Writer
from whylogs.core import DatasetProfile, TrackImage, METADATA_DEFAULT_ATTRIBUTES, TrackBB
from whylogs.io import LocalDataset
Expand All @@ -23,6 +22,8 @@
SegmentTag = Dict[str, any]
Segment = List[SegmentTag]

logger = logging.getLogger(__name__)


class Logger:
"""
Expand Down Expand Up @@ -363,7 +364,7 @@ def log_image(self,

track_image(self._profiles[-1]["full_profile"])

def log_local_dataset(self, root_dir, folder_feature_name="folder_feature", image_feature_transforms=None):
def log_local_dataset(self, root_dir, folder_feature_name="folder_feature", image_feature_transforms=None, show_progress=False):
"""
Log a local folder dataset
It will log data from the files, along with structure file data like
Expand All @@ -378,10 +379,25 @@ def log_local_dataset(self, root_dir, folder_feature_name="folder_feature", imag
Raises:
NotImplementedError: Description
"""
from PIL.Image import Image as ImageType
try:
from PIL.Image import Image as ImageType
except ImportError as e:
ImageType = None
logger.debug(str(e))
logger.debug(
"Unable to load PIL; install Pillow for image support")

if show_progress:
try:
from tqdm import tqdm
except ImportError as e:
show_progress = False
logger.debug(str(e))
logger.debug(
"Unable to load tqdm; install tqdm for progress support")

dst = LocalDataset(root_dir)
for idx in tqdm(range(len(dst))):
for idx in tqdm(range(len(dst)), disable=(not show_progress)):
# load internal and metadata from the next file
((data, magic_data), fmt), segment_value = dst[idx]

Expand Down

0 comments on commit e113c14

Please sign in to comment.