Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cooking_tasks.py
# Copyright (C) 2016-2017 The Software Heritage developers | # Copyright (C) 2016-2017 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from swh.scheduler.task import Task | from celery import current_app as app | ||||
from swh.vault.cookers import get_cooker | from swh.vault.cookers import get_cooker | ||||
class SWHCookingTask(Task): | @app.task(name=__name__ + '.SWHCookingTask') | ||||
def cook_bundle(obj_type, obj_id): | |||||
"""Main task to cook a bundle.""" | """Main task to cook a bundle.""" | ||||
get_cooker(obj_type)(obj_type, obj_id).cook() | |||||
task_queue = 'swh_vault_cooking' | |||||
def run_task(self, obj_type, obj_id): | |||||
cooker = get_cooker(obj_type)(obj_type, obj_id) | |||||
cooker.cook() | |||||
# TODO: remove once the scheduler handles priority tasks | # TODO: remove once the scheduler handles priority tasks | ||||
class SWHBatchCookingTask(Task): | @app.task(name=__name__ + '.SWHBatchCookingTask') | ||||
def batch_cook_bundle(obj_type, obj_id): | |||||
"""Temporary task for the batch queue.""" | """Temporary task for the batch queue.""" | ||||
get_cooker(obj_type)(obj_type, obj_id).cook() | |||||
task_queue = 'swh_vault_batch_cooking' | |||||
def run_task(self, obj_type, obj_id): | |||||
cooker = get_cooker(obj_type)(obj_type, obj_id) | |||||
cooker.cook() |