mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
rename endpoint for scanning
This commit is contained in:
parent
e731645f0e
commit
e18763438b
@ -235,23 +235,23 @@ async def list_tags() -> Set[str]:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@model_manager_router.get(
|
@model_manager_router.get(
|
||||||
"/search",
|
"/scan_folder",
|
||||||
operation_id="search_for_models",
|
operation_id="scan_for_models",
|
||||||
responses={
|
responses={
|
||||||
200: {"description": "Directory searched successfully"},
|
200: {"description": "Directory scanned successfully"},
|
||||||
404: {"description": "Invalid directory path"},
|
400: {"description": "Invalid directory path"},
|
||||||
},
|
},
|
||||||
status_code=200,
|
status_code=200,
|
||||||
response_model=List[pathlib.Path],
|
response_model=List[pathlib.Path],
|
||||||
)
|
)
|
||||||
async def search_for_models(
|
async def scan_for_models(
|
||||||
search_path: str = Query(description="Directory path to search for models", default=None),
|
scan_path: str = Query(description="Directory path to search for models", default=None),
|
||||||
) -> List[pathlib.Path]:
|
) -> List[pathlib.Path]:
|
||||||
path = pathlib.Path(search_path)
|
path = pathlib.Path(scan_path)
|
||||||
if not search_path or not path.is_dir():
|
if not scan_path or not path.is_dir():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=404,
|
status_code=400,
|
||||||
detail=f"The search path '{search_path}' does not exist or is not directory",
|
detail=f"The search path '{scan_path}' does not exist or is not directory",
|
||||||
)
|
)
|
||||||
|
|
||||||
search = ModelSearch()
|
search = ModelSearch()
|
||||||
@ -259,7 +259,7 @@ async def search_for_models(
|
|||||||
models_found = list(search.search(path))
|
models_found = list(search.search(path))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=404,
|
status_code=500,
|
||||||
detail=f"An error occurred while searching the directory: {e}",
|
detail=f"An error occurred while searching the directory: {e}",
|
||||||
)
|
)
|
||||||
return models_found
|
return models_found
|
||||||
|
Loading…
Reference in New Issue
Block a user