RDF store¶
app.rdf
¶
RDF store wrapper: Oxigraph for SPARQL, rdflib for SHACL introspection.
RDFStore(data_path, shapes_path, vocab_path)
¶
In-process ontology store used by every query route.
Oxigraph answers SPARQL; a lazily built rdflib Graph serves SHACL
introspection. A single process-wide instance is held on _instance.
Load Turtle files into a fresh Oxigraph store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_path
|
str
|
Path to |
required |
shapes_path
|
str
|
Path to |
required |
vocab_path
|
str
|
Path to |
required |
Source code in src/backend/app/rdf.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
graph
property
¶
Merged rdflib graph of shapes, data, and vocab, parsed on first use.
query(sparql)
¶
Run a SPARQL SELECT; one dict per row, unbound variables omitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sparql
|
str
|
Full SELECT query string. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of row dicts keyed by variable name. |
Raises:
| Type | Description |
|---|---|
QueryError
|
When Oxigraph rejects or fails the query; the query text is logged. |
Source code in src/backend/app/rdf.py
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 | |
entity_shapes()
¶
Return the EntityShape descriptors projected from SHACL, cached.
Returns:
| Type | Description |
|---|---|
list[EntityShape]
|
Property descriptors used to build SPARQL and decode GeoJSON. |
Source code in src/backend/app/rdf.py
86 87 88 89 90 91 92 93 94 | |
validate()
¶
Reject a store that parsed but cannot drive the map.
Raises:
| Type | Description |
|---|---|
ReloadError
|
When shapes yield nothing or no entity has coordinates. |
Source code in src/backend/app/rdf.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
from_settings()
classmethod
¶
Build a store from the configured ontology and use-case directories.
Returns:
| Type | Description |
|---|---|
RDFStore
|
New |
RDFStore
|
|
RDFStore
|
|
Source code in src/backend/app/rdf.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
instance()
classmethod
¶
Return the single live store, creating it from settings if needed.
Returns:
| Type | Description |
|---|---|
RDFStore
|
Process-wide |
Source code in src/backend/app/rdf.py
132 133 134 135 136 137 138 139 140 141 | |
reload_instance()
classmethod
¶
Swap in the files currently on disk, keeping the live store on failure.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Status dict with |
dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
ReloadError
|
When the on-disk ontology is not usable. |
Source code in src/backend/app/rdf.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |