repo_id
stringlengths
15
89
file_path
stringlengths
27
180
content
stringlengths
1
2.23M
__index_level_0__
int64
0
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/doc_utils.py
from typing import Callable def is_documented_by(function_with_docstring: Callable): """Decorator to share docstrings across common functions. Args: function_with_docstring (`Callable`): Name of the function with the docstring. """ def wrapper(target_function): target_function.__doc_...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/metadata.py
import textwrap from collections import Counter from pathlib import Path from typing import Any, ClassVar, Dict, Optional, Tuple, Union import yaml from huggingface_hub import DatasetCardData from ..config import METADATA_CONFIGS_FIELD from ..utils.logging import get_logger from .deprecation_utils import deprecated ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/readme.py
# loading package files: https://stackoverflow.com/a/20885799 import importlib.resources as pkg_resources import logging from pathlib import Path from typing import Any, List, Tuple import yaml from . import resources from .deprecation_utils import deprecated BASE_REF_URL = "https://github.com/huggingface/datasets/...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/sharding.py
from typing import List import numpy as np def _number_of_shards_in_gen_kwargs(gen_kwargs: dict) -> int: """Return the number of possible shards according to the input gen_kwargs""" # Having lists of different sizes makes sharding ambigious, raise an error in this case # until we decide how to define sha...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/filelock.py
# deprecated, please use the `filelock` package instead from filelock import ( # noqa: F401 # imported for backward compatibility TODO: remove in 3.0.0 BaseFileLock, SoftFileLock, Timeout, UnixFileLock, WindowsFileLock, ) from ._filelock import FileLock # noqa: F401 # imported for backward compa...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/deprecation_utils.py
import enum import inspect import warnings from functools import wraps from typing import Callable, Optional from .logging import get_logger _emitted_deprecation_warnings = set() logger = get_logger(__name__) def deprecated(help_message: Optional[str] = None): """Decorator to mark a class or a function as depr...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/logging.py
# Copyright 2020 Optuna, Hugging Face # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/file_utils.py
""" Utilities for working with the local dataset cache. This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp Copyright by the AllenNLP authors. """ import copy import io import json import os import posixpath import re import shutil import sys import time import urllib import warnings ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/info_utils.py
import enum import os from typing import Optional from huggingface_hub.utils import insecure_hashlib from .. import config from .logging import get_logger logger = get_logger(__name__) class VerificationMode(enum.Enum): """`Enum` that specifies which verification checks to run. The default mode is `BASIC...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/extract.py
import bz2 import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from ._filelock import FileLock from .logging import get_logger ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/download_manager.py
# deprecated, please use datasets.download.download_manager
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/patching.py
from importlib import import_module from .logging import get_logger logger = get_logger(__name__) class _PatchedModuleObj: """Set all the modules components as attributes of the _PatchedModuleObj object.""" def __init__(self, module, attrs=None): attrs = attrs or [] if module is not None: ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/typing.py
import os from typing import Dict, List, Tuple, TypeVar, Union T = TypeVar("T") ListLike = Union[List[T], Tuple[T, ...]] NestedDataStructureLike = Union[T, List[T], Dict[str, T]] PathLike = Union[str, bytes, os.PathLike]
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/__init__.py
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/_filelock.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/utils/version.py
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
0
hf_public_repos/datasets/src/datasets/utils
hf_public_repos/datasets/src/datasets/utils/resources/readme_structure.yaml
name: "" # Filename comes here allow_empty: false allow_empty_text: true subsections: - name: "Dataset Card for X" # First-level markdown heading allow_empty: false allow_empty_text: true subsections: - name: "Table of Contents" allow_empty: false allow_empty_text: false subs...
0
hf_public_repos/datasets/src/datasets/utils
hf_public_repos/datasets/src/datasets/utils/resources/multilingualities.json
{ "monolingual": "contains a single language", "multilingual": "contains multiple languages", "translation": "contains translated or aligned text", "other": "other type of language distribution" }
0
hf_public_repos/datasets/src/datasets/utils
hf_public_repos/datasets/src/datasets/utils/resources/size_categories.json
[ "unknown", "n<1K", "1K<n<10K", "10K<n<100K", "100K<n<1M", "1M<n<10M", "10M<n<100M", "100M<n<1B", "1B<n<10B", "10B<n<100B", "100B<n<1T", "n>1T" ]
0
hf_public_repos/datasets/src/datasets/utils
hf_public_repos/datasets/src/datasets/utils/resources/creators.json
{ "language": [ "found", "crowdsourced", "expert-generated", "machine-generated", "other" ], "annotations": [ "found", "crowdsourced", "expert-generated", "machine-generated", "no-annotation", "other" ] }
0
hf_public_repos/datasets/src/datasets/utils
hf_public_repos/datasets/src/datasets/utils/resources/languages.json
{ "code": "Programming language (C++, Java, Javascript, Python, etc.)", "aa": "Afar", "aaa": "Ghotuo", "aab": "Alumu-Tesu", "aac": "Ari", "aad": "Amal", "aae": "Arbëreshë Albanian", "aaf": "Aranadan", "aag": "Ambrak", "aah": "Abu' Arapesh", "aai": "Arifama-Miniafia", "aak...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/parallel/parallel.py
import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging logger = logging.get_logger(__name__) class ParallelBackendConfig: backend_name = None @experimental def parallel_map(function, iterable, num_proc, types, disable_tqdm, desc, single...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/parallel/__init__.py
from .parallel import parallel_backend, parallel_map, ParallelBackendConfig # noqa F401
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/download/mock_download_manager.py
# Copyright 2020 The TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/download/download_config.py
import copy import warnings from dataclasses import InitVar, dataclass, field from pathlib import Path from typing import Any, Dict, Optional, Union from .. import config @dataclass class DownloadConfig: """Configuration for our cached path manager. Attributes: cache_dir (`str` or `Path`, *optional*...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/download/streaming_download_manager.py
import glob import io import os import posixpath import re import tarfile import time import xml.dom.minidom import zipfile from asyncio import TimeoutError from io import BytesIO from itertools import chain from pathlib import Path, PurePosixPath from typing import Any, Callable, Dict, Generator, Iterable, List, Optio...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/download/download_manager.py
# Copyright 2020 The TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/download/__init__.py
__all__ = [ "DownloadConfig", "DownloadManager", "DownloadMode", "StreamingDownloadManager", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/language_modeling.py
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=True) class LanguageModeling(TaskTemplate): task: str = field(default="language-modeling", metadata={"include_in_asdict_even_if_is_default": True}) ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/text_classification.py
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=True) class TextClassification(TaskTemplate): # `task` is not a ClassVar since we want it to be part of the `asdict` output fo...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/question_answering.py
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=True) class QuestionAnsweringExtractive(TaskTemplate): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSO...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/automatic_speech_recognition.py
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=True) class AutomaticSpeechRecognition(TaskTemplate): task: str = field(default="automatic-speech-recognition", metadata={"include_...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/base.py
import abc import copy import dataclasses from dataclasses import dataclass from typing import ClassVar, Dict, Type, TypeVar from ..features import Features T = TypeVar("T", bound="TaskTemplate") @dataclass(frozen=True) class TaskTemplate(abc.ABC): # `task` is not a ClassVar since we want it to be part of the ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/image_classification.py
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=True) class ImageClassification(TaskTemplate): task: str = field(default="image-classification", metadata={"include_in_asdict_...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/audio_classification.py
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=True) class AudioClassification(TaskTemplate): task: str = field(default="audio-classification", metadata={"include_in_asdict_...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/__init__.py
from typing import Optional from ..utils.logging import get_logger from .audio_classification import AudioClassification from .automatic_speech_recognition import AutomaticSpeechRecognition from .base import TaskTemplate from .image_classification import ImageClassification from .language_modeling import LanguageModel...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/tasks/summarization.py
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=True) class Summarization(TaskTemplate): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization task...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/jax_formatter.py
# Copyright 2021 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/np_formatter.py
# Copyright 2020 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/formatting.py
# Copyright 2020 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/torch_formatter.py
# Copyright 2020 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/__init__.py
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/formatting/tf_formatter.py
# Copyright 2020 The HuggingFace Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/packaged_modules/__init__.py
import inspect import re from typing import Dict, List from huggingface_hub.utils import insecure_hashlib from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql imp...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/generator/generator.py
from dataclasses import dataclass from typing import Callable, Optional import datasets @dataclass class GeneratorConfig(datasets.BuilderConfig): generator: Optional[Callable] = None gen_kwargs: Optional[dict] = None features: Optional[datasets.Features] = None def __post_init__(self): asser...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/arrow/arrow.py
import itertools from dataclasses import dataclass from typing import Optional import pyarrow as pa import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ArrowConfig(datasets.BuilderConfig): """BuilderConfig for Arrow.""" features: Opt...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/csv/csv.py
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_util...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/spark/spark.py
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from dataset...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/parquet/parquet.py
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) @dataclass class ParquetConfig(datasets.BuilderConfig): """BuilderCo...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/imagefolder/imagefolder.py
from typing import List import datasets from datasets.tasks import ImageClassification from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class ImageFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """BuilderConfig for ImageFolder.""" ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/folder_based_builder/folder_based_builder.py
import collections import itertools import os from dataclasses import dataclass from typing import List, Optional, Tuple, Type import pandas as pd import pyarrow as pa import pyarrow.json as paj import datasets from datasets.features.features import FeatureType from datasets.tasks.base import TaskTemplate logger = ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/webdataset/webdataset.py
import io import json from itertools import islice from typing import Any, Callable, Dict, List import numpy as np import pyarrow as pa import datasets logger = datasets.utils.logging.get_logger(__name__) class WebDataset(datasets.GeneratorBasedBuilder): DEFAULT_WRITER_BATCH_SIZE = 100 IMAGE_EXTENSIONS: L...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/webdataset/_tenbin.py
# # Copyright (c) 2017-2021 NVIDIA CORPORATION. All rights reserved. # This file coems from the WebDataset library. # See the LICENSE file for licensing terms (BSD-style). # """ Binary tensor encodings for PyTorch and NumPy. This defines efficient binary encodings for tensors. The format is 8 byte aligned and can be ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/json/json.py
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline logger = datasets.utils.logging.get_logger(__name__) @dataclass ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/audiofolder/audiofolder.py
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder logger = datasets.utils.logging.get_logger(__name__) class AudioFolderConfig(folder_based_builder.FolderBasedBuilderConfig): """Builder Config for AudioFolder.""" ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/sql/sql.py
import sys from dataclasses import dataclass from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast if TYPE_CHECKING: im...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/text/text.py
import itertools import warnings from dataclasses import InitVar, dataclass from io import StringIO from typing import Optional import pyarrow as pa import datasets from datasets.features.features import require_storage_cast from datasets.table import table_cast logger = datasets.utils.logging.get_logger(__name__) ...
0
hf_public_repos/datasets/src/datasets/packaged_modules
hf_public_repos/datasets/src/datasets/packaged_modules/pandas/pandas.py
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class PandasConfig(datasets.BuilderConfig): """BuilderConfig for Pandas.""" features: Optional[datasets.Features] = None ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/spark.py
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class SparkDatasetReader(AbstractDatasetReader): """A dataset reader that reads from a Spark DataFrame. ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/text.py
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class TextDatasetReader(AbstractDatasetReader): def __init__( self, path_or_paths: Nest...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/csv.py
import multiprocessing import os from typing import BinaryIO, Optional, Union from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.csv.csv import Csv from ..utils import tqdm as hf_tqdm from ..utils.typing import NestedDataStructureLike, PathLike from .abc i...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/sql.py
import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import tqdm as hf_tqdm from .abc import AbstractDatasetInputStream if TYPE_CHECKING: import sqlite3 i...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/parquet.py
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_MO...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/json.py
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import tqdm as hf_tqdm from ..utils.typing import NestedDataStructureLike, Pa...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/abc.py
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class AbstractDatasetReader(ABC): def __init__( self, path_or_paths: ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/io/generator.py
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class GeneratorDatasetInputStream(AbstractDatasetInputStream): def __init__( self, generator: Callable, features: Optional...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/features/audio.py
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..download.streaming_download_manager import xopen, ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/features/translation.py
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class Translation: """`FeatureConnector` for translations with fixed languages per example. Here for ...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/features/image.py
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.download_config import DownloadConfig from ..download.streamin...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/features/features.py
# Copyright 2020 The HuggingFace Datasets Authors and the TensorFlow Datasets Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/features/__init__.py
# flake8: noqa __all__ = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import Array2D, Array3D, Array4D, Array5D, Cla...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/dummy_data.py
import fnmatch import json import os import shutil import tempfile import xml.etree.ElementTree as ET from argparse import ArgumentParser from pathlib import Path from typing import Optional from datasets import config from datasets.commands import BaseDatasetsCLICommand from datasets.download.download_config import D...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/env.py
import platform from argparse import ArgumentParser import fsspec import huggingface_hub import pandas import pyarrow from datasets import __version__ as version from datasets.commands import BaseDatasetsCLICommand def info_command_factory(_): return EnvironmentCommand() class EnvironmentCommand(BaseDatasetsC...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/run_beam.py
import os from argparse import ArgumentParser from pathlib import Path from shutil import copyfile from typing import List from datasets import config from datasets.builder import DatasetBuilder from datasets.commands import BaseDatasetsCLICommand from datasets.download.download_config import DownloadConfig from datas...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/convert.py
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger HIGHLIGHT_MESSAGE_PRE = """<<<<<<< This should probably be modified because it mentions: """ HIGHLIGHT_MESSAGE_POST = """======= >>>>>>>...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/test.py
import logging import os from argparse import ArgumentParser from pathlib import Path from shutil import copyfile, rmtree from typing import Generator import datasets.config from datasets.builder import DatasetBuilder from datasets.commands import BaseDatasetsCLICommand from datasets.download.download_manager import D...
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/__init__.py
from abc import ABC, abstractmethod from argparse import ArgumentParser class BaseDatasetsCLICommand(ABC): @staticmethod @abstractmethod def register_subcommand(parser: ArgumentParser): raise NotImplementedError() @abstractmethod def run(self): raise NotImplementedError()
0
hf_public_repos/datasets/src/datasets
hf_public_repos/datasets/src/datasets/commands/datasets_cli.py
#!/usr/bin/env python from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestComm...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_dataset_dict.py
import os import tempfile from unittest import TestCase import numpy as np import pandas as pd import pytest from datasets import load_from_disk from datasets.arrow_dataset import Dataset from datasets.dataset_dict import DatasetDict, IterableDatasetDict from datasets.features import ClassLabel, Features, Sequence, V...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_download_manager.py
import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename URL = "http://www.mocksite.com/file1.txt" CONTENT = '"text": ["foo", "fo...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_file_utils.py
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, get_...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/README.md
## Add Dummy data test **Important** In order to pass the `load_dataset_<dataset_name>` test, dummy data is required for all possible config names. First we distinguish between datasets scripts that - A) have no config class and - B) have a config class For A) the dummy data folder structure, will always look as fol...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_load.py
import importlib import os import pickle import shutil import tempfile import time from hashlib import sha256 from multiprocessing import Pool from pathlib import Path from unittest import TestCase from unittest.mock import patch import dill import pyarrow as pa import pytest import requests import datasets from data...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_fingerprint.py
import json import os import pickle import subprocess from functools import partial from pathlib import Path from tempfile import gettempdir from textwrap import dedent from types import FunctionType from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from multiprocess import...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_extract.py
import os import zipfile import pytest from datasets.utils.extract import ( Bzip2Extractor, Extractor, GzipExtractor, Lz4Extractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lz4, require_py7zr, require_zstandard @pyte...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_arrow_writer.py
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Array...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_version.py
import pytest from datasets.utils.version import Version @pytest.mark.parametrize( "other, expected_equality", [ (Version("1.0.0"), True), ("1.0.0", True), (Version("2.0.0"), False), ("2.0.0", False), ("1", False), ("a", False), (1, False), (Non...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_tqdm.py
import unittest from unittest.mock import patch import pytest from pytest import CaptureFixture from datasets.utils import ( are_progress_bars_disabled, disable_progress_bars, enable_progress_bars, tqdm, ) class TestTqdmUtils(unittest.TestCase): @pytest.fixture(autouse=True) def capsys(self,...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_dataset_list.py
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class DatasetListTest(TestCase): def _create_example_records(self): return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2, "col_2": "b"}, {"col_1": 1, "col_2": "c"}...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/conftest.py
import pytest import datasets import datasets.config # Import fixture modules as plugins pytest_plugins = ["tests.fixtures.files", "tests.fixtures.hub", "tests.fixtures.fsspec"] def pytest_collection_modifyitems(config, items): # Mark tests as "unit" by default if not marked as "integration" (or already marked...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_builder.py
import importlib import os import tempfile import types from contextlib import nullcontext as does_not_raise from multiprocessing import Process from pathlib import Path from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_inspect.py
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) pytestmark = pytest.mark.integration @pytest.mark.parametrize("path", ["paws", "csv"]) def test_inspect_dataset(p...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/utils.py
import asyncio import importlib.metadata import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_beam.py
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class DummyBeamDataset(datasets.BeamBasedBuilder): """Dummy beam dataset.""" def _info(self): return datasets....
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_filesystem.py
import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, extract_path_from_uri, is_remote_filesystem from .utils import require_lz4, require_zstandard def tes...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_table.py
import copy import pickle import warnings from typing import List, Union import numpy as np import pyarrow as pa import pytest import datasets from datasets import Sequence, Value from datasets.features.features import Array2D, Array2DExtensionType, ClassLabel, Features, Image from datasets.table import ( Concate...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_metadata_util.py
import re import sys import tempfile import unittest from pathlib import Path import pytest import yaml from huggingface_hub import DatasetCard, DatasetCardData from datasets.config import METADATA_CONFIGS_FIELD from datasets.utils.metadata import MetadataConfigs def _dedent(string: str) -> str: indent_level = ...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_search.py
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, require_...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_info.py
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files", [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "dataset_infos.json"], ["dataset_infos...
0
hf_public_repos/datasets
hf_public_repos/datasets/tests/test_streaming_download_manager.py
import json import os import re from pathlib import Path import pytest from fsspec.registry import _registry as _fsspec_registry from fsspec.spec import AbstractBufferedFile, AbstractFileSystem from datasets.download.download_config import DownloadConfig from datasets.download.streaming_download_manager import ( ...
0