






'''simple docstring'''

import argparse
import os
import re

import packaging.version


UpperCamelCase      					="examples/"
UpperCamelCase      					={
    "examples": (re.compile(R"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"),
    "init": (re.compile(R"^__version__\s+=\s+\"([^\"]+)\"\s*$", re.MULTILINE), "__version__ = \"VERSION\"\n"),
    "setup": (re.compile(R"^(\s*)version\s*=\s*\"[^\"]+\",", re.MULTILINE), R"\1version=\"VERSION\","),
    "doc": (re.compile(R"^(\s*)release\s*=\s*\"[^\"]+\"$", re.MULTILINE), "release = \"VERSION\"\n"),
}
UpperCamelCase      					={
    "init": "src/diffusers/__init__.py",
    "setup": "setup.py",
}
UpperCamelCase      					="README.md"



def 				snake_case       (  a_				:			Any     , a_				:			Optional[int]     , a_				:			str						)							->					str:





      """simple docstring"""

      with open(a_     , """r"""     , encoding="""utf-8"""     , newline="""\n"""						) as f:
            UpperCamelCase_					: Union[str, Any]            =				f.read()
      UpperCamelCase_     ,      UpperCamelCase_					: Dict            =				REPLACE_PATTERNS[pattern]
      UpperCamelCase_					: List[str]            =				replace.replace("""VERSION"""     , a_						)
      UpperCamelCase_					: List[str]            =				re_pattern.sub(a_     , a_						)
      with open(a_     , """w"""     , encoding="""utf-8"""     , newline="""\n"""						) as f:
            f.write(a_						)



def 				snake_case       (  a_				:			Union[str, Any]						)							->					Optional[Any]:





      """simple docstring"""

      for folder, directories, fnames in os.walk(a_						):
            # Removing some of the folders with non-actively maintained examples from the walk
            if "research_projects" in directories:
                  directories.remove("""research_projects"""						)
            if "legacy" in directories:
                  directories.remove("""legacy"""						)
            for fname in fnames:
                  if fname.endswith(""".py"""						):
                        update_version_in_file(os.path.join(a_     , a_						)     , a_     , pattern="""examples"""						)



def 				snake_case       (  a_				:			List[Any]     , a_				:			List[str]=False						)							->					Optional[int]:





      """simple docstring"""

      for pattern, fname in REPLACE_FILES.items():
            update_version_in_file(a_     , a_     , a_						)
      if not patch:
            update_version_in_examples(a_						)



def 				snake_case       (  )							->					Optional[Any]:





      """simple docstring"""

      UpperCamelCase_					: List[str]            =				"""🤗 Transformers currently provides the following architectures"""
      UpperCamelCase_					: Optional[int]            =				"""1. Want to contribute a new model?"""
      with open(a_     , """r"""     , encoding="""utf-8"""     , newline="""\n"""						) as f:
            UpperCamelCase_					: Union[str, Any]            =				f.readlines()

      # Find the start of the list.
      UpperCamelCase_					: str            =				0
      while not lines[start_index].startswith(_start_prompt						):
            start_index += 1
      start_index += 1

      UpperCamelCase_					: Dict            =				start_index
      # Update the lines in the model list.
      while not lines[index].startswith(_end_prompt						):
            if lines[index].startswith("""1."""						):
                  UpperCamelCase_					: int            =				lines[index].replace(
                      """https://huggingface.co/docs/diffusers/main/model_doc"""     , """https://huggingface.co/docs/diffusers/model_doc"""     , )
            index += 1

      with open(a_     , """w"""     , encoding="""utf-8"""     , newline="""\n"""						) as f:
            f.writelines(a_						)



def 				snake_case       (  )							->					Optional[Any]:





      """simple docstring"""

      with open(REPLACE_FILES["""init"""]     , """r"""						) as f:
            UpperCamelCase_					: Any            =				f.read()
      UpperCamelCase_					: Union[str, Any]            =				REPLACE_PATTERNS["""init"""][0].search(a_						).groups()[0]
      return packaging.version.parse(a_						)



def 				snake_case       (  a_				:			Optional[Any]=False						)							->					Union[str, Any]:





      """simple docstring"""

      UpperCamelCase_					: List[str]            =				get_version()
      if patch and default_version.is_devrelease:
            raise ValueError("""Can't create a patch version from the dev branch, checkout a released version!"""						)
      if default_version.is_devrelease:
            UpperCamelCase_					: str            =				default_version.base_version
      elif patch:
            UpperCamelCase_					: int            =				f"{default_version.major}.{default_version.minor}.{default_version.micro + 1}"
      else:
            UpperCamelCase_					: Optional[int]            =				f"{default_version.major}.{default_version.minor + 1}.0"

      # Now let's ask nicely if that's the right one.
      UpperCamelCase_					: int            =				input(f"Which version are you releasing? [{default_version}]"						)
      if len(a_						) == 0:
            UpperCamelCase_					: str            =				default_version

      print(f"Updating version to {version}."						)
      global_version_update(a_     , patch=a_						)



def 				snake_case       (  )							->					int:





      """simple docstring"""

      UpperCamelCase_					: Optional[Any]            =				get_version()
      UpperCamelCase_					: Optional[Any]            =				f"{current_version.major}.{current_version.minor + 1}.0.dev0"
      UpperCamelCase_					: Dict            =				current_version.base_version

      # Check with the user we got that right.
      UpperCamelCase_					: Dict            =				input(f"Which version are we developing now? [{dev_version}]"						)
      if len(a_						) == 0:
            UpperCamelCase_					: str            =				dev_version

      print(f"Updating version to {version}."						)
      global_version_update(a_						)


#    print("Cleaning main README, don't forget to run `make fix-copies`.")
#    clean_main_ref_in_model_list()


if __name__ == "__main__":
      UpperCamelCase      					=argparse.ArgumentParser()
      parser.add_argument("--post_release", action="store_true", help="Whether this is pre or post release.")
      parser.add_argument("--patch", action="store_true", help="Whether or not this is a patch release.")
      UpperCamelCase      					=parser.parse_args()
      if not args.post_release:
            pre_release_work(patch=args.patch)
      elif args.patch:
            print("Nothing to do after a patch :-)")
      else:
            post_release_work()














'''simple docstring'''

import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


UpperCamelCase      					="\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.\n\nIn March 2021, Hugging Face raised $40 million in a Series B funding round.[3]\n\nOn April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]\n"




class      A     (   unittest.TestCase, SCREAMING_SNAKE_CASE__    ):






 """simple docstring"""





 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Optional[Any]            =				load_tool("""text-question-answering"""			)
       self.tool.setup()
       UpperCamelCase_					: List[str]            =				load_tool("""text-question-answering"""      ,  remote=__lowerCAmelCase			)
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Union[str, Any]            =				self.tool(__lowerCAmelCase      ,  """What did Hugging Face do in April 2021?"""			)
       self.assertEqual(__lowerCAmelCase      ,  """launched the BigScience Research Workshop"""			)
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Optional[Any]            =				self.remote_tool(__lowerCAmelCase      ,  """What did Hugging Face do in April 2021?"""			)
       self.assertEqual(__lowerCAmelCase      ,  """launched the BigScience Research Workshop"""			)
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: List[Any]            =				self.tool(text=__lowerCAmelCase      ,  question="""What did Hugging Face do in April 2021?"""			)
       self.assertEqual(__lowerCAmelCase      ,  """launched the BigScience Research Workshop"""			)





 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Dict            =				self.remote_tool(text=__lowerCAmelCase      ,  question="""What did Hugging Face do in April 2021?"""			)
       self.assertEqual(__lowerCAmelCase      ,  """launched the BigScience Research Workshop"""			)






