





import os
from datetime import datetime as dt

from github import Github


_a				:	List[Any]           =       [
    'good first issue',
    'feature request',
    'wip',
]



def  UpperCamelCase__     (   ):




      '''simple docstring'''







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

      for issue in open_issues:
            __lowerCamelCase				   =       sorted([comment for comment in issue.get_comments()]							,    key=lambda _A				: i.created_at							,    reverse=_lowerCAmelCase				)
            __lowerCamelCase				   =       comments[0] if len(_lowerCAmelCase				) > 0 else None
            __lowerCamelCase				   =       dt.utcnow()
            __lowerCamelCase				   =       (current_time - issue.updated_at).days
            __lowerCamelCase				   =       (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()











'''simple docstring'''





import os
from tempfile import TemporaryDirectory
from unittest import TestCase

import pytest
from absl.testing import parameterized

from datasets import config
from datasets.arrow_reader import HF_GCP_BASE_URL
from datasets.builder import DatasetBuilder
from datasets.dataset_dict import IterableDatasetDict
from datasets.iterable_dataset import IterableDataset
from datasets.load import dataset_module_factory, import_main_class
from datasets.utils.file_utils import cached_path


__a  			=						[
    {"dataset": "wikipedia", "config_name": "20220301.de"},
    {"dataset": "wikipedia", "config_name": "20220301.en"},
    {"dataset": "wikipedia", "config_name": "20220301.fr"},
    {"dataset": "wikipedia", "config_name": "20220301.frr"},
    {"dataset": "wikipedia", "config_name": "20220301.it"},
    {"dataset": "wikipedia", "config_name": "20220301.simple"},
    {"dataset": "snli", "config_name": "plain_text"},
    {"dataset": "eli5", "config_name": "LFQA_reddit"},
    {"dataset": "wiki40b", "config_name": "en"},
    {"dataset": "wiki_dpr", "config_name": "psgs_w100.nq.compressed"},
    {"dataset": "wiki_dpr", "config_name": "psgs_w100.nq.no_index"},
    {"dataset": "wiki_dpr", "config_name": "psgs_w100.multiset.no_index"},
    {"dataset": "natural_questions", "config_name": "default"},
]





def 		__snake_case(							_lowerCAmelCase=True						)						->					Dict:
      if with_config:
            return [
                {
                    "testcase_name": d["dataset"] + "/" + d["config_name"],
                    "dataset": d["dataset"],
                    "config_name": d["config_name"],
                }
                for d in DATASETS_ON_HF_GCP
            ]
      else:
            return [
                {"testcase_name": dataset, "dataset": dataset} for dataset in {d["dataset"] for d in DATASETS_ON_HF_GCP}
            ]







@parameterized.named_parameters(list_datasets_on_hf_gcp_parameters(with_config=_a      )      )
class        UpperCAmelCase_			(			_a      ):
    """simple docstring"""







    lowercase   =						None
    lowercase   =						None




    def lowerCamelCase			(       self   :	List[Any]					,	snake_case_   :	Union[str, Any]					,	snake_case_   :	Optional[int]		):
          with TemporaryDirectory() as tmp_dir:
                snake_case__    :       Dict       		= dataset_module_factory(snake_case_					,	cache_dir=snake_case_		)

                snake_case__    :       Optional[int]       		= import_main_class(dataset_module.module_path					,	dataset=snake_case_		)

                snake_case__    :       DatasetBuilder       		= builder_cls(
                    cache_dir=snake_case_					,	config_name=snake_case_					,	hash=dataset_module.hash					,	)

                snake_case__    :       Dict       		= """/""".join(
                    [
                        HF_GCP_BASE_URL,
                        builder_instance._relative_data_dir(with_hash=snake_case_		).replace(os.sep					,	"""/"""		),
                        config.DATASET_INFO_FILENAME,
                    ]		)
                snake_case__    :       List[str]       		= cached_path(snake_case_					,	cache_dir=snake_case_		)
                self.assertTrue(os.path.exists(snake_case_		)		)





@pytest.mark.integration
def 		__snake_case(							_lowerCAmelCase						)						->					Tuple:
      snake_case__    :       Optional[int]       		= tmp_path_factory.mktemp("""test_hf_gcp"""						) / """test_wikipedia_simple"""
      snake_case__    :       Dict       		= dataset_module_factory("""wikipedia"""	,  cache_dir=_lowerCAmelCase						)
      snake_case__    :       Dict       		= import_main_class(dataset_module.module_path						)
      snake_case__    :       DatasetBuilder       		= builder_cls(
          cache_dir=_lowerCAmelCase	,  config_name="""20220301.frr"""	,  hash=dataset_module.hash	,  )
      # use the HF cloud storage, not the original download_and_prepare that uses apache-beam
      snake_case__    :       Any       		= None
      builder_instance.download_and_prepare()
      snake_case__    :       Union[str, Any]       		= builder_instance.as_dataset()
      assert ds





@pytest.mark.integration
def 		__snake_case(							_lowerCAmelCase						)						->					List[str]:
      snake_case__    :       Optional[int]       		= dataset_module_factory("""wikipedia"""	,  cache_dir=_lowerCAmelCase						)
      snake_case__    :       List[str]       		= import_main_class(dataset_module.module_path	,  dataset=_lowerCAmelCase						)
      snake_case__    :       DatasetBuilder       		= builder_cls(
          cache_dir=_lowerCAmelCase	,  config_name="""20220301.frr"""	,  hash=dataset_module.hash	,  )
      snake_case__    :       Any       		= builder_instance.as_streaming_dataset()
      assert ds
      assert isinstance(_lowerCAmelCase	,  _lowerCAmelCase						)
      assert "train" in ds
      assert isinstance(ds["""train"""]	,  _lowerCAmelCase						)
      assert next(iter(ds["""train"""]						)						)
