Skip to content

Commit

Permalink
add ! model Config at the admin panel (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitali-yanushchyk-valor authored Oct 21, 2024
1 parent b5c4dd7 commit 4920915
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
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

0 comments on commit 4920915

Please sign in to comment.