Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
from .archive import ArchiveInterface | from .archive import ArchiveInterface | ||||
from .postgresql.archive import ArchivePostgreSQL | from .postgresql.archive import ArchivePostgreSQL | ||||
from .postgresql.db_utils import connect | from .postgresql.db_utils import connect | ||||
from .postgresql.provenance import ProvenancePostgreSQL | from .postgresql.provenance import ProvenancePostgreSQL | ||||
from .postgresql_nopath.provenance import ProvenancePostgreSQLNoPath | from .postgresql_nopath.provenance import ProvenancePostgreSQLNoPath | ||||
from .provenance import ProvenanceInterface | from .provenance import ProvenanceInterface | ||||
from .storage.archive import ArchiveStorage | from .storage.archive import ArchiveStorage | ||||
def get_archive(cls: str, **kwargs) -> ArchiveInterface: | def get_archive(cls: str, **kwargs) -> ArchiveInterface: | ||||
if cls == "api": | if cls == "api": | ||||
return ArchiveStorage(**kwargs["storage"]) | return ArchiveStorage(**kwargs["storage"]) | ||||
elif cls == "ps": | elif cls == "direct": | ||||
conn = connect(kwargs["db"]) | conn = connect(kwargs["db"]) | ||||
return ArchivePostgreSQL(conn) | return ArchivePostgreSQL(conn) | ||||
else: | else: | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def get_provenance(cls: str, **kwargs) -> ProvenanceInterface: | def get_provenance(cls: str, **kwargs) -> ProvenanceInterface: | ||||
if cls == "ps": | if cls == "local": | ||||
vlorentz: let's call it `"postgres"` (we should also rename it that way in swh-storage) | |||||
aevisoUnsubmitted Not Done Inline ActionsI agree "postgres" is more declarative as we can have several "local" db types. aeviso: I agree `"postgres"` is more declarative as we can have several `"local"` db types. | |||||
douarddaAuthorUnsubmitted Done Inline Actionsthen I'll change it here when it's done in "core components" douardda: then I'll change it here when it's done in "core components" | |||||
conn = connect(kwargs["db"]) | conn = connect(kwargs["db"]) | ||||
if kwargs.get("with_path", False): | |||||
return ProvenancePostgreSQL(conn) | return ProvenancePostgreSQL(conn) | ||||
elif cls == "ps_np": | else: | ||||
conn = connect(kwargs["db"]) | |||||
return ProvenancePostgreSQLNoPath(conn) | return ProvenancePostgreSQLNoPath(conn) | ||||
Not Done Inline ActionsDoes this mean that the default is without path? I think we want it the other way around. aeviso: Does this mean that the default is without path? I think we want it the other way around. | |||||
Done Inline Actionsoh you're right, let me fix this douardda: oh you're right, let me fix this | |||||
else: | else: | ||||
raise NotImplementedError | raise NotImplementedError |
let's call it "postgres" (we should also rename it that way in swh-storage)