





'''simple docstring'''




import inspect
import re

from transformers.utils import direct_transformers_import


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_config_docstrings.py
__SCREAMING_SNAKE_CASE     :Optional[Any]       =				'''src/transformers'''


# This is to make sure the transformers module imported is the one in the repo.
__SCREAMING_SNAKE_CASE     :Tuple       =				direct_transformers_import(PATH_TO_TRANSFORMERS)

__SCREAMING_SNAKE_CASE     :Tuple       =				transformers.models.auto.configuration_auto.CONFIG_MAPPING

# Regex pattern used to find the checkpoint mentioned in the docstring of `config_class`.
# For example, `[bert-base-uncased](https://huggingface.co/bert-base-uncased)`
__SCREAMING_SNAKE_CASE     :List[str]       =				re.compile(R'''\[(.+?)\]\((https://huggingface\.co/.+?)\)''')


__SCREAMING_SNAKE_CASE     :Union[str, Any]       =				{
    '''DecisionTransformerConfig''',
    '''EncoderDecoderConfig''',
    '''MusicgenConfig''',
    '''RagConfig''',
    '''SpeechEncoderDecoderConfig''',
    '''TimmBackboneConfig''',
    '''VisionEncoderDecoderConfig''',
    '''VisionTextDualEncoderConfig''',
    '''LlamaConfig''',
}
def 	UpperCAmelCase_							(					__lowercase							:      List[Any]       )		->       Optional[int]:


     '''simple docstring'''



     _UpperCAmelCase     							=   None

     # source code of `config_class`
     _UpperCAmelCase     							=   inspect.getsource(__lowercase       )
     _UpperCAmelCase     							=   _re_checkpoint.findall(__lowercase       )

     # Each `checkpoint` is a tuple of a checkpoint name and a checkpoint link.
     # For example, `('bert-base-uncased', 'https://huggingface.co/bert-base-uncased')`
     for ckpt_name, ckpt_link in checkpoints:
          # allow the link to end with `/`
          if ckpt_link.endswith("/"       ):
               _UpperCAmelCase     							=   ckpt_link[:-1]

          # verify the checkpoint name corresponds to the checkpoint link
          _UpperCAmelCase     							=   f'https://huggingface.co/{ckpt_name}'
          if ckpt_link == ckpt_link_from_name:
               _UpperCAmelCase     							=   ckpt_name
               break

     return checkpoint
def 	UpperCAmelCase_							(					)		->       List[str]:


     '''simple docstring'''



     _UpperCAmelCase     							=   []

     for config_class in list(CONFIG_MAPPING.values()       ):
          # Skip deprecated models
          if "models.deprecated" in config_class.__module__:
               continue
          _UpperCAmelCase     							=   get_checkpoint_from_config_class(__lowercase       )

          _UpperCAmelCase     							=   config_class.__name__
          if checkpoint is None and name not in CONFIG_CLASSES_TO_IGNORE_FOR_DOCSTRING_CHECKPOINT_CHECK:
               configs_without_checkpoint.append(__lowercase       )

     if len(__lowercase       ) > 0:
          _UpperCAmelCase     							=   "\n".join(sorted(__lowercase       )       )
          raise ValueError(f'The following configurations don\'t contain any valid checkpoint:\n{message}'       )


if __name__ == "__main__":
  check_config_docstrings_have_checkpoints()











'''simple docstring'''




import os
from datetime import datetime as dt

from github import Github


__SCREAMING_SNAKE_CASE     :str       =				[
    '''good first issue''',
    '''feature request''',
    '''wip''',
]
def 	UpperCAmelCase_							(					)		->       Optional[Any]:


     '''simple docstring'''



     _UpperCAmelCase     							=   Github(os.environ["GITHUB_TOKEN"]       )
     _UpperCAmelCase     							=   g.get_repo("huggingface/accelerate"       )
     _UpperCAmelCase     							=   repo.get_issues(state="open"       )

     for issue in open_issues:
          _UpperCAmelCase     							=   sorted([comment for comment in issue.get_comments()]			,     key=lambda __lowercase       : i.created_at			,     reverse=__lowercase       )
          _UpperCAmelCase     							=   comments[0] if len(__lowercase       ) > 0 else None
          _UpperCAmelCase     							=   dt.utcnow()
          _UpperCAmelCase     							=   (current_time - issue.updated_at).days
          _UpperCAmelCase     							=   (current_time - issue.created_at).days
          if (
              last_comment is not None
              and last_comment.user.login == "github-actions[bot]"
              and days_since_updated > 7
              and days_since_creation >= 30
              and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()       )
          ):
               # Close issue since it has been 7 days of inactivity since bot mention.
               issue.edit(state="closed"       )
          elif (
              days_since_updated > 23
              and days_since_creation >= 30
              and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()       )
          ):
               # Add stale comment
               issue.create_comment(
                   "This issue has been automatically marked as stale because it has not had "
                   "recent activity. If you think this still needs to be addressed "
                   "please comment on this thread.\n\nPlease note that issues that do not follow the "
                   "[contributing guidelines](https://github.com/huggingface/accelerate/blob/main/CONTRIBUTING.md) "
                   "are likely to be ignored."       )


if __name__ == "__main__":
  main()




