






"""simple docstring"""



import argparse
import math
import traceback

import dateutil.parser as date_parser
import requests




def      _lowerCAmelCase		(							UpperCAmelCase__       :					Optional[int]      )		->Tuple:
						A__						:  Optional[int]		  =  {}

						A__						:  int		  =  job["""started_at"""]
						A__						:  Any		  =  job["""completed_at"""]

						A__						:  Optional[int]		  =  date_parser.parse(UpperCAmelCase__      )
						A__						:  Optional[Any]		  =  date_parser.parse(UpperCAmelCase__      )

						A__						:  Any		  =  round((end_datetime - start_datetime).total_seconds() / 60.0      )

						A__						:  List[str]		  =  start
						A__						:  Optional[int]		  =  end
						A__						:  Optional[int]		  =  duration_in_min

						return job_info




def      _lowerCAmelCase		(							UpperCAmelCase__       :					Dict,						UpperCAmelCase__       :					Optional[int]=None      )		->Optional[int]:
						A__						:  List[Any]		  =  None
						if token is not None:
												A__						:  Optional[Any]		  =  {"""Accept""": """application/vnd.github+json""", """Authorization""": f'Bearer {token}'}

						A__						:  Any		  =  f'https://api.github.com/repos/huggingface/transformers/actions/runs/{workflow_run_id}/jobs?per_page=100'
						A__						:  Any		  =  requests.get(UpperCAmelCase__,						headers=UpperCAmelCase__      ).json()
						A__						:  int		  =  {}

						try:
												job_time.update({job["""name"""]: extract_time_from_single_job(UpperCAmelCase__      ) for job in result["""jobs"""]}      )
												A__						:  str		  =  math.ceil((result["""total_count"""] - 1_0_0) / 1_0_0      )

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

						A_    =							get_job_time(args.workflow_run_id)
						A_    =							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"]}')














"""simple docstring"""



def      _lowerCAmelCase		(							UpperCAmelCase__       :					int,						UpperCAmelCase__       :					int      )		->str:
						if a < 0 or b < 0:
												raise ValueError("""the value of both inputs must be positive"""      )

						A__						:  str		  =  str(bin(UpperCAmelCase__      )      )[2:]  # remove the leading "0b"
						A__						:  List[Any]		  =  str(bin(UpperCAmelCase__      )      )[2:]  # remove the leading "0b"

						A__						:  List[str]		  =  max(len(UpperCAmelCase__      ),						len(UpperCAmelCase__      )      )

						return "0b" + "".join(
						    str(int(char_a == """1""" and char_b == """1"""      )      )
						    for char_a, char_b in zip(a_binary.zfill(UpperCAmelCase__      ),						b_binary.zfill(UpperCAmelCase__      )      )      )


if __name__ == "__main__":
						import doctest

						doctest.testmod()






