


'''simple docstring'''




import json
import logging
import os
import sys
from time import time
from unittest.mock import patch

from transformers.testing_utils import TestCasePlus, require_torch_tpu


logging.basicConfig(level=logging.DEBUG)

__snake_case       		=logging.getLogger()





def       a_   (					lowerCamelCase      :	List[str]							):
   lowerCAmelCase	=     {}
   lowerCAmelCase	=     os.path.join(_UpperCamelCase      ,					'all_results.json'							)
   if os.path.exists(_UpperCamelCase							):
      with open(_UpperCamelCase      ,					'r'							) as f:
         lowerCAmelCase	=     json.load(_UpperCamelCase							)
   else:
      raise ValueError(f'''can\'t find {path}'''							)
   return results


__snake_case       		=logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)




@require_torch_tpu
class 						UpperCAmelCase_ (    __snake_case						):





     def 				__UpperCAmelCase (					self			: Any       )							->    Dict:
        import xla_spawn

        lowerCAmelCase	=     self.get_auto_remove_tmp_dir()
        lowerCAmelCase	=     F'''\n            ./examples/pytorch/text-classification/run_glue.py\n            --num_cores=8\n            ./examples/pytorch/text-classification/run_glue.py\n            --model_name_or_path distilbert-base-uncased\n            --output_dir {tmp_dir}\n            --overwrite_output_dir\n            --train_file ./tests/fixtures/tests_samples/MRPC/train.csv\n            --validation_file ./tests/fixtures/tests_samples/MRPC/dev.csv\n            --do_train\n            --do_eval\n            --debug tpu_metrics_debug\n            --per_device_train_batch_size=2\n            --per_device_eval_batch_size=1\n            --learning_rate=1e-4\n            --max_steps=10\n            --warmup_steps=2\n            --seed=42\n            --max_seq_length=128\n            '''.split()

        with patch.object(_SCREAMING_SNAKE_CASE       , 'argv'       , _SCREAMING_SNAKE_CASE       ):
           lowerCAmelCase	=     time()
           xla_spawn.main()
           lowerCAmelCase	=     time()

           lowerCAmelCase	=     get_results(_SCREAMING_SNAKE_CASE       )
           self.assertGreaterEqual(result['eval_accuracy']       , 0.75       )

           # Assert that the script takes less than 500 seconds to make sure it doesn't hang.
           self.assertLess(end - start       , 5_0_0       )





     def 				__UpperCAmelCase (					self			: str       )							->    Any:
        import xla_spawn

        lowerCAmelCase	=     '\n            ./tests/test_trainer_tpu.py\n            --num_cores=8\n            ./tests/test_trainer_tpu.py\n            '.split()
        with patch.object(_SCREAMING_SNAKE_CASE       , 'argv'       , _SCREAMING_SNAKE_CASE       ):
           xla_spawn.main()













from datetime import datetime as dt
import os

from github import Github


__magic_name__   :  Dict        =							[
    '''good first issue''',
    '''good second issue''',
    '''good difficult issue''',
    '''feature request''',
    '''new model''',
    '''wip''',
]
def 		lowercase__  (				) ->			Dict:
      """simple docstring"""

      UpperCamelCase					       =  Github(os.environ['GITHUB_TOKEN'])
      UpperCamelCase					       =  g.get_repo('huggingface/transformers')
      UpperCamelCase					       =  repo.get_issues(state='open')

      for issue in open_issues:
            UpperCamelCase					       =  sorted([comment for comment in issue.get_comments()]       ,							key=lambda _UpperCamelCase: i.created_at       ,							reverse=_UpperCamelCase)
            UpperCamelCase					       =  comments[0] if len(_UpperCamelCase) > 0 else None
            if (
                last_comment is not None
                and last_comment.user.login == "github-actions[bot]"
                and (dt.utcnow() - issue.updated_at).days > 7
                and (dt.utcnow() - issue.created_at).days >= 30
                and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
            ):
                  # print(f"Would close issue {issue.number} since it has been 7 days of inactivity since bot mention.")
                  issue.edit(state='closed')
            elif (
                (dt.utcnow() - issue.updated_at).days > 23
                and (dt.utcnow() - issue.created_at).days >= 30
                and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
            ):
                  # print(f"Would add stale comment to {issue.number}")
                  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/transformers/blob/main/CONTRIBUTING.md) '
                      'are likely to be ignored.')


if __name__ == "__main__":
       main()



