diff --git a/src/hope_dedup_engine/apps/api/admin/__init__.py b/src/hope_dedup_engine/apps/api/admin/__init__.py index 1f93271..2cd9c3d 100644 --- a/src/hope_dedup_engine/apps/api/admin/__init__.py +++ b/src/hope_dedup_engine/apps/api/admin/__init__.py @@ -1,5 +1,6 @@ from django.contrib import admin +from .config import ConfigAdmin # noqa from .deduplicationset import DeduplicationSetAdmin # noqa from .duplicate import DuplicateAdmin # noqa from .hdetoken import HDETokenAdmin # noqa diff --git a/src/hope_dedup_engine/apps/api/admin/config.py b/src/hope_dedup_engine/apps/api/admin/config.py new file mode 100644 index 0000000..18d4320 --- /dev/null +++ b/src/hope_dedup_engine/apps/api/admin/config.py @@ -0,0 +1,8 @@ +from django.contrib.admin import ModelAdmin, register + +from hope_dedup_engine.apps.api.models import Config + + +@register(Config) +class ConfigAdmin(ModelAdmin): + pass diff --git a/src/hope_dedup_engine/apps/api/models/__init__.py b/src/hope_dedup_engine/apps/api/models/__init__.py index 40bdb2f..3192920 100644 --- a/src/hope_dedup_engine/apps/api/models/__init__.py +++ b/src/hope_dedup_engine/apps/api/models/__init__.py @@ -1,5 +1,6 @@ from hope_dedup_engine.apps.api.models.auth import HDEToken # noqa: F401 from hope_dedup_engine.apps.api.models.deduplication import ( # noqa: F401 + Config, DeduplicationSet, Duplicate, Image, diff --git a/src/hope_dedup_engine/apps/api/models/deduplication.py b/src/hope_dedup_engine/apps/api/models/deduplication.py index f42d204..95cb695 100644 --- a/src/hope_dedup_engine/apps/api/models/deduplication.py +++ b/src/hope_dedup_engine/apps/api/models/deduplication.py @@ -2,6 +2,7 @@ from uuid import uuid4 from django.conf import settings +from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from hope_dedup_engine.apps.api.utils.notification import send_notification @@ -11,7 +12,17 @@ class Config(models.Model): - face_distance_threshold = models.FloatField(null=True) + face_distance_threshold = models.FloatField( + null=True, + validators=[MinValueValidator(0.1), MaxValueValidator(1.0)], + ) + + def __str__(self) -> str: + return " | ".join( + f"{field.name}: {getattr(self, field.name)}" + for field in self._meta.fields + if field.name not in ("id",) + ) class DeduplicationSet(models.Model): diff --git a/src/hope_dedup_engine/apps/faces/admin.py b/src/hope_dedup_engine/apps/faces/admin.py index 6fd74cf..efa34ea 100644 --- a/src/hope_dedup_engine/apps/faces/admin.py +++ b/src/hope_dedup_engine/apps/faces/admin.py @@ -45,7 +45,6 @@ def sync_dnn_files(self, request): else: worker_count = len(active_workers) if worker_count > 1: - print(f"{worker_count=}") job = group(sync_dnn_files.s(force=True) for _ in range(worker_count)) result = job.apply_async() self.message_user(