





import argparse
import math
import traceback

import dateutil.parser as date_parser
import requests

def   a_    ( lowerCAmelCase_      :			str	):
   __lowerCAmelCase								=	{}

   __lowerCAmelCase								=	job['started_at']
   __lowerCAmelCase								=	job['completed_at']

   __lowerCAmelCase								=	date_parser.parse(lowerCAmelCase_	)
   __lowerCAmelCase								=	date_parser.parse(lowerCAmelCase_	)

   __lowerCAmelCase								=	round((end_datetime - start_datetime).total_seconds() / 60.0	)

   __lowerCAmelCase								=	start
   __lowerCAmelCase								=	end
   __lowerCAmelCase								=	duration_in_min

   return job_info

def   a_    ( lowerCAmelCase_      :			int,	lowerCAmelCase_      :			int=None	):
   __lowerCAmelCase								=	None
   if token is not None:
      __lowerCAmelCase								=	{'Accept': 'application/vnd.github+json', 'Authorization': F"""Bearer {token}"""}

   __lowerCAmelCase								=	F"""https://api.github.com/repos/huggingface/transformers/actions/runs/{workflow_run_id}/jobs?per_page=100"""
   __lowerCAmelCase								=	requests.get(lowerCAmelCase_,	headers=lowerCAmelCase_	).json()
   __lowerCAmelCase								=	{}

   try:
      job_time.update({job['name']: extract_time_from_single_job(lowerCAmelCase_	) for job in result['jobs']}	)
      __lowerCAmelCase								=	math.ceil((result['total_count'] - 100) / 100	)

      for i in range(lowerCAmelCase_	):
         __lowerCAmelCase								=	requests.get(url + F"""&page={i + 2}""",	headers=lowerCAmelCase_	).json()
         job_time.update({job['name']: extract_time_from_single_job(lowerCAmelCase_	) for job in result['jobs']}	)

      return job_time
   except Exception:
      print(F"""Unknown error, could not fetch links:\n{traceback.format_exc()}"""	)

   return {}


if __name__ == "__main__":
     _snake_case  :    int						    =  argparse.ArgumentParser()
     # Required parameters
     parser.add_argument('--workflow_run_id', type=str, required=True, help='A GitHub Actions workflow run id.')
     _snake_case  :    Optional[int]						    =  parser.parse_args()

     _snake_case  :    Any						    =  get_job_time(args.workflow_run_id)
     _snake_case  :    Dict						    =  dict(sorted(job_time.items(), key=lambda item: item[1]["duration"], reverse=True))

     for k, v in job_time.items():
          print(F"""{k}: {v["duration"]}""")








from timeit import timeit

def   a_    ( lowerCAmelCase_      :			int	):
   if number < 0:
      raise ValueError('the value of input must not be negative'	)
   __lowerCAmelCase								=	0
   while number:
      number &= number - 1
      result += 1
   return result

def   a_    ( lowerCAmelCase_      :			int	):
   if number < 0:
      raise ValueError('the value of input must not be negative'	)
   __lowerCAmelCase								=	0
   while number:
      if number % 2 == 1:
         result += 1
      number >>= 1
   return result

def   a_    ( ):

   def do_benchmark(lowerCAmelCase_      :			int	) -> None:
      __lowerCAmelCase								=	'import __main__ as z'
      print(F"""Benchmark when {number = }:"""	)
      print(F"""{get_set_bits_count_using_modulo_operator(lowerCAmelCase_	) = }"""	)
      __lowerCAmelCase								=	timeit('z.get_set_bits_count_using_modulo_operator(25)',	setup=lowerCAmelCase_	)
      print(F"""timeit() runs in {timing} seconds"""	)
      print(F"""{get_set_bits_count_using_brian_kernighans_algorithm(lowerCAmelCase_	) = }"""	)
      __lowerCAmelCase								=	timeit(
          'z.get_set_bits_count_using_brian_kernighans_algorithm(25)',	setup=lowerCAmelCase_,	)
      print(F"""timeit() runs in {timing} seconds"""	)

   for number in (25, 37, 58, 0):
      do_benchmark(lowerCAmelCase_	)
      print()


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     benchmark()

