Skip to content

Commit 3c9e037

Browse files
committed
chore: ruff and typegen
1 parent d8820bf commit 3c9e037

File tree

4 files changed

+149
-4
lines changed

4 files changed

+149
-4
lines changed

invokeai/app/api/routers/model_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ async def get_orphaned_models() -> list[OrphanedModelInfo]:
11061106

11071107
# Access the database through the model records service
11081108
model_records_service = ApiDependencies.invoker.services.model_manager.store
1109-
1109+
11101110
service = OrphanedModelsService(
11111111
config=ApiDependencies.invoker.services.configuration,
11121112
db=model_records_service._db, # Access the database from model records service
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Service for finding and removing orphaned model files."""
22

3-
from .orphaned_models_service import OrphanedModelInfo, OrphanedModelsService
3+
from invokeai.app.services.orphaned_models.orphaned_models_service import OrphanedModelInfo, OrphanedModelsService
44

55
__all__ = ["OrphanedModelsService", "OrphanedModelInfo"]

invokeai/app/services/orphaned_models/orphaned_models_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ def delete_orphaned_models(self, orphaned_paths: list[str]) -> dict[str, str]:
137137
try:
138138
full_path = models_path / rel_path
139139
if not full_path.exists():
140-
results[rel_path] = f"error: path does not exist"
140+
results[rel_path] = "error: path does not exist"
141141
continue
142142

143143
# Safety check: ensure path is under models directory
144144
try:
145145
full_path.relative_to(models_path)
146146
except ValueError:
147-
results[rel_path] = f"error: path is not under models directory"
147+
results[rel_path] = "error: path is not under models directory"
148148
continue
149149

150150
# Delete the directory

invokeai/frontend/web/src/services/api/schema.ts

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,43 @@ export type paths = {
403403
patch?: never;
404404
trace?: never;
405405
};
406+
"/api/v2/models/sync/orphaned": {
407+
parameters: {
408+
query?: never;
409+
header?: never;
410+
path?: never;
411+
cookie?: never;
412+
};
413+
/**
414+
* Get Orphaned Models
415+
* @description Find orphaned model directories.
416+
*
417+
* Orphaned models are directories in the models folder that contain model files
418+
* but are not referenced in the database. This can happen when models are deleted
419+
* from the database but the files remain on disk.
420+
*
421+
* Returns:
422+
* List of orphaned model directory information
423+
*/
424+
get: operations["get_orphaned_models"];
425+
put?: never;
426+
post?: never;
427+
/**
428+
* Delete Orphaned Models
429+
* @description Delete specified orphaned model directories.
430+
*
431+
* Args:
432+
* request: Request containing list of relative paths to delete
433+
*
434+
* Returns:
435+
* Response indicating which paths were deleted and which had errors
436+
*/
437+
delete: operations["delete_orphaned_models"];
438+
options?: never;
439+
head?: never;
440+
patch?: never;
441+
trace?: never;
442+
};
406443
"/api/v1/download_queue/": {
407444
parameters: {
408445
query?: never;
@@ -6419,6 +6456,35 @@ export type components = {
64196456
*/
64206457
deleted_images: string[];
64216458
};
6459+
/**
6460+
* DeleteOrphanedModelsRequest
6461+
* @description Request to delete specific orphaned model directories.
6462+
*/
6463+
DeleteOrphanedModelsRequest: {
6464+
/**
6465+
* Paths
6466+
* @description List of relative paths to delete
6467+
*/
6468+
paths: string[];
6469+
};
6470+
/**
6471+
* DeleteOrphanedModelsResponse
6472+
* @description Response from deleting orphaned models.
6473+
*/
6474+
DeleteOrphanedModelsResponse: {
6475+
/**
6476+
* Deleted
6477+
* @description Paths that were successfully deleted
6478+
*/
6479+
deleted: string[];
6480+
/**
6481+
* Errors
6482+
* @description Paths that had errors, with error messages
6483+
*/
6484+
errors: {
6485+
[key: string]: string;
6486+
};
6487+
};
64226488
/**
64236489
* Denoise - SD1.5, SDXL
64246490
* @description Denoises noisy latents to decodable images
@@ -20398,6 +20464,32 @@ export type components = {
2039820464
*/
2039920465
items: components["schemas"]["ImageDTO"][];
2040020466
};
20467+
/**
20468+
* OrphanedModelInfo
20469+
* @description Information about an orphaned model directory.
20470+
*/
20471+
OrphanedModelInfo: {
20472+
/**
20473+
* Path
20474+
* @description Relative path to the orphaned directory from models root
20475+
*/
20476+
path: string;
20477+
/**
20478+
* Absolute Path
20479+
* @description Absolute path to the orphaned directory
20480+
*/
20481+
absolute_path: string;
20482+
/**
20483+
* Files
20484+
* @description List of model files in this directory
20485+
*/
20486+
files: string[];
20487+
/**
20488+
* Size Bytes
20489+
* @description Total size of all files in bytes
20490+
*/
20491+
size_bytes: number;
20492+
};
2040120493
/**
2040220494
* OutputFieldJSONSchemaExtra
2040320495
* @description Extra attributes to be added to input fields and their OpenAPI schema. Used by the workflow editor
@@ -28160,6 +28252,59 @@ export interface operations {
2816028252
};
2816128253
};
2816228254
};
28255+
get_orphaned_models: {
28256+
parameters: {
28257+
query?: never;
28258+
header?: never;
28259+
path?: never;
28260+
cookie?: never;
28261+
};
28262+
requestBody?: never;
28263+
responses: {
28264+
/** @description Successful Response */
28265+
200: {
28266+
headers: {
28267+
[name: string]: unknown;
28268+
};
28269+
content: {
28270+
"application/json": components["schemas"]["OrphanedModelInfo"][];
28271+
};
28272+
};
28273+
};
28274+
};
28275+
delete_orphaned_models: {
28276+
parameters: {
28277+
query?: never;
28278+
header?: never;
28279+
path?: never;
28280+
cookie?: never;
28281+
};
28282+
requestBody: {
28283+
content: {
28284+
"application/json": components["schemas"]["DeleteOrphanedModelsRequest"];
28285+
};
28286+
};
28287+
responses: {
28288+
/** @description Successful Response */
28289+
200: {
28290+
headers: {
28291+
[name: string]: unknown;
28292+
};
28293+
content: {
28294+
"application/json": components["schemas"]["DeleteOrphanedModelsResponse"];
28295+
};
28296+
};
28297+
/** @description Validation Error */
28298+
422: {
28299+
headers: {
28300+
[name: string]: unknown;
28301+
};
28302+
content: {
28303+
"application/json": components["schemas"]["HTTPValidationError"];
28304+
};
28305+
};
28306+
};
28307+
};
2816328308
list_downloads: {
2816428309
parameters: {
2816528310
query?: never;

0 commit comments

Comments
 (0)