


import pytest

import datasets


# Import fixture modules as plugins
__UpperCamelCase				:				Optional[int]  				= ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec''']

def 	_a     ( SCREAMING_SNAKE_CASE		: List[str]			,       SCREAMING_SNAKE_CASE		: List[Any]   ):







 """simple docstring"""



 for item in items:
  if any(marker in item.keywords for marker in ['''integration''', '''unit''']   ):
   continue
  item.add_marker(pytest.mark.unit   )

def 	_a     ( SCREAMING_SNAKE_CASE		: Optional[int]   ):







 """simple docstring"""



 config.addinivalue_line('''markers'''			,       '''torchaudio_latest: mark test to run with torchaudio>=0.12'''   )

@pytest.fixture(autouse=snake_case_   )
def 	_a     ( SCREAMING_SNAKE_CASE		: Optional[int]			,       SCREAMING_SNAKE_CASE		: Dict   ):







 """simple docstring"""



 UpperCamelCase__    :			Optional[Any]      				=      tmp_path_factory.getbasetemp() / '''cache'''
 UpperCamelCase__    :			Optional[Any]      				=      test_hf_cache_home / '''datasets'''
 UpperCamelCase__    :			str      				=      test_hf_cache_home / '''metrics'''
 UpperCamelCase__    :			int      				=      test_hf_cache_home / '''modules'''
 monkeypatch.setattr('''datasets.config.HF_DATASETS_CACHE'''			,       str(snake_case_   )   )
 monkeypatch.setattr('''datasets.config.HF_METRICS_CACHE'''			,       str(snake_case_   )   )
 monkeypatch.setattr('''datasets.config.HF_MODULES_CACHE'''			,       str(snake_case_   )   )
 UpperCamelCase__    :			int      				=      test_hf_datasets_cache / '''downloads'''
 monkeypatch.setattr('''datasets.config.DOWNLOADED_DATASETS_PATH'''			,       str(snake_case_   )   )
 UpperCamelCase__    :			int      				=      test_hf_datasets_cache / '''downloads''' / '''extracted'''
 monkeypatch.setattr('''datasets.config.EXTRACTED_DATASETS_PATH'''			,       str(snake_case_   )   )

@pytest.fixture(autouse=snake_case_			,       scope='''session'''   )
def 	_a     ( ):







 """simple docstring"""



 datasets.disable_progress_bar()

@pytest.fixture(autouse=snake_case_   )
def 	_a     ( SCREAMING_SNAKE_CASE		: List[str]   ):







 """simple docstring"""



 monkeypatch.setattr('''datasets.config.HF_UPDATE_DOWNLOAD_COUNTS'''			,       snake_case_   )






@pytest.fixture
def 	_a     ( SCREAMING_SNAKE_CASE		: Dict   ):







 """simple docstring"""



 monkeypatch.setattr('''sqlalchemy.util.deprecations.SILENCE_UBER_WARNING'''			,       snake_case_   )



'''simple docstring'''

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 				_lowercase     (				datasets.BuilderConfig			):


 '''simple docstring'''






 _SCREAMING_SNAKE_CASE     :       Optional[datasets.Features]      	=					None







class 				_lowercase     (				datasets.ArrowBasedBuilder			):


 '''simple docstring'''






 _SCREAMING_SNAKE_CASE     :       Union[str, Any]      	=					PandasConfig
 def a					(      self   :	Union[str, Any]							)  ->    int:
  return datasets.DatasetInfo(features=self.config.features							)
 def a					(      self   :	Any      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]							)  ->    str:
  if not self.config.data_files:
   raise ValueError(f"""At least one data file must be specified, but got data_files={self.config.data_files}"""							)
  __lowerCAmelCase											=						dl_manager.download_and_extract(self.config.data_files							)
  if isinstance(SCREAMING_SNAKE_CASE__      ,       (str, list, tuple)							):
   __lowerCAmelCase											=						data_files
   if isinstance(SCREAMING_SNAKE_CASE__      ,       SCREAMING_SNAKE_CASE__							):
    __lowerCAmelCase											=						[files]
   # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
   __lowerCAmelCase											=						[dl_manager.iter_files(SCREAMING_SNAKE_CASE__							) for file in files]
   return [datasets.SplitGenerator(name=datasets.Split.TRAIN      ,       gen_kwargs={"""files""": files}							)]
  __lowerCAmelCase											=						[]
  for split_name, files in data_files.items():
   if isinstance(SCREAMING_SNAKE_CASE__      ,       SCREAMING_SNAKE_CASE__							):
    __lowerCAmelCase											=						[files]
   # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
   __lowerCAmelCase											=						[dl_manager.iter_files(SCREAMING_SNAKE_CASE__							) for file in files]
   splits.append(datasets.SplitGenerator(name=SCREAMING_SNAKE_CASE__      ,       gen_kwargs={"""files""": files}							)							)
  return splits
 def a					(      self   :	Any      ,       SCREAMING_SNAKE_CASE__   :	pa.Table							)  ->    pa.Table:
  if self.config.features is not None:
   # more expensive cast to support nested features with keys in a different order
   # allows str <-> int/float or str to Audio for example
   __lowerCAmelCase											=						table_cast(SCREAMING_SNAKE_CASE__      ,       self.config.features.arrow_schema							)
  return pa_table





 def a					(      self   :	Any      ,       SCREAMING_SNAKE_CASE__   :	Optional[Any]							)  ->    List[Any]:
  for i, file in enumerate(itertools.chain.from_iterable(SCREAMING_SNAKE_CASE__							)							):
   with open(SCREAMING_SNAKE_CASE__      ,       """rb"""							) as f:
    __lowerCAmelCase											=						pa.Table.from_pandas(pd.read_pickle(SCREAMING_SNAKE_CASE__							)							)
    yield i, self._cast_table(SCREAMING_SNAKE_CASE__							)






