From f84db2872d1bce2fa5a3e199323b546f80ad67d4 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz <vlorentz@softwareheritage.org> Date: Fri, 3 Mar 2023 12:13:23 +0100 Subject: [PATCH] Fix a bunch of deprecation warnings from other SWH modules --- swh/vault/cli.py | 2 +- swh/vault/cookers/__init__.py | 2 +- swh/vault/cookers/git_bare.py | 4 ++-- swh/vault/tests/conftest.py | 2 +- swh/vault/tests/test_cookers.py | 8 +++----- swh/vault/tests/test_git_bare_cooker.py | 10 ++++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/swh/vault/cli.py b/swh/vault/cli.py index e274405..a390a48 100644 --- a/swh/vault/cli.py +++ b/swh/vault/cli.py @@ -84,7 +84,7 @@ def cook( conf = config.read(config_file) try: - from swh.graph.client import RemoteGraphClient # optional dependency + from swh.graph.http_client import RemoteGraphClient # optional dependency graph = RemoteGraphClient(**conf["graph"]) if conf.get("graph") else None except ModuleNotFoundError: diff --git a/swh/vault/cookers/__init__.py b/swh/vault/cookers/__init__.py index 878c77c..9689d96 100644 --- a/swh/vault/cookers/__init__.py +++ b/swh/vault/cookers/__init__.py @@ -111,7 +111,7 @@ def get_cooker(bundle_type: str, swhid: CoreSWHID): backend = get_vault(**vcfg) try: - from swh.graph.client import RemoteGraphClient # optional dependency + from swh.graph.http_client import RemoteGraphClient # optional dependency graph = RemoteGraphClient(**vcfg["graph"]) if vcfg.get("graph") else None except ModuleNotFoundError: diff --git a/swh/vault/cookers/git_bare.py b/swh/vault/cookers/git_bare.py index 1ac10e0..62a395a 100644 --- a/swh/vault/cookers/git_bare.py +++ b/swh/vault/cookers/git_bare.py @@ -425,7 +425,7 @@ class GitBareCooker(BaseVaultCooker): loaded_from_graph = False if self.graph: - from swh.graph.client import GraphArgumentException + from swh.graph.http_client import GraphArgumentException # First, try to cook using swh-graph, as it is more efficient than # swh-storage for querying the history @@ -482,7 +482,7 @@ class GitBareCooker(BaseVaultCooker): directory_ids = [] content_ids = [] - from swh.graph.client import GraphArgumentException + from swh.graph.http_client import GraphArgumentException # First, try to cook using swh-graph, as it is more efficient than # swh-storage for querying the history diff --git a/swh/vault/tests/conftest.py b/swh/vault/tests/conftest.py index 9c4b0a6..70c1409 100644 --- a/swh/vault/tests/conftest.py +++ b/swh/vault/tests/conftest.py @@ -11,7 +11,7 @@ import pkg_resources.extern.packaging.version import pytest from pytest_postgresql import factories -from swh.core.db.pytest_plugin import initialize_database_for_module +from swh.core.db.db_utils import initialize_database_for_module from swh.vault import get_vault from swh.vault.backend import VaultBackend diff --git a/swh/vault/tests/test_cookers.py b/swh/vault/tests/test_cookers.py index 6654380..48c21e1 100644 --- a/swh/vault/tests/test_cookers.py +++ b/swh/vault/tests/test_cookers.py @@ -25,7 +25,7 @@ import dulwich.porcelain import dulwich.repo import pytest -from swh.loader.git.from_disk import GitLoaderFromDisk +from swh.loader.git.loader import GitLoader from swh.model import from_disk, hashutil from swh.model.model import ( Person, @@ -169,11 +169,9 @@ def git_loader( """Instantiate a Git Loader using the storage instance as storage.""" def _create_loader(directory): - return GitLoaderFromDisk( + return GitLoader( swh_storage, - "fake_origin", - directory=directory, - visit_date=datetime.datetime.now(datetime.timezone.utc), + directory, ) return _create_loader diff --git a/swh/vault/tests/test_git_bare_cooker.py b/swh/vault/tests/test_git_bare_cooker.py index 923f77a..893d4e0 100644 --- a/swh/vault/tests/test_git_bare_cooker.py +++ b/swh/vault/tests/test_git_bare_cooker.py @@ -24,7 +24,7 @@ import pytest from pytest import param from pytest_postgresql import factories -from swh.core.db.pytest_plugin import initialize_database_for_module +from swh.core.db.db_utils import initialize_database_for_module from swh.model.from_disk import DentryPerms from swh.model.model import ( Content, @@ -55,7 +55,9 @@ storage_postgresql = factories.postgresql("storage_postgresql_proc") @pytest.fixture def swh_storage(storage_postgresql): - return get_storage("local", db=storage_postgresql.dsn, objstorage={"cls": "memory"}) + return get_storage( + "postgresql", db=storage_postgresql.dsn, objstorage={"cls": "memory"} + ) class RootObjects(enum.Enum): @@ -175,7 +177,7 @@ def test_graph_revisions( If weird_branches is False, dir4, cnt4, rel3, rel4, and cnt5 are excluded. """ - from swh.graph.naive_client import NaiveClient as GraphClient + from swh.graph.http_naive_client import NaiveClient as GraphClient # Create objects: @@ -631,7 +633,7 @@ def test_ignore_displayname(swh_storage, use_graph): # Add all objects to graph if use_graph: - from swh.graph.naive_client import NaiveClient as GraphClient + from swh.graph.http_naive_client import NaiveClient as GraphClient nodes = [ str(x.swhid()) for x in [content, directory, revision, release, snapshot] -- GitLab