cognite-neat 0.86.0__py3-none-any.whl → 0.87.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.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- cognite/neat/_version.py +1 -1
- cognite/neat/app/api/configuration.py +1 -10
- cognite/neat/app/api/routers/data_exploration.py +1 -1
- cognite/neat/config.py +84 -17
- cognite/neat/constants.py +11 -9
- cognite/neat/graph/extractors/_classic_cdf/_assets.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_events.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_files.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_labels.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_relationships.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_sequences.py +1 -1
- cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +1 -1
- cognite/neat/graph/extractors/_dexpi.py +1 -1
- cognite/neat/graph/extractors/_mock_graph_generator.py +8 -9
- cognite/neat/graph/loaders/__init__.py +5 -2
- cognite/neat/graph/loaders/_base.py +13 -5
- cognite/neat/graph/loaders/_rdf2asset.py +185 -55
- cognite/neat/graph/loaders/_rdf2dms.py +7 -7
- cognite/neat/graph/queries/_base.py +20 -11
- cognite/neat/graph/queries/_construct.py +5 -5
- cognite/neat/graph/queries/_shared.py +21 -7
- cognite/neat/graph/stores/_base.py +16 -4
- cognite/neat/graph/transformers/__init__.py +3 -0
- cognite/neat/graph/transformers/_rdfpath.py +42 -0
- cognite/neat/legacy/graph/extractors/_dexpi.py +0 -5
- cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +1 -1
- cognite/neat/legacy/graph/loaders/_asset_loader.py +2 -2
- cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +5 -2
- cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +4 -1
- cognite/neat/legacy/graph/loaders/rdf_to_dms.py +3 -1
- cognite/neat/legacy/graph/stores/_base.py +24 -8
- cognite/neat/legacy/graph/stores/_graphdb_store.py +3 -2
- cognite/neat/legacy/graph/stores/_memory_store.py +3 -3
- cognite/neat/legacy/graph/stores/_oxigraph_store.py +8 -4
- cognite/neat/legacy/graph/stores/_rdf_to_graph.py +5 -3
- cognite/neat/legacy/graph/transformations/query_generator/sparql.py +49 -16
- cognite/neat/legacy/graph/transformations/transformer.py +1 -1
- cognite/neat/legacy/rules/exporters/_rules2dms.py +8 -3
- cognite/neat/legacy/rules/exporters/_rules2graphql.py +1 -1
- cognite/neat/legacy/rules/exporters/_rules2ontology.py +2 -1
- cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +3 -4
- cognite/neat/legacy/rules/importers/_dms2rules.py +4 -1
- cognite/neat/legacy/rules/importers/_graph2rules.py +3 -3
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +1 -1
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +2 -1
- cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +1 -1
- cognite/neat/legacy/rules/models/raw_rules.py +19 -7
- cognite/neat/legacy/rules/models/rules.py +32 -12
- cognite/neat/rules/_shared.py +6 -1
- cognite/neat/rules/analysis/__init__.py +4 -4
- cognite/neat/rules/analysis/_asset.py +143 -0
- cognite/neat/rules/analysis/_base.py +385 -6
- cognite/neat/rules/analysis/_information.py +183 -0
- cognite/neat/rules/exporters/_rules2dms.py +1 -1
- cognite/neat/rules/exporters/_rules2ontology.py +6 -5
- cognite/neat/rules/importers/_dms2rules.py +3 -1
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +2 -8
- cognite/neat/rules/importers/_inference2rules.py +3 -7
- cognite/neat/rules/importers/_owl2rules/_owl2classes.py +1 -1
- cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +2 -1
- cognite/neat/rules/importers/_owl2rules/_owl2properties.py +1 -1
- cognite/neat/rules/issues/spreadsheet.py +35 -0
- cognite/neat/rules/models/_base.py +7 -7
- cognite/neat/rules/models/_rdfpath.py +17 -21
- cognite/neat/rules/models/asset/_rules.py +4 -5
- cognite/neat/rules/models/asset/_validation.py +38 -1
- cognite/neat/rules/models/dms/_converter.py +1 -2
- cognite/neat/rules/models/dms/_exporter.py +7 -3
- cognite/neat/rules/models/dms/_rules.py +3 -0
- cognite/neat/rules/models/dms/_schema.py +5 -4
- cognite/neat/rules/models/domain.py +5 -2
- cognite/neat/rules/models/entities.py +28 -17
- cognite/neat/rules/models/information/_rules.py +10 -8
- cognite/neat/rules/models/information/_rules_input.py +1 -2
- cognite/neat/rules/models/information/_validation.py +2 -2
- cognite/neat/utils/__init__.py +0 -3
- cognite/neat/utils/auth.py +47 -28
- cognite/neat/utils/auxiliary.py +141 -1
- cognite/neat/utils/cdf/__init__.py +0 -0
- cognite/neat/utils/{cdf_classes.py → cdf/data_classes.py} +122 -2
- cognite/neat/utils/{cdf_loaders → cdf/loaders}/_data_modeling.py +37 -0
- cognite/neat/utils/{cdf_loaders → cdf/loaders}/_ingestion.py +2 -1
- cognite/neat/utils/collection_.py +18 -0
- cognite/neat/utils/rdf_.py +165 -0
- cognite/neat/utils/text.py +4 -0
- cognite/neat/utils/time_.py +17 -0
- cognite/neat/utils/upload.py +13 -1
- cognite/neat/workflows/_exceptions.py +5 -5
- cognite/neat/workflows/base.py +1 -1
- cognite/neat/workflows/steps/lib/current/graph_store.py +28 -8
- cognite/neat/workflows/steps/lib/current/rules_validator.py +2 -2
- cognite/neat/workflows/steps/lib/legacy/graph_extractor.py +130 -28
- cognite/neat/workflows/steps/lib/legacy/graph_loader.py +1 -1
- cognite/neat/workflows/steps/lib/legacy/graph_store.py +4 -4
- cognite/neat/workflows/steps/lib/legacy/rules_exporter.py +1 -1
- cognite/neat/workflows/steps/lib/legacy/rules_importer.py +1 -1
- {cognite_neat-0.86.0.dist-info → cognite_neat-0.87.3.dist-info}/METADATA +2 -2
- {cognite_neat-0.86.0.dist-info → cognite_neat-0.87.3.dist-info}/RECORD +103 -102
- cognite/neat/rules/analysis/_information_rules.py +0 -476
- cognite/neat/utils/cdf.py +0 -59
- cognite/neat/utils/cdf_loaders/data_classes.py +0 -121
- cognite/neat/utils/exceptions.py +0 -41
- cognite/neat/utils/utils.py +0 -429
- /cognite/neat/utils/{cdf_loaders → cdf/loaders}/__init__.py +0 -0
- /cognite/neat/utils/{cdf_loaders → cdf/loaders}/_base.py +0 -0
- {cognite_neat-0.86.0.dist-info → cognite_neat-0.87.3.dist-info}/LICENSE +0 -0
- {cognite_neat-0.86.0.dist-info → cognite_neat-0.87.3.dist-info}/WHEEL +0 -0
- {cognite_neat-0.86.0.dist-info → cognite_neat-0.87.3.dist-info}/entry_points.txt +0 -0
|
@@ -8,14 +8,20 @@ from typing import ClassVar, cast
|
|
|
8
8
|
|
|
9
9
|
from rdflib import RDF, XSD, Literal, Namespace, URIRef
|
|
10
10
|
|
|
11
|
-
from cognite.neat.constants import
|
|
11
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
12
12
|
from cognite.neat.legacy.graph import extractors
|
|
13
|
-
from cognite.neat.legacy.graph.extractors._mock_graph_generator import
|
|
13
|
+
from cognite.neat.legacy.graph.extractors._mock_graph_generator import (
|
|
14
|
+
generate_triples as generate_mock_triples,
|
|
15
|
+
)
|
|
14
16
|
from cognite.neat.legacy.rules.exporters._rules2triples import get_instances_as_triples
|
|
15
|
-
from cognite.neat.utils.
|
|
17
|
+
from cognite.neat.utils.auxiliary import create_sha256_hash
|
|
16
18
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
17
19
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
18
|
-
from cognite.neat.workflows.steps.data_contracts import
|
|
20
|
+
from cognite.neat.workflows.steps.data_contracts import (
|
|
21
|
+
RulesData,
|
|
22
|
+
SolutionGraph,
|
|
23
|
+
SourceGraph,
|
|
24
|
+
)
|
|
19
25
|
from cognite.neat.workflows.steps.step_model import Configurable, Step
|
|
20
26
|
|
|
21
27
|
__all__ = [
|
|
@@ -196,7 +202,10 @@ class ExtractGraphFromMockGraph(Step):
|
|
|
196
202
|
label="Target number of instances for each class",
|
|
197
203
|
),
|
|
198
204
|
Configurable(
|
|
199
|
-
name="graph_name",
|
|
205
|
+
name="graph_name",
|
|
206
|
+
value="solution",
|
|
207
|
+
label="The name of target graph.",
|
|
208
|
+
options=["source", "solution"],
|
|
200
209
|
),
|
|
201
210
|
]
|
|
202
211
|
|
|
@@ -225,7 +234,10 @@ class ExtractGraphFromMockGraph(Step):
|
|
|
225
234
|
try:
|
|
226
235
|
triples = generate_mock_triples(transformation_rules=transformation_rules.rules, class_count=class_count)
|
|
227
236
|
except Exception as e:
|
|
228
|
-
return FlowMessage(
|
|
237
|
+
return FlowMessage(
|
|
238
|
+
error_text=f"Error: {e}",
|
|
239
|
+
step_execution_status=StepExecutionStatus.ABORT_AND_FAIL,
|
|
240
|
+
)
|
|
229
241
|
|
|
230
242
|
logging.info("Adding mock triples to graph")
|
|
231
243
|
graph_store.graph.add_triples(triples, verbose=True) # type: ignore[arg-type]
|
|
@@ -243,7 +255,10 @@ class ExtractGraphFromRulesInstanceSheet(Step):
|
|
|
243
255
|
|
|
244
256
|
configurables: ClassVar[list[Configurable]] = [
|
|
245
257
|
Configurable(
|
|
246
|
-
name="graph_name",
|
|
258
|
+
name="graph_name",
|
|
259
|
+
value="solution",
|
|
260
|
+
label="The name of target graph.",
|
|
261
|
+
options=["source", "solution"],
|
|
247
262
|
),
|
|
248
263
|
]
|
|
249
264
|
|
|
@@ -264,7 +279,10 @@ class ExtractGraphFromRulesInstanceSheet(Step):
|
|
|
264
279
|
try:
|
|
265
280
|
graph_store.graph.add_triples(triples, verbose=True) # type: ignore[arg-type]
|
|
266
281
|
except Exception as e:
|
|
267
|
-
return FlowMessage(
|
|
282
|
+
return FlowMessage(
|
|
283
|
+
error_text=f"Error: {e}",
|
|
284
|
+
step_execution_status=StepExecutionStatus.ABORT_AND_FAIL,
|
|
285
|
+
)
|
|
268
286
|
|
|
269
287
|
return FlowMessage(output_text=output_text)
|
|
270
288
|
|
|
@@ -281,7 +299,7 @@ class ExtractGraphFromRulesDataModel(Step):
|
|
|
281
299
|
def run( # type: ignore[override, syntax]
|
|
282
300
|
self, transformation_rules: RulesData, source_graph: SourceGraph
|
|
283
301
|
) -> FlowMessage:
|
|
284
|
-
ns =
|
|
302
|
+
ns = DEFAULT_NAMESPACE
|
|
285
303
|
classes = transformation_rules.rules.classes
|
|
286
304
|
properties = transformation_rules.rules.properties
|
|
287
305
|
counter = 0
|
|
@@ -291,16 +309,29 @@ class ExtractGraphFromRulesDataModel(Step):
|
|
|
291
309
|
source_graph.graph.graph.add((rdf_instance_id, RDF.type, URIRef(ns + class_def.class_id)))
|
|
292
310
|
if class_def.parent_class:
|
|
293
311
|
source_graph.graph.graph.add(
|
|
294
|
-
(
|
|
312
|
+
(
|
|
313
|
+
rdf_instance_id,
|
|
314
|
+
URIRef(ns + "hasParent"),
|
|
315
|
+
URIRef(ns + "_" + cast(str, class_def.parent_class)),
|
|
316
|
+
)
|
|
295
317
|
)
|
|
296
318
|
counter += 1
|
|
297
319
|
|
|
298
320
|
for _property_name, property_def in properties.items():
|
|
299
321
|
rdf_instance_id = URIRef(ns + "_" + property_def.class_id)
|
|
300
322
|
source_graph.graph.graph.add(
|
|
301
|
-
(
|
|
323
|
+
(
|
|
324
|
+
rdf_instance_id,
|
|
325
|
+
URIRef(ns + property_def.property_id),
|
|
326
|
+
Literal(property_def.expected_value_type),
|
|
327
|
+
)
|
|
302
328
|
)
|
|
303
|
-
if property_def.expected_value_type.suffix not in (
|
|
329
|
+
if property_def.expected_value_type.suffix not in (
|
|
330
|
+
"string",
|
|
331
|
+
"integer",
|
|
332
|
+
"float",
|
|
333
|
+
"boolean",
|
|
334
|
+
):
|
|
304
335
|
source_graph.graph.graph.add(
|
|
305
336
|
(
|
|
306
337
|
rdf_instance_id,
|
|
@@ -324,10 +355,15 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
324
355
|
version = "legacy"
|
|
325
356
|
configurables: ClassVar[list[Configurable]] = [
|
|
326
357
|
Configurable(
|
|
327
|
-
name="file_name",
|
|
358
|
+
name="file_name",
|
|
359
|
+
value="data_dump.json",
|
|
360
|
+
label="Full path to the file containing data dump in JSON format",
|
|
328
361
|
),
|
|
329
362
|
Configurable(
|
|
330
|
-
name="graph_name",
|
|
363
|
+
name="graph_name",
|
|
364
|
+
value="solution",
|
|
365
|
+
label="The name of target graph.",
|
|
366
|
+
options=["source", "solution"],
|
|
331
367
|
),
|
|
332
368
|
Configurable(
|
|
333
369
|
name="object_id_generation_method",
|
|
@@ -340,7 +376,12 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
340
376
|
hash_of_json_element - takes a hash of the JSON element.Very generic method but \
|
|
341
377
|
can be slow working with big objects. \
|
|
342
378
|
uuid - generates a random UUID, the option produces unstables ids . ",
|
|
343
|
-
options=[
|
|
379
|
+
options=[
|
|
380
|
+
"source_object_properties",
|
|
381
|
+
"source_object_id_mapping",
|
|
382
|
+
"hash_of_json_element",
|
|
383
|
+
"uuid",
|
|
384
|
+
],
|
|
344
385
|
),
|
|
345
386
|
Configurable(
|
|
346
387
|
name="json_object_id_mapping",
|
|
@@ -359,10 +400,21 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
359
400
|
value="http://purl.org/cognite/neat#",
|
|
360
401
|
label="Namespace to be used for the generated objects.",
|
|
361
402
|
),
|
|
362
|
-
Configurable(
|
|
403
|
+
Configurable(
|
|
404
|
+
name="namespace_prefix",
|
|
405
|
+
value="neat",
|
|
406
|
+
label="The prefix to be used for the namespace.",
|
|
407
|
+
),
|
|
363
408
|
]
|
|
364
409
|
|
|
365
|
-
def get_json_object_id(
|
|
410
|
+
def get_json_object_id(
|
|
411
|
+
self,
|
|
412
|
+
method,
|
|
413
|
+
object_name: str,
|
|
414
|
+
json_object: dict,
|
|
415
|
+
parent_object_id: str,
|
|
416
|
+
id_mapping: dict,
|
|
417
|
+
):
|
|
366
418
|
if method == "source_object_properties":
|
|
367
419
|
object_id = ""
|
|
368
420
|
if object_name in id_mapping:
|
|
@@ -385,7 +437,11 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
385
437
|
# back to hashing
|
|
386
438
|
logging.debug(f"Object {object_name} doesn't have a valid id.Error : {e}")
|
|
387
439
|
object_id = self.get_json_object_id(
|
|
388
|
-
"hash_of_json_element",
|
|
440
|
+
"hash_of_json_element",
|
|
441
|
+
object_name,
|
|
442
|
+
json_object,
|
|
443
|
+
parent_object_id,
|
|
444
|
+
id_mapping,
|
|
389
445
|
)
|
|
390
446
|
else:
|
|
391
447
|
raise ValueError(
|
|
@@ -436,7 +492,11 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
436
492
|
|
|
437
493
|
# Iterate through the JSON data and convert it to triples
|
|
438
494
|
def convert_json_to_triples(
|
|
439
|
-
data: dict,
|
|
495
|
+
data: dict,
|
|
496
|
+
parent_node: URIRef,
|
|
497
|
+
parent_object_id: str,
|
|
498
|
+
parent_node_path: str,
|
|
499
|
+
property_name=None,
|
|
440
500
|
):
|
|
441
501
|
nonlocal nodes_counter, property_counter
|
|
442
502
|
if isinstance(data, dict):
|
|
@@ -456,7 +516,13 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
456
516
|
new_node = URIRef(ns + object_id)
|
|
457
517
|
graph.graph.add((new_node, RDF.type, URIRef(ns + property_name)))
|
|
458
518
|
if labels_mapping and property_name in labels_mapping:
|
|
459
|
-
graph.graph.add(
|
|
519
|
+
graph.graph.add(
|
|
520
|
+
(
|
|
521
|
+
new_node,
|
|
522
|
+
URIRef(ns + "label"),
|
|
523
|
+
Literal(data[labels_mapping[property_name]]),
|
|
524
|
+
)
|
|
525
|
+
)
|
|
460
526
|
else:
|
|
461
527
|
graph.graph.add((new_node, URIRef(ns + "label"), Literal(property_name)))
|
|
462
528
|
graph.graph.add((new_node, URIRef(ns + "parent"), parent_node))
|
|
@@ -470,7 +536,13 @@ class ExtractGraphFromJsonFile(Step):
|
|
|
470
536
|
convert_json_to_triples(value, parent_node, parent_object_id, parent_node_path, key)
|
|
471
537
|
else:
|
|
472
538
|
for item in data:
|
|
473
|
-
convert_json_to_triples(
|
|
539
|
+
convert_json_to_triples(
|
|
540
|
+
item,
|
|
541
|
+
parent_node,
|
|
542
|
+
parent_object_id,
|
|
543
|
+
parent_node_path,
|
|
544
|
+
property_name,
|
|
545
|
+
)
|
|
474
546
|
else:
|
|
475
547
|
# Convert scalar values to RDF literals
|
|
476
548
|
if isinstance(data, bool):
|
|
@@ -513,7 +585,10 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
513
585
|
containing data dump in XML format",
|
|
514
586
|
),
|
|
515
587
|
Configurable(
|
|
516
|
-
name="graph_name",
|
|
588
|
+
name="graph_name",
|
|
589
|
+
value="solution",
|
|
590
|
+
label="The name of target graph.",
|
|
591
|
+
options=["source", "solution"],
|
|
517
592
|
),
|
|
518
593
|
Configurable(
|
|
519
594
|
name="root_node_external_id",
|
|
@@ -535,7 +610,11 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
535
610
|
value="http://purl.org/cognite/neat#",
|
|
536
611
|
label="Namespace to be used for the generated objects.",
|
|
537
612
|
),
|
|
538
|
-
Configurable(
|
|
613
|
+
Configurable(
|
|
614
|
+
name="namespace_prefix",
|
|
615
|
+
value="neat",
|
|
616
|
+
label="The prefix to be used for the namespace.",
|
|
617
|
+
),
|
|
539
618
|
]
|
|
540
619
|
|
|
541
620
|
def add_root_asset_to_source_graph(self) -> str:
|
|
@@ -556,7 +635,10 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
556
635
|
if source_file := self.configs["file_name"]:
|
|
557
636
|
source_pi_dump = Path(self.data_store_path) / source_file
|
|
558
637
|
else:
|
|
559
|
-
return FlowMessage(
|
|
638
|
+
return FlowMessage(
|
|
639
|
+
output_text="No source file specified",
|
|
640
|
+
next_step_ids=["step_error_handler"],
|
|
641
|
+
)
|
|
560
642
|
|
|
561
643
|
# self.graph.bind
|
|
562
644
|
if self.configs["graph_name"] == "solution":
|
|
@@ -586,7 +668,11 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
586
668
|
self.graph_store.graph.add((rdf_instance_id, URIRef(self.ns + "Path"), Literal(new_element_path)))
|
|
587
669
|
if parent_element_id:
|
|
588
670
|
self.graph_store.graph.add(
|
|
589
|
-
(
|
|
671
|
+
(
|
|
672
|
+
rdf_instance_id,
|
|
673
|
+
URIRef(self.ns + "hasParent"),
|
|
674
|
+
URIRef(self.ns + parent_element_id),
|
|
675
|
+
)
|
|
590
676
|
)
|
|
591
677
|
for child in af_element:
|
|
592
678
|
if child.tag == "AFAttribute":
|
|
@@ -595,7 +681,13 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
595
681
|
pass
|
|
596
682
|
else:
|
|
597
683
|
try:
|
|
598
|
-
self.graph_store.graph.add(
|
|
684
|
+
self.graph_store.graph.add(
|
|
685
|
+
(
|
|
686
|
+
rdf_instance_id,
|
|
687
|
+
URIRef(self.ns + child.tag),
|
|
688
|
+
Literal(child.text),
|
|
689
|
+
)
|
|
690
|
+
)
|
|
599
691
|
except Exception as e:
|
|
600
692
|
logging.error(f"Error parsing AFAttribute {name} : {e}")
|
|
601
693
|
|
|
@@ -610,7 +702,11 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
610
702
|
self.graph_store.graph.add((rdf_instance_id, URIRef(self.ns + "Path"), Literal(new_element_path)))
|
|
611
703
|
if parent_element_id:
|
|
612
704
|
self.graph_store.graph.add(
|
|
613
|
-
(
|
|
705
|
+
(
|
|
706
|
+
rdf_instance_id,
|
|
707
|
+
URIRef(self.ns + "hasParent"),
|
|
708
|
+
URIRef(self.ns + parent_element_id),
|
|
709
|
+
)
|
|
614
710
|
)
|
|
615
711
|
|
|
616
712
|
for child in af_element:
|
|
@@ -624,7 +720,13 @@ class ExtractGraphFromAvevaPiAssetFramework(Step):
|
|
|
624
720
|
counter += 1
|
|
625
721
|
process_af_element(child, new_element_path, element_id)
|
|
626
722
|
else:
|
|
627
|
-
self.graph_store.graph.add(
|
|
723
|
+
self.graph_store.graph.add(
|
|
724
|
+
(
|
|
725
|
+
rdf_instance_id,
|
|
726
|
+
URIRef(self.ns + child.tag),
|
|
727
|
+
Literal(child.text),
|
|
728
|
+
)
|
|
729
|
+
)
|
|
628
730
|
|
|
629
731
|
if template:
|
|
630
732
|
self.graph_store.graph.add((rdf_instance_id, RDF.type, URIRef(self.ns + template)))
|
|
@@ -26,7 +26,7 @@ from cognite.neat.legacy.graph.loaders.core.rdf_to_relationships import (
|
|
|
26
26
|
from cognite.neat.legacy.graph.loaders.rdf_to_dms import upload_edges, upload_nodes
|
|
27
27
|
from cognite.neat.legacy.graph.loaders.validator import validate_asset_hierarchy
|
|
28
28
|
from cognite.neat.legacy.rules.models.rdfpath import TransformationRuleType
|
|
29
|
-
from cognite.neat.utils.
|
|
29
|
+
from cognite.neat.utils.auxiliary import generate_exception_report
|
|
30
30
|
from cognite.neat.workflows._exceptions import StepFlowContextNotInitialized, StepNotInitialized
|
|
31
31
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
32
32
|
from cognite.neat.workflows.steps.data_contracts import (
|
|
@@ -2,7 +2,7 @@ import logging
|
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
from typing import ClassVar, cast
|
|
4
4
|
|
|
5
|
-
from cognite.neat.constants import DEFAULT_NAMESPACE,
|
|
5
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE, get_default_prefixes
|
|
6
6
|
from cognite.neat.legacy.graph import stores
|
|
7
7
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
8
8
|
from cognite.neat.workflows.model import FlowMessage
|
|
@@ -83,7 +83,7 @@ class ConfigureDefaultGraphStores(Step):
|
|
|
83
83
|
]
|
|
84
84
|
|
|
85
85
|
def run(self, rules_data: RulesData | None = None) -> (FlowMessage, SourceGraph, SolutionGraph): # type: ignore[override, syntax]
|
|
86
|
-
prefixes = rules_data.rules.prefixes if rules_data else
|
|
86
|
+
prefixes = rules_data.rules.prefixes if rules_data else get_default_prefixes()
|
|
87
87
|
|
|
88
88
|
if self.configs is None or self.data_store_path is None:
|
|
89
89
|
raise StepNotInitialized(type(self).__name__)
|
|
@@ -126,7 +126,7 @@ class ConfigureDefaultGraphStores(Step):
|
|
|
126
126
|
|
|
127
127
|
try:
|
|
128
128
|
solution_graph = stores.STORE_BY_TYPE[solution_store_type](
|
|
129
|
-
prefixes=prefixes, base_prefix="neat", namespace=
|
|
129
|
+
prefixes=prefixes, base_prefix="neat", namespace=DEFAULT_NAMESPACE
|
|
130
130
|
)
|
|
131
131
|
except KeyError:
|
|
132
132
|
return FlowMessage(output_text="Invalid store type")
|
|
@@ -258,7 +258,7 @@ class ConfigureGraphStore(Step):
|
|
|
258
258
|
graph_store = None
|
|
259
259
|
logging.info("Graph reset complete")
|
|
260
260
|
|
|
261
|
-
prefixes = rules_data.rules.prefixes if rules_data else
|
|
261
|
+
prefixes = rules_data.rules.prefixes if rules_data else get_default_prefixes()
|
|
262
262
|
|
|
263
263
|
if store_type == stores.OxiGraphStore.rdf_store_type and graph_store is not None:
|
|
264
264
|
# OXIGRAPH doesn't like to be initialized twice without a good reason
|
|
@@ -12,7 +12,7 @@ from cognite.neat.legacy.rules import exporters
|
|
|
12
12
|
from cognite.neat.legacy.rules.exporters._rules2dms import DMSSchemaComponents
|
|
13
13
|
from cognite.neat.legacy.rules.exporters._rules2graphql import GraphQLSchema
|
|
14
14
|
from cognite.neat.legacy.rules.exporters._rules2ontology import Ontology
|
|
15
|
-
from cognite.neat.utils.
|
|
15
|
+
from cognite.neat.utils.auxiliary import generate_exception_report
|
|
16
16
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
17
17
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
18
18
|
from cognite.neat.workflows.steps.data_contracts import CogniteClient, DMSSchemaComponentsData, RulesData
|
|
@@ -13,7 +13,7 @@ from cognite.neat.legacy.rules import exporters, importers
|
|
|
13
13
|
from cognite.neat.legacy.rules.models.rdfpath import TransformationRuleType
|
|
14
14
|
from cognite.neat.legacy.rules.models.rules import Class, Classes, Metadata, Properties, Property, Rules
|
|
15
15
|
from cognite.neat.legacy.rules.models.value_types import ValueType
|
|
16
|
-
from cognite.neat.utils.
|
|
16
|
+
from cognite.neat.utils.auxiliary import generate_exception_report
|
|
17
17
|
from cognite.neat.workflows import utils
|
|
18
18
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
19
19
|
from cognite.neat.workflows.cdf_store import CdfStore
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.87.3
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
Home-page: https://cognite-neat.readthedocs-hosted.com/
|
|
6
6
|
License: Apache-2.0
|
|
@@ -21,7 +21,7 @@ Provides-Extra: oxi
|
|
|
21
21
|
Provides-Extra: service
|
|
22
22
|
Requires-Dist: PyYAML
|
|
23
23
|
Requires-Dist: backports.strenum (>=1.2,<2.0) ; python_version < "3.11"
|
|
24
|
-
Requires-Dist: cognite-sdk (>=7.
|
|
24
|
+
Requires-Dist: cognite-sdk (>=7.54.6,<8.0.0)
|
|
25
25
|
Requires-Dist: deepdiff
|
|
26
26
|
Requires-Dist: exceptiongroup (>=1.1.3,<2.0.0) ; python_version < "3.11"
|
|
27
27
|
Requires-Dist: fastapi (>=0,<1) ; extra == "service" or extra == "all"
|