


'''simple docstring'''







import pytest

from datasets.parallel import ParallelBackendConfig, parallel_backend
from datasets.utils.py_utils import map_nested

from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows






def 			lowercase				(_A					):  # picklable for multiprocessing







       """simple docstring"""







       return i + 1






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def 			lowercase				():







       """simple docstring"""







       with parallel_backend('spark'					):
              assert ParallelBackendConfig.backend_name == "spark"

       _lowerCAmelCase    :							Optional[Any]   			=       [1, 2, 3]
       with pytest.raises(_A					):
              with parallel_backend('unsupported backend'					):
                     map_nested(_A   ,						_A   ,						num_proc=2					)

       with pytest.raises(_A					):
              with parallel_backend('unsupported backend'					):
                     map_nested(_A   ,						_A   ,						num_proc=-1					)






@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('num_proc'   ,						[2, -1]					)
def 			lowercase				(_A					):







       """simple docstring"""







       _lowerCAmelCase    :							List[Any]   			=       [1, 2]
       _lowerCAmelCase    :							Dict   			=       {'a': 1, 'b': 2}
       _lowerCAmelCase    :							Optional[Any]   			=       {'a': [1, 2], 'b': [3, 4]}
       _lowerCAmelCase    :							List[str]   			=       {'a': {'1': 1}, 'b': 2}
       _lowerCAmelCase    :							int   			=       {'a': 1, 'b': 2, 'c': 3, 'd': 4}
       _lowerCAmelCase    :							Dict   			=       [2, 3]
       _lowerCAmelCase    :							Optional[Any]   			=       {'a': 2, 'b': 3}
       _lowerCAmelCase    :							Tuple   			=       {'a': [2, 3], 'b': [4, 5]}
       _lowerCAmelCase    :							List[str]   			=       {'a': {'1': 2}, 'b': 3}
       _lowerCAmelCase    :							int   			=       {'a': 2, 'b': 3, 'c': 4, 'd': 5}

       with parallel_backend('spark'					):
              assert map_nested(_A   ,						_A   ,						num_proc=_A					) == expected_map_nested_sa
              assert map_nested(_A   ,						_A   ,						num_proc=_A					) == expected_map_nested_sa
              assert map_nested(_A   ,						_A   ,						num_proc=_A					) == expected_map_nested_sa
              assert map_nested(_A   ,						_A   ,						num_proc=_A					) == expected_map_nested_sa
              assert map_nested(_A   ,						_A   ,						num_proc=_A					) == expected_map_nested_sa





'''simple docstring'''







import pytest

import datasets


# Import fixture modules as plugins
lowerCAmelCase    :     List[str]					=						["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""]






def 			lowercase				(_A   ,						_A					):







       """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 			lowercase				(_A					):







       """simple docstring"""







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






@pytest.fixture(autouse=_A					)
def 			lowercase				(_A   ,						_A					):







       """simple docstring"""







       _lowerCAmelCase    :							str   			=       tmp_path_factory.getbasetemp() / 'cache'
       _lowerCAmelCase    :							Dict   			=       test_hf_cache_home / 'datasets'
       _lowerCAmelCase    :							List[Any]   			=       test_hf_cache_home / 'metrics'
       _lowerCAmelCase    :							List[Any]   			=       test_hf_cache_home / 'modules'
       monkeypatch.setattr('datasets.config.HF_DATASETS_CACHE'   ,						str(_A					)					)
       monkeypatch.setattr('datasets.config.HF_METRICS_CACHE'   ,						str(_A					)					)
       monkeypatch.setattr('datasets.config.HF_MODULES_CACHE'   ,						str(_A					)					)
       _lowerCAmelCase    :							Dict   			=       test_hf_datasets_cache / 'downloads'
       monkeypatch.setattr('datasets.config.DOWNLOADED_DATASETS_PATH'   ,						str(_A					)					)
       _lowerCAmelCase    :							Union[str, Any]   			=       test_hf_datasets_cache / 'downloads' / 'extracted'
       monkeypatch.setattr('datasets.config.EXTRACTED_DATASETS_PATH'   ,						str(_A					)					)






@pytest.fixture(autouse=_A   ,						scope='session'					)
def 			lowercase				():







       """simple docstring"""







       datasets.disable_progress_bar()






@pytest.fixture(autouse=_A					)
def 			lowercase				(_A					):







       """simple docstring"""







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






@pytest.fixture
def 			lowercase				(_A					):







       """simple docstring"""







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

