diff --git a/swh/vault/__init__.py b/swh/vault/__init__.py index 425a5b25ce16bf9ae5b1691c4938cca3a1c41de1..96b95503c977664d096cdb2e28913ac930768068 100644 --- a/swh/vault/__init__.py +++ b/swh/vault/__init__.py @@ -10,6 +10,8 @@ import logging from typing import Dict import warnings +from swh.vault.backend import VaultDB + logger = logging.getLogger(__name__) @@ -57,4 +59,4 @@ def get_vault(cls: str = "remote", **kwargs): return Vault(**kwargs) -get_datastore = get_vault +get_datastore = VaultDB diff --git a/swh/vault/backend.py b/swh/vault/backend.py index 5c00fa053ae74d33bd0395f478e136bb752cb268..a14d349fcc4f7e17d1e94b127ae3eabc992cf42d 100644 --- a/swh/vault/backend.py +++ b/swh/vault/backend.py @@ -66,18 +66,15 @@ The Software Heritage Developers """ -class VaultBackend: +class VaultDB: """ - Backend for the Software Heritage Vault. + PostgreSQL backend for the Software Heritage Vault. """ current_version = 4 def __init__(self, **config): self.config = config - self.cache = VaultCache(**config["cache"]) - self.scheduler = get_scheduler(**config["scheduler"]) - self.storage = get_storage(**config["storage"]) if "db" not in self.config: raise ValueError( @@ -102,6 +99,18 @@ class VaultBackend: if db is not self._db: db.put_conn() + +class VaultBackend(VaultDB): + """ + Backend for the Software Heritage Vault. + """ + + def __init__(self, **config): + super().__init__(**config) + self.cache = VaultCache(**config["cache"]) + self.scheduler = get_scheduler(**config["scheduler"]) + self.storage = get_storage(**config["storage"]) + @db_transaction() def progress( self, diff --git a/swh/vault/cookers/__init__.py b/swh/vault/cookers/__init__.py index 9689d96b381c1719bbe3397ccc3a4c94ffe7924e..1053628ee95421d41a56ddd45302f97b5f30560e 100644 --- a/swh/vault/cookers/__init__.py +++ b/swh/vault/cookers/__init__.py @@ -12,7 +12,6 @@ from swh.core.config import load_named_config from swh.core.config import read as read_config from swh.model.swhids import CoreSWHID, ObjectType from swh.storage import get_storage -from swh.vault import get_vault from swh.vault.cookers.base import DEFAULT_CONFIG, DEFAULT_CONFIG_PATH, BaseVaultCooker from swh.vault.cookers.directory import DirectoryCooker from swh.vault.cookers.git_bare import GitBareCooker @@ -98,6 +97,8 @@ def get_cooker(bundle_type: str, swhid: CoreSWHID): EnvironmentError in case the vault configuration reference a non remote class. """ + from swh.vault import get_vault + if "SWH_CONFIG_FILENAME" in os.environ: cfg = read_config(os.environ["SWH_CONFIG_FILENAME"], DEFAULT_CONFIG) else: