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 magic
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pydicom
|
import pydicom
|
||||||
|
from dicom import tasks
|
||||||
from dicom.models import Coordinate, Dicom, Project
|
from dicom.models import Coordinate, Dicom, Project
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
|
from django.core.files.uploadedfile import InMemoryUploadedFile, TemporaryUploadedFile
|
||||||
|
@ -45,6 +46,7 @@ def process_files(
|
||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
shutil.rmtree(dit_path)
|
shutil.rmtree(dit_path)
|
||||||
|
tasks.process_project.apply_async(kwargs={"pk": project.pk}, countdown=3)
|
||||||
return project
|
return project
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from dicom.models import Dicom, Project
|
from dicom.models import Dicom, Project
|
||||||
from dicom.tasks import process_project
|
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from utils.generators import generate_charset
|
from utils.generators import generate_charset
|
||||||
|
@ -13,7 +12,6 @@ def create_project(sender, instance: Project, created, **kwargs):
|
||||||
slug = generate_charset(5)
|
slug = generate_charset(5)
|
||||||
instance.slug = slug
|
instance.slug = slug
|
||||||
instance.save()
|
instance.save()
|
||||||
process_project.apply_async(kwargs={"slug": slug})
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Dicom)
|
@receiver(post_save, sender=Dicom)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
|
from dicom import services
|
||||||
from dicom.models import Project
|
from dicom.models import Project
|
||||||
from dicom.services import generate_3d_model
|
|
||||||
|
|
||||||
|
|
||||||
@shared_task()
|
@shared_task()
|
||||||
def process_project(slug: str):
|
def process_project(pk: int):
|
||||||
print(slug)
|
services.generate_3d_model(Project.objects.get(pk=pk))
|
||||||
generate_3d_model(Project.objects.get(slug=slug))
|
return pk
|
||||||
return slug
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user