Skip to content
Open
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
13 changes: 10 additions & 3 deletions cleanlab_studio/internal/dataset_source/filepath_dataset_source.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import mimetypes
import os
import pathlib
from typing import Any, Optional
import os

from .dataset_source import DatasetSource
from cleanlab_studio.errors import InvalidDatasetError, InvalidFilepathError

from .dataset_source import DatasetSource


class FilepathDatasetSource(DatasetSource):
def __init__(
Expand All @@ -21,7 +22,13 @@ def __init__(

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(filepath)[0]

maybe_file_type: Optional[str]
if filepath.suffix.lower() == ".jsonl":
maybe_file_type = "application/json"
else:
maybe_file_type = mimetypes.guess_type(filepath)[0]

if maybe_file_type is None:
raise InvalidDatasetError(
f"Could not identify type of file at {filepath}. Make sure file name has valid extension"
Expand Down