ontocast.tool.shapes_catalog¶
SHACL shapes catalog: the shapes partition of the triple store.
Shapes are a deployment artifact, not a per-process file path. A catalog that declares constraints ships them alongside its schema, and a tenant that owns a catalog owns its shapes -- so they live in the triple store, in their own partition, seeded once from disk and mutable over HTTP thereafter.
Why a partition of their own rather than the ontologies dataset: catalog
discovery claims every named graph carrying an owl:Ontology subject, and a
shapes document declares one. Stored beside the ontologies, a shapes file
registers as a catalog entry, gets indexed as ontology atoms, and is offered to
the renderer as first-class schema.
The facts validation gate is synchronous, so it cannot read the store itself.
This catalog resolves the merged shapes graph once, asynchronously, and hands
the gate a plain :class:~ontocast.onto.rdfgraph.RDFGraph.
ShapesCatalog
¶
Bases: Tool
The shapes partition, and the merged graph the validation gate reads.
Partition-scoped, like
:class:~ontocast.tool.ontology_manager.OntologyManager: everything held
here belongs to one tenant/project, so a tenancy switch must
:meth:reset it.
Source code in ontocast/tool/shapes_catalog.py
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
__init__(**kwargs)
¶
Initialize an empty catalog with no triple store registered.
delete(graph_uri)
async
¶
Remove one shapes document and refresh the merged graph.
Source code in ontocast/tool/shapes_catalog.py
graph()
¶
Return the merged shapes graph, or None when nothing is stored.
None is load-bearing downstream: it is what keeps
facts_conformance.shacl_evaluated at None ("never checked")
rather than reporting a clean run against no shapes.
Source code in ontocast/tool/shapes_catalog.py
ingest(graph, *, graph_uri)
async
¶
Store one shapes document and refresh the merged graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
The parsed shapes document. |
required |
graph_uri
|
str
|
Named graph to store it under. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The graph URI it was stored at. |
Source code in ontocast/tool/shapes_catalog.py
list_graph_uris()
async
¶
List the named graphs in the shapes partition.
Uses a named-graph listing rather than the ontology header query: a
shapes document is not required to declare an owl:Ontology header,
and one stored without a header must still be visible.
Source code in ontocast/tool/shapes_catalog.py
register_triple_store(manager)
¶
reset()
¶
sync(shapes_dir=None)
async
¶
Seed from shapes_dir when needed, then materialize the merged graph.
Seeding mirrors the ontology bootstrap in
:meth:ontocast.toolbox.ToolBox._synchronize_ontologies: the directory
is a read-only fixture, the store is the persistence. Unlike that path
the search is recursive, matching what the validation gate accepted from
FACTS_SHAPES_DIR before shapes were stored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapes_dir
|
str | None
|
Seed directory of |
None
|
Source code in ontocast/tool/shapes_catalog.py
content_graph_uri(ttl)
¶
seed_graph_uri(path, root)
¶
Fallback graph name for a headerless shapes file, derived from its path.
Source code in ontocast/tool/shapes_catalog.py
shapes_graph_uri(graph, *, fallback)
¶
Name the named graph a shapes document is stored under.
A shapes document that declares an owl:Ontology header is addressed by
that IRI, which makes replace and delete by IRI work the way they do for
ontologies. A bare SHACL file has no identity of its own, so the caller's
fallback names it -- stable across edits, so re-seeding replaces the
document rather than accumulating stale copies beside it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
The parsed shapes document. |
required |
fallback
|
str
|
Graph name to use when the document declares no ontology IRI. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The named-graph URI. |