mirror of
https://github.com/leaders-of-digital-9-task/backend.git
synced 2024-11-22 01:16:33 +03:00
added celery
This commit is contained in:
parent
8b88e97489
commit
d5731ad8af
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user