


'''simple docstring'''





import argparse
import math
import traceback

import dateutil.parser as date_parser
import requests





def __UpperCAmelCase       (		__A			)						->					Dict:



       '''simple docstring'''





       UpperCAmelCase__										=     {}

       UpperCAmelCase__										=     job["started_at"]
       UpperCAmelCase__										=     job["completed_at"]

       UpperCAmelCase__										=     date_parser.parse(__UpperCamelCase			)
       UpperCAmelCase__										=     date_parser.parse(__UpperCamelCase			)

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

       UpperCAmelCase__										=     start
       UpperCAmelCase__										=     end
       UpperCAmelCase__										=     duration_in_min

       return job_info





def __UpperCAmelCase       (		__A ,						__A=None			)						->					Union[str, Any]:



       '''simple docstring'''





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

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

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

              for i in range(__UpperCamelCase			):
                     UpperCAmelCase__										=     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']}")









import unittest

import numpy as np

from diffusers import OnnxStableDiffusionInpaintPipelineLegacy
from diffusers.utils.testing_utils import (
    is_onnx_available,
    load_image,
    load_numpy,
    nightly,
    require_onnxruntime,
    require_torch_gpu,
)


if is_onnx_available():
    import onnxruntime as ort


@nightly
@require_onnxruntime
@require_torch_gpu
class     lowercase__  (					unittest.TestCase		):






  @property
  def 			_UpperCAmelCase  (					self      :					Union[str, Any] ):




         """simple docstring"""







         return (
             "CUDAExecutionProvider",
             {
                 "gpu_mem_limit": "15000000000",  # 15GB
                 "arena_extend_strategy": "kSameAsRequested",
             },
         )






  @property
  def 			_UpperCAmelCase  (					self      :					Optional[Any] ):




         """simple docstring"""







         UpperCAmelCase__										=     ort.SessionOptions()
         UpperCAmelCase__										=     False
         return options






  def 			_UpperCAmelCase  (					self      :					Dict ):




         """simple docstring"""







         UpperCAmelCase__										=     load_image(
             "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
             "/in_paint/overture-creations-5sI6fQgYIuo.png" )
         UpperCAmelCase__										=     load_image(
             "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
             "/in_paint/overture-creations-5sI6fQgYIuo_mask.png" )
         UpperCAmelCase__										=     load_numpy(
             "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main"
             "/in_paint/red_cat_sitting_on_a_park_bench_onnx.npy" )

         # using the PNDM scheduler by default
         UpperCAmelCase__										=     OnnxStableDiffusionInpaintPipelineLegacy.from_pretrained(
             "CompVis/stable-diffusion-v1-4"		,						revision="onnx"		,						safety_checker=_lowercase		,						feature_extractor=_lowercase		,						provider=self.gpu_provider		,						sess_options=self.gpu_options		,						)
         pipe.set_progress_bar_config(disable=_lowercase )

         UpperCAmelCase__										=     "A red cat sitting on a park bench"

         UpperCAmelCase__										=     np.random.RandomState(0 )
         UpperCAmelCase__										=     pipe(
             prompt=_lowercase		,						image=_lowercase		,						mask_image=_lowercase		,						strength=0.7_5		,						guidance_scale=7.5		,						num_inference_steps=15		,						generator=_lowercase		,						output_type="np"		,						)

         UpperCAmelCase__										=     output.images[0]

         assert image.shape == (5_12, 5_12, 3)
         assert np.abs(expected_image - image ).max() < 1E-2





