




"""simple docstring"""




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   UpperCAmelCase_    (			snake_case		):
		def __init__(						self				,						UpperCamelCase_				,						UpperCamelCase_ = None				,						UpperCamelCase_ = None				,						UpperCamelCase_ = None				,						UpperCamelCase_ = False				,						UpperCamelCase_ = False				,						UpperCamelCase_ = None				,						**UpperCamelCase_				,						)						->       Optional[Any]:
					super().__init__(
					    UpperCamelCase_				,						split=UpperCamelCase_				,						features=UpperCamelCase_				,						cache_dir=UpperCamelCase_				,						keep_in_memory=UpperCamelCase_				,						streaming=UpperCamelCase_				,						num_proc=UpperCamelCase_				,						**UpperCamelCase_				,						)
					__lowercase			:  Union[str, Any]								=       path_or_paths if isinstance(UpperCamelCase_				,						UpperCamelCase_       ) else {self.split: path_or_paths}
					__lowercase			:  List[str]								=       Text(
					    cache_dir=UpperCamelCase_				,						data_files=UpperCamelCase_				,						features=UpperCamelCase_				,						**UpperCamelCase_				,						)
		def 	_lowerCamelCase							(						self       )						->       Union[str, Any]:
					# Build iterable dataset
					if self.streaming:
								__lowercase			:  Union[str, Any]								=       self.builder.as_streaming_dataset(split=self.split       )
					# Build regular (map-style) dataset
					else:
								__lowercase			:  Optional[int]								=       None
								__lowercase			:  Dict								=       None
								__lowercase			:  List[Any]								=       None
								__lowercase			:  int								=       None

								self.builder.download_and_prepare(
								    download_config=UpperCamelCase_				,						download_mode=UpperCamelCase_				,						verification_mode=UpperCamelCase_				,						base_path=UpperCamelCase_				,						num_proc=self.num_proc				,						)
								__lowercase			:  str								=       self.builder.as_dataset(
								    split=self.split				,						verification_mode=UpperCamelCase_				,						in_memory=self.keep_in_memory       )
					return dataset







'''simple docstring'''
import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline







@pytest.mark.integration
def       a_				(	):
							with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ):
														with pytest.raises(UpperCamelCase_ ):
																					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       a_				(	):
							with offline(OfflineSimulationMode.CONNECTION_FAILS ):
														with pytest.raises(requests.exceptions.ConnectionError ):
																					requests.request("GET"						,  "https://huggingface.co" )







def       a_				(	):
							with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1 ):
														with pytest.raises(UpperCamelCase_ ):
																					http_head("https://huggingface.co" )





