Use tuple type from annotations.

This commit is contained in:
Robin Huang 2024-08-08 12:53:17 -07:00
parent 5537d25e72
commit db1ce51fdf

View File

@ -1,14 +1,16 @@
from __future__ import annotations
import aiohttp import aiohttp
import os import os
import traceback import traceback
import logging import logging
from folder_paths import models_dir from folder_paths import models_dir
import re import re
from typing import Callable, Any, Optional, Awaitable, Tuple, Dict from typing import Callable, Any, Optional, Awaitable, Dict
from enum import Enum from enum import Enum
import time import time
from dataclasses import dataclass from dataclasses import dataclass
class DownloadStatusType(Enum): class DownloadStatusType(Enum):
PENDING = "pending" PENDING = "pending"
IN_PROGRESS = "in_progress" IN_PROGRESS = "in_progress"
@ -93,7 +95,7 @@ async def download_model(model_download_request: Callable[[str], Awaitable[aioht
return await handle_download_error(e, model_name, progress_callback, relative_path) return await handle_download_error(e, model_name, progress_callback, relative_path)
def create_model_path(model_name: str, model_directory: str, models_base_dir: str) -> Tuple[str, str]: def create_model_path(model_name: str, model_directory: str, models_base_dir: str) -> tuple[str, str]:
full_model_dir = os.path.join(models_base_dir, model_directory) full_model_dir = os.path.join(models_base_dir, model_directory)
os.makedirs(full_model_dir, exist_ok=True) os.makedirs(full_model_dir, exist_ok=True)
file_path = os.path.join(full_model_dir, model_name) file_path = os.path.join(full_model_dir, model_name)