from __future__ import absolute_import
from __future__ import unicode_literals
from corehq.apps.fixtures.upload import upload_fixture_file
from soil import DownloadBase
from celery.task import task


@task(serializer='pickle')
def fixture_upload_async(domain, download_id, replace):
    task = fixture_upload_async
    DownloadBase.set_progress(task, 0, 100)
    download_ref = DownloadBase.get(download_id)
    result = upload_fixture_file(domain, download_ref.get_filename(), replace, task)
    DownloadBase.set_progress(task, 100, 100)
    return {
        'messages': {
            'success': result.success,
            'messages': result.messages,
            'errors': result.errors,
            'number_of_fixtures': result.number_of_fixtures,
        },
    }


@task(serializer='pickle')
def fixture_download_async(prepare_download, *args, **kw):
    task = fixture_download_async
    DownloadBase.set_progress(task, 0, 100)
    prepare_download(task=task, *args, **kw)
    DownloadBase.set_progress(task, 100, 100)

from __future__ import absolute_import, unicode_literals

from celery.task import task

from soil import DownloadBase

from corehq.apps.fixtures.upload import upload_fixture_file


@task
def fixture_upload_async(domain, download_id, replace):
    task = fixture_upload_async
    DownloadBase.set_progress(task, 0, 100)
    download_ref = DownloadBase.get(download_id)
    result = upload_fixture_file(domain, download_ref.get_filename(), replace, task)
    DownloadBase.set_progress(task, 100, 100)
    return {
        'messages': {
            'success': result.success,
            'messages': result.messages,
            'errors': result.errors,
            'number_of_fixtures': result.number_of_fixtures,
        },
    }


@task(serializer='pickle')
def fixture_download_async(prepare_download, *args, **kw):
    task = fixture_download_async
    DownloadBase.set_progress(task, 0, 100)
    prepare_download(task=task, *args, **kw)
    DownloadBase.set_progress(task, 100, 100)

Change fixture upload task to json serializer
Change fixture upload task to json serializer

- from __future__ import absolute_import
- from __future__ import unicode_literals
+ from __future__ import absolute_import, unicode_literals
+ 
- from corehq.apps.fixtures.upload import upload_fixture_file
- from soil import DownloadBase
  from celery.task import task
  
+ from soil import DownloadBase
  
- @task(serializer='pickle')
+ from corehq.apps.fixtures.upload import upload_fixture_file
+ 
+ 
+ @task
  def fixture_upload_async(domain, download_id, replace):
      task = fixture_upload_async
      DownloadBase.set_progress(task, 0, 100)
      download_ref = DownloadBase.get(download_id)
      result = upload_fixture_file(domain, download_ref.get_filename(), replace, task)
      DownloadBase.set_progress(task, 100, 100)
      return {
          'messages': {
              'success': result.success,
              'messages': result.messages,
              'errors': result.errors,
              'number_of_fixtures': result.number_of_fixtures,
          },
      }
  
  
  @task(serializer='pickle')
  def fixture_download_async(prepare_download, *args, **kw):
      task = fixture_download_async
      DownloadBase.set_progress(task, 0, 100)
      prepare_download(task=task, *args, **kw)
      DownloadBase.set_progress(task, 100, 100)
  
Change fixture upload task to json serializer
## Code Before:
from __future__ import absolute_import
from __future__ import unicode_literals
from corehq.apps.fixtures.upload import upload_fixture_file
from soil import DownloadBase
from celery.task import task


@task(serializer='pickle')
def fixture_upload_async(domain, download_id, replace):
    task = fixture_upload_async
    DownloadBase.set_progress(task, 0, 100)
    download_ref = DownloadBase.get(download_id)
    result = upload_fixture_file(domain, download_ref.get_filename(), replace, task)
    DownloadBase.set_progress(task, 100, 100)
    return {
        'messages': {
            'success': result.success,
            'messages': result.messages,
            'errors': result.errors,
            'number_of_fixtures': result.number_of_fixtures,
        },
    }


@task(serializer='pickle')
def fixture_download_async(prepare_download, *args, **kw):
    task = fixture_download_async
    DownloadBase.set_progress(task, 0, 100)
    prepare_download(task=task, *args, **kw)
    DownloadBase.set_progress(task, 100, 100)

## Instruction:
Change fixture upload task to json serializer
## Code After:
from __future__ import absolute_import, unicode_literals

from celery.task import task

from soil import DownloadBase

from corehq.apps.fixtures.upload import upload_fixture_file


@task
def fixture_upload_async(domain, download_id, replace):
    task = fixture_upload_async
    DownloadBase.set_progress(task, 0, 100)
    download_ref = DownloadBase.get(download_id)
    result = upload_fixture_file(domain, download_ref.get_filename(), replace, task)
    DownloadBase.set_progress(task, 100, 100)
    return {
        'messages': {
            'success': result.success,
            'messages': result.messages,
            'errors': result.errors,
            'number_of_fixtures': result.number_of_fixtures,
        },
    }


@task(serializer='pickle')
def fixture_download_async(prepare_download, *args, **kw):
    task = fixture_download_async
    DownloadBase.set_progress(task, 0, 100)
    prepare_download(task=task, *args, **kw)
    DownloadBase.set_progress(task, 100, 100)
