ontocast.tool.triple_manager.core¶
Triple store management tools for OntoCast.
This module provides functionality for managing RDF triple stores, including abstract interfaces and concrete implementations for different triple store backends.
TripleStoreManager
¶
Bases: Tool
Source code in ontocast/tool/triple_manager/core.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
__init__(**kwargs)
¶
Initialize the triple store manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
afetch_ontologies()
async
¶
aserialize(o, **kwargs)
async
¶
Async serialize helper for backends without native async I/O.
aserialize_graph(graph, **kwargs)
async
¶
Async serialize helper for backends without native async I/O.
async_init()
async
¶
clean()
abstractmethod
async
¶
Clean/flush data managed by this store (backend-specific scope).
Warning: This operation is irreversible and will delete data.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the triple store doesn't support cleaning. |
Source code in ontocast/tool/triple_manager/core.py
clean_tenancy(tenant, project)
async
¶
Remove all triples for datasets derived from tenant / project.
Backends without per-tenant partitions raise :class:NotImplementedError.
Source code in ontocast/tool/triple_manager/core.py
drop_all_ontology_graphs_for_iri(ontology_iri)
async
¶
Remove named graphs for ontology_iri (base and versioned).
Source code in ontocast/tool/triple_manager/core.py
drop_named_graph(graph_uri, *, use_ontologies_dataset=True)
async
¶
Drop a single named graph.
Source code in ontocast/tool/triple_manager/core.py
fetch_ontologies()
abstractmethod
¶
Fetch all available ontologies from the triple store.
This method should retrieve all ontologies stored in the triple store and return them as Ontology objects with their associated RDF graphs.
Returns:
| Type | Description |
|---|---|
list[Ontology]
|
list[Ontology]: List of available ontologies with their graphs. |
Source code in ontocast/tool/triple_manager/core.py
serialize(o, **kwargs)
abstractmethod
¶
serialize_graph(graph, **kwargs)
abstractmethod
¶
strip_provenance(graph)
classmethod
¶
Return a graph without reification/provenance scaffolding triples.
Source code in ontocast/tool/triple_manager/core.py
supports_tenancy_partition()
¶
update_tenancy(tenant, project, *, sep=TENANCY_SEP)
async
¶
Switch the active tenant/project partition when supported.
Source code in ontocast/tool/triple_manager/core.py
TripleStoreManagerWithAuth
¶
Bases: TripleStoreManager
Base class for triple store managers that require authentication.
This class provides common functionality for triple store managers that need URI and authentication credentials. It handles environment variable loading and credential parsing.
Attributes:
| Name | Type | Description |
|---|---|---|
uri |
str | None
|
The connection URI for the triple store. |
auth |
tuple | None
|
Authentication tuple (username, password) for the triple store. |
Source code in ontocast/tool/triple_manager/core.py
__init__(uri=None, auth=None, env_uri=None, env_auth=None, **kwargs)
¶
Initialize the triple store manager with authentication.
This method handles loading URI and authentication credentials from either direct parameters or environment variables. It also parses authentication strings in the format "user/password".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
Direct URI for the triple store connection. |
None
|
|
auth
|
Direct authentication tuple or string in "user/password" format. |
None
|
|
env_uri
|
Environment variable name for the URI (e.g., "NEO4J_URI"). |
None
|
|
env_auth
|
Environment variable name for authentication (e.g., "NEO4J_AUTH"). |
None
|
|
**kwargs
|
Additional keyword arguments passed to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If authentication string is not in "user/password" format. |
Example
manager = TripleStoreManagerWithAuth( ... env_uri="NEO4J_URI", ... env_auth="NEO4J_AUTH" ... )