rdf4j-python 0.1.1a0__py3-none-any.whl → 0.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rdf4j_python/__init__.py +9 -4
- rdf4j_python/_client/_client.py +156 -5
- rdf4j_python/_driver/__init__.py +2 -0
- rdf4j_python/_driver/_async_named_graph.py +76 -0
- rdf4j_python/_driver/_async_rdf4j_db.py +60 -34
- rdf4j_python/_driver/_async_repository.py +307 -25
- rdf4j_python/exception/__init__.py +5 -0
- rdf4j_python/exception/repo_exception.py +26 -5
- rdf4j_python/model/__init__.py +5 -10
- rdf4j_python/model/_namespace.py +115 -14
- rdf4j_python/model/_repository_info.py +36 -15
- rdf4j_python/model/{_repository_config.py → repository_config.py} +671 -70
- rdf4j_python/model/term.py +20 -0
- rdf4j_python/model/vocabulary.py +7 -0
- rdf4j_python/utils/__init__.py +3 -0
- rdf4j_python/utils/const.py +4 -4
- rdf4j_python/utils/helpers.py +20 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.3.dist-info}/METADATA +13 -13
- rdf4j_python-0.1.3.dist-info/RECORD +23 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.3.dist-info}/WHEEL +1 -1
- rdf4j_python/model/_base_model.py +0 -26
- rdf4j_python-0.1.1a0.dist-info/RECORD +0 -19
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.3.dist-info}/licenses/LICENSE +0 -0
- {rdf4j_python-0.1.1a0.dist-info → rdf4j_python-0.1.3.dist-info}/top_level.txt +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
from typing import Any, Dict, Optional
|
|
2
2
|
|
|
3
|
-
from
|
|
4
|
-
|
|
3
|
+
from pyoxigraph import Dataset, Quad, RdfFormat, serialize
|
|
4
|
+
|
|
5
|
+
from rdf4j_python.model import Namespace
|
|
6
|
+
from rdf4j_python.model.term import IRI as URIRef
|
|
7
|
+
from rdf4j_python.model.term import BlankNode as BNode
|
|
8
|
+
from rdf4j_python.model.term import Literal
|
|
9
|
+
from rdf4j_python.model.vocabulary import RDF, RDFS, XSD
|
|
5
10
|
|
|
6
11
|
# Define the RDF4J configuration namespace
|
|
7
|
-
CONFIG = Namespace("tag:rdf4j.org,2023:config/")
|
|
12
|
+
CONFIG = Namespace("config", "tag:rdf4j.org,2023:config/")
|
|
8
13
|
|
|
9
14
|
|
|
10
15
|
class RepositoryConfig:
|
|
11
16
|
"""
|
|
12
|
-
Represents the configuration for an RDF4J Repository
|
|
17
|
+
Represents the configuration for an RDF4J Repository.
|
|
13
18
|
"""
|
|
14
19
|
|
|
15
20
|
_repo_id: str
|
|
@@ -22,60 +27,77 @@ class RepositoryConfig:
|
|
|
22
27
|
title: Optional[str] = None,
|
|
23
28
|
impl: Optional["RepositoryImplConfig"] = None,
|
|
24
29
|
):
|
|
30
|
+
"""
|
|
31
|
+
Initializes a new RepositoryConfig instance.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
repo_id (str): The unique identifier for the repository.
|
|
35
|
+
title (Optional[str], optional): A human-readable title for the repository. Defaults to None.
|
|
36
|
+
impl (Optional[RepositoryImplConfig], optional): The implementation configuration for the repository. Defaults to None.
|
|
37
|
+
"""
|
|
25
38
|
self._repo_id = repo_id
|
|
26
39
|
self._title = title
|
|
27
40
|
self._impl = impl
|
|
28
41
|
|
|
29
42
|
@property
|
|
30
43
|
def repo_id(self) -> str:
|
|
44
|
+
"""
|
|
45
|
+
Returns the repository ID.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
str: The repository ID.
|
|
49
|
+
"""
|
|
31
50
|
return self._repo_id
|
|
32
51
|
|
|
33
52
|
@property
|
|
34
53
|
def title(self) -> Optional[str]:
|
|
54
|
+
"""
|
|
55
|
+
Returns the human-readable title for the repository.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Optional[str]: The human-readable title for the repository, or None if not set.
|
|
59
|
+
"""
|
|
35
60
|
return self._title
|
|
36
61
|
|
|
37
62
|
def to_turtle(self) -> str:
|
|
38
63
|
"""
|
|
39
|
-
Serializes the Repository configuration to Turtle syntax using
|
|
64
|
+
Serializes the Repository configuration to Turtle syntax using .
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
str: A UTF-8 encoded Turtle string representing the RDF4J repository configuration.
|
|
68
|
+
The serialization includes the repository ID, optional human-readable title,
|
|
69
|
+
and nested repository implementation configuration if available.
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
ValueError: If any of the configuration values are of unsupported types during serialization.
|
|
40
73
|
"""
|
|
41
|
-
graph =
|
|
42
|
-
graph.bind("rdfs", RDFS)
|
|
43
|
-
graph.bind("config", CONFIG)
|
|
44
|
-
graph.bind("xsd", XSD)
|
|
74
|
+
graph = Dataset()
|
|
45
75
|
repo_node = BNode()
|
|
46
|
-
graph.add((repo_node, RDF["type"], CONFIG["Repository"]))
|
|
76
|
+
graph.add(Quad(repo_node, RDF["type"], CONFIG["Repository"], None))
|
|
47
77
|
|
|
48
|
-
graph.add((repo_node, CONFIG["rep.id"], Literal(self._repo_id)))
|
|
78
|
+
graph.add(Quad(repo_node, CONFIG["rep.id"], Literal(self._repo_id), None))
|
|
49
79
|
|
|
50
80
|
if self._title:
|
|
51
|
-
graph.add((repo_node, RDFS["label"], Literal(self._title)))
|
|
81
|
+
graph.add(Quad(repo_node, RDFS["label"], Literal(self._title), None))
|
|
52
82
|
|
|
53
83
|
if self._impl:
|
|
54
84
|
impl_node = self._impl.add_to_graph(graph)
|
|
55
|
-
graph.add((repo_node, CONFIG["rep.impl"], impl_node))
|
|
56
|
-
|
|
57
|
-
return graph.serialize(format="turtle").encode("utf-8")
|
|
58
|
-
|
|
59
|
-
@staticmethod
|
|
60
|
-
def builder_with_sail_repository(
|
|
61
|
-
sail_impl: "SailConfig",
|
|
62
|
-
) -> "RepositoryConfig.Builder":
|
|
63
|
-
"""
|
|
64
|
-
Convenience method to create a RepositoryConfig with a SailRepositoryConfig.
|
|
65
|
-
"""
|
|
85
|
+
graph.add(Quad(repo_node, CONFIG["rep.impl"], impl_node, None))
|
|
66
86
|
|
|
67
|
-
|
|
68
|
-
SailRepositoryConfig.Builder().sail_impl(sail_impl).build()
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
return repo_config
|
|
87
|
+
return serialize(graph, format=RdfFormat.TURTLE)
|
|
72
88
|
|
|
73
89
|
class Builder:
|
|
74
90
|
"""
|
|
75
|
-
Builder
|
|
91
|
+
Builder for creating RepositoryConfig instances.
|
|
76
92
|
"""
|
|
77
93
|
|
|
78
94
|
def __init__(self, repo_id: Optional[str] = None):
|
|
95
|
+
"""
|
|
96
|
+
Initializes a new RepositoryConfig.Builder instance.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
repo_id (Optional[str], optional): The unique identifier for the repository. Defaults to None.
|
|
100
|
+
"""
|
|
79
101
|
self._repo_id = repo_id
|
|
80
102
|
self._title: Optional[str] = None
|
|
81
103
|
self._impl: Optional["RepositoryImplConfig"] = None
|
|
@@ -83,6 +105,12 @@ class RepositoryConfig:
|
|
|
83
105
|
def repo_id(self, repo_id: str) -> "RepositoryConfig.Builder":
|
|
84
106
|
"""
|
|
85
107
|
Sets the repository ID.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
repo_id (str): The unique identifier for the repository.
|
|
111
|
+
|
|
112
|
+
Returns:
|
|
113
|
+
RepositoryConfig.Builder: The builder instance.
|
|
86
114
|
"""
|
|
87
115
|
self._repo_id = repo_id
|
|
88
116
|
return self
|
|
@@ -90,6 +118,12 @@ class RepositoryConfig:
|
|
|
90
118
|
def title(self, title: str) -> "RepositoryConfig.Builder":
|
|
91
119
|
"""
|
|
92
120
|
Sets the human-readable title for the repository.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
title (str): The human-readable title for the repository.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
RepositoryConfig.Builder: The builder instance.
|
|
93
127
|
"""
|
|
94
128
|
self._title = title
|
|
95
129
|
return self
|
|
@@ -97,13 +131,37 @@ class RepositoryConfig:
|
|
|
97
131
|
def repo_impl(self, impl: "RepositoryImplConfig") -> "RepositoryConfig.Builder":
|
|
98
132
|
"""
|
|
99
133
|
Sets the repository implementation configuration.
|
|
134
|
+
|
|
135
|
+
Args:
|
|
136
|
+
impl (RepositoryImplConfig): The implementation configuration for the repository.
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
RepositoryConfig.Builder: The builder instance.
|
|
100
140
|
"""
|
|
101
141
|
self._impl = impl
|
|
102
142
|
return self
|
|
103
143
|
|
|
144
|
+
def sail_repository_impl(
|
|
145
|
+
self, sail_impl: "SailConfig"
|
|
146
|
+
) -> "RepositoryConfig.Builder":
|
|
147
|
+
"""
|
|
148
|
+
Sets the repository implementation configuration to a SailRepositoryConfig.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
sail_impl (SailConfig): The Sail configuration for the repository.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
RepositoryConfig.Builder: The builder instance.
|
|
155
|
+
"""
|
|
156
|
+
self.repo_impl(SailRepositoryConfig.Builder().sail_impl(sail_impl).build())
|
|
157
|
+
return self
|
|
158
|
+
|
|
104
159
|
def build(self) -> "RepositoryConfig":
|
|
105
160
|
"""
|
|
106
161
|
Builds and returns the RepositoryConfig instance.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
RepositoryConfig: The constructed RepositoryConfig instance.
|
|
107
165
|
"""
|
|
108
166
|
return RepositoryConfig(
|
|
109
167
|
repo_id=self._repo_id, title=self._title, impl=self._impl
|
|
@@ -112,14 +170,14 @@ class RepositoryConfig:
|
|
|
112
170
|
|
|
113
171
|
class RepositoryImplConfig:
|
|
114
172
|
"""
|
|
115
|
-
Base class for repository implementation configurations using
|
|
173
|
+
Base class for repository implementation configurations using .
|
|
116
174
|
"""
|
|
117
175
|
|
|
118
176
|
def __init__(self, rep_type: str):
|
|
119
177
|
self.rep_type = rep_type
|
|
120
178
|
self.config_params: Dict[str, Any] = {}
|
|
121
179
|
|
|
122
|
-
def add_to_graph(self, graph:
|
|
180
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
123
181
|
"""
|
|
124
182
|
Adds the repository implementation configuration to the RDF graph.
|
|
125
183
|
|
|
@@ -127,28 +185,45 @@ class RepositoryImplConfig:
|
|
|
127
185
|
The RDF node representing this configuration.
|
|
128
186
|
"""
|
|
129
187
|
sail_node = BNode()
|
|
130
|
-
graph.add((sail_node, CONFIG["rep.type"], Literal(self.rep_type)))
|
|
188
|
+
graph.add(Quad(sail_node, CONFIG["rep.type"], Literal(self.rep_type), None))
|
|
131
189
|
for key, value in self.config_params.items():
|
|
132
190
|
if isinstance(value, str):
|
|
133
|
-
graph.add((sail_node, CONFIG[key], Literal(value)))
|
|
134
|
-
elif isinstance(value, int):
|
|
191
|
+
graph.add(Quad(sail_node, CONFIG[key], Literal(value), None))
|
|
192
|
+
elif isinstance(value, int) and not isinstance(value, bool):
|
|
135
193
|
graph.add(
|
|
136
|
-
(
|
|
194
|
+
Quad(
|
|
195
|
+
sail_node,
|
|
196
|
+
CONFIG[key],
|
|
197
|
+
Literal(value, datatype=XSD["integer"]),
|
|
198
|
+
None,
|
|
199
|
+
)
|
|
137
200
|
)
|
|
138
201
|
elif isinstance(value, float):
|
|
139
|
-
graph.add(
|
|
202
|
+
graph.add(
|
|
203
|
+
Quad(
|
|
204
|
+
sail_node,
|
|
205
|
+
CONFIG[key],
|
|
206
|
+
Literal(value, datatype=XSD["double"]),
|
|
207
|
+
None,
|
|
208
|
+
)
|
|
209
|
+
)
|
|
140
210
|
elif isinstance(value, bool):
|
|
141
211
|
graph.add(
|
|
142
|
-
(
|
|
212
|
+
Quad(
|
|
213
|
+
sail_node,
|
|
214
|
+
CONFIG[key],
|
|
215
|
+
Literal(str(value).lower(), datatype=XSD["boolean"]),
|
|
216
|
+
None,
|
|
217
|
+
)
|
|
143
218
|
)
|
|
144
219
|
elif isinstance(value, list):
|
|
145
220
|
for item in value:
|
|
146
|
-
graph.add((sail_node, CONFIG[key], URIRef(item)))
|
|
221
|
+
graph.add(Quad(sail_node, CONFIG[key], URIRef(item), None))
|
|
147
222
|
elif isinstance(value, RepositoryImplConfig) or isinstance(
|
|
148
223
|
value, SailConfig
|
|
149
224
|
):
|
|
150
225
|
nested_node = value.add_to_graph(graph)
|
|
151
|
-
graph.add((sail_node, CONFIG[key], nested_node))
|
|
226
|
+
graph.add(Quad(sail_node, CONFIG[key], nested_node, None))
|
|
152
227
|
else:
|
|
153
228
|
raise ValueError(f"Unsupported configuration value type: {type(value)}")
|
|
154
229
|
return sail_node
|
|
@@ -156,12 +231,19 @@ class RepositoryImplConfig:
|
|
|
156
231
|
|
|
157
232
|
class SPARQLRepositoryConfig(RepositoryImplConfig):
|
|
158
233
|
"""
|
|
159
|
-
Configuration for a SPARQLRepository
|
|
234
|
+
Configuration for a SPARQLRepository.
|
|
160
235
|
"""
|
|
161
236
|
|
|
162
237
|
TYPE = "openrdf:SPARQLRepository"
|
|
163
238
|
|
|
164
239
|
def __init__(self, query_endpoint: str, update_endpoint: Optional[str] = None):
|
|
240
|
+
"""
|
|
241
|
+
Initializes a new SPARQLRepositoryConfig instance.
|
|
242
|
+
|
|
243
|
+
Args:
|
|
244
|
+
query_endpoint (str): The SPARQL query endpoint URL.
|
|
245
|
+
update_endpoint (Optional[str], optional): The SPARQL update endpoint URL. Defaults to None.
|
|
246
|
+
"""
|
|
165
247
|
super().__init__(rep_type=SPARQLRepositoryConfig.TYPE)
|
|
166
248
|
self.config_params["sparql.queryEndpoint"] = query_endpoint
|
|
167
249
|
if update_endpoint:
|
|
@@ -169,12 +251,27 @@ class SPARQLRepositoryConfig(RepositoryImplConfig):
|
|
|
169
251
|
|
|
170
252
|
class Builder:
|
|
171
253
|
def __init__(self, query_endpoint: str):
|
|
254
|
+
"""
|
|
255
|
+
Initializes a new SPARQLRepositoryConfig.Builder instance.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
query_endpoint (str): The SPARQL query endpoint URL.
|
|
259
|
+
"""
|
|
172
260
|
self._query_endpoint = query_endpoint
|
|
173
261
|
self._update_endpoint: Optional[str] = None
|
|
174
262
|
|
|
175
263
|
def update_endpoint(
|
|
176
264
|
self, update_endpoint: str
|
|
177
265
|
) -> "SPARQLRepositoryConfig.Builder":
|
|
266
|
+
"""
|
|
267
|
+
Sets the SPARQL update endpoint URL.
|
|
268
|
+
|
|
269
|
+
Args:
|
|
270
|
+
update_endpoint (str): The SPARQL update endpoint URL.
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
SPARQLRepositoryConfig.Builder: The builder instance.
|
|
274
|
+
"""
|
|
178
275
|
self._update_endpoint = update_endpoint
|
|
179
276
|
return self
|
|
180
277
|
|
|
@@ -187,7 +284,7 @@ class SPARQLRepositoryConfig(RepositoryImplConfig):
|
|
|
187
284
|
|
|
188
285
|
class HTTPRepositoryConfig(RepositoryImplConfig):
|
|
189
286
|
"""
|
|
190
|
-
Configuration for an HTTPRepository
|
|
287
|
+
Configuration for an HTTPRepository.
|
|
191
288
|
"""
|
|
192
289
|
|
|
193
290
|
TYPE = "openrdf:HTTPRepository"
|
|
@@ -209,10 +306,28 @@ class HTTPRepositoryConfig(RepositoryImplConfig):
|
|
|
209
306
|
self._password: Optional[str] = None
|
|
210
307
|
|
|
211
308
|
def username(self, username: str) -> "HTTPRepositoryConfig.Builder":
|
|
309
|
+
"""
|
|
310
|
+
Sets the username for the HTTP repository.
|
|
311
|
+
|
|
312
|
+
Args:
|
|
313
|
+
username (str): The username for the HTTP repository.
|
|
314
|
+
|
|
315
|
+
Returns:
|
|
316
|
+
HTTPRepositoryConfig.Builder: The builder instance.
|
|
317
|
+
"""
|
|
212
318
|
self._username = username
|
|
213
319
|
return self
|
|
214
320
|
|
|
215
321
|
def password(self, password: str) -> "HTTPRepositoryConfig.Builder":
|
|
322
|
+
"""
|
|
323
|
+
Sets the password for the HTTP repository.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
password (str): The password for the HTTP repository.
|
|
327
|
+
|
|
328
|
+
Returns:
|
|
329
|
+
HTTPRepositoryConfig.Builder: The builder instance.
|
|
330
|
+
"""
|
|
216
331
|
self._password = password
|
|
217
332
|
return self
|
|
218
333
|
|
|
@@ -224,7 +339,7 @@ class HTTPRepositoryConfig(RepositoryImplConfig):
|
|
|
224
339
|
|
|
225
340
|
class SailRepositoryConfig(RepositoryImplConfig):
|
|
226
341
|
"""
|
|
227
|
-
Configuration for a SailRepository
|
|
342
|
+
Configuration for a SailRepository.
|
|
228
343
|
"""
|
|
229
344
|
|
|
230
345
|
TYPE = "openrdf:SailRepository"
|
|
@@ -233,7 +348,7 @@ class SailRepositoryConfig(RepositoryImplConfig):
|
|
|
233
348
|
super().__init__(rep_type=SailRepositoryConfig.TYPE)
|
|
234
349
|
self.config_params["sail.impl"] = sail_impl
|
|
235
350
|
|
|
236
|
-
def add_to_graph(self, graph:
|
|
351
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
237
352
|
"""
|
|
238
353
|
Adds the SailRepository configuration to the RDF graph.
|
|
239
354
|
"""
|
|
@@ -244,16 +359,31 @@ class SailRepositoryConfig(RepositoryImplConfig):
|
|
|
244
359
|
self._sail_impl = sail_impl
|
|
245
360
|
|
|
246
361
|
def sail_impl(self, sail_impl: "SailConfig") -> "SailRepositoryConfig.Builder":
|
|
362
|
+
"""
|
|
363
|
+
Sets the Sail configuration for the repository.
|
|
364
|
+
|
|
365
|
+
Args:
|
|
366
|
+
sail_impl (SailConfig): The Sail configuration for the repository.
|
|
367
|
+
|
|
368
|
+
Returns:
|
|
369
|
+
SailRepositoryConfig.Builder: The builder instance.
|
|
370
|
+
"""
|
|
247
371
|
self._sail_impl = sail_impl
|
|
248
372
|
return self
|
|
249
373
|
|
|
250
374
|
def build(self) -> "SailRepositoryConfig":
|
|
375
|
+
"""
|
|
376
|
+
Builds and returns the SailRepositoryConfig instance.
|
|
377
|
+
|
|
378
|
+
Returns:
|
|
379
|
+
SailRepositoryConfig: The constructed SailRepositoryConfig instance.
|
|
380
|
+
"""
|
|
251
381
|
return SailRepositoryConfig(sail_impl=self._sail_impl)
|
|
252
382
|
|
|
253
383
|
|
|
254
384
|
class DatasetRepositoryConfig(RepositoryImplConfig):
|
|
255
385
|
"""
|
|
256
|
-
Configuration for a DatasetRepository using
|
|
386
|
+
Configuration for a DatasetRepository using .
|
|
257
387
|
"""
|
|
258
388
|
|
|
259
389
|
TYPE = "openrdf:DatasetRepository"
|
|
@@ -262,7 +392,7 @@ class DatasetRepositoryConfig(RepositoryImplConfig):
|
|
|
262
392
|
super().__init__(rep_type=DatasetRepositoryConfig.TYPE)
|
|
263
393
|
self.config_params["delegate"] = delegate
|
|
264
394
|
|
|
265
|
-
def add_to_graph(self, graph:
|
|
395
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
266
396
|
"""
|
|
267
397
|
Adds the DatasetRepository configuration to the RDF Graph
|
|
268
398
|
"""
|
|
@@ -279,7 +409,7 @@ class DatasetRepositoryConfig(RepositoryImplConfig):
|
|
|
279
409
|
|
|
280
410
|
class SailConfig:
|
|
281
411
|
"""
|
|
282
|
-
Base class for SAIL configurations using
|
|
412
|
+
Base class for SAIL configurations using .
|
|
283
413
|
"""
|
|
284
414
|
|
|
285
415
|
def __init__(
|
|
@@ -299,7 +429,7 @@ class SailConfig:
|
|
|
299
429
|
default_query_evaluation_mode
|
|
300
430
|
)
|
|
301
431
|
|
|
302
|
-
def add_to_graph(self, graph:
|
|
432
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
303
433
|
"""
|
|
304
434
|
Adds the SAIL configuration to the RDF graph.
|
|
305
435
|
|
|
@@ -307,28 +437,45 @@ class SailConfig:
|
|
|
307
437
|
The RDF node representing this configuration.
|
|
308
438
|
"""
|
|
309
439
|
sail_node = BNode()
|
|
310
|
-
graph.add((sail_node, CONFIG["sail.type"], Literal(self.sail_type)))
|
|
440
|
+
graph.add(Quad(sail_node, CONFIG["sail.type"], Literal(self.sail_type), None))
|
|
311
441
|
for key, value in self.config_params.items():
|
|
312
442
|
if isinstance(value, str):
|
|
313
|
-
graph.add((sail_node, CONFIG[key], Literal(value)))
|
|
314
|
-
elif isinstance(value,
|
|
443
|
+
graph.add(Quad(sail_node, CONFIG[key], Literal(value), None))
|
|
444
|
+
elif isinstance(value, bool):
|
|
315
445
|
graph.add(
|
|
316
|
-
(
|
|
446
|
+
Quad(
|
|
447
|
+
sail_node,
|
|
448
|
+
CONFIG[key],
|
|
449
|
+
Literal(str(value).lower(), datatype=XSD["boolean"]),
|
|
450
|
+
None,
|
|
451
|
+
)
|
|
452
|
+
)
|
|
453
|
+
elif isinstance(value, int) and not isinstance(value, bool):
|
|
454
|
+
graph.add(
|
|
455
|
+
Quad(
|
|
456
|
+
sail_node,
|
|
457
|
+
CONFIG[key],
|
|
458
|
+
Literal(str(value), datatype=XSD["integer"]),
|
|
459
|
+
None,
|
|
460
|
+
)
|
|
317
461
|
)
|
|
318
462
|
elif isinstance(value, float):
|
|
319
|
-
graph.add((sail_node, CONFIG[key], Literal(value, datatype=XSD.double)))
|
|
320
|
-
elif isinstance(value, bool):
|
|
321
463
|
graph.add(
|
|
322
|
-
(
|
|
464
|
+
Quad(
|
|
465
|
+
sail_node,
|
|
466
|
+
CONFIG[key],
|
|
467
|
+
Literal(str(value), datatype=XSD["double"]),
|
|
468
|
+
None,
|
|
469
|
+
)
|
|
323
470
|
)
|
|
324
471
|
elif isinstance(value, list):
|
|
325
472
|
for item in value:
|
|
326
|
-
graph.add((sail_node, CONFIG[key], URIRef(item)))
|
|
473
|
+
graph.add(Quad(sail_node, CONFIG[key], URIRef(item), None))
|
|
327
474
|
elif isinstance(value, SailConfig) or isinstance(
|
|
328
475
|
value, RepositoryImplConfig
|
|
329
476
|
):
|
|
330
477
|
nested_node = value.add_to_graph(graph)
|
|
331
|
-
graph.add((sail_node, CONFIG[key], nested_node))
|
|
478
|
+
graph.add(Quad(sail_node, CONFIG[key], nested_node, None))
|
|
332
479
|
else:
|
|
333
480
|
raise ValueError(f"Unsupported configuration value type: {type(value)}")
|
|
334
481
|
return sail_node
|
|
@@ -336,7 +483,7 @@ class SailConfig:
|
|
|
336
483
|
|
|
337
484
|
class MemoryStoreConfig(SailConfig):
|
|
338
485
|
"""
|
|
339
|
-
Configuration for a MemoryStore using
|
|
486
|
+
Configuration for a MemoryStore using .
|
|
340
487
|
"""
|
|
341
488
|
|
|
342
489
|
TYPE = "openrdf:MemoryStore"
|
|
@@ -366,22 +513,58 @@ class MemoryStoreConfig(SailConfig):
|
|
|
366
513
|
self._default_query_evaluation_mode: Optional[str] = None
|
|
367
514
|
|
|
368
515
|
def persist(self, persist: bool) -> "MemoryStoreConfig.Builder":
|
|
516
|
+
"""
|
|
517
|
+
Sets the persist flag for the MemoryStore configuration.
|
|
518
|
+
|
|
519
|
+
Args:
|
|
520
|
+
persist (bool): The persist flag for the MemoryStore configuration.
|
|
521
|
+
|
|
522
|
+
Returns:
|
|
523
|
+
MemoryStoreConfig.Builder: The builder instance.
|
|
524
|
+
"""
|
|
369
525
|
self._persist = persist
|
|
370
526
|
return self
|
|
371
527
|
|
|
372
528
|
def sync_delay(self, sync_delay: int) -> "MemoryStoreConfig.Builder":
|
|
529
|
+
"""
|
|
530
|
+
Sets the sync delay for the MemoryStore configuration.
|
|
531
|
+
|
|
532
|
+
Args:
|
|
533
|
+
sync_delay (int): The sync delay for the MemoryStore configuration.
|
|
534
|
+
|
|
535
|
+
Returns:
|
|
536
|
+
MemoryStoreConfig.Builder: The builder instance.
|
|
537
|
+
"""
|
|
373
538
|
self._sync_delay = sync_delay
|
|
374
539
|
return self
|
|
375
540
|
|
|
376
541
|
def iteration_cache_sync_threshold(
|
|
377
542
|
self, threshold: int
|
|
378
543
|
) -> "MemoryStoreConfig.Builder":
|
|
544
|
+
"""
|
|
545
|
+
Sets the iteration cache sync threshold for the MemoryStore configuration.
|
|
546
|
+
|
|
547
|
+
Args:
|
|
548
|
+
threshold (int): The iteration cache sync threshold for the MemoryStore configuration.
|
|
549
|
+
|
|
550
|
+
Returns:
|
|
551
|
+
MemoryStoreConfig.Builder: The builder instance.
|
|
552
|
+
"""
|
|
379
553
|
self._iteration_cache_sync_threshold = threshold
|
|
380
554
|
return self
|
|
381
555
|
|
|
382
556
|
def default_query_evaluation_mode(
|
|
383
557
|
self, mode: str
|
|
384
558
|
) -> "MemoryStoreConfig.Builder":
|
|
559
|
+
"""
|
|
560
|
+
Sets the default query evaluation mode for the MemoryStore configuration.
|
|
561
|
+
|
|
562
|
+
Args:
|
|
563
|
+
mode (str): The default query evaluation mode for the MemoryStore configuration.
|
|
564
|
+
|
|
565
|
+
Returns:
|
|
566
|
+
MemoryStoreConfig.Builder: The builder instance.
|
|
567
|
+
"""
|
|
385
568
|
self._default_query_evaluation_mode = mode
|
|
386
569
|
return self
|
|
387
570
|
|
|
@@ -396,7 +579,7 @@ class MemoryStoreConfig(SailConfig):
|
|
|
396
579
|
|
|
397
580
|
class NativeStoreConfig(SailConfig):
|
|
398
581
|
"""
|
|
399
|
-
Configuration for a NativeStore using
|
|
582
|
+
Configuration for a NativeStore using .
|
|
400
583
|
"""
|
|
401
584
|
|
|
402
585
|
TYPE = "openrdf:NativeStore"
|
|
@@ -442,38 +625,110 @@ class NativeStoreConfig(SailConfig):
|
|
|
442
625
|
self._default_query_evaluation_mode: Optional[str] = None
|
|
443
626
|
|
|
444
627
|
def triple_indexes(self, indexes: str) -> "NativeStoreConfig.Builder":
|
|
628
|
+
"""
|
|
629
|
+
Sets the triple indexes for the NativeStore configuration.
|
|
630
|
+
|
|
631
|
+
Args:
|
|
632
|
+
indexes (str): The triple indexes for the NativeStore configuration.
|
|
633
|
+
|
|
634
|
+
Returns:
|
|
635
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
636
|
+
"""
|
|
445
637
|
self._triple_indexes = indexes
|
|
446
638
|
return self
|
|
447
639
|
|
|
448
640
|
def force_sync(self, sync: bool) -> "NativeStoreConfig.Builder":
|
|
641
|
+
"""
|
|
642
|
+
Sets the force sync flag for the NativeStore configuration.
|
|
643
|
+
|
|
644
|
+
Args:
|
|
645
|
+
sync (bool): The force sync flag for the NativeStore configuration.
|
|
646
|
+
|
|
647
|
+
Returns:
|
|
648
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
649
|
+
"""
|
|
449
650
|
self._force_sync = sync
|
|
450
651
|
return self
|
|
451
652
|
|
|
452
653
|
def value_cache_size(self, size: int) -> "NativeStoreConfig.Builder":
|
|
654
|
+
"""
|
|
655
|
+
Sets the value cache size for the NativeStore configuration.
|
|
656
|
+
|
|
657
|
+
Args:
|
|
658
|
+
size (int): The value cache size for the NativeStore configuration.
|
|
659
|
+
|
|
660
|
+
Returns:
|
|
661
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
662
|
+
"""
|
|
453
663
|
self._value_cache_size = size
|
|
454
664
|
return self
|
|
455
665
|
|
|
456
666
|
def value_id_cache_size(self, size: int) -> "NativeStoreConfig.Builder":
|
|
667
|
+
"""
|
|
668
|
+
Sets the value ID cache size for the NativeStore configuration.
|
|
669
|
+
|
|
670
|
+
Args:
|
|
671
|
+
size (int): The value ID cache size for the NativeStore configuration.
|
|
672
|
+
|
|
673
|
+
Returns:
|
|
674
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
675
|
+
"""
|
|
457
676
|
self._value_id_cache_size = size
|
|
458
677
|
return self
|
|
459
678
|
|
|
460
679
|
def namespace_cache_size(self, size: int) -> "NativeStoreConfig.Builder":
|
|
680
|
+
"""
|
|
681
|
+
Sets the namespace cache size for the NativeStore configuration.
|
|
682
|
+
|
|
683
|
+
Args:
|
|
684
|
+
size (int): The namespace cache size for the NativeStore configuration.
|
|
685
|
+
|
|
686
|
+
Returns:
|
|
687
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
688
|
+
"""
|
|
461
689
|
self._namespace_cache_size = size
|
|
462
690
|
return self
|
|
463
691
|
|
|
464
692
|
def namespace_id_cache_size(self, size: int) -> "NativeStoreConfig.Builder":
|
|
693
|
+
"""
|
|
694
|
+
Sets the namespace ID cache size for the NativeStore configuration.
|
|
695
|
+
|
|
696
|
+
Args:
|
|
697
|
+
size (int): The namespace ID cache size for the NativeStore configuration.
|
|
698
|
+
|
|
699
|
+
Returns:
|
|
700
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
701
|
+
"""
|
|
465
702
|
self._namespace_id_cache_size = size
|
|
466
703
|
return self
|
|
467
704
|
|
|
468
705
|
def iteration_cache_sync_threshold(
|
|
469
706
|
self, threshold: int
|
|
470
707
|
) -> "NativeStoreConfig.Builder":
|
|
708
|
+
"""
|
|
709
|
+
Sets the iteration cache sync threshold for the NativeStore configuration.
|
|
710
|
+
|
|
711
|
+
Args:
|
|
712
|
+
threshold (int): The iteration cache sync threshold for the NativeStore configuration.
|
|
713
|
+
|
|
714
|
+
Returns:
|
|
715
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
716
|
+
"""
|
|
471
717
|
self._iteration_cache_sync_threshold = threshold
|
|
472
718
|
return self
|
|
473
719
|
|
|
474
720
|
def default_query_evaluation_mode(
|
|
475
721
|
self, mode: str
|
|
476
722
|
) -> "NativeStoreConfig.Builder":
|
|
723
|
+
"""
|
|
724
|
+
Sets the default query evaluation mode for the NativeStore configuration.
|
|
725
|
+
|
|
726
|
+
Args:
|
|
727
|
+
mode (str): The default query evaluation mode for the NativeStore configuration.
|
|
728
|
+
|
|
729
|
+
Returns:
|
|
730
|
+
NativeStoreConfig.Builder: The builder instance.
|
|
731
|
+
"""
|
|
477
732
|
self._default_query_evaluation_mode = mode
|
|
478
733
|
return self
|
|
479
734
|
|
|
@@ -492,7 +747,7 @@ class NativeStoreConfig(SailConfig):
|
|
|
492
747
|
|
|
493
748
|
class ElasticsearchStoreConfig(SailConfig):
|
|
494
749
|
"""
|
|
495
|
-
Configuration for an ElasticsearchStore using
|
|
750
|
+
Configuration for an ElasticsearchStore using .
|
|
496
751
|
"""
|
|
497
752
|
|
|
498
753
|
TYPE = "rdf4j:ElasticsearchStore"
|
|
@@ -529,30 +784,81 @@ class ElasticsearchStoreConfig(SailConfig):
|
|
|
529
784
|
self._default_query_evaluation_mode: Optional[str] = None
|
|
530
785
|
|
|
531
786
|
def port(self, port: int) -> "ElasticsearchStoreConfig.Builder":
|
|
787
|
+
"""
|
|
788
|
+
Sets the port for the ElasticsearchStore configuration.
|
|
789
|
+
|
|
790
|
+
Args:
|
|
791
|
+
port (int): The port for the ElasticsearchStore configuration.
|
|
792
|
+
|
|
793
|
+
Returns:
|
|
794
|
+
ElasticsearchStoreConfig.Builder: The builder instance.
|
|
795
|
+
"""
|
|
532
796
|
self._port = port
|
|
533
797
|
return self
|
|
534
798
|
|
|
535
799
|
def cluster_name(self, cluster_name: str) -> "ElasticsearchStoreConfig.Builder":
|
|
800
|
+
"""
|
|
801
|
+
Sets the cluster name for the ElasticsearchStore configuration.
|
|
802
|
+
|
|
803
|
+
Args:
|
|
804
|
+
cluster_name (str): The cluster name for the ElasticsearchStore configuration.
|
|
805
|
+
|
|
806
|
+
Returns:
|
|
807
|
+
ElasticsearchStoreConfig.Builder: The builder instance.
|
|
808
|
+
"""
|
|
536
809
|
self._cluster_name = cluster_name
|
|
537
810
|
return self
|
|
538
811
|
|
|
539
812
|
def index(self, index: str) -> "ElasticsearchStoreConfig.Builder":
|
|
813
|
+
"""
|
|
814
|
+
Sets the index for the ElasticsearchStore configuration.
|
|
815
|
+
|
|
816
|
+
Args:
|
|
817
|
+
index (str): The index for the ElasticsearchStore configuration.
|
|
818
|
+
|
|
819
|
+
Returns:
|
|
820
|
+
ElasticsearchStoreConfig.Builder: The builder instance.
|
|
821
|
+
"""
|
|
540
822
|
self._index = index
|
|
541
823
|
return self
|
|
542
824
|
|
|
543
825
|
def iteration_cache_sync_threshold(
|
|
544
826
|
self, threshold: int
|
|
545
827
|
) -> "ElasticsearchStoreConfig.Builder":
|
|
828
|
+
"""
|
|
829
|
+
Sets the iteration cache sync threshold for the ElasticsearchStore configuration.
|
|
830
|
+
|
|
831
|
+
Args:
|
|
832
|
+
threshold (int): The iteration cache sync threshold for the ElasticsearchStore configuration.
|
|
833
|
+
|
|
834
|
+
Returns:
|
|
835
|
+
ElasticsearchStoreConfig.Builder: The builder instance.
|
|
836
|
+
"""
|
|
546
837
|
self._iteration_cache_sync_threshold = threshold
|
|
547
838
|
return self
|
|
548
839
|
|
|
549
840
|
def default_query_evaluation_mode(
|
|
550
841
|
self, mode: str
|
|
551
842
|
) -> "ElasticsearchStoreConfig.Builder":
|
|
843
|
+
"""
|
|
844
|
+
Sets the default query evaluation mode for the ElasticsearchStore configuration.
|
|
845
|
+
|
|
846
|
+
Args:
|
|
847
|
+
mode (str): The default query evaluation mode for the ElasticsearchStore configuration.
|
|
848
|
+
|
|
849
|
+
Returns:
|
|
850
|
+
ElasticsearchStoreConfig.Builder: The builder instance.
|
|
851
|
+
"""
|
|
552
852
|
self._default_query_evaluation_mode = mode
|
|
553
853
|
return self
|
|
554
854
|
|
|
555
855
|
def build(self) -> "ElasticsearchStoreConfig":
|
|
856
|
+
"""
|
|
857
|
+
Builds and returns the ElasticsearchStoreConfig instance.
|
|
858
|
+
|
|
859
|
+
Returns:
|
|
860
|
+
ElasticsearchStoreConfig: The constructed ElasticsearchStoreConfig instance.
|
|
861
|
+
"""
|
|
556
862
|
return ElasticsearchStoreConfig(
|
|
557
863
|
hostname=self._hostname,
|
|
558
864
|
port=self._port,
|
|
@@ -565,7 +871,7 @@ class ElasticsearchStoreConfig(SailConfig):
|
|
|
565
871
|
|
|
566
872
|
class SchemaCachingRDFSInferencerConfig(SailConfig):
|
|
567
873
|
"""
|
|
568
|
-
Configuration for the RDF Schema inferencer using
|
|
874
|
+
Configuration for the RDF Schema inferencer using .
|
|
569
875
|
"""
|
|
570
876
|
|
|
571
877
|
TYPE = "rdf4j:SchemaCachingRDFSInferencer"
|
|
@@ -576,6 +882,14 @@ class SchemaCachingRDFSInferencerConfig(SailConfig):
|
|
|
576
882
|
iteration_cache_sync_threshold: Optional[int] = None,
|
|
577
883
|
default_query_evaluation_mode: Optional[str] = None,
|
|
578
884
|
):
|
|
885
|
+
"""
|
|
886
|
+
Initializes a new SchemaCachingRDFSInferencerConfig.
|
|
887
|
+
|
|
888
|
+
Args:
|
|
889
|
+
delegate (SailConfig): The delegate configuration for the SchemaCachingRDFSInferencer.
|
|
890
|
+
iteration_cache_sync_threshold (Optional[int]): The iteration cache sync threshold.
|
|
891
|
+
default_query_evaluation_mode (Optional[str]): The default query evaluation mode.
|
|
892
|
+
"""
|
|
579
893
|
super().__init__(
|
|
580
894
|
sail_type=SchemaCachingRDFSInferencerConfig.TYPE,
|
|
581
895
|
iteration_cache_sync_threshold=iteration_cache_sync_threshold,
|
|
@@ -583,9 +897,15 @@ class SchemaCachingRDFSInferencerConfig(SailConfig):
|
|
|
583
897
|
)
|
|
584
898
|
self.config_params["delegate"] = delegate
|
|
585
899
|
|
|
586
|
-
def add_to_graph(self, graph:
|
|
900
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
587
901
|
"""
|
|
588
902
|
Adds the SchemaCachingRDFSInferencer configuration to the RDF graph.
|
|
903
|
+
|
|
904
|
+
Args:
|
|
905
|
+
graph (Graph): The RDF graph to add the configuration to.
|
|
906
|
+
|
|
907
|
+
Returns:
|
|
908
|
+
URIRef: The URIRef of the added configuration.
|
|
589
909
|
"""
|
|
590
910
|
sail_node = super().add_to_graph(graph)
|
|
591
911
|
delegate_node = self.config_params["delegate"].to_rdf(graph)
|
|
@@ -601,16 +921,40 @@ class SchemaCachingRDFSInferencerConfig(SailConfig):
|
|
|
601
921
|
def iteration_cache_sync_threshold(
|
|
602
922
|
self, threshold: int
|
|
603
923
|
) -> "SchemaCachingRDFSInferencerConfig.Builder":
|
|
924
|
+
"""
|
|
925
|
+
Sets the iteration cache sync threshold for the SchemaCachingRDFSInferencer configuration.
|
|
926
|
+
|
|
927
|
+
Args:
|
|
928
|
+
threshold (int): The iteration cache sync threshold for the SchemaCachingRDFSInferencer configuration.
|
|
929
|
+
|
|
930
|
+
Returns:
|
|
931
|
+
SchemaCachingRDFSInferencerConfig.Builder: The builder instance.
|
|
932
|
+
"""
|
|
604
933
|
self._iteration_cache_sync_threshold = threshold
|
|
605
934
|
return self
|
|
606
935
|
|
|
607
936
|
def default_query_evaluation_mode(
|
|
608
937
|
self, mode: str
|
|
609
938
|
) -> "SchemaCachingRDFSInferencerConfig.Builder":
|
|
939
|
+
"""
|
|
940
|
+
Sets the default query evaluation mode for the SchemaCachingRDFSInferencer configuration.
|
|
941
|
+
|
|
942
|
+
Args:
|
|
943
|
+
mode (str): The default query evaluation mode for the SchemaCachingRDFSInferencer configuration.
|
|
944
|
+
|
|
945
|
+
Returns:
|
|
946
|
+
SchemaCachingRDFSInferencerConfig.Builder: The builder instance.
|
|
947
|
+
"""
|
|
610
948
|
self._default_query_evaluation_mode = mode
|
|
611
949
|
return self
|
|
612
950
|
|
|
613
951
|
def build(self) -> "SchemaCachingRDFSInferencerConfig":
|
|
952
|
+
"""
|
|
953
|
+
Builds and returns the SchemaCachingRDFSInferencerConfig instance.
|
|
954
|
+
|
|
955
|
+
Returns:
|
|
956
|
+
SchemaCachingRDFSInferencerConfig: The constructed SchemaCachingRDFSInferencerConfig instance.
|
|
957
|
+
"""
|
|
614
958
|
return SchemaCachingRDFSInferencerConfig(
|
|
615
959
|
delegate=self._delegate,
|
|
616
960
|
iteration_cache_sync_threshold=self._iteration_cache_sync_threshold,
|
|
@@ -620,7 +964,7 @@ class SchemaCachingRDFSInferencerConfig(SailConfig):
|
|
|
620
964
|
|
|
621
965
|
class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
622
966
|
"""
|
|
623
|
-
Configuration for the Direct Type inferencer using
|
|
967
|
+
Configuration for the Direct Type inferencer using .
|
|
624
968
|
"""
|
|
625
969
|
|
|
626
970
|
TYPE = "openrdf:DirectTypeHierarchyInferencer"
|
|
@@ -631,6 +975,14 @@ class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
|
631
975
|
iteration_cache_sync_threshold: Optional[int] = None,
|
|
632
976
|
default_query_evaluation_mode: Optional[str] = None,
|
|
633
977
|
):
|
|
978
|
+
"""
|
|
979
|
+
Initializes a new DirectTypeHierarchyInferencerConfig.
|
|
980
|
+
|
|
981
|
+
Args:
|
|
982
|
+
delegate (SailConfig): The delegate configuration for the DirectTypeHierarchyInferencer.
|
|
983
|
+
iteration_cache_sync_threshold (Optional[int]): The iteration cache sync threshold.
|
|
984
|
+
default_query_evaluation_mode (Optional[str]): The default query evaluation mode.
|
|
985
|
+
"""
|
|
634
986
|
super().__init__(
|
|
635
987
|
sail_type=DirectTypeHierarchyInferencerConfig.TYPE,
|
|
636
988
|
iteration_cache_sync_threshold=iteration_cache_sync_threshold,
|
|
@@ -638,9 +990,15 @@ class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
|
638
990
|
)
|
|
639
991
|
self.config_params["delegate"] = delegate
|
|
640
992
|
|
|
641
|
-
def add_to_graph(self, graph:
|
|
993
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
642
994
|
"""
|
|
643
995
|
Adds the DirectTypeHierarchyInferencerConfig to the graph
|
|
996
|
+
|
|
997
|
+
Args:
|
|
998
|
+
graph (Graph): The RDF graph to add the configuration to.
|
|
999
|
+
|
|
1000
|
+
Returns:
|
|
1001
|
+
URIRef: The URIRef of the added configuration.
|
|
644
1002
|
"""
|
|
645
1003
|
sail_node = super().add_to_graph(graph)
|
|
646
1004
|
delegate_node = self.config_params["delegate"].to_rdf(graph)
|
|
@@ -649,6 +1007,12 @@ class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
|
649
1007
|
|
|
650
1008
|
class Builder:
|
|
651
1009
|
def __init__(self, delegate: "SailConfig"):
|
|
1010
|
+
"""
|
|
1011
|
+
Initializes a new DirectTypeHierarchyInferencerConfig.Builder.
|
|
1012
|
+
|
|
1013
|
+
Args:
|
|
1014
|
+
delegate (SailConfig): The delegate configuration for the DirectTypeHierarchyInferencer.
|
|
1015
|
+
"""
|
|
652
1016
|
self._delegate = delegate
|
|
653
1017
|
self._iteration_cache_sync_threshold: Optional[int] = None
|
|
654
1018
|
self._default_query_evaluation_mode: Optional[str] = None
|
|
@@ -656,16 +1020,40 @@ class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
|
656
1020
|
def iteration_cache_sync_threshold(
|
|
657
1021
|
self, threshold: int
|
|
658
1022
|
) -> "DirectTypeHierarchyInferencerConfig.Builder":
|
|
1023
|
+
"""
|
|
1024
|
+
Sets the iteration cache sync threshold for the DirectTypeHierarchyInferencer configuration.
|
|
1025
|
+
|
|
1026
|
+
Args:
|
|
1027
|
+
threshold (int): The iteration cache sync threshold for the DirectTypeHierarchyInferencer configuration.
|
|
1028
|
+
|
|
1029
|
+
Returns:
|
|
1030
|
+
DirectTypeHierarchyInferencerConfig.Builder: The builder instance.
|
|
1031
|
+
"""
|
|
659
1032
|
self._iteration_cache_sync_threshold = threshold
|
|
660
1033
|
return self
|
|
661
1034
|
|
|
662
1035
|
def default_query_evaluation_mode(
|
|
663
1036
|
self, mode: str
|
|
664
1037
|
) -> "DirectTypeHierarchyInferencerConfig.Builder":
|
|
1038
|
+
"""
|
|
1039
|
+
Sets the default query evaluation mode for the DirectTypeHierarchyInferencer configuration.
|
|
1040
|
+
|
|
1041
|
+
Args:
|
|
1042
|
+
mode (str): The default query evaluation mode for the DirectTypeHierarchyInferencer configuration.
|
|
1043
|
+
|
|
1044
|
+
Returns:
|
|
1045
|
+
DirectTypeHierarchyInferencerConfig.Builder: The builder instance.
|
|
1046
|
+
"""
|
|
665
1047
|
self._default_query_evaluation_mode = mode
|
|
666
1048
|
return self
|
|
667
1049
|
|
|
668
1050
|
def build(self) -> "DirectTypeHierarchyInferencerConfig":
|
|
1051
|
+
"""
|
|
1052
|
+
Builds and returns the DirectTypeHierarchyInferencerConfig instance.
|
|
1053
|
+
|
|
1054
|
+
Returns:
|
|
1055
|
+
DirectTypeHierarchyInferencerConfig: The constructed DirectTypeHierarchyInferencerConfig instance.
|
|
1056
|
+
"""
|
|
669
1057
|
return DirectTypeHierarchyInferencerConfig(
|
|
670
1058
|
delegate=self._delegate,
|
|
671
1059
|
iteration_cache_sync_threshold=self._iteration_cache_sync_threshold,
|
|
@@ -675,7 +1063,7 @@ class DirectTypeHierarchyInferencerConfig(SailConfig):
|
|
|
675
1063
|
|
|
676
1064
|
class SHACLSailConfig(SailConfig):
|
|
677
1065
|
"""
|
|
678
|
-
Configuration for the SHACL Sail using
|
|
1066
|
+
Configuration for the SHACL Sail using .
|
|
679
1067
|
"""
|
|
680
1068
|
|
|
681
1069
|
TYPE = "rdf4j:ShaclSail"
|
|
@@ -701,6 +1089,29 @@ class SHACLSailConfig(SailConfig):
|
|
|
701
1089
|
iteration_cache_sync_threshold: Optional[int] = None,
|
|
702
1090
|
default_query_evaluation_mode: Optional[str] = None,
|
|
703
1091
|
):
|
|
1092
|
+
"""
|
|
1093
|
+
Initializes a new SHACLSailConfig.
|
|
1094
|
+
|
|
1095
|
+
Args:
|
|
1096
|
+
delegate (SailConfig): The delegate configuration for the SHACL Sail.
|
|
1097
|
+
parallel_validation (Optional[bool]): Whether to enable parallel validation.
|
|
1098
|
+
undefined_target_validates_all_subjects (Optional[bool]): Whether to validate all subjects when undefined targets are encountered.
|
|
1099
|
+
log_validation_plans (Optional[bool]): Whether to log validation plans.
|
|
1100
|
+
log_validation_violations (Optional[bool]): Whether to log validation violations.
|
|
1101
|
+
ignore_no_shapes_loaded_exception (Optional[bool]): Whether to ignore exceptions when no shapes are loaded.
|
|
1102
|
+
validation_enabled (Optional[bool]): Whether to enable validation.
|
|
1103
|
+
cache_select_nodes (Optional[bool]): Whether to cache select nodes.
|
|
1104
|
+
global_log_validation_execution (Optional[bool]): Whether to log validation execution globally.
|
|
1105
|
+
rdfs_sub_class_reasoning (Optional[bool]): Whether to enable RDFS sub-class reasoning.
|
|
1106
|
+
performance_logging (Optional[bool]): Whether to enable performance logging.
|
|
1107
|
+
serializable_validation (Optional[bool]): Whether to enable serializable validation.
|
|
1108
|
+
eclipse_rdf4j_shacl_extensions (Optional[bool]): Whether to enable Eclipse RDF4J SHACL extensions.
|
|
1109
|
+
dash_data_shapes (Optional[bool]): Whether to enable Dash Data Shapes.
|
|
1110
|
+
validation_results_limit_total (Optional[int]): The total number of validation results to limit.
|
|
1111
|
+
validation_results_limit_per_constraint (Optional[int]): The number of validation results to limit per constraint.
|
|
1112
|
+
iteration_cache_sync_threshold (Optional[int]): The iteration cache sync threshold.
|
|
1113
|
+
default_query_evaluation_mode (Optional[str]): The default query evaluation mode.
|
|
1114
|
+
"""
|
|
704
1115
|
super().__init__(
|
|
705
1116
|
sail_type=SHACLSailConfig.TYPE,
|
|
706
1117
|
iteration_cache_sync_threshold=iteration_cache_sync_threshold,
|
|
@@ -752,8 +1163,16 @@ class SHACLSailConfig(SailConfig):
|
|
|
752
1163
|
validation_results_limit_per_constraint
|
|
753
1164
|
)
|
|
754
1165
|
|
|
755
|
-
def add_to_graph(self, graph:
|
|
756
|
-
"""
|
|
1166
|
+
def add_to_graph(self, graph: Dataset) -> URIRef:
|
|
1167
|
+
"""
|
|
1168
|
+
Adds the SHACLSailConfig to the RDF graph.
|
|
1169
|
+
|
|
1170
|
+
Args:
|
|
1171
|
+
graph (Graph): The RDF graph to add the configuration to.
|
|
1172
|
+
|
|
1173
|
+
Returns:
|
|
1174
|
+
URIRef: The URIRef of the added configuration.
|
|
1175
|
+
"""
|
|
757
1176
|
sail_node = super().add_to_graph(graph) # Get the basic node
|
|
758
1177
|
delegate_node = self.config_params["delegate"].to_rdf(graph)
|
|
759
1178
|
graph.add((sail_node, CONFIG.delegate, delegate_node))
|
|
@@ -763,18 +1182,41 @@ class SHACLSailConfig(SailConfig):
|
|
|
763
1182
|
if key != "delegate": # Delegate is already handled
|
|
764
1183
|
if isinstance(value, bool):
|
|
765
1184
|
graph.add(
|
|
766
|
-
(
|
|
1185
|
+
Quad(
|
|
1186
|
+
sail_node,
|
|
1187
|
+
CONFIG[key],
|
|
1188
|
+
Literal(str(value).lower(), datatype=XSD["boolean"]),
|
|
1189
|
+
None,
|
|
1190
|
+
)
|
|
767
1191
|
)
|
|
768
|
-
elif isinstance(value, int):
|
|
1192
|
+
elif isinstance(value, int) and not isinstance(value, bool):
|
|
769
1193
|
graph.add(
|
|
770
|
-
(
|
|
1194
|
+
Quad(
|
|
1195
|
+
sail_node,
|
|
1196
|
+
CONFIG[key],
|
|
1197
|
+
Literal(str(value), datatype=XSD["integer"]),
|
|
1198
|
+
None,
|
|
1199
|
+
)
|
|
771
1200
|
)
|
|
772
1201
|
else:
|
|
773
|
-
graph.add(
|
|
1202
|
+
graph.add(
|
|
1203
|
+
Quad(
|
|
1204
|
+
sail_node,
|
|
1205
|
+
CONFIG[key],
|
|
1206
|
+
Literal(value),
|
|
1207
|
+
None,
|
|
1208
|
+
)
|
|
1209
|
+
)
|
|
774
1210
|
return sail_node
|
|
775
1211
|
|
|
776
1212
|
class Builder:
|
|
777
1213
|
def __init__(self, delegate: "SailConfig"):
|
|
1214
|
+
"""
|
|
1215
|
+
Initializes a new SHACLSailConfig.Builder.
|
|
1216
|
+
|
|
1217
|
+
Args:
|
|
1218
|
+
delegate (SailConfig): The delegate configuration for the SHACL Sail.
|
|
1219
|
+
"""
|
|
778
1220
|
self._delegate = delegate
|
|
779
1221
|
self._parallel_validation: Optional[bool] = None
|
|
780
1222
|
self._undefined_target_validates_all_subjects: Optional[bool] = None
|
|
@@ -795,88 +1237,247 @@ class SHACLSailConfig(SailConfig):
|
|
|
795
1237
|
self._default_query_evaluation_mode: Optional[str] = None
|
|
796
1238
|
|
|
797
1239
|
def parallel_validation(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1240
|
+
"""
|
|
1241
|
+
Sets the parallel validation flag for the SHACL Sail configuration.
|
|
1242
|
+
|
|
1243
|
+
Args:
|
|
1244
|
+
value (bool): The parallel validation flag for the SHACL Sail configuration.
|
|
1245
|
+
|
|
1246
|
+
Returns:
|
|
1247
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1248
|
+
"""
|
|
798
1249
|
self._parallel_validation = value
|
|
799
1250
|
return self
|
|
800
1251
|
|
|
801
1252
|
def undefined_target_validates_all_subjects(
|
|
802
1253
|
self, value: bool
|
|
803
1254
|
) -> "SHACLSailConfig.Builder":
|
|
1255
|
+
"""
|
|
1256
|
+
Sets the undefined target validates all subjects flag for the SHACL Sail configuration.
|
|
1257
|
+
|
|
1258
|
+
Args:
|
|
1259
|
+
value (bool): The undefined target validates all subjects flag for the SHACL Sail configuration.
|
|
1260
|
+
|
|
1261
|
+
Returns:
|
|
1262
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1263
|
+
"""
|
|
804
1264
|
self._undefined_target_validates_all_subjects = value
|
|
805
1265
|
return self
|
|
806
1266
|
|
|
807
1267
|
def log_validation_plans(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1268
|
+
"""
|
|
1269
|
+
Sets the log validation plans flag for the SHACL Sail configuration.
|
|
1270
|
+
|
|
1271
|
+
Args:
|
|
1272
|
+
value (bool): The log validation plans flag for the SHACL Sail configuration.
|
|
1273
|
+
|
|
1274
|
+
Returns:
|
|
1275
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1276
|
+
"""
|
|
808
1277
|
self._log_validation_plans = value
|
|
809
1278
|
return self
|
|
810
1279
|
|
|
811
1280
|
def log_validation_violations(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1281
|
+
"""
|
|
1282
|
+
Sets the log validation violations flag for the SHACL Sail configuration.
|
|
1283
|
+
|
|
1284
|
+
Args:
|
|
1285
|
+
value (bool): The log validation violations flag for the SHACL Sail configuration.
|
|
1286
|
+
|
|
1287
|
+
Returns:
|
|
1288
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1289
|
+
"""
|
|
812
1290
|
self._log_validation_violations = value
|
|
813
1291
|
return self
|
|
814
1292
|
|
|
815
1293
|
def ignore_no_shapes_loaded_exception(
|
|
816
1294
|
self, value: bool
|
|
817
1295
|
) -> "SHACLSailConfig.Builder":
|
|
1296
|
+
"""
|
|
1297
|
+
Sets the ignore no shapes loaded exception flag for the SHACL Sail configuration.
|
|
1298
|
+
|
|
1299
|
+
Args:
|
|
1300
|
+
value (bool): The ignore no shapes loaded exception flag for the SHACL Sail configuration.
|
|
1301
|
+
|
|
1302
|
+
Returns:
|
|
1303
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1304
|
+
"""
|
|
818
1305
|
self._ignore_no_shapes_loaded_exception = value
|
|
819
1306
|
return self
|
|
820
1307
|
|
|
821
1308
|
def validation_enabled(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1309
|
+
"""
|
|
1310
|
+
Sets the validation enabled flag for the SHACL Sail configuration.
|
|
1311
|
+
|
|
1312
|
+
Args:
|
|
1313
|
+
value (bool): The validation enabled flag for the SHACL Sail configuration.
|
|
1314
|
+
|
|
1315
|
+
Returns:
|
|
1316
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1317
|
+
"""
|
|
822
1318
|
self._validation_enabled = value
|
|
823
1319
|
return self
|
|
824
1320
|
|
|
825
1321
|
def cache_select_nodes(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1322
|
+
"""
|
|
1323
|
+
Sets the cache select nodes flag for the SHACL Sail configuration.
|
|
1324
|
+
|
|
1325
|
+
Args:
|
|
1326
|
+
value (bool): The cache select nodes flag for the SHACL Sail configuration.
|
|
1327
|
+
|
|
1328
|
+
Returns:
|
|
1329
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1330
|
+
"""
|
|
826
1331
|
self._cache_select_nodes = value
|
|
827
1332
|
return self
|
|
828
1333
|
|
|
829
1334
|
def global_log_validation_execution(
|
|
830
1335
|
self, value: bool
|
|
831
1336
|
) -> "SHACLSailConfig.Builder":
|
|
1337
|
+
"""
|
|
1338
|
+
Sets the global log validation execution flag for the SHACL Sail configuration.
|
|
1339
|
+
|
|
1340
|
+
Args:
|
|
1341
|
+
value (bool): The global log validation execution flag for the SHACL Sail configuration.
|
|
1342
|
+
|
|
1343
|
+
Returns:
|
|
1344
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1345
|
+
"""
|
|
832
1346
|
self._global_log_validation_execution = value
|
|
833
1347
|
return self
|
|
834
1348
|
|
|
835
1349
|
def rdfs_sub_class_reasoning(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1350
|
+
"""
|
|
1351
|
+
Sets the RDFS sub-class reasoning flag for the SHACL Sail configuration.
|
|
1352
|
+
|
|
1353
|
+
Args:
|
|
1354
|
+
value (bool): The RDFS sub-class reasoning flag for the SHACL Sail configuration.
|
|
1355
|
+
|
|
1356
|
+
Returns:
|
|
1357
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1358
|
+
"""
|
|
836
1359
|
self._rdfs_sub_class_reasoning = value
|
|
837
1360
|
return self
|
|
838
1361
|
|
|
839
1362
|
def performance_logging(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1363
|
+
"""
|
|
1364
|
+
Sets the performance logging flag for the SHACL Sail configuration.
|
|
1365
|
+
|
|
1366
|
+
Args:
|
|
1367
|
+
value (bool): The performance logging flag for the SHACL Sail configuration.
|
|
1368
|
+
|
|
1369
|
+
Returns:
|
|
1370
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1371
|
+
"""
|
|
840
1372
|
self._performance_logging = value
|
|
841
1373
|
return self
|
|
842
1374
|
|
|
843
1375
|
def serializable_validation(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1376
|
+
"""
|
|
1377
|
+
Sets the serializable validation flag for the SHACL Sail configuration.
|
|
1378
|
+
|
|
1379
|
+
Args:
|
|
1380
|
+
value (bool): The serializable validation flag for the SHACL Sail configuration.
|
|
1381
|
+
|
|
1382
|
+
Returns:
|
|
1383
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1384
|
+
"""
|
|
844
1385
|
self._serializable_validation = value
|
|
845
1386
|
return self
|
|
846
1387
|
|
|
847
1388
|
def eclipse_rdf4j_shacl_extensions(
|
|
848
1389
|
self, value: bool
|
|
849
1390
|
) -> "SHACLSailConfig.Builder":
|
|
1391
|
+
"""
|
|
1392
|
+
Sets the Eclipse RDF4J SHACL extensions flag for the SHACL Sail configuration.
|
|
1393
|
+
|
|
1394
|
+
Args:
|
|
1395
|
+
value (bool): The Eclipse RDF4J SHACL extensions flag for the SHACL Sail configuration.
|
|
1396
|
+
|
|
1397
|
+
Returns:
|
|
1398
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1399
|
+
"""
|
|
850
1400
|
self._eclipse_rdf4j_shacl_extensions = value
|
|
851
1401
|
return self
|
|
852
1402
|
|
|
853
1403
|
def dash_data_shapes(self, value: bool) -> "SHACLSailConfig.Builder":
|
|
1404
|
+
"""
|
|
1405
|
+
Sets the Dash Data Shapes flag for the SHACL Sail configuration.
|
|
1406
|
+
|
|
1407
|
+
Args:
|
|
1408
|
+
value (bool): The Dash Data Shapes flag for the SHACL Sail configuration.
|
|
1409
|
+
|
|
1410
|
+
Returns:
|
|
1411
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1412
|
+
"""
|
|
854
1413
|
self._dash_data_shapes = value
|
|
855
1414
|
return self
|
|
856
1415
|
|
|
857
1416
|
def validation_results_limit_total(
|
|
858
1417
|
self, value: int
|
|
859
1418
|
) -> "SHACLSailConfig.Builder":
|
|
1419
|
+
"""
|
|
1420
|
+
Sets the validation results limit total flag for the SHACL Sail configuration.
|
|
1421
|
+
|
|
1422
|
+
Args:
|
|
1423
|
+
value (int): The validation results limit total flag for the SHACL Sail configuration.
|
|
1424
|
+
|
|
1425
|
+
Returns:
|
|
1426
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1427
|
+
"""
|
|
860
1428
|
self._validation_results_limit_total = value
|
|
861
1429
|
return self
|
|
862
1430
|
|
|
863
1431
|
def validation_results_limit_per_constraint(
|
|
864
1432
|
self, value: int
|
|
865
1433
|
) -> "SHACLSailConfig.Builder":
|
|
1434
|
+
"""
|
|
1435
|
+
Sets the validation results limit per constraint flag for the SHACL Sail configuration.
|
|
1436
|
+
|
|
1437
|
+
Args:
|
|
1438
|
+
value (int): The validation results limit per constraint flag for the SHACL Sail configuration.
|
|
1439
|
+
|
|
1440
|
+
Returns:
|
|
1441
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1442
|
+
"""
|
|
866
1443
|
self._validation_results_limit_per_constraint = value
|
|
867
1444
|
return self
|
|
868
1445
|
|
|
869
1446
|
def iteration_cache_sync_threshold(
|
|
870
1447
|
self, threshold: int
|
|
871
1448
|
) -> "SHACLSailConfig.Builder":
|
|
1449
|
+
"""
|
|
1450
|
+
Sets the iteration cache sync threshold flag for the SHACL Sail configuration.
|
|
1451
|
+
|
|
1452
|
+
Args:
|
|
1453
|
+
threshold (int): The iteration cache sync threshold flag for the SHACL Sail configuration.
|
|
1454
|
+
|
|
1455
|
+
Returns:
|
|
1456
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1457
|
+
"""
|
|
872
1458
|
self._iteration_cache_sync_threshold = threshold
|
|
873
1459
|
return self
|
|
874
1460
|
|
|
875
1461
|
def default_query_evaluation_mode(self, mode: str) -> "SHACLSailConfig.Builder":
|
|
1462
|
+
"""
|
|
1463
|
+
Sets the default query evaluation mode flag for the SHACL Sail configuration.
|
|
1464
|
+
|
|
1465
|
+
Args:
|
|
1466
|
+
mode (str): The default query evaluation mode flag for the SHACL Sail configuration.
|
|
1467
|
+
|
|
1468
|
+
Returns:
|
|
1469
|
+
SHACLSailConfig.Builder: The builder instance.
|
|
1470
|
+
"""
|
|
876
1471
|
self._default_query_evaluation_mode = mode
|
|
877
1472
|
return self
|
|
878
1473
|
|
|
879
1474
|
def build(self) -> "SHACLSailConfig":
|
|
1475
|
+
"""
|
|
1476
|
+
Builds the SHACLSailConfig.
|
|
1477
|
+
|
|
1478
|
+
Returns:
|
|
1479
|
+
SHACLSailConfig: The built SHACLSailConfig.
|
|
1480
|
+
"""
|
|
880
1481
|
return SHACLSailConfig(
|
|
881
1482
|
delegate=self._delegate,
|
|
882
1483
|
parallel_validation=self._parallel_validation,
|