cognite-neat 0.123.40__py3-none-any.whl → 0.123.41__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/_data_model/importers/__init__.py +3 -0
- cognite/neat/_data_model/importers/_base.py +16 -0
- cognite/neat/_data_model/models/dms/__init__.py +4 -0
- cognite/neat/_data_model/models/dms/_data_model.py +8 -1
- cognite/neat/_data_model/models/dms/_references.py +24 -4
- cognite/neat/_data_model/models/dms/_schema.py +18 -0
- cognite/neat/_data_model/models/dms/_views.py +3 -0
- cognite/neat/_version.py +1 -1
- cognite/neat/v0/core/_instances/queries/_select.py +42 -0
- {cognite_neat-0.123.40.dist-info → cognite_neat-0.123.41.dist-info}/METADATA +1 -1
- {cognite_neat-0.123.40.dist-info → cognite_neat-0.123.41.dist-info}/RECORD +13 -10
- {cognite_neat-0.123.40.dist-info → cognite_neat-0.123.41.dist-info}/WHEEL +0 -0
- {cognite_neat-0.123.40.dist-info → cognite_neat-0.123.41.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
|
|
3
|
+
from cognite.neat._data_model.models.dms import RequestSchema
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DMSImporter(ABC):
|
|
7
|
+
"""This is the base class for all DMS importers."""
|
|
8
|
+
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def to_data_model(self) -> RequestSchema:
|
|
11
|
+
"""Convert the imported data to a RequestSchema.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
RequestSchema: The data model as a RequestSchema.
|
|
15
|
+
"""
|
|
16
|
+
raise NotImplementedError()
|
|
@@ -36,10 +36,12 @@ from ._data_model import DataModelRequest, DataModelResponse
|
|
|
36
36
|
from ._references import (
|
|
37
37
|
ContainerDirectReference,
|
|
38
38
|
ContainerReference,
|
|
39
|
+
DataModelReference,
|
|
39
40
|
NodeReference,
|
|
40
41
|
ViewDirectReference,
|
|
41
42
|
ViewReference,
|
|
42
43
|
)
|
|
44
|
+
from ._schema import RequestSchema
|
|
43
45
|
from ._view_property import (
|
|
44
46
|
ConnectionPropertyDefinition,
|
|
45
47
|
ConstraintOrIndexState,
|
|
@@ -74,6 +76,7 @@ __all__ = [
|
|
|
74
76
|
"ContainerReference",
|
|
75
77
|
"ContainerRequest",
|
|
76
78
|
"ContainerResponse",
|
|
79
|
+
"DataModelReference",
|
|
77
80
|
"DataModelRequest",
|
|
78
81
|
"DataModelResponse",
|
|
79
82
|
"DataType",
|
|
@@ -94,6 +97,7 @@ __all__ = [
|
|
|
94
97
|
"MultiReverseDirectRelationPropertyResponse",
|
|
95
98
|
"NodeReference",
|
|
96
99
|
"PropertyTypeDefinition",
|
|
100
|
+
"RequestSchema",
|
|
97
101
|
"RequiresConstraintDefinition",
|
|
98
102
|
"Resource",
|
|
99
103
|
"SequenceCDFExternalIdReference",
|
|
@@ -8,7 +8,7 @@ from ._constants import (
|
|
|
8
8
|
DM_VERSION_PATTERN,
|
|
9
9
|
SPACE_FORMAT_PATTERN,
|
|
10
10
|
)
|
|
11
|
-
from ._references import ViewReference
|
|
11
|
+
from ._references import DataModelReference, ViewReference
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class DataModel(Resource, ABC):
|
|
@@ -52,6 +52,13 @@ class DataModel(Resource, ABC):
|
|
|
52
52
|
default=None,
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
def as_reference(self) -> DataModelReference:
|
|
56
|
+
return DataModelReference(
|
|
57
|
+
space=self.space,
|
|
58
|
+
externalId=self.external_id,
|
|
59
|
+
version=self.version,
|
|
60
|
+
)
|
|
61
|
+
|
|
55
62
|
|
|
56
63
|
class DataModelRequest(DataModel): ...
|
|
57
64
|
|
|
@@ -31,7 +31,7 @@ class ContainerReference(ReferenceObject):
|
|
|
31
31
|
)
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
class ViewReference(
|
|
34
|
+
class ViewReference(ReferenceObject):
|
|
35
35
|
type: Literal["view"] = "view"
|
|
36
36
|
space: str = Field(
|
|
37
37
|
description="Id of the space that the view belongs to.",
|
|
@@ -52,7 +52,27 @@ class ViewReference(BaseModelObject):
|
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
class
|
|
55
|
+
class DataModelReference(ReferenceObject):
|
|
56
|
+
space: str = Field(
|
|
57
|
+
description="Id of the space that the data model belongs to.",
|
|
58
|
+
min_length=1,
|
|
59
|
+
max_length=43,
|
|
60
|
+
pattern=SPACE_FORMAT_PATTERN,
|
|
61
|
+
)
|
|
62
|
+
external_id: str = Field(
|
|
63
|
+
description="External-id of the data model.",
|
|
64
|
+
min_length=1,
|
|
65
|
+
max_length=255,
|
|
66
|
+
pattern=DM_EXTERNAL_ID_PATTERN,
|
|
67
|
+
)
|
|
68
|
+
version: str = Field(
|
|
69
|
+
description="Version of the data model.",
|
|
70
|
+
max_length=43,
|
|
71
|
+
pattern=DM_VERSION_PATTERN,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class NodeReference(ReferenceObject):
|
|
56
76
|
space: str = Field(
|
|
57
77
|
description="Id of the space hosting (containing) the node.",
|
|
58
78
|
min_length=1,
|
|
@@ -67,7 +87,7 @@ class NodeReference(BaseModelObject):
|
|
|
67
87
|
)
|
|
68
88
|
|
|
69
89
|
|
|
70
|
-
class ContainerDirectReference(
|
|
90
|
+
class ContainerDirectReference(ReferenceObject):
|
|
71
91
|
source: ContainerReference = Field(
|
|
72
92
|
description="Reference to the container from where this relation is inherited.",
|
|
73
93
|
)
|
|
@@ -79,7 +99,7 @@ class ContainerDirectReference(BaseModelObject):
|
|
|
79
99
|
)
|
|
80
100
|
|
|
81
101
|
|
|
82
|
-
class ViewDirectReference(
|
|
102
|
+
class ViewDirectReference(ReferenceObject):
|
|
83
103
|
source: ViewReference = Field(
|
|
84
104
|
description="Reference to the view from where this relation is inherited.",
|
|
85
105
|
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pydantic import Field
|
|
2
|
+
|
|
3
|
+
from ._base import Resource
|
|
4
|
+
from ._container import ContainerRequest
|
|
5
|
+
from ._data_model import DataModelRequest
|
|
6
|
+
from ._references import NodeReference
|
|
7
|
+
from ._space import SpaceRequest
|
|
8
|
+
from ._views import ViewRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RequestSchema(Resource):
|
|
12
|
+
"""Represents a schema for creating or updating a data model in DMS."""
|
|
13
|
+
|
|
14
|
+
data_model: DataModelRequest
|
|
15
|
+
views: list[ViewRequest] = Field(default_factory=list)
|
|
16
|
+
containers: list[ContainerRequest] = Field(default_factory=list)
|
|
17
|
+
spaces: list[SpaceRequest] = Field(default_factory=list)
|
|
18
|
+
node_types: list[NodeReference] = Field(default_factory=list)
|
|
@@ -61,6 +61,9 @@ class View(Resource, ABC):
|
|
|
61
61
|
description="References to the views from where this view will inherit properties.",
|
|
62
62
|
)
|
|
63
63
|
|
|
64
|
+
def as_reference(self) -> ViewReference:
|
|
65
|
+
return ViewReference(space=self.space, externalId=self.external_id, version=self.version)
|
|
66
|
+
|
|
64
67
|
@model_validator(mode="before")
|
|
65
68
|
def set_connection_type_on_primary_properties(cls, data: dict) -> dict:
|
|
66
69
|
if "properties" not in data:
|
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.123.
|
|
1
|
+
__version__ = "0.123.41"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -450,3 +450,45 @@ class SelectQueries(BaseQuery):
|
|
|
450
450
|
yield instance_id, str(space.toPython())
|
|
451
451
|
else:
|
|
452
452
|
yield instance_id, str(space)
|
|
453
|
+
|
|
454
|
+
def _get_graph_diff(
|
|
455
|
+
self, source_graph: URIRef, target_graph: URIRef
|
|
456
|
+
) -> Iterable[tuple[URIRef, URIRef, URIRef | RdfLiteral]]:
|
|
457
|
+
query = f"""
|
|
458
|
+
SELECT ?s ?p ?o
|
|
459
|
+
WHERE {{
|
|
460
|
+
GRAPH <{source_graph}> {{ ?s ?p ?o }}
|
|
461
|
+
FILTER NOT EXISTS {{
|
|
462
|
+
GRAPH <{target_graph}> {{ ?s ?p ?o }}
|
|
463
|
+
}}
|
|
464
|
+
}}
|
|
465
|
+
"""
|
|
466
|
+
return cast(Iterable[tuple[URIRef, URIRef, URIRef | RdfLiteral]], self.dataset.query(query))
|
|
467
|
+
|
|
468
|
+
def get_triples_to_delete(
|
|
469
|
+
self, old_graph: URIRef, new_graph: URIRef
|
|
470
|
+
) -> Iterable[tuple[URIRef, URIRef, URIRef | RdfLiteral]]:
|
|
471
|
+
"""Find triples that exist in old graph but not in new graph.
|
|
472
|
+
|
|
473
|
+
Args:
|
|
474
|
+
old_graph: URI of the old named graph
|
|
475
|
+
new_graph: URI of the new named graph
|
|
476
|
+
|
|
477
|
+
Returns:
|
|
478
|
+
List of triples (subject, predicate, object) to delete
|
|
479
|
+
"""
|
|
480
|
+
return self._get_graph_diff(old_graph, new_graph)
|
|
481
|
+
|
|
482
|
+
def get_triples_to_add(
|
|
483
|
+
self, old_graph: URIRef, new_graph: URIRef
|
|
484
|
+
) -> Iterable[tuple[URIRef, URIRef, URIRef | RdfLiteral]]:
|
|
485
|
+
"""Find triples that exist in new graph but not in old graph.
|
|
486
|
+
|
|
487
|
+
Args:
|
|
488
|
+
old_graph: URI of the old named graph
|
|
489
|
+
new_graph: URI of the new named graph
|
|
490
|
+
|
|
491
|
+
Returns:
|
|
492
|
+
List of triples (subject, predicate, object) to add
|
|
493
|
+
"""
|
|
494
|
+
return self._get_graph_diff(new_graph, old_graph)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 0.123.
|
|
3
|
+
Version: 0.123.41
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
Project-URL: Documentation, https://cognite-neat.readthedocs-hosted.com/
|
|
6
6
|
Project-URL: Homepage, https://cognite-neat.readthedocs-hosted.com/
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
cognite/neat/__init__.py,sha256=Lo4DbjDOwnhCYUoAgPp5RG1fDdF7OlnomalTe7n1ydw,211
|
|
2
2
|
cognite/neat/_issues.py,sha256=uv0fkkWwTKqNmTmHqyoBB3L6yMCh42EZpEkLGmIJYOY,812
|
|
3
|
-
cognite/neat/_version.py,sha256=
|
|
3
|
+
cognite/neat/_version.py,sha256=ufRXfLAZOiccgiTU2G1cLrNuGEalUnTHSuR_tpkSN2w,47
|
|
4
4
|
cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite/neat/_data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
cognite/neat/_data_model/_constants.py,sha256=NGGvWHlQqhkkSBP_AqoofGYjNph3SiZX6QPINlMsy04,107
|
|
7
7
|
cognite/neat/_data_model/_identifiers.py,sha256=a0LcQ_h0NffxSKTCrzCDpYkrlaUTk-D_rfaQUh-BhWc,1921
|
|
8
|
+
cognite/neat/_data_model/importers/__init__.py,sha256=GUp7WkjX6R02lQRHD-2ygkwNGPSWbFjrFettnCdrrAQ,58
|
|
9
|
+
cognite/neat/_data_model/importers/_base.py,sha256=NRB0FcEBj4GaethU68nRffBfTedBBA866A3zfJNfmiQ,433
|
|
8
10
|
cognite/neat/_data_model/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
11
|
cognite/neat/_data_model/models/conceptual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
12
|
cognite/neat/_data_model/models/conceptual/_base.py,sha256=SFkoBJDM51pqew_isHFJoB20OgfofpwVRnTrg-rKkNY,710
|
|
11
13
|
cognite/neat/_data_model/models/conceptual/_concept.py,sha256=0Pk4W2TJ_Y0Z7oPHpzely1kPXrAkmkyqw6a0n3il6LY,2248
|
|
12
14
|
cognite/neat/_data_model/models/conceptual/_properties.py,sha256=CpF37vJYBTLT4DH4ZOu2U-JyWtkb_27V8fw52qiaE_k,4007
|
|
13
15
|
cognite/neat/_data_model/models/conceptual/_property.py,sha256=CpF37vJYBTLT4DH4ZOu2U-JyWtkb_27V8fw52qiaE_k,4007
|
|
14
|
-
cognite/neat/_data_model/models/dms/__init__.py,sha256=
|
|
16
|
+
cognite/neat/_data_model/models/dms/__init__.py,sha256=I_yw2GoEjUdLk8VOiLSlU4BWgE3u_GgCHJayeEa1w1w,3583
|
|
15
17
|
cognite/neat/_data_model/models/dms/_base.py,sha256=R8SP3Zi9daTBqewYKGjuNEkrWc-j91f-6t34CN-9YJ0,719
|
|
16
18
|
cognite/neat/_data_model/models/dms/_constants.py,sha256=wBkLjAPwufPc2naxOfPA1XC0CM2RbDbo6Dpiv9dPrew,1344
|
|
17
19
|
cognite/neat/_data_model/models/dms/_constraints.py,sha256=7Nv-EoNl6lSHUQh6r15Ei0LzR3gWV006K3RlAi1Ic68,956
|
|
18
20
|
cognite/neat/_data_model/models/dms/_container.py,sha256=SgrMCRo04A1gqayJsCia6oMhYT7q3NaeMBZMOQNI-lA,5967
|
|
19
|
-
cognite/neat/_data_model/models/dms/_data_model.py,sha256=
|
|
21
|
+
cognite/neat/_data_model/models/dms/_data_model.py,sha256=GNa05JEj_eSRGoKB8vkR85-Qv-IhPlDR3gXZNQMfe6g,2537
|
|
20
22
|
cognite/neat/_data_model/models/dms/_data_types.py,sha256=XSGQWVzYFRYAzKsDln20nC2kqiHQC6JAvDeTzCBPT-0,5202
|
|
21
23
|
cognite/neat/_data_model/models/dms/_indexes.py,sha256=MsiHbGCH50QaF1mw_pIY-AZ5dY37vS3fQECOd2rBXWo,780
|
|
22
|
-
cognite/neat/_data_model/models/dms/_references.py,sha256=
|
|
24
|
+
cognite/neat/_data_model/models/dms/_references.py,sha256=LJ7xlXATf7AP_Uj-8LlxatQk5GG1Tu4CHGK63cJqUU4,3078
|
|
25
|
+
cognite/neat/_data_model/models/dms/_schema.py,sha256=2JFLcm52smzPdtZ69Lf02UbYAD8I_hpRbI7ZAzdxJJs,641
|
|
23
26
|
cognite/neat/_data_model/models/dms/_space.py,sha256=-1LkRmQaAdIj2EYDcVv5Mcejl5uswgAEVv7DztpIUk4,1680
|
|
24
27
|
cognite/neat/_data_model/models/dms/_view_property.py,sha256=wiRxb5qtzGnBooBUzN7xtwMBZiZ9aRFcN5ML4lCTXdQ,8331
|
|
25
|
-
cognite/neat/_data_model/models/dms/_views.py,sha256=
|
|
28
|
+
cognite/neat/_data_model/models/dms/_views.py,sha256=afUZisM-6r0_IeSwn8ZVFAqWfodHBWrMcFnk_a-ewSI,6579
|
|
26
29
|
cognite/neat/_data_model/models/entities/__init__.py,sha256=qdtIpyy2hjfdMwEHya-efOCvWassaalQla15RnqK00E,798
|
|
27
30
|
cognite/neat/_data_model/models/entities/_base.py,sha256=PaNrD29iwxuqTpRWbmESMTxRhhKXmRyDF_cLZEC69dg,3927
|
|
28
31
|
cognite/neat/_data_model/models/entities/_constants.py,sha256=EK9Bus8UgFgxK5cVFMTAqWSl6aWkDe7d59hpUmlHlBs,517
|
|
@@ -152,7 +155,7 @@ cognite/neat/v0/core/_instances/loaders/_rdf_to_instance_space.py,sha256=T1nNzhY
|
|
|
152
155
|
cognite/neat/v0/core/_instances/queries/__init__.py,sha256=W477LMyB4l6HIRbQhJoFgA_MUBwVCh2GBvtFeZu0AUA,53
|
|
153
156
|
cognite/neat/v0/core/_instances/queries/_base.py,sha256=APevHeeWQDEoOQ0MlBtVlPf9hbZukVkI5fOvt5oPJCE,543
|
|
154
157
|
cognite/neat/v0/core/_instances/queries/_queries.py,sha256=4BidSQXhdZYZ6_kyG7jMJ2iG0UtSrbQxfmwPM7V167A,466
|
|
155
|
-
cognite/neat/v0/core/_instances/queries/_select.py,sha256=
|
|
158
|
+
cognite/neat/v0/core/_instances/queries/_select.py,sha256=NYEEGafbb02poVb3vJ9Ov0XQq9f8YRxpfqq1WFc-36Q,20539
|
|
156
159
|
cognite/neat/v0/core/_instances/queries/_update.py,sha256=WJmh0hGoKT4pbbWeED6udFAXiv_qFPd3v9tnZLORcNk,1293
|
|
157
160
|
cognite/neat/v0/core/_instances/transformers/__init__.py,sha256=YzC1Z8BuT77NwagWX4Z-F9R9BARLSS7zM4bCdxBbqKg,1761
|
|
158
161
|
cognite/neat/v0/core/_instances/transformers/_base.py,sha256=a8TVhgYGdt7Mj5-omT6gxOHeGvYnMd9vJCty6p7ctx4,4707
|
|
@@ -228,7 +231,7 @@ cognite/neat/v0/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4
|
|
|
228
231
|
cognite/neat/v0/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
|
|
229
232
|
cognite/neat/v0/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
|
|
230
233
|
cognite/neat/v0/session/engine/_load.py,sha256=u0x7vuQCRoNcPt25KJBJRn8sJabonYK4vtSZpiTdP4k,5201
|
|
231
|
-
cognite_neat-0.123.
|
|
232
|
-
cognite_neat-0.123.
|
|
233
|
-
cognite_neat-0.123.
|
|
234
|
-
cognite_neat-0.123.
|
|
234
|
+
cognite_neat-0.123.41.dist-info/METADATA,sha256=x1il3bStkdRMLwIwGMK5UABcb2tkCyc3Zr63dkY27Vw,9148
|
|
235
|
+
cognite_neat-0.123.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
236
|
+
cognite_neat-0.123.41.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
237
|
+
cognite_neat-0.123.41.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|