Skip to content

Commit

Permalink
Ruff checks
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonrising committed Feb 23, 2024
1 parent 884db30 commit a48b3a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion invokeai/app/api/routers/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,13 @@ async def list_tags() -> Set[str]:
async def scan_for_models(
scan_path: str = Query(description="Directory path to search for models", default=None),
) -> List[pathlib.Path]:
if not scan_path:
raise HTTPException(
status_code=400,
detail=f"The search path '{scan_path}' does not exist or is not directory",
)
path = pathlib.Path(scan_path)
if not scan_path or not path.is_dir():
if not path.is_dir():
raise HTTPException(
status_code=400,
detail=f"The search path '{scan_path}' does not exist or is not directory",
Expand Down
6 changes: 3 additions & 3 deletions invokeai/backend/model_manager/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def find_main_models(model: Path) -> bool:
from logging import Logger
from pathlib import Path
from typing import Callable, Optional, Set, Union
from invokeai.app.services.config import InvokeAIAppConfig

from pydantic import BaseModel, Field

from invokeai.app.services.config import InvokeAIAppConfig
from invokeai.backend.util.logging import InvokeAILogger

default_logger: Logger = InvokeAILogger.get_logger()
Expand Down Expand Up @@ -167,15 +167,15 @@ def _walk_directory(self, path: Union[Path, str], max_depth: int = 20) -> None:
):
try:
self.model_found(absolute_path)
return
except KeyboardInterrupt:
raise
except Exception as e:
self.logger.warning(str(e))
finally:
return

for n in file_names:
if any([n.endswith(suffix) for suffix in {".ckpt", ".bin", ".pth", ".safetensors", ".pt"}]):
if n.endswith((".ckpt", ".bin", ".pth", ".safetensors", ".pt")):
try:
self.model_found(absolute_path / n)
except KeyboardInterrupt:
Expand Down

0 comments on commit a48b3a0

Please sign in to comment.