NexusPlatformPipeline
What it is
- A
Pipelinethat initializes the Nexus platform RDF named graph by:- registering all available named graphs as
KnowledgeGraphinstances, - registering runtime agents (from loaded ABI modules) as
Agentinstances, - creating a default
GraphView(currently an “Agent” view).
- registering all available named graphs as
- Writes all produced triples into the configured Nexus named graph via
TripleStoreService.
Public API
Configuration / Parameters
NexusPlatformPipelineConfiguration(PipelineConfiguration)triple_store: TripleStoreService(required): triple store adapter/service.nexus_namespace: Namespace(default:http://ontology.naas.ai/nexus/)nexus_graph_uri: URIRef(default:http://ontology.naas.ai/graph/nexus)force_update: bool(default:True): ifTrue, clears the Nexus graph during initialization.
NexusPlatformPipelineParameters(PipelineParameters)- No fields; used only for type checking.
Pipeline
class NexusPlatformPipeline(Pipeline)list_nexus_graphs() -> List[Dict]- Lists
KnowledgeGraphinstances currently stored in the Nexus graph.
- Lists
initialize_nexus_graphs() -> rdflib.Graph- Ensures each named graph known to the triple store (plus the Nexus graph itself) is represented as a
KnowledgeGraphinstance in the Nexus graph.
- Ensures each named graph known to the triple store (plus the Nexus graph itself) is represented as a
list_nexus_agents(metadata: dict[str, URIRef] = {}) -> List[Dict]- Lists
Agentinstances in the Nexus graph; optional metadata fields are retrieved via OPTIONAL patterns.
- Lists
initialize_nexus_agents() -> rdflib.Graph- Creates several
AgentRoleinstances and registers runtime agents discovered from loaded ABI modules into the Nexus graph.
- Creates several
list_nexus_graph_views(metadata: dict[str, URIRef] = {}) -> List[Dict]- Lists
GraphViewinstances in the Nexus graph.
- Lists
initialize_nexus_graph_views() -> rdflib.Graph- Creates a
GraphViewlabeled"Agent"using aGraphFiltermatchingrdf:type Agent.
- Creates a
run(parameters: PipelineParameters) -> rdflib.Graph- Type-checks parameters (
NexusPlatformPipelineParameters) and runs all three initialization steps; returns the combinedrdflib.Graph.
- Type-checks parameters (
as_tools() -> list[BaseTool]- Returns an empty list.
as_api(...) -> None- No-op (Nexus initialization is handled during engine startup).
Configuration/Dependencies
- Requires:
naas_abi_core.services.triple_store.TripleStoreServicefor graph list/create/clear/query/insert.naas_abi.ontologies.modules.NexusPlatformOntologyclasses (Agent,KnowledgeGraph,GraphView, etc.) to generate RDF.rdflibfor RDF graphs (Graph,Namespace,URIRef) and common namespaces.
- Side effects during
__init__:- Creates the Nexus named graph if missing.
- If
force_update=True, clears the Nexus named graph.
Usage
from naas_abi_core.engine.Engine import Engine
from naas_abi.pipelines.NexusPlatformPipeline import (
NexusPlatformPipeline,
NexusPlatformPipelineConfiguration,
NexusPlatformPipelineParameters,
)
engine = Engine()
engine.load(module_names=["naas_abi"])
store = engine.services.triple_store
pipeline = NexusPlatformPipeline(
NexusPlatformPipelineConfiguration(triple_store=store, force_update=True)
)
graph = pipeline.run(NexusPlatformPipelineParameters())
print(graph.serialize(format="turtle"))
Caveats
force_update=Trueclears the Nexus named graph on startup; use with care in persistent environments.initialize_nexus_agents()prints the inserted RDF (turtle) to stdout (print(...)), which may be noisy in production logs.- Agent discovery depends on the ABI engine/module loading (
ABIModule.get_instance(),engine.modules); if modules aren’t loaded, few or no agents will be registered.