TripleStoreFactory
What it is
- A small factory module that builds
TripleStoreServiceinstances backed by different secondary adaptors:- Naas object storage
- Local filesystem
- AWS Neptune via SSH tunnel
- Oxigraph HTTP endpoint
- Apache Jena Fuseki (TDB2) HTTP endpoint
Public API
class TripleStoreFactoryTripleStoreServiceNaas(naas_api_key: str, workspace_id: str, storage_name: str, base_prefix: str = "ontologies") -> TripleStoreService- Creates a
TripleStoreServiceusing Naas object storage viaObjectStorageFactory.ObjectStorageServiceNaasand an object-storage-backed triple store adaptor.
- Creates a
TripleStoreServiceFilesystem(path: str) -> TripleStoreService- Creates a
TripleStoreServiceusing a filesystem-backed adaptor rooted atpath.
- Creates a
TripleStoreServiceAWSNeptuneSSHTunnel(...) -> TripleStoreService- Creates a
TripleStoreServiceusing an AWS Neptune SSH tunnel adaptor. - Note: Although parameters are present, the implementation reads required values from environment variables (see below).
- Creates a
TripleStoreServiceOxigraph(oxigraph_url: str | None = None) -> TripleStoreService- Creates a
TripleStoreServiceusing an Oxigraph adaptor pointed atoxigraph_url(or env/default).
- Creates a
TripleStoreServiceApacheJenaTDB2(jena_tdb2_url: str | None = None) -> TripleStoreService- Creates a
TripleStoreServiceusing an Apache Jena Fuseki (TDB2) adaptor pointed atjena_tdb2_url(or env/default).
- Creates a
Configuration/Dependencies
- Imports/depends on:
TripleStoreService- Secondary adaptors:
TripleStoreService__SecondaryAdaptor__ObjectStorageTripleStoreService__SecondaryAdaptor__FilesystemAWSNeptuneSSHTunnelOxigraphApacheJenaTDB2
ObjectStorageFactoryfor Naas storage integration
- Environment variables:
- For
TripleStoreServiceAWSNeptuneSSHTunnel(required; asserted non-null/non-sentinel):AWS_REGIONAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_NEPTUNE_DB_INSTANCE_IDENTIFIERAWS_BASTION_HOSTAWS_BASTION_PORT(must parse to int and not equal-42)AWS_BASTION_USERAWS_BASTION_PRIVATE_KEY
- For
TripleStoreServiceOxigraph:OXIGRAPH_URL(default:http://localhost:7878)
- For
TripleStoreServiceApacheJenaTDB2:JENA_TDB2_URL(default:http://localhost:3030/ds)
- For
Usage
from naas_abi_core.services.triple_store.TripleStoreFactory import TripleStoreFactory
# Filesystem-backed triple store
ts = TripleStoreFactory.TripleStoreServiceFilesystem("/tmp/triples")
# Oxigraph-backed triple store (uses OXIGRAPH_URL or default)
ts_oxi = TripleStoreFactory.TripleStoreServiceOxigraph()
# Apache Jena Fuseki (TDB2) dataset (uses JENA_TDB2_URL or default)
ts_jena = TripleStoreFactory.TripleStoreServiceApacheJenaTDB2("http://localhost:3030/ds")
# Naas object-storage-backed triple store
ts_naas = TripleStoreFactory.TripleStoreServiceNaas(
naas_api_key="...",
workspace_id="...",
storage_name="...",
base_prefix="ontologies",
)
Caveats
TripleStoreServiceAWSNeptuneSSHTunnel(...)ignores its passed arguments and always overwrites them from environment variables; missing/invalid env vars triggerassertfailures.AWS_BASTION_PORTmust be set; if absent it defaults to-42and will fail the assertion.