update_vocabs
Implements an entailment + validation workflow.
update_vocabs
starts by loading one or more
DomainConfiguration's from
RDF files and/or SPARQL endpoints, and a series of profile definitions
(also from a list of RDF files and/or SPARQL endpoints).
From there, individual or batch processing of files can be done,
as well as uploading the results to a target triplestore.
This script can be used as a library, or run directly from the cli; please refer to the OGC NamingAuthority repository for usage details on the latter.
Defining the SPARQL graph URI
The graph URI that will be used for an RDF document when pushing the data to a SPARQL endpoint can
be defined by adding a http://www.opengis.net/ogc-na#targetGraph
predicate anywhere
inside it, for example:
[] <http://www.opengis.net/ogc-na#targetGraph> <https://example.com/target-graph> .
get_entailed_base_path(f, g, rootpattern=None, entailed_dir=DEFAULT_ENTAILED_DIR)
Tries to find the base output file path for an entailed version of a source Graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
Path
|
the original path of the source file |
required |
g
|
Graph
|
the Graph loaded from the source file |
required |
rootpattern
|
Union[str, None]
|
a root pattern to filter candidate URIs |
None
|
entailed_dir
|
str
|
the name of the base entailed files directory |
DEFAULT_ENTAILED_DIR
|
Source code in ogc/na/update_vocabs.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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
get_graph_uri_for_vocab(g=None)
Find a target graph URI in a vocabulary Graph.
This function looks for any object of the http://www.opengis.net/ogc-na#targetGraph predicate, and in its absence for a SKOS ConceptScheme's.
The following can be included in a Turtle document to specify its graph:
[] <http://www.opengis.net/ogc-na#targetGraph> <https://example.com/target/graph> .
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g
|
Graph
|
the Graph for which to find the target URI |
None
|
Returns:
Type | Description |
---|---|
Generator[str, None, None]
|
a Node generator |
Source code in ogc/na/update_vocabs.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
load_vocab(vocab, graph_uri, graph_store, auth_details=None, append=False)
Loads a vocabulary onto a triplestore using the SPARQL Graph Store protocol.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vocab
|
Union[Graph, str, Path]
|
the file or Graph to load |
required |
graph_uri
|
str
|
a target graph URI |
required |
graph_store
|
str
|
the target SPARQL Graph Store protocol URL |
required |
auth_details
|
tuple[str]
|
a |
None
|
append
|
whether to append the data to the graph (otherwise the graph data will be replaced) |
False
|
Returns:
Type | Description |
---|---|
None
|
|
Source code in ogc/na/update_vocabs.py
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 |
|
make_rdf(filename, g, rootpath=None, entailment_directory=DEFAULT_ENTAILED_DIR, provenance_metadata=None)
Serializes entailed RDF graphs in several output formats for a given input graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
Union[str, Path]
|
the original source filename |
required |
g
|
Graph
|
Graph loaded from the source file |
required |
rootpath
|
Union[str, None]
|
a path to filter concept schemes inside the Graph and infer the main one |
None
|
provenance_metadata
|
ProvenanceMetadata
|
provenance metadata (None to ignore) |
None
|
entailment_directory
|
Union[str, Path]
|
name for the output subdirectory for entailed files |
DEFAULT_ENTAILED_DIR
|
Returns:
Type | Description |
---|---|
Path
|
the output path for the Turtle version of the entailed files |
Source code in ogc/na/update_vocabs.py
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 |
|
setup_logging(debug=False)
Sets up logging level and handlers (logs WARNING and ERROR to stderr).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug
|
bool
|
whether to set DEBUG level |
False
|
Source code in ogc/na/update_vocabs.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|