Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while creating export job with celery #131

Open
N1K1TAS95 opened this issue Sep 20, 2024 · 0 comments
Open

Error while creating export job with celery #131

N1K1TAS95 opened this issue Sep 20, 2024 · 0 comments

Comments

@N1K1TAS95
Copy link

Hi there!
I have and issue creating and export job using celery.
Each time I'm getting this error: TypeError: str() argument 'encoding' must be str, not tuple

Stack Trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1730, in runner
    return sentry_patched_function(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/celery/__init__.py", line 406, in _inner
    reraise(*exc_info)
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/utils.py", line 1659, in reraise
    raise value
  File "/usr/local/lib/python3.11/site-packages/sentry_sdk/integrations/celery/__init__.py", line 401, in _inner
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/celery/app/trace.py", line 736, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/import_export_celery/tasks.py", line 220, in run_export_job
    class Resource(resource_class):
TypeError: str() argument 'encoding' must be str, not tuple

Here is my configurations for ModelResource:

class OdlExportForISOResource(resources.ModelResource):
    code = Field(
        attribute='code',
        column_name='Codice',
        widget=CharWidget()
    )
    state = Field(
        attribute='state',
        column_name='Stato',
        widget=ChoicesWidget(
            choices=ODL_STATES
        )
    )
    creation_date = Field(
        attribute='creation_date',
        column_name='Data Apertura',
        widget=DateTimeWidget(format='%d/%m/%Y')
    )
    data_primo_intervento = Field(
        attribute='data_primo_intervento',
        column_name='Data Primo Intervento',
        widget=DateTimeWidget(format='%d/%m/%Y')
    )
    closing_date = Field(
        attribute='closing_date',
        column_name='Data Chiusura',
        widget=DateTimeWidget(format='%d/%m/%Y')
    )

    tipologia = Field(
        attribute='tipologia',
        column_name='Tipologia',
        widget=CharWidget()
    )
    in_garanzia = Field(
        attribute='in_garanzia',
        column_name='In Garanzia',
        widget=BooleanWidget()
    )
    rapporto_fgas = Field(
        attribute='rapporto_fgas',
        column_name='Rapporto FGAS',
        widget=BooleanWidget()
    )
    soddisfazione_cliente = Field(
        attribute='soddisfazione_cliente',
        column_name='Soddisfazione Cliente',
        widget=CharWidget()
    )

    class Meta:
        name= 'Esporta gli ODL per la ISO'
        model = Odl
        fields = [
            'code',
            'state',
            'creation_date',
            'data_primo_intervento',
            'closing_date',
            'tipologia',
            'in_garanzia',
            'rapporto_fgas',
            'soddisfazione_cliente'
        ]

    def get_queryset(self):
        queryset = super().get_queryset()
        queryset = queryset.prefetch_related(
            'odl_intervention_reports',
            'odl_type'
        )
        return queryset

This is a classmethod:

@classmethod
    def export_resource_classes(cls):
        return {
            'odl': ('ODL Export for ISO Resource', 'odl.resources.OdlExportForISOResource'),
        }

And this is creation of export job:
Immagine 2024-09-20 132015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant