





'''simple docstring'''



import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


_SCREAMING_SNAKE_CASE					=    logging.getLogger()






@unittest.skip("Temporarily disable the doc tests."						)
@require_torch
@require_tf
@slow
class 							__lowercase       (      unittest.TestCase						):







	'''simple docstring'''

	def 						_UpperCAmelCase     (self     ,_lowerCamelCase     ,_lowerCamelCase = None     ,_lowerCamelCase = None     ,_lowerCamelCase = None     ,_lowerCamelCase = True     ,)							->							Optional[int]:







				'''simple docstring'''





				__lowercase										=							[file for file in os.listdir(_lowerCamelCase ) if os.path.isfile(os.path.join(_lowerCamelCase     ,_lowerCamelCase ) )]

				if identifier is not None:
							__lowercase										=							[file for file in files if identifier in file]

				if n_identifier is not None:
							if isinstance(_lowerCamelCase     ,_lowerCamelCase ):
										for n_ in n_identifier:
													__lowercase										=							[file for file in files if n_ not in file]
							else:
										__lowercase										=							[file for file in files if n_identifier not in file]

				__lowercase										=							ignore_files or []
				ignore_files.append('''__init__.py''' )
				__lowercase										=							[file for file in files if file not in ignore_files]

				for file in files:
							# Open all files
							print('''Testing'''     ,_lowerCamelCase )

							if only_modules:
										__lowercase										=							file.split('''.''' )[0]
										try:
													__lowercase										=							getattr(_lowerCamelCase     ,_lowerCamelCase )
													__lowercase										=							doctest.DocTestSuite(_lowerCamelCase )
													__lowercase										=							unittest.TextTestRunner().run(_lowerCamelCase )
													self.assertIs(len(result.failures )     ,0 )
										except AttributeError:
													logger.info(f"{module_identifier} is not a module." )
							else:
										__lowercase										=							doctest.testfile(str('''..''' / directory / file )     ,optionflags=doctest.ELLIPSIS )
										self.assertIs(result.failed     ,0 )


	def 						_UpperCAmelCase     (self )							->							str:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''modeling'''
				__lowercase										=							[
				    '''modeling_ctrl.py''',
				    '''modeling_tf_ctrl.py''',
				]
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase     ,ignore_files=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							Any:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''tokenization'''
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							int:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							'''configuration'''
				self.analyze_directory(_lowerCamelCase     ,identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							List[Any]:







				'''simple docstring'''





				__lowercase										=							Path('''src/transformers''' )
				__lowercase										=							['''configuration''', '''modeling''', '''tokenization''']
				self.analyze_directory(_lowerCamelCase     ,n_identifier=_lowerCamelCase )


	def 						_UpperCAmelCase     (self )							->							Optional[int]:







				'''simple docstring'''





				__lowercase										=							Path('''docs/source''' )
				__lowercase										=							['''favicon.ico''']
				self.analyze_directory(_lowerCamelCase     ,ignore_files=_lowerCamelCase     ,only_modules=_lowerCamelCase )












'''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()





