


"""simple docstring"""






import os
import shutil
import unittest
from unittest.mock import patch

from transformers.testing_utils import CaptureStd, is_pt_tf_cross_test, require_torch


class 			SCREAMING_SNAKE_CASE_  (   unittest.TestCase):




							'''simple docstring'''





							@patch("sys.argv"	,					["fakeprogrampath", "env"])
							def        UpperCAmelCase (						self)   ->	Dict:







								'''simple docstring'''




								import transformers.commands.transformers_cli

								with CaptureStd() as cs:
									transformers.commands.transformers_cli.main()
								self.assertIn("Python version"	,					cs.out)
								self.assertIn("Platform"	,					cs.out)
								self.assertIn("Using distributed or parallel set-up in script?"	,					cs.out)




							@is_pt_tf_cross_test
							@patch(
							    "sys.argv"	,					["fakeprogrampath", "pt-to-tf", "--model-name", "hf-internal-testing/tiny-random-gptj", "--no-pr"])
							def        UpperCAmelCase (						self)   ->	List[Any]:







								'''simple docstring'''




								import transformers.commands.transformers_cli

								shutil.rmtree("/tmp/hf-internal-testing/tiny-random-gptj"	,					ignore_errors=lowerCamelCase__)  # cleans potential past runs
								transformers.commands.transformers_cli.main()

								# The original repo has no TF weights -- if they exist, they were created by the CLI
								self.assertTrue(os.path.exists("/tmp/hf-internal-testing/tiny-random-gptj/tf_model.h5"))




							@require_torch
							@patch("sys.argv"	,					["fakeprogrampath", "download", "hf-internal-testing/tiny-random-gptj", "--cache-dir", "/tmp"])
							def        UpperCAmelCase (						self)   ->	int:







								'''simple docstring'''




								import transformers.commands.transformers_cli

								# # remove any previously downloaded model to start clean
								shutil.rmtree("/tmp/models--hf-internal-testing--tiny-random-gptj"	,					ignore_errors=lowerCamelCase__)

								# run the command
								transformers.commands.transformers_cli.main()

								# check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--tiny-random-gptj
								self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/blobs"))
								self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/refs"))
								self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--tiny-random-gptj/snapshots"))







							@require_torch
							@patch(
							    "sys.argv"	,					[
							        "fakeprogrampath",
							        "download",
							        "hf-internal-testing/test_dynamic_model_with_tokenizer",
							        "--trust-remote-code",
							        "--cache-dir",
							        "/tmp",
							    ]	,					)
							def        UpperCAmelCase (						self)   ->	Optional[int]:







								'''simple docstring'''




								import transformers.commands.transformers_cli

								# # remove any previously downloaded model to start clean
								shutil.rmtree("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer"	,					ignore_errors=lowerCamelCase__)

								# run the command
								transformers.commands.transformers_cli.main()

								# check if the model files are downloaded correctly on /tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer
								self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/blobs"))
								self.assertTrue(os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/refs"))
								self.assertTrue(
								    os.path.exists("/tmp/models--hf-internal-testing--test_dynamic_model_with_tokenizer/snapshots"))







"""simple docstring"""




import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


A__   :						Optional[Any] 							=     set()
A__   :						List[str] 							=     get_logger(__name__)



def 				a__			(					lowerCAmelCase						:							Optional[str] = None		):






     '''simple docstring'''

     def decorator(lowerCAmelCase						:							Callable		):
          global _emitted_deprecation_warnings

          if inspect.isclass(lowerCAmelCase		):
               UpperCAmelCase__				:			Any							=    deprecated_class_or_function.__init__
               UpperCAmelCase__				:			Optional[int]							=    deprecated_class_or_function.__name__
          else:
               UpperCAmelCase__				:			str							=    deprecated_class_or_function
               UpperCAmelCase__				:			List[Any]							=    deprecated_function.__name__
               # Support deprecating __init__ class method: class name instead
               UpperCAmelCase__				:			List[str]							=    name if name != "__init__" else deprecated_function.__qualname__.split("."		)[-2]

          UpperCAmelCase__				:			Optional[Any]							=    (
              F"{name} is deprecated and will be removed in the next major version of datasets." + F" {help_message}"
              if help_message
              else ""
          )

          @wraps(lowerCAmelCase		)
          def wrapper(*lowerCAmelCase						:							int							,     **lowerCAmelCase						:							str		):
               UpperCAmelCase__				:			List[str]							=    hash(lowerCAmelCase		)
               if func_hash not in _emitted_deprecation_warnings:
                    warnings.warn(lowerCAmelCase							,     category=lowerCAmelCase							,     stacklevel=2		)
                    _emitted_deprecation_warnings.add(lowerCAmelCase		)
               return deprecated_function(*lowerCAmelCase							,     **lowerCAmelCase		)

          UpperCAmelCase__				:			List[str]							=    "deprecated"

          if inspect.isclass(lowerCAmelCase		):
               UpperCAmelCase__				:			List[str]							=    wrapper
               return deprecated_class_or_function
          else:
               return wrapper

     return decorator







class 	_lowercase    (							enum.EnumMeta					):


     '''simple docstring'''





     def __getattribute__(   cls			,      __UpperCamelCase	)->       Optional[Any]:
          UpperCAmelCase__				:			Optional[int]							=    super().__getattribute__(__UpperCamelCase	)
          if isinstance(__UpperCamelCase			,      enum.Enum	) and obj._on_access:
               obj._on_access()
          return obj



     def __getitem__(   cls			,      __UpperCamelCase	)->       Optional[int]:
          UpperCAmelCase__				:			Union[str, Any]							=    super().__getitem__(__UpperCamelCase	)
          if member._on_access:
               member._on_access()
          return member



     def __call__(   cls			,      __UpperCamelCase			,      __UpperCamelCase=None			,      *, __UpperCamelCase=None			,      __UpperCamelCase=None			,      __UpperCamelCase=None			,      __UpperCamelCase=1	)->       Dict:
          UpperCAmelCase__				:			Optional[int]							=    super().__call__(__UpperCamelCase			,      __UpperCamelCase			,      module=__UpperCamelCase			,      qualname=__UpperCamelCase			,      type=__UpperCamelCase			,      start=__UpperCamelCase	)
          if isinstance(__UpperCamelCase			,      enum.Enum	) and obj._on_access:
               obj._on_access()
          return obj







class 	_lowercase    (							enum.Enum						, metaclass=lowerCAmelCase_					):


     '''simple docstring'''





     def __new__(   cls			,      __UpperCamelCase	)->       Union[str, Any]:
          UpperCAmelCase__				:			int							=    object.__new__(cls	)
          UpperCAmelCase__				:			int							=    value
          UpperCAmelCase__				:			Optional[int]							=    member.deprecate
          return member



     @property
     def 			lowerCAmelCase__							(   self	)->       Union[str, Any]:
          return ""



     def 			lowerCAmelCase__							(   self	)->       int:
          UpperCAmelCase__				:			Tuple							=    F" {self.help_message}" if self.help_message else ""
          warnings.warn(
              F"'{self.__objclass__.__name__}' is deprecated and will be removed in the next major version of datasets."
              + help_message			,      __UpperCamelCase			,      stacklevel=3			,      )



