EngineConfiguration_TripleStoreService
What it is
Pydantic-based configuration models for wiring a TripleStoreService with a selectable backend (“adapter”). It validates adapter-specific config and lazily imports/instantiates the correct triple store port implementation.
Public API
OxigraphAdapterConfiguration(pydanticBaseModel)- Config for the
oxigraphadapter (oxigraph_url,timeout).
- Config for the
ApacheJenaTDB2AdapterConfiguration(pydanticBaseModel)- Config for the
apache_jena_tdb2adapter (jena_tdb2_url,timeout).
- Config for the
AWSNeptuneAdapterConfiguration(pydanticBaseModel)- Config for the
aws_neptuneadapter (aws_region_name,aws_access_key_id,aws_secret_access_key,db_instance_identifier).
- Config for the
AWSNeptuneSSHTunnelAdapterConfiguration(pydanticBaseModel)- Extends
AWSNeptuneAdapterConfigurationwith SSH tunnel/bastion fields.
- Extends
TripleStoreAdapterFilesystemConfiguration(pydanticBaseModel)- Config for the
fsadapter (store_path,triples_path).
- Config for the
TripleStoreAdapterObjectStorageConfiguration(pydanticBaseModel)- Config for the
object_storageadapter (object_storage_service,triples_prefix).
- Config for the
TripleStoreAdapterConfiguration(GenericLoader)- Fields:
adapter: one of"oxigraph" | "apache_jena_tdb2" | "aws_neptune_sshtunnel" | "aws_neptune" | "fs" | "object_storage" | "custom"config: adapter-specific config model,dict, orNone
- Methods:
validate_adapter() -> Self: pydantic model validator; enforcesconfigpresence for non-customadapters and validates shape by adapter.load() -> ITripleStorePort: instantiates and returns the configured adapter (or delegates toGenericLoader.load()whenadapter == "custom").
- Fields:
TripleStoreServiceConfiguration(pydanticBaseModel)- Fields:
triple_store_adapter: TripleStoreAdapterConfiguration
- Methods:
load() -> TripleStoreService: constructsTripleStoreService(triple_store_adapter=...).
- Fields:
Configuration/Dependencies
- Uses Pydantic v2 features:
ConfigDict(extra="forbid")on adapter config models (unknown fields rejected).@model_validator(mode="after")for cross-field validation.
- Depends on:
GenericLoader(for"custom"adapter behavior)pydantic_model_validatorutility for validatingconfigobjectsObjectStorageServiceConfigurationfor the object storage adapter- Triple store service/ports:
ITripleStorePortTripleStoreService
- Lazy-imported adapter implementations (imported only when selected):
OxigraphApacheJenaTDB2AWSNeptune,AWSNeptuneSSHTunnelTripleStoreService__SecondaryAdaptor__FilesystemTripleStoreService__SecondaryAdaptor__ObjectStorage
Usage
Minimal example using the filesystem adapter:
from naas_abi_core.engine.engine_configuration.EngineConfiguration_TripleStoreService import (
TripleStoreServiceConfiguration,
TripleStoreAdapterConfiguration,
TripleStoreAdapterFilesystemConfiguration,
)
cfg = TripleStoreServiceConfiguration(
triple_store_adapter=TripleStoreAdapterConfiguration(
adapter="fs",
config=TripleStoreAdapterFilesystemConfiguration(
store_path="storage/triplestore",
triples_path="triples",
),
)
)
service = cfg.load() # -> TripleStoreService
Caveats
- For any adapter other than
"custom",configis required; otherwise validation/assertions will fail. - Adapter config models forbid extra fields (
extra="forbid"). "custom"adapter delegates toGenericLoader.load(); its expected shape/behavior is defined byGenericLoader, not by this module.- Unknown
adaptervalues raiseValueError("Adapter ... not supported").