Correctly remove classification model from config (#20772)

* Correctly remove classification model from config

* Undo

* fix

* Use existing config update API and dynamically remove models that were running

* Set update message for face
This commit is contained in:
Nicolas Mowen
2025-11-03 08:01:30 -07:00
committed by GitHub
parent 740c618240
commit 31fa87ce73
5 changed files with 89 additions and 72 deletions

View File

@@ -34,12 +34,10 @@ from frigate.config.camera import DetectConfig
from frigate.const import CLIPS_DIR, FACE_DIR, MODEL_CACHE_DIR
from frigate.embeddings import EmbeddingsContext
from frigate.models import Event
from frigate.util.builtin import update_yaml_file_bulk
from frigate.util.classification import (
collect_object_classification_examples,
collect_state_classification_examples,
)
from frigate.util.config import find_config_file
from frigate.util.path import get_event_snapshot
logger = logging.getLogger(__name__)
@@ -840,24 +838,6 @@ def delete_classification_model(request: Request, name: str):
if os.path.exists(model_dir):
shutil.rmtree(model_dir)
# Remove the model from the config file
config_file = find_config_file()
try:
# Setting value to empty string deletes the key
updates = {f"classification.custom.{name}": None}
update_yaml_file_bulk(config_file, updates)
except Exception as e:
logger.error(f"Error updating config file: {e}")
return JSONResponse(
content=(
{
"success": False,
"message": "Failed to update config file.",
}
),
status_code=500,
)
return JSONResponse(
content=(
{