Skip to content
Snippets Groups Projects
Commit 8bfda8f5 authored by David Douard's avatar David Douard
Browse files

setup: declare vault's cooking task using the scheduler's plugin system

So that we can get rid of vault task types being created from swh-schedulers'
sql init scripts.
parent cfe1c019
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,8 @@ setup(
entry_points="""
[swh.cli.subcommands]
vault=swh.vault.cli
[swh.workers]
vault.cookers=swh.vault:register_tasks
""",
classifiers=[
"Programming Language :: Python :: 3",
......
......@@ -7,7 +7,7 @@ from __future__ import annotations
import importlib
import logging
from typing import Dict
from typing import Any, Dict
import warnings
from swh.vault.backend import VaultDB
......@@ -60,3 +60,22 @@ def get_vault(cls: str = "remote", **kwargs):
get_datastore = VaultDB
default_cfg = {
"default_interval": "1 day",
"min_interval": "1 day",
"max_interval": "1 day",
"backoff_factor": 1,
"max_queue_length": 10000,
}
def register_tasks() -> Dict[str, Any]:
return {
"task_modules": [f"{__name__}.cooking_tasks"],
"task_types": {
"vault-cook-bundle": default_cfg,
"vault-batch-cook-bundle": default_cfg,
},
}
......@@ -10,13 +10,13 @@ from swh.vault.cookers import get_cooker
@app.task(name=__name__ + ".SWHCookingTask")
def cook_bundle(bundle_type, swhid):
def vault_cook_bundle(bundle_type, swhid):
"""Main task to cook a bundle."""
get_cooker(bundle_type, CoreSWHID.from_string(swhid)).cook()
# TODO: remove once the scheduler handles priority tasks
@app.task(name=__name__ + ".SWHBatchCookingTask")
def batch_cook_bundle(bundle_type, swhid):
def vault_batch_cook_bundle(bundle_type, swhid):
"""Temporary task for the batch queue."""
get_cooker(bundle_type, CoreSWHID.from_string(swhid)).cook()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment