Skip to content

Commit

Permalink
Autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
seyuboglu committed Mar 14, 2023
1 parent d28e68d commit af64fdc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion meerkat/columns/deferred/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def load_audio(path: str) -> Audio:
"loader": load_audio,
"formatters": DeferredAudioFormatterGroup,
"exts": [".wav", ".mp3"],
"defer": False
"defer": False,
},
}

Expand Down
7 changes: 5 additions & 2 deletions meerkat/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ def from_huggingface(cls, *args, **kwargs):
>>> dict_of_dataframes = DataFrame.from_huggingface('boolq')
"""
import datasets

datasets.logging.set_verbosity_error()
import pyarrow.compute as pc

Expand All @@ -700,6 +701,7 @@ def _convert_columns(dataset: datasets.Dataset):
)
elif (~path.isnull()).all():
from meerkat.columns.deferred.file import FileColumn

df[name] = FileColumn(path, type="audio")
else:
raise ValueError(
Expand All @@ -711,10 +713,12 @@ def _convert_columns(dataset: datasets.Dataset):
bytes = ArrowScalarColumn(pc.struct_field(column._data, "bytes"))
path = ArrowScalarColumn(pc.struct_field(column._data, "path"))
if (~ArrowScalarColumn(bytes).isnull()).all():
from meerkat.interactive.formatter import ImageFormatterGroup
import io

from PIL import Image

from meerkat.interactive.formatter import ImageFormatterGroup

df[name] = bytes.defer(
lambda x: Image.open(io.BytesIO(x))
).format(ImageFormatterGroup().defer())
Expand All @@ -741,7 +745,6 @@ def _convert_columns(dataset: datasets.Dataset):
)
)
else:
df = cls.from_arrow(dataset._data)
return _convert_columns(dataset)

@classmethod
Expand Down
7 changes: 6 additions & 1 deletion meerkat/interactive/formatter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
from .base import Formatter, deferred_formatter_group
from .boolean import BooleanFormatter, BooleanFormatterGroup
from .code import CodeFormatter, CodeFormatterGroup
from .image import ImageFormatter, ImageFormatterGroup, DeferredImageFormatter, DeferredImageFormatterGroup
from .image import (
DeferredImageFormatter,
DeferredImageFormatterGroup,
ImageFormatter,
ImageFormatterGroup,
)
from .number import NumberFormatter, NumberFormatterGroup
from .pdf import PDFFormatter, PDFFormatterGroup
from .raw_html import HTMLFormatter, HTMLFormatterGroup
Expand Down

0 comments on commit af64fdc

Please # to comment.