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

support for uploading .jsonl files #273

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
Loading