Skip to content

Commit

Permalink
✨ logger method
Browse files Browse the repository at this point in the history
  • Loading branch information
lalmei committed Jan 26, 2021
1 parent 5fd052a commit 2140a66
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/whylogs/app/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from typing.io import IO

from whylogs.app.writers import Writer
from whylogs.core import DatasetProfile, TrackImage, METADATA_DEFAULT_ATTRIBUTES

from whylogs.core import DatasetProfile, TrackImage, METADATA_DEFAULT_ATTRIBUTES, TrackBB
from whylogs.io import LocalDataset
TIME_ROTATION_VALUES = ["s", "m", "h", "d"]

# TODO upgrade to Classes
Expand Down Expand Up @@ -359,14 +359,27 @@ def log_image(self,

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

# def log_dataset(self, root_dir):
# dst = LocalDataset(root_dir, file_loader=lambda x: x)
# for idx in range(len(dst)):
# data, fmt = dst[idx]
# if ftm == "csv":
# log_dataframe(data)
# elif ftm == "image":
# log_image(data)
def log_local_dataset(self, root_dir):
from PIL.Image import Image as ImageType
dst = LocalDataset(root_dir, file_loader=lambda x: x)
for idx in range(len(dst)):
(data, magic_data), fmt = dst[idx]
self.log(feature_name="file_format", data=fmt)
self.log(feature=magic_data)
if isinstance(data, pd.DataFrame):
self.log_dataframe(data)
elif isinstance(data, Dict) or isinstance(data, list):
self.log_annotation(annotation_data=data)
elif isinstance(data, ImageType):
self.log_image(data)
else:
raise NotImplementedError("File format not supported")

def log_annotation(self, annotation_data):
if not self.tracking_checks():
return None
track_bounding_box = TrackBB(obj=annotation_data)
track_bounding_box(self._profiles[-1]["full_profile"])

def log_csv(self,
filepath_or_buffer: Union[str, Path, IO[AnyStr]],
Expand Down

0 comments on commit 2140a66

Please sign in to comment.