import argparse
import math
import traceback

import dateutil.parser as date_parser
import requests



def 	__A		(      _A       ):



 """simple docstring"""


 __a							=	{}

 __a							=	job["started_at"]
 __a							=	job["completed_at"]

 __a							=	date_parser.parse(_A       )
 __a							=	date_parser.parse(_A       )

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

 __a							=	start
 __a							=	end
 __a							=	duration_in_min

 return job_info



def 	__A		(      _A				,					_A=None       ):



 """simple docstring"""


 __a							=	None
 if token is not None:
  __a							=	{"Accept": "application/vnd.github+json", "Authorization": f"""Bearer {token}"""}

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

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

  for i in range(_A       ):
   __a							=	requests.get(url + f"""&page={i + 2}"""				,					headers=_A       ).json()
   job_time.update({job["name"]: extract_time_from_single_job(_A       ) 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__":
  SCREAMING_SNAKE_CASE			:						Tuple				  =		argparse.ArgumentParser()
  # Required parameters
  parser.add_argument("""--workflow_run_id""", type=str, required=True, help="""A GitHub Actions workflow run id.""")
  SCREAMING_SNAKE_CASE			:						int				  =		parser.parse_args()

  SCREAMING_SNAKE_CASE			:						List[str]				  =		get_job_time(args.workflow_run_id)
  SCREAMING_SNAKE_CASE			:						Optional[Any]				  =		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 typing import Any



def 	__A		(      _A       ):



 """simple docstring"""


 if not input_list:
  return []
 __a							=	[input_list.count(_A       ) for value in input_list]
 __a							=	max(_A       )  # Gets the maximum count in the input list.
 # Gets values of modes
 return sorted({input_list[i] for i, value in enumerate(_A       ) if value == y}       )


if __name__ == "__main__":
  import doctest

  doctest.testmod()


