Commit 49bf361d authored by Mickaël Desfrênes's avatar Mickaël Desfrênes
Browse files

replace huey with django's tasks

parent 20b6cd4f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ update: ## mise à jour des paquets et dépendances
.PHONY: update

run: ## démarrage de l'environnement de développement
	@.cache/tandem 'uv run jama runserver' 'uv run jama run_huey'
	@.cache/tandem 'uv run jama runserver' 'uv run jama db_worker' 'uv run jama crontask --no-heartbeat'
.PHONY: run

format: ## Formatage des sources avec Ruff
+2 −0
Original line number Diff line number Diff line
@@ -12,9 +12,11 @@ dependencies = [
    "Django>=6.0.3",
    "django-auth-cli-certic>=0.1.6",
    "django-cors-headers>=4.7.0",
    "django-crontask>=1.1.3",
    "django-extensions>=3.1.5",
    "django-modshib-certic>=0.5.4",
    "django-revproxy>=0.13.0",
    "django-tasks-db>=0.12.0",
    "django-vite>=2.1.3",
    "fusepy>=3.0.1",
    "gunicorn>=25.3.0",
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ def move_collection_to_project(from_collection_id: int, to_project_id: int):
                res.file.project = to_project_instance
                res.file.save()
                print(f"File({res.file.id})")
                ocr_task(res.file.id)
                ocr_task.enqueue(res.file.id)
    print("Done.")


+4 −26
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ VAR_DIR = os.getenv("JAMA_VAR_DIR") or Path(Path.home(), ".jama")
VAR_DIR = Path(VAR_DIR).resolve()

os.makedirs(VAR_DIR, exist_ok=True)
os.makedirs(Path(VAR_DIR, "huey_files").resolve(), exist_ok=True)
env_file = Path(VAR_DIR, "env")
if not env_file.exists():
    secret = "".join(secrets.choice(string.ascii_letters) for _ in range(32))
@@ -50,7 +49,6 @@ JAMA_PERIODIC_FILE_INTEGRITY_CHECK = (
JAMA_USE_POSTGIS = True if os.getenv("JAMA_USE_POSTGIS") == "1" else False
JAMA_ROOT_URL_REDIRECT = os.getenv("JAMA_ROOT_URL_REDIRECT")
JAMA_CACHE_BACKEND = os.getenv("JAMA_CACHE_BACKEND") or "file"
JAMA_HUEY_CLASS = os.getenv("JAMA_HUEY_CLASS") or "huey.FileHuey"
JAMA_DB_ADAPTER = os.getenv("JAMA_DB_ADAPTER") or "sqlite"
JAMA_URL_BASE_PATH = os.getenv("JAMA_URL_BASE_PATH") or ""
JAMA_USE_MODSHIB = True if os.getenv("JAMA_USE_MODSHIB", "1") == "1" else False
@@ -136,7 +134,8 @@ INSTALLED_APPS = [
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "huey.contrib.djhuey",
    "django_tasks_db",
    "crontask",
    "authcli.apps.AuthcliConfig",
    "annotations.apps.AnnotationsConfig",
    "jama.apps.JamaConfig",
@@ -324,31 +323,10 @@ INTERNAL_IPS = [
    "127.0.0.1",
]

HUEY = {
    "huey_class": JAMA_HUEY_CLASS,  # Huey implementation to use. Defaults to huey.FileHuey. Other possible values: huey.RedisHuey, huey.SqliteHuey
    "results": False,  # Store return values of tasks.
    "store_none": False,  # If a task returns None, do not save to results.
    "immediate": False,
    "utc": True,  # Use UTC for all times internally.
    "consumer": {
        "workers": 1,
        "worker_type": "thread",
        "initial_delay": 0.1,  # Smallest polling interval, same as -d.
        "backoff": 1.15,  # Exponential backoff using this rate, -b.
        "max_delay": 10.0,  # Max possible polling interval, -m.
        "scheduler_interval": 1,  # Check schedule every second, -s.
        "periodic": True,  # Enable crontab feature.
        "check_worker_health": True,  # Enable worker health checks.
        "health_check_interval": 1,  # Check worker health every second.
    },
TASKS = {
    "default": {"BACKEND": "django_tasks_db.DatabaseBackend", "QUEUES": ["default"]}
}

if JAMA_HUEY_CLASS == "huey.SqliteHuey":
    HUEY["filename"] = str(Path(VAR_DIR, "huey.db").resolve())

if JAMA_HUEY_CLASS == "huey.FileHuey":
    HUEY["path"] = str(Path(VAR_DIR, "huey_files").resolve())

if JAMA_CACHE_BACKEND == "memcached":
    CACHES = {
        "default": {
+5 −1
Original line number Diff line number Diff line
@@ -392,7 +392,11 @@ def make_iiif(f: Union[models.File, int], force: bool = False):
        )
        call(["chmod", "775", iiif_destination_file])
        f.tiled = True
        models.File.objects.filter(pk=f.pk).update(tiled=True)
        width = f.image_width()
        height = f.image_height()
        models.File.objects.filter(pk=f.pk).update(
            tiled=True, denormalized_image_width=width, denormalized_image_height=height
        )


def delete_exif_metas(f: models.File) -> int:
Loading