diff --git a/swh/provenance/__init__.py b/swh/provenance/__init__.py --- a/swh/provenance/__init__.py +++ b/swh/provenance/__init__.py @@ -96,12 +96,19 @@ db = MongoClient(**kwargs["db"]).get_database(dbname) return ProvenanceStorageMongoDb(db) - elif cls == "remote": - from .api.client import RemoteProvenanceStorage + elif cls in ["remote", "rpcapi"]: + from .api.client import ProvenanceStorageRPCClient - storage = RemoteProvenanceStorage(**kwargs) - assert isinstance(storage, ProvenanceStorageInterface) - return storage + if cls == "remote": + warnings.warn( + '"remote" class is deprecated for provenance storage, please ' + 'use "rpcapi" class instead.', + DeprecationWarning, + ) - else: - raise ValueError + rpc_storage = ProvenanceStorageRPCClient(**kwargs) + if TYPE_CHECKING: + assert isinstance(rpc_storage, ProvenanceStorageInterface) + return rpc_storage + + raise ValueError diff --git a/swh/provenance/api/client.py b/swh/provenance/api/client.py --- a/swh/provenance/api/client.py +++ b/swh/provenance/api/client.py @@ -9,7 +9,7 @@ from .serializers import DECODERS, ENCODERS -class RemoteProvenanceStorage(RPCClient): +class ProvenanceStorageRPCClient(RPCClient): """Proxy to a remote provenance storage API""" backend_class = ProvenanceStorageInterface diff --git a/swh/provenance/api/server.py b/swh/provenance/api/server.py --- a/swh/provenance/api/server.py +++ b/swh/provenance/api/server.py @@ -26,12 +26,12 @@ return storage -class ProvenanceStorageServerApp(RPCServerApp): +class ProvenanceStorageRPCServerApp(RPCServerApp): extra_type_decoders = DECODERS extra_type_encoders = ENCODERS -app = ProvenanceStorageServerApp( +app = ProvenanceStorageRPCServerApp( __name__, backend_class=ProvenanceStorageInterface, backend_factory=get_global_provenance_storage, @@ -130,7 +130,7 @@ api_cfg: Optional[Dict[str, Any]] = None -def make_app_from_configfile() -> ProvenanceStorageServerApp: +def make_app_from_configfile() -> ProvenanceStorageRPCServerApp: """Run the WSGI app from the webserver, loading the configuration from a configuration file. diff --git a/swh/provenance/cli.py b/swh/provenance/cli.py --- a/swh/provenance/cli.py +++ b/swh/provenance/cli.py @@ -54,8 +54,8 @@ # "db": { # "dbname": "provenance", # }, - # Remote REST-API/PostgreSQL - # "cls": "remote", + # Remote RPC-API/PostgreSQL + # "cls": "rpcapi", # "url": "http://localhost:8080/%2f", }, } diff --git a/swh/provenance/tests/conftest.py b/swh/provenance/tests/conftest.py --- a/swh/provenance/tests/conftest.py +++ b/swh/provenance/tests/conftest.py @@ -16,7 +16,7 @@ from swh.journal.serializers import msgpack_ext_hook from swh.provenance import get_provenance, get_provenance_storage -from swh.provenance.api.client import RemoteProvenanceStorage +from swh.provenance.api.client import ProvenanceStorageRPCClient import swh.provenance.api.server as server from swh.provenance.archive import ArchiveInterface from swh.provenance.interface import ProvenanceInterface, ProvenanceStorageInterface @@ -50,7 +50,7 @@ @pytest.fixture def app( provenance_postgresqldb: Dict[str, str] -) -> Iterator[server.ProvenanceStorageServerApp]: +) -> Iterator[server.ProvenanceStorageRPCServerApp]: assert hasattr(server, "storage") server.storage = get_provenance_storage( cls="postgresql", db=provenance_postgresqldb @@ -61,19 +61,19 @@ # the RPCClient class used as client used in these tests @pytest.fixture def swh_rpc_client_class() -> type: - return RemoteProvenanceStorage + return ProvenanceStorageRPCClient -@pytest.fixture(params=["mongodb", "postgresql", "remote"]) +@pytest.fixture(params=["mongodb", "postgresql", "rpcapi"]) def provenance_storage( request: SubRequest, provenance_postgresqldb: Dict[str, str], mongodb: pymongo.database.Database, - swh_rpc_client: RemoteProvenanceStorage, + swh_rpc_client: ProvenanceStorageRPCClient, ) -> ProvenanceStorageInterface: """Return a working and initialized ProvenanceStorageInterface object""" - if request.param == "remote": + if request.param == "rpcapi": assert isinstance(swh_rpc_client, ProvenanceStorageInterface) return swh_rpc_client