





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    _lowerCAmelCase						(				lowerCamelCase_			:  Dict				):  # picklable for multiprocessing
			return i + 1




@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
def    _lowerCAmelCase						(				):
			with parallel_backend('''spark'''				):
						assert ParallelBackendConfig.backend_name == "spark"

			__lowercase										=							[1, 2, 3]
			with pytest.raises(lowerCamelCase_				):
						with parallel_backend('''unsupported backend'''				):
									map_nested(lowerCamelCase_		,       lowerCamelCase_		,       num_proc=2				)

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




@require_dill_gt_0_3_2
@require_joblibspark
@require_not_windows
@pytest.mark.parametrize('''num_proc'''		,       [2, -1]				)
def    _lowerCAmelCase						(				lowerCamelCase_			:  List[str]				):
			__lowercase										=							[1, 2]
			__lowercase										=							{'''a''': 1, '''b''': 2}
			__lowercase										=							{'''a''': [1, 2], '''b''': [3, 4]}
			__lowercase										=							{'''a''': {'''1''': 1}, '''b''': 2}
			__lowercase										=							{'''a''': 1, '''b''': 2, '''c''': 3, '''d''': 4}
			__lowercase										=							[2, 3]
			__lowercase										=							{'''a''': 2, '''b''': 3}
			__lowercase										=							{'''a''': [2, 3], '''b''': [4, 5]}
			__lowercase										=							{'''a''': {'''1''': 2}, '''b''': 3}
			__lowercase										=							{'''a''': 2, '''b''': 3, '''c''': 4, '''d''': 5}

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












'''simple docstring'''



from argparse import ArgumentParser

from .env import EnvironmentCommand




def    _lowerCAmelCase						(				):
			__lowercase										=							ArgumentParser('''Diffusers CLI tool'''		,       usage='''diffusers-cli <command> [<args>]'''				)
			__lowercase										=							parser.add_subparsers(help='''diffusers-cli command helpers'''				)

			# Register commands
			EnvironmentCommand.register_subcommand(lowerCamelCase_				)

			# Let's go
			__lowercase										=							parser.parse_args()

			if not hasattr(lowerCamelCase_		,       '''func'''				):
						parser.print_help()
						exit(1				)

			# Run
			__lowercase										=							args.func(lowerCamelCase_				)
			service.run()


if __name__ == "__main__":
	main()





