Skip to content

Commit

Permalink
guess filetype from filename instead of dataset name
Browse files Browse the repository at this point in the history
  • Loading branch information
axl1313 committed Jul 19, 2023
1 parent fbc6f6b commit 52a6c40
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

class FilepathDatasetSource(DatasetSource):
def __init__(
self, *args: Any, filepath: pathlib.Path, dataset_name: Optional[str] = None, **kwargs: Any
self,
*args: Any,
filepath: pathlib.Path,
dataset_name: Optional[str] = None,
**kwargs: Any,
):
super().__init__(*args, **kwargs)
self.dataset_name = dataset_name if dataset_name is not None else filepath.name
self.file_size = filepath.stat().st_size
maybe_file_type = mimetypes.guess_type(self.dataset_name)[0]
maybe_file_type = mimetypes.guess_type(filepath)[0]
if maybe_file_type is None:
raise ValueError(
f"Could not identify type of file at {filepath}. Make sure file name has valid extension"
Expand Down

0 comments on commit 52a6c40

Please sign in to comment.