diff --git a/image_markuper/dicom/services.py b/image_markuper/dicom/services.py index 17f2072..4155172 100644 --- a/image_markuper/dicom/services.py +++ b/image_markuper/dicom/services.py @@ -7,6 +7,7 @@ from pathlib import Path import magic import numpy as np import pydicom +from dicom import tasks from dicom.models import Coordinate, Dicom, Project from django.core.files import File from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile @@ -45,6 +46,7 @@ def process_files( user=user, ) shutil.rmtree(dit_path) + tasks.process_project.apply_async(kwargs={"pk": project.pk}, countdown=3) return project diff --git a/image_markuper/dicom/signals.py b/image_markuper/dicom/signals.py index 73917e8..47305e8 100644 --- a/image_markuper/dicom/signals.py +++ b/image_markuper/dicom/signals.py @@ -1,5 +1,4 @@ from dicom.models import Dicom, Project -from dicom.tasks import process_project from django.db.models.signals import post_save from django.dispatch import receiver from utils.generators import generate_charset @@ -13,7 +12,6 @@ def create_project(sender, instance: Project, created, **kwargs): slug = generate_charset(5) instance.slug = slug instance.save() - process_project.apply_async(kwargs={"slug": slug}) @receiver(post_save, sender=Dicom) diff --git a/image_markuper/dicom/tasks.py b/image_markuper/dicom/tasks.py index 3375bb0..202f1d6 100644 --- a/image_markuper/dicom/tasks.py +++ b/image_markuper/dicom/tasks.py @@ -1,10 +1,9 @@ from celery import shared_task +from dicom import services from dicom.models import Project -from dicom.services import generate_3d_model @shared_task() -def process_project(slug: str): - print(slug) - generate_3d_model(Project.objects.get(slug=slug)) - return slug +def process_project(pk: int): + services.generate_3d_model(Project.objects.get(pk=pk)) + return pk