From 1ba49707d900b327aac91df6ee7c8e1521d86544 Mon Sep 17 00:00:00 2001 From: Hossein Rashidi Date: Thu, 11 Jul 2024 14:08:57 +0000 Subject: [PATCH] add raises docstring & formatting --- aana/core/models/video.py | 4 +++- aana/deployments/vllm_deployment.py | 7 ++++--- aana/integrations/external/yt_dlp.py | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/aana/core/models/video.py b/aana/core/models/video.py index bb5ba69e..1413cc87 100644 --- a/aana/core/models/video.py +++ b/aana/core/models/video.py @@ -133,7 +133,9 @@ class VideoMetadata(BaseModel): title: str = Field(None, description="The title of the video.") description: str = Field(None, description="The description of the video.") - duration: float | None = Field(None, description="The duration of the video in seconds.") + duration: float | None = Field( + None, description="The duration of the video in seconds." + ) model_config = ConfigDict( json_schema_extra={ "description": "Metadata of a video.", diff --git a/aana/deployments/vllm_deployment.py b/aana/deployments/vllm_deployment.py index 7aea55fc..4482c49b 100644 --- a/aana/deployments/vllm_deployment.py +++ b/aana/deployments/vllm_deployment.py @@ -41,7 +41,7 @@ class VLLMConfig(BaseModel): chat_template (str): the name of the chat template, if not provided, the chat template from the model will be used but some models may not have a chat template (optional, default: None) enforce_eager: whether to enforce eager execution (optional, default: False) - engine_args: extra engine arguments (optional, default: {}) + engine_args: extra engine arguments (optional, default: {}) """ @@ -57,6 +57,7 @@ class VLLMConfig(BaseModel): enforce_eager: bool | None = Field(default=False) engine_args: CustomConfig = {} + @serve.deployment class VLLMDeployment(BaseTextGenerationDeployment): """Deployment to serve large language models using vLLM.""" @@ -101,7 +102,7 @@ async def apply_config(self, config: dict[str, Any]): enforce_eager=config_obj.enforce_eager, gpu_memory_utilization=self.gpu_memory_utilization, max_model_len=config_obj.max_model_len, - **config_obj.engine_args + **config_obj.engine_args, ) # TODO: check if the model is already loaded. @@ -153,7 +154,7 @@ async def generate_stream( results_generator = self.engine.generate( sampling_params=sampling_params_vllm, request_id=request_id, - inputs=TokensPrompt(prompt_token_ids=prompt_token_ids) + inputs=TokensPrompt(prompt_token_ids=prompt_token_ids), ) num_returned = 0 diff --git a/aana/integrations/external/yt_dlp.py b/aana/integrations/external/yt_dlp.py index 652677ae..a59e592f 100644 --- a/aana/integrations/external/yt_dlp.py +++ b/aana/integrations/external/yt_dlp.py @@ -20,6 +20,9 @@ def get_video_metadata(video_url: str) -> VideoMetadata: Returns: metadata (VideoMetadata): the metadata of the video + + Raises: + DownloadException: Request does not succeed. """ ydl_options = { @@ -51,6 +54,9 @@ def download_video(video_input: VideoInput | Video) -> Video: Returns: Video: the video object + + Raises: + DownloadException: Request does not succeed. """ if isinstance(video_input, Video): return video_input