Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ! model Config at the admin panel #102

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hope_dedup_engine/apps/api/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/hope_dedup_engine/apps/api/admin/config.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions src/hope_dedup_engine/apps/api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
13 changes: 12 additions & 1 deletion src/hope_dedup_engine/apps/api/models/deduplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
1 change: 0 additions & 1 deletion src/hope_dedup_engine/apps/faces/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading