





'''simple docstring'''




import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__SCREAMING_SNAKE_CASE     :Any       =				50000
__SCREAMING_SNAKE_CASE     :List[str]       =				5000

__SCREAMING_SNAKE_CASE  ,__SCREAMING_SNAKE_CASE     :Dict       =				os.path.split(__file__)
__SCREAMING_SNAKE_CASE     :str       =				os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))
@get_duration
def 	UpperCAmelCase_							(					__lowercase							:      datasets.Dataset			,     __lowercase							:      Any       )		->       Dict:


     '''simple docstring'''



     for i in range(__lowercase       ):
          _UpperCAmelCase     							=   dataset[i]
@get_duration
def 	UpperCAmelCase_							(					__lowercase							:      datasets.Dataset			,     __lowercase							:      int			,     __lowercase							:      Union[str, Any]       )		->       str:


     '''simple docstring'''



     for i in range(0			,     len(__lowercase       )			,     __lowercase       ):
          _UpperCAmelCase     							=   dataset[i : i + batch_size]
@get_duration
def 	UpperCAmelCase_							(					__lowercase							:      datasets.Dataset			,     __lowercase							:      int			,     __lowercase							:      Union[str, Any]       )		->       Dict:


     '''simple docstring'''



     with dataset.formatted_as(type=__lowercase       ):
          for i in range(__lowercase       ):
               _UpperCAmelCase     							=   dataset[i]
@get_duration
def 	UpperCAmelCase_							(					__lowercase							:      datasets.Dataset			,     __lowercase							:      Optional[int]			,     __lowercase							:      List[str]			,     __lowercase							:      Any       )		->       Union[str, Any]:


     '''simple docstring'''



     with dataset.formatted_as(type=__lowercase       ):
          for i in range(0			,     __lowercase			,     __lowercase       ):
               _UpperCAmelCase     							=   dataset[i : i + batch_size]
def 	UpperCAmelCase_							(					)		->       Union[str, Any]:


     '''simple docstring'''



     _UpperCAmelCase     							=   {"num examples": SPEED_TEST_N_EXAMPLES}
     _UpperCAmelCase     							=   [
         (read, {"length": SMALL_TEST}),
         (read, {"length": SPEED_TEST_N_EXAMPLES}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 10}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 100}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 1000}),
         (read_formatted, {"type": "numpy", "length": SMALL_TEST}),
         (read_formatted, {"type": "pandas", "length": SMALL_TEST}),
         (read_formatted, {"type": "torch", "length": SMALL_TEST}),
         (read_formatted, {"type": "tensorflow", "length": SMALL_TEST}),
         (read_formatted_batch, {"type": "numpy", "length": SMALL_TEST, "batch_size": 10}),
         (read_formatted_batch, {"type": "numpy", "length": SMALL_TEST, "batch_size": 1000}),
     ]

     _UpperCAmelCase     							=   [
         (read, {"length": SMALL_TEST}),
         (read, {"length": SPEED_TEST_N_EXAMPLES}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 10}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 100}),
         (read_batch, {"length": SPEED_TEST_N_EXAMPLES, "batch_size": 1000}),
         (read_formatted, {"type": "numpy", "length": SMALL_TEST}),
         (read_formatted_batch, {"type": "numpy", "length": SMALL_TEST, "batch_size": 10}),
         (read_formatted_batch, {"type": "numpy", "length": SMALL_TEST, "batch_size": 1000}),
     ]
     with tempfile.TemporaryDirectory() as tmp_dir:
          print("generating dataset"       )
          _UpperCAmelCase     							=   datasets.Features(
              {"list": datasets.Sequence(datasets.Value("float32"       )       ), "numbers": datasets.Value("float32"       )}       )
          _UpperCAmelCase     							=   generate_example_dataset(
              os.path.join(__lowercase			,     "dataset.arrow"       )			,     __lowercase			,     num_examples=__lowercase			,     seq_shapes={"list": (100,)}			,     )
          print("first set of iterations"       )
          for func, kwargs in functions:
               print(func.__name__			,     str(__lowercase       )       )
               _UpperCAmelCase     							=   func(__lowercase			,     **__lowercase       )

          print("shuffling dataset"       )
          _UpperCAmelCase     							=   dataset.shuffle()
          print("Second set of iterations (after shuffling"       )
          for func, kwargs in functions_shuffled:
               print("shuffled "			,     func.__name__			,     str(__lowercase       )       )
               _UpperCAmelCase     							=   func(
                   __lowercase			,     **__lowercase       )

     with open(__lowercase			,     "wb"       ) as f:
          f.write(json.dumps(__lowercase       ).encode("utf-8"       )       )


if __name__ == "__main__":  # useful to run the profiler
  benchmark_iterating()











'''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()




