




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"""





      _snake_case												=						None




class 						__lowercase		(datasets.ArrowBasedBuilder							):




      """simple docstring"""





      _snake_case												=						PandasConfig

      def      UpperCAmelCase				(				self     )		->    Union[str, Any]:
         return datasets.DatasetInfo(features=self.config.features     )

      def      UpperCAmelCase				(				self    ,				A     )		->    Tuple:
         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}"""     )
         snake_case				:    Union[str, Any]           =	dl_manager.download_and_extract(self.config.data_files     )
         if isinstance(A    ,				(str, list, tuple)     ):
            snake_case				:    str           =	data_files
            if isinstance(A    ,				A     ):
               snake_case				:    Any           =	[files]
            # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
            snake_case				:    Optional[int]           =	[dl_manager.iter_files(A     ) for file in files]
            return [datasets.SplitGenerator(name=datasets.Split.TRAIN    ,				gen_kwargs={"""files""": files}     )]
         snake_case				:    Any           =	[]
         for split_name, files in data_files.items():
            if isinstance(A    ,				A     ):
               snake_case				:    Optional[int]           =	[files]
            # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
            snake_case				:    Optional[Any]           =	[dl_manager.iter_files(A     ) for file in files]
            splits.append(datasets.SplitGenerator(name=A    ,				gen_kwargs={"""files""": files}     )     )
         return splits

      def      UpperCAmelCase				(				self    ,				A     )		->    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
            snake_case				:    Optional[Any]           =	table_cast(A    ,				self.config.features.arrow_schema     )
         return pa_table

      def      UpperCAmelCase				(				self    ,				A     )		->    Any:
         for i, file in enumerate(itertools.chain.from_iterable(A     )     ):
            with open(A    ,				"""rb"""     ) as f:
               snake_case				:    Dict           =	pa.Table.from_pandas(pd.read_pickle(A     )     )
               yield i, self._cast_table(A     )











import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline




@pytest.mark.integration
def 						SCREAMING_SNAKE_CASE__ (   )  ->       List[Any]:
   with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT					):
      with pytest.raises(lowercase					):
         requests.request("""GET"""						,"""https://huggingface.co"""					)
      with pytest.raises(requests.exceptions.ConnectTimeout					):
         requests.request("""GET"""						,"""https://huggingface.co"""						,timeout=1.0					)




@pytest.mark.integration
def 						SCREAMING_SNAKE_CASE__ (   )  ->       Any:
   with offline(OfflineSimulationMode.CONNECTION_FAILS					):
      with pytest.raises(requests.exceptions.ConnectionError					):
         requests.request("""GET"""						,"""https://huggingface.co"""					)




def 						SCREAMING_SNAKE_CASE__ (   )  ->       int:
   with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1					):
      with pytest.raises(lowercase					):
         http_head("""https://huggingface.co"""					)





