






"""simple docstring"""






import os
import zipfile

import requests
from get_ci_error_statistics import download_artifact, get_artifacts_links



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__=7				):
				A__							 =       None
				if token is not None:
								A__							 =       {'Accept': 'application/vnd.github+json', 'Authorization': f'''Bearer {token}'''}

				# The id of a workflow (not of a workflow run)
				A__							 =       '636036'

				A__							 =       f'''https://api.github.com/repos/huggingface/transformers/actions/workflows/{workflow_id}/runs'''
				# On `main` branch + event being `schedule` + not returning PRs + only `num_runs` results
				url += f'''?branch=main&event=schedule&exclude_pull_requests=true&per_page={num_runs}'''

				A__							 =       requests.get(lowerCAmelCase__       ,headers=lowerCAmelCase__				).json()

				return result["workflow_runs"]



def  __lowerCamelCase					(					lowerCAmelCase__				):
				A__							 =       get_daily_ci_runs(lowerCAmelCase__				)
				A__							 =       None
				for workflow_run in workflow_runs:
								if workflow_run["status"] == "completed":
												A__							 =       workflow_run['id']
												break

				return workflow_run_id



def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				):
				A__							 =       get_last_daily_ci_runs(lowerCAmelCase__				)
				if workflow_run_id is not None:
								A__							 =       get_artifacts_links(worflow_run_id=lowerCAmelCase__       ,token=lowerCAmelCase__				)
								for artifact_name in artifact_names:
												if artifact_name in artifacts_links:
																A__							 =       artifacts_links[artifact_name]
																download_artifact(
																    artifact_name=lowerCAmelCase__       ,artifact_url=lowerCAmelCase__       ,output_dir=lowerCAmelCase__       ,token=lowerCAmelCase__				)







def  __lowerCamelCase					(					lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				):
				get_last_daily_ci_artifacts(lowerCAmelCase__       ,lowerCAmelCase__       ,lowerCAmelCase__				)

				A__							 =       {}
				for artifact_name in artifact_names:
								A__							 =       os.path.join(lowerCAmelCase__       ,f'''{artifact_name}.zip'''				)
								if os.path.isfile(lowerCAmelCase__				):
												A__							 =       {}
												with zipfile.ZipFile(lowerCAmelCase__				) as z:
																for filename in z.namelist():
																				if not os.path.isdir(lowerCAmelCase__				):
																								# read the file
																								with z.open(lowerCAmelCase__				) as f:
																												A__							 =       f.read().decode('UTF-8'				)

				return results










"""simple docstring"""






from ...processing_utils import ProcessorMixin





class       snake_case_       (    _lowerCamelCase       ):



	"""simple docstring"""

	SCREAMING_SNAKE_CASE_:							List[str]   			=					"""WhisperFeatureExtractor"""
	SCREAMING_SNAKE_CASE_:							Union[str, Any]   			=					"""WhisperTokenizer"""


	def __init__(      self  ,					__a  ,					__a						):


					"""simple docstring"""

					super().__init__(__a  ,					__a						)
					A__							 =       self.feature_extractor
					A__							 =       False


	def       _UpperCAmelCase						(      self  ,					__a=None  ,					__a=None  ,					__a=True						):


					"""simple docstring"""

					return self.tokenizer.get_decoder_prompt_ids(task=__a  ,					language=__a  ,					no_timestamps=__a						)


	def __call__(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					if self._in_target_context_manager:
									return self.current_processor(*__a  ,					**__a						)

					A__							 =       kwargs.pop('audio'  ,					__a						)
					A__							 =       kwargs.pop('sampling_rate'  ,					__a						)
					A__							 =       kwargs.pop('text'  ,					__a						)
					if len(__a						) > 0:
									A__							 =       args[0]
									A__							 =       args[1:]

					if audio is None and text is None:
									raise ValueError('You need to specify either an `audio` or `text` input to process.'						)

					if audio is not None:
									A__							 =       self.feature_extractor(__a  ,					*__a  ,					sampling_rate=__a  ,					**__a						)
					if text is not None:
									A__							 =       self.tokenizer(__a  ,					**__a						)

					if text is None:
									return inputs

					elif audio is None:
									return encodings
					else:
									A__							 =       encodings['input_ids']
									return inputs


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					return self.tokenizer.batch_decode(*__a  ,					**__a						)


	def       _UpperCAmelCase						(      self  ,					*__a  ,					**__a						):


					"""simple docstring"""

					return self.tokenizer.decode(*__a  ,					**__a						)






	def       _UpperCAmelCase						(      self  ,					__a  ,					__a="np"						):


					"""simple docstring"""

					return self.tokenizer.get_prompt_ids(__a  ,					return_tensors=__a						)


