You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
725 B

  1. from celery import shared_task
  2. from celery.utils.log import get_task_logger
  3. from django.conf import settings
  4. from django.shortcuts import get_object_or_404
  5. from projects.models import Project
  6. from .pipeline.factories import create_repository, create_writer
  7. from .pipeline.services import ExportApplicationService
  8. logger = get_task_logger(__name__)
  9. @shared_task
  10. def export_dataset(project_id, file_format: str, export_approved=False):
  11. project = get_object_or_404(Project, pk=project_id)
  12. repository = create_repository(project)
  13. writer = create_writer(file_format)(settings.MEDIA_ROOT)
  14. service = ExportApplicationService(repository, writer)
  15. filepath = service.export(export_approved)
  16. return filepath