Skip to content

loader/tasks: Prevent side effect due to django when module is imported

Recent changes in swh-deposit codebase introduce cascading import of swh.deposit.models.Deposit when importing DepositChecker class from the swh.deposit.loader.checker module.

Importing swh.deposit.models.Deposit requires django to be properly initialized which is usually not the case when the celery task modules are imported through the swh_scheduler_celery_worker pytest fixture, so numerous tests related to scheduler tasks in various swh packages were failing.

So move import of DepositChecker class from top level to the task function to avoid such side effect.

See https://jenkins.softwareheritage.org/job/DENV/job/tests/1044/artifact/swh-lister.log

Merge request reports