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: guess filetype from filename instead of dataset name #116

Merged
merged 1 commit into from
Jul 19, 2023
Merged
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
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
Loading