cognite-neat 0.121.0__py3-none-any.whl → 0.121.2__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/core/_client/_api/statistics.py +91 -0
- cognite/neat/core/_client/_api_client.py +2 -0
- cognite/neat/core/_client/data_classes/statistics.py +125 -0
- cognite/neat/core/_client/testing.py +4 -0
- cognite/neat/core/_constants.py +6 -7
- cognite/neat/core/{_rules → _data_model}/_constants.py +25 -18
- cognite/neat/core/_data_model/_shared.py +59 -0
- cognite/neat/core/_data_model/analysis/__init__.py +3 -0
- cognite/neat/core/{_rules → _data_model}/analysis/_base.py +202 -195
- cognite/neat/core/{_rules → _data_model}/catalog/__init__.py +1 -1
- cognite/neat/core/{_rules → _data_model}/exporters/__init__.py +5 -5
- cognite/neat/core/{_rules → _data_model}/exporters/_base.py +10 -8
- cognite/neat/core/{_rules/exporters/_rules2dms.py → _data_model/exporters/_data_model2dms.py} +22 -18
- cognite/neat/core/{_rules/exporters/_rules2excel.py → _data_model/exporters/_data_model2excel.py} +61 -56
- cognite/neat/core/{_rules/exporters/_rules2instance_template.py → _data_model/exporters/_data_model2instance_template.py} +11 -9
- cognite/neat/core/{_rules/exporters/_rules2ontology.py → _data_model/exporters/_data_model2ontology.py} +64 -61
- cognite/neat/core/{_rules/exporters/_rules2yaml.py → _data_model/exporters/_data_model2yaml.py} +21 -18
- cognite/neat/core/{_rules → _data_model}/importers/__init__.py +6 -8
- cognite/neat/core/{_rules → _data_model}/importers/_base.py +8 -6
- cognite/neat/core/_data_model/importers/_base_file_reader.py +56 -0
- cognite/neat/core/{_rules/importers/_yaml2rules.py → _data_model/importers/_dict2data_model.py} +41 -21
- cognite/neat/core/{_rules/importers/_dms2rules.py → _data_model/importers/_dms2data_model.py} +79 -66
- cognite/neat/core/{_rules/importers/_dtdl2rules → _data_model/importers/_dtdl2data_model}/dtdl_converter.py +41 -41
- cognite/neat/core/{_rules/importers/_dtdl2rules → _data_model/importers/_dtdl2data_model}/dtdl_importer.py +16 -16
- cognite/neat/core/{_rules/importers/_dtdl2rules → _data_model/importers/_dtdl2data_model}/spec.py +3 -3
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_base.py +18 -16
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_imf2rules.py +17 -17
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_inference2rules.py +50 -50
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_owl2rules.py +14 -14
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_shared.py +25 -25
- cognite/neat/core/{_rules/importers/_spreadsheet2rules.py → _data_model/importers/_spreadsheet2data_model.py} +69 -38
- cognite/neat/core/_data_model/models/__init__.py +36 -0
- cognite/neat/core/{_rules/models/_base_input.py → _data_model/models/_base_unverified.py} +12 -12
- cognite/neat/core/{_rules/models/_base_rules.py → _data_model/models/_base_verified.py} +13 -13
- cognite/neat/core/{_rules → _data_model}/models/_types.py +13 -13
- cognite/neat/core/_data_model/models/conceptual/__init__.py +25 -0
- cognite/neat/core/{_rules/models/information/_rules_input.py → _data_model/models/conceptual/_unverified.py} +46 -43
- cognite/neat/core/{_rules/models/information → _data_model/models/conceptual}/_validation.py +93 -79
- cognite/neat/core/{_rules/models/information/_rules.py → _data_model/models/conceptual/_verified.py} +83 -83
- cognite/neat/core/{_rules → _data_model}/models/data_types.py +4 -4
- cognite/neat/core/{_rules → _data_model}/models/entities/__init__.py +8 -8
- cognite/neat/core/{_rules → _data_model}/models/entities/_loaders.py +12 -11
- cognite/neat/core/{_rules → _data_model}/models/entities/_multi_value.py +7 -7
- cognite/neat/core/{_rules → _data_model}/models/entities/_single_value.py +45 -39
- cognite/neat/core/{_rules → _data_model}/models/entities/_types.py +9 -3
- cognite/neat/core/{_rules → _data_model}/models/entities/_wrapped.py +3 -3
- cognite/neat/core/{_rules → _data_model}/models/mapping/_classic2core.py +12 -9
- cognite/neat/core/_data_model/models/physical/__init__.py +40 -0
- cognite/neat/core/{_rules/models/dms → _data_model/models/physical}/_exporter.py +83 -64
- cognite/neat/core/{_rules/models/dms/_rules_input.py → _data_model/models/physical/_unverified.py} +56 -44
- cognite/neat/core/{_rules/models/dms → _data_model/models/physical}/_validation.py +20 -17
- cognite/neat/core/{_rules/models/dms/_rules.py → _data_model/models/physical/_verified.py} +79 -71
- cognite/neat/core/{_rules → _data_model}/transformers/__init__.py +27 -23
- cognite/neat/core/{_rules → _data_model}/transformers/_base.py +29 -19
- cognite/neat/core/{_rules → _data_model}/transformers/_converters.py +758 -659
- cognite/neat/core/{_rules → _data_model}/transformers/_mapping.py +79 -60
- cognite/neat/core/_data_model/transformers/_verification.py +120 -0
- cognite/neat/core/{_graph → _instances}/extractors/_base.py +2 -2
- cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_base.py +1 -1
- cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_classic.py +17 -11
- cognite/neat/core/{_graph → _instances}/extractors/_dms_graph.py +47 -39
- cognite/neat/core/{_graph → _instances}/extractors/_mock_graph_generator.py +102 -99
- cognite/neat/core/{_graph → _instances}/extractors/_rdf_file.py +2 -2
- cognite/neat/core/{_graph → _instances}/loaders/_base.py +2 -2
- cognite/neat/core/{_graph → _instances}/loaders/_rdf2dms.py +16 -14
- cognite/neat/core/{_graph → _instances}/transformers/_base.py +7 -4
- cognite/neat/core/{_graph → _instances}/transformers/_classic_cdf.py +1 -1
- cognite/neat/core/{_graph → _instances}/transformers/_value_type.py +2 -6
- cognite/neat/core/_issues/_base.py +4 -4
- cognite/neat/core/_issues/errors/__init__.py +2 -2
- cognite/neat/core/_issues/errors/_wrapper.py +2 -2
- cognite/neat/core/_issues/warnings/__init__.py +2 -0
- cognite/neat/core/_issues/warnings/_models.py +4 -4
- cognite/neat/core/_issues/warnings/_properties.py +7 -0
- cognite/neat/core/_store/__init__.py +3 -3
- cognite/neat/core/_store/{_rules_store.py → _data_model.py} +128 -121
- cognite/neat/core/_store/{_graph_store.py → _instance.py} +7 -8
- cognite/neat/core/_store/_provenance.py +2 -2
- cognite/neat/core/_store/exceptions.py +4 -4
- cognite/neat/core/_utils/rdf_.py +14 -0
- cognite/neat/core/_utils/spreadsheet.py +1 -1
- cognite/neat/core/_utils/text.py +2 -2
- cognite/neat/session/_base.py +29 -25
- cognite/neat/session/_drop.py +3 -3
- cognite/neat/session/_fix.py +2 -2
- cognite/neat/session/_inspect.py +5 -5
- cognite/neat/session/_mapping.py +11 -9
- cognite/neat/session/_prepare.py +4 -4
- cognite/neat/session/_read.py +15 -15
- cognite/neat/session/_set.py +5 -5
- cognite/neat/session/_show.py +11 -11
- cognite/neat/session/_state.py +17 -17
- cognite/neat/session/_subset.py +14 -11
- cognite/neat/session/_template.py +19 -19
- cognite/neat/session/_to.py +21 -21
- cognite/neat/session/_wizard.py +1 -1
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.2.dist-info}/METADATA +1 -1
- cognite_neat-0.121.2.dist-info/RECORD +189 -0
- cognite/neat/core/_rules/_shared.py +0 -43
- cognite/neat/core/_rules/analysis/__init__.py +0 -3
- cognite/neat/core/_rules/exporters/_validation.py +0 -14
- cognite/neat/core/_rules/models/__init__.py +0 -34
- cognite/neat/core/_rules/models/dms/__init__.py +0 -32
- cognite/neat/core/_rules/models/information/__init__.py +0 -20
- cognite/neat/core/_rules/transformers/_verification.py +0 -111
- cognite_neat-0.121.0.dist-info/RECORD +0 -187
- /cognite/neat/core/{_graph → _data_model}/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/classic_model.xlsx +0 -0
- /cognite/neat/core/{_rules/catalog/info-rules-imf.xlsx → _data_model/catalog/conceptual-imf-data-model.xlsx} +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/hello_world_pump.xlsx +0 -0
- /cognite/neat/core/{_rules/importers/_dtdl2rules → _data_model/importers/_dtdl2data_model}/__init__.py +0 -0
- /cognite/neat/core/{_rules/importers/_dtdl2rules → _data_model/importers/_dtdl2data_model}/_unit_lookup.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/importers/_rdf/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/entities/_constants.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/mapping/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/mapping/_classic2core.yaml +0 -0
- /cognite/neat/core/{_graph/extractors/_classic_cdf → _instances}/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/_shared.py +0 -0
- /cognite/neat/core/{_graph → _instances}/_tracking/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/_tracking/base.py +0 -0
- /cognite/neat/core/{_graph → _instances}/_tracking/log.py +0 -0
- /cognite/neat/core/{_graph → _instances}/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/core/{_graph → _instances}/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/core/{_graph → _instances}/examples/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/__init__.py +0 -0
- /cognite/neat/core/{_rules → _instances/extractors/_classic_cdf}/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_assets.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_data_sets.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_events.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_files.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_labels.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_relationships.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_sequences.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_classic_cdf/_timeseries.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_dict.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_dms.py +0 -0
- /cognite/neat/core/{_graph → _instances}/extractors/_raw.py +0 -0
- /cognite/neat/core/{_graph → _instances}/loaders/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/queries/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/queries/_base.py +0 -0
- /cognite/neat/core/{_graph → _instances}/queries/_queries.py +0 -0
- /cognite/neat/core/{_graph → _instances}/queries/_select.py +0 -0
- /cognite/neat/core/{_graph → _instances}/queries/_update.py +0 -0
- /cognite/neat/core/{_graph → _instances}/transformers/__init__.py +0 -0
- /cognite/neat/core/{_graph → _instances}/transformers/_prune_graph.py +0 -0
- /cognite/neat/core/{_graph → _instances}/transformers/_rdfpath.py +0 -0
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.2.dist-info}/WHEEL +0 -0
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.2.dist-info}/licenses/LICENSE +0 -0
|
@@ -25,6 +25,20 @@ from cognite.neat.core._constants import (
|
|
|
25
25
|
DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
|
|
26
26
|
DMS_PRIMITIVE_LIST_DEFAULT_LIMIT,
|
|
27
27
|
)
|
|
28
|
+
from cognite.neat.core._data_model.models.data_types import DataType, Double, Enum, Float
|
|
29
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
30
|
+
ConceptEntity,
|
|
31
|
+
ContainerEntity,
|
|
32
|
+
DMSFilter,
|
|
33
|
+
DMSNodeEntity,
|
|
34
|
+
EdgeEntity,
|
|
35
|
+
HasDataFilter,
|
|
36
|
+
NodeTypeFilter,
|
|
37
|
+
PhysicalUnknownEntity,
|
|
38
|
+
ReverseConnectionEntity,
|
|
39
|
+
UnitEntity,
|
|
40
|
+
ViewEntity,
|
|
41
|
+
)
|
|
28
42
|
from cognite.neat.core._issues.errors import (
|
|
29
43
|
NeatTypeError,
|
|
30
44
|
NeatValueError,
|
|
@@ -38,22 +52,14 @@ from cognite.neat.core._issues.warnings.user_modeling import (
|
|
|
38
52
|
EmptyContainerWarning,
|
|
39
53
|
HasDataFilterOnNoPropertiesViewWarning,
|
|
40
54
|
)
|
|
41
|
-
from cognite.neat.core._rules.models.data_types import DataType, Double, Enum, Float
|
|
42
|
-
from cognite.neat.core._rules.models.entities import (
|
|
43
|
-
ClassEntity,
|
|
44
|
-
ContainerEntity,
|
|
45
|
-
DMSFilter,
|
|
46
|
-
DMSNodeEntity,
|
|
47
|
-
DMSUnknownEntity,
|
|
48
|
-
EdgeEntity,
|
|
49
|
-
HasDataFilter,
|
|
50
|
-
NodeTypeFilter,
|
|
51
|
-
ReverseConnectionEntity,
|
|
52
|
-
UnitEntity,
|
|
53
|
-
ViewEntity,
|
|
54
|
-
)
|
|
55
55
|
|
|
56
|
-
from .
|
|
56
|
+
from ._verified import (
|
|
57
|
+
PhysicalDataModel,
|
|
58
|
+
PhysicalEnum,
|
|
59
|
+
PhysicalMetadata,
|
|
60
|
+
PhysicalProperty,
|
|
61
|
+
PhysicalView,
|
|
62
|
+
)
|
|
57
63
|
|
|
58
64
|
|
|
59
65
|
class _DMSExporter:
|
|
@@ -69,29 +75,34 @@ class _DMSExporter:
|
|
|
69
75
|
remove_cdf_spaces(bool): The
|
|
70
76
|
"""
|
|
71
77
|
|
|
72
|
-
def __init__(
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
data_model: PhysicalDataModel,
|
|
81
|
+
instance_space: str | None = None,
|
|
82
|
+
remove_cdf_spaces: bool = False,
|
|
83
|
+
):
|
|
73
84
|
self.instance_space = instance_space
|
|
74
|
-
self.
|
|
85
|
+
self.data_model = data_model
|
|
75
86
|
self.remove_cdf_spaces = remove_cdf_spaces
|
|
76
87
|
|
|
77
88
|
def to_schema(self) -> DMSSchema:
|
|
78
|
-
|
|
79
|
-
container_properties_by_id, view_properties_by_id = self._gather_properties(list(self.
|
|
89
|
+
data_model = self.data_model
|
|
90
|
+
container_properties_by_id, view_properties_by_id = self._gather_properties(list(self.data_model.properties))
|
|
80
91
|
|
|
81
|
-
containers = self._create_containers(container_properties_by_id,
|
|
92
|
+
containers = self._create_containers(container_properties_by_id, data_model.enum) # type: ignore[arg-type]
|
|
82
93
|
|
|
83
94
|
view_properties_with_ancestors_by_id = self._gather_properties_with_ancestors(
|
|
84
|
-
view_properties_by_id,
|
|
95
|
+
view_properties_by_id, data_model.views
|
|
85
96
|
)
|
|
86
97
|
|
|
87
98
|
views = self._create_views(view_properties_by_id, view_properties_with_ancestors_by_id)
|
|
88
99
|
view_node_type_filters: set[dm.NodeId] = set()
|
|
89
|
-
for dms_view in
|
|
100
|
+
for dms_view in data_model.views:
|
|
90
101
|
if isinstance(dms_view.filter_, NodeTypeFilter):
|
|
91
102
|
view_node_type_filters.update(node.as_id() for node in dms_view.filter_.inner or [])
|
|
92
|
-
if
|
|
103
|
+
if data_model.nodes:
|
|
93
104
|
node_types = NodeApplyDict(
|
|
94
|
-
[node.as_node() for node in
|
|
105
|
+
[node.as_node() for node in data_model.nodes]
|
|
95
106
|
+ [dm.NodeApply(node.space, node.external_id) for node in view_node_type_filters]
|
|
96
107
|
)
|
|
97
108
|
else:
|
|
@@ -103,17 +114,17 @@ class _DMSExporter:
|
|
|
103
114
|
]
|
|
104
115
|
)
|
|
105
116
|
|
|
106
|
-
|
|
117
|
+
dms_data_model = data_model.metadata.as_data_model()
|
|
107
118
|
# Sorting to ensure deterministic order
|
|
108
|
-
|
|
109
|
-
[dms_view.view.as_id() for dms_view in
|
|
119
|
+
dms_data_model.views = sorted(
|
|
120
|
+
[dms_view.view.as_id() for dms_view in data_model.views if dms_view.in_model],
|
|
110
121
|
key=lambda x: x.as_tuple(), # type: ignore[union-attr]
|
|
111
122
|
)
|
|
112
|
-
spaces = self._create_spaces(
|
|
123
|
+
spaces = self._create_spaces(data_model.metadata, containers, views, dms_data_model)
|
|
113
124
|
|
|
114
125
|
return DMSSchema(
|
|
115
126
|
spaces=spaces,
|
|
116
|
-
data_model=
|
|
127
|
+
data_model=dms_data_model,
|
|
117
128
|
views=views,
|
|
118
129
|
containers=containers,
|
|
119
130
|
node_types=node_types,
|
|
@@ -121,7 +132,7 @@ class _DMSExporter:
|
|
|
121
132
|
|
|
122
133
|
def _create_spaces(
|
|
123
134
|
self,
|
|
124
|
-
metadata:
|
|
135
|
+
metadata: PhysicalMetadata,
|
|
125
136
|
containers: ContainerApplyDict,
|
|
126
137
|
views: ViewApplyDict,
|
|
127
138
|
data_model: dm.DataModelApply,
|
|
@@ -140,10 +151,10 @@ class _DMSExporter:
|
|
|
140
151
|
|
|
141
152
|
def _create_views(
|
|
142
153
|
self,
|
|
143
|
-
view_properties_by_id: dict[dm.ViewId, list[
|
|
144
|
-
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[
|
|
154
|
+
view_properties_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
155
|
+
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
145
156
|
) -> ViewApplyDict:
|
|
146
|
-
input_views = list(self.
|
|
157
|
+
input_views = list(self.data_model.views)
|
|
147
158
|
|
|
148
159
|
views = ViewApplyDict(
|
|
149
160
|
[
|
|
@@ -172,7 +183,7 @@ class _DMSExporter:
|
|
|
172
183
|
return views
|
|
173
184
|
|
|
174
185
|
@classmethod
|
|
175
|
-
def _create_edge_type_from_prop(cls, prop:
|
|
186
|
+
def _create_edge_type_from_prop(cls, prop: PhysicalProperty) -> dm.DirectRelationReference:
|
|
176
187
|
if isinstance(prop.connection, EdgeEntity) and prop.connection.edge_type is not None:
|
|
177
188
|
return prop.connection.edge_type.as_reference()
|
|
178
189
|
elif isinstance(prop.value_type, ViewEntity):
|
|
@@ -191,10 +202,10 @@ class _DMSExporter:
|
|
|
191
202
|
@classmethod
|
|
192
203
|
def _edge_types_by_view_property_id(
|
|
193
204
|
cls,
|
|
194
|
-
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[
|
|
195
|
-
view_by_id: dict[ViewEntity,
|
|
205
|
+
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
206
|
+
view_by_id: dict[ViewEntity, PhysicalView],
|
|
196
207
|
) -> dict[tuple[ViewEntity, str], dm.DirectRelationReference]:
|
|
197
|
-
edge_connection_property_by_view_property_id: dict[tuple[ViewEntity, str],
|
|
208
|
+
edge_connection_property_by_view_property_id: dict[tuple[ViewEntity, str], PhysicalProperty] = {}
|
|
198
209
|
for properties in view_properties_with_ancestors_by_id.values():
|
|
199
210
|
for prop in properties:
|
|
200
211
|
if isinstance(prop.connection, EdgeEntity):
|
|
@@ -248,10 +259,10 @@ class _DMSExporter:
|
|
|
248
259
|
@classmethod
|
|
249
260
|
def _get_edge_type_outwards_connection(
|
|
250
261
|
cls,
|
|
251
|
-
view:
|
|
252
|
-
prop:
|
|
253
|
-
view_by_id: dict[ViewEntity,
|
|
254
|
-
edge_connection_by_view_property_id: dict[tuple[ViewEntity, str],
|
|
262
|
+
view: PhysicalView,
|
|
263
|
+
prop: PhysicalProperty,
|
|
264
|
+
view_by_id: dict[ViewEntity, PhysicalView],
|
|
265
|
+
edge_connection_by_view_property_id: dict[tuple[ViewEntity, str], PhysicalProperty],
|
|
255
266
|
) -> dm.DirectRelationReference:
|
|
256
267
|
connection = cast(EdgeEntity, prop.connection)
|
|
257
268
|
if connection.edge_type is not None:
|
|
@@ -284,14 +295,14 @@ class _DMSExporter:
|
|
|
284
295
|
|
|
285
296
|
def _create_containers(
|
|
286
297
|
self,
|
|
287
|
-
container_properties_by_id: dict[dm.ContainerId, list[
|
|
288
|
-
enum: Collection[
|
|
298
|
+
container_properties_by_id: dict[dm.ContainerId, list[PhysicalProperty]],
|
|
299
|
+
enum: Collection[PhysicalEnum] | None,
|
|
289
300
|
) -> ContainerApplyDict:
|
|
290
|
-
enum_values_by_collection: dict[
|
|
301
|
+
enum_values_by_collection: dict[ConceptEntity, list[PhysicalEnum]] = defaultdict(list)
|
|
291
302
|
for enum_value in enum or []:
|
|
292
303
|
enum_values_by_collection[enum_value.collection].append(enum_value)
|
|
293
304
|
|
|
294
|
-
containers = list(self.
|
|
305
|
+
containers = list(self.data_model.containers or [])
|
|
295
306
|
|
|
296
307
|
containers = dm.ContainerApplyList(
|
|
297
308
|
[
|
|
@@ -390,10 +401,13 @@ class _DMSExporter:
|
|
|
390
401
|
|
|
391
402
|
@staticmethod
|
|
392
403
|
def _gather_properties(
|
|
393
|
-
properties: Sequence[
|
|
394
|
-
) -> tuple[
|
|
395
|
-
|
|
396
|
-
|
|
404
|
+
properties: Sequence[PhysicalProperty],
|
|
405
|
+
) -> tuple[
|
|
406
|
+
dict[dm.ContainerId, list[PhysicalProperty]],
|
|
407
|
+
dict[dm.ViewId, list[PhysicalProperty]],
|
|
408
|
+
]:
|
|
409
|
+
container_properties_by_id: dict[dm.ContainerId, list[PhysicalProperty]] = defaultdict(list)
|
|
410
|
+
view_properties_by_id: dict[dm.ViewId, list[PhysicalProperty]] = defaultdict(list)
|
|
397
411
|
for prop in properties:
|
|
398
412
|
view_id = prop.view.as_id()
|
|
399
413
|
view_properties_by_id[view_id].append(prop)
|
|
@@ -406,12 +420,12 @@ class _DMSExporter:
|
|
|
406
420
|
|
|
407
421
|
def _gather_properties_with_ancestors(
|
|
408
422
|
self,
|
|
409
|
-
view_properties_by_id: dict[dm.ViewId, list[
|
|
410
|
-
views: Sequence[
|
|
411
|
-
) -> dict[dm.ViewId, list[
|
|
423
|
+
view_properties_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
424
|
+
views: Sequence[PhysicalView],
|
|
425
|
+
) -> dict[dm.ViewId, list[PhysicalProperty]]:
|
|
412
426
|
all_view_properties_by_id = view_properties_by_id.copy()
|
|
413
427
|
|
|
414
|
-
view_properties_with_parents_by_id: dict[dm.ViewId, list[
|
|
428
|
+
view_properties_with_parents_by_id: dict[dm.ViewId, list[PhysicalProperty]] = defaultdict(list)
|
|
415
429
|
view_by_view_id = {view.view.as_id(): view for view in views}
|
|
416
430
|
for view in views:
|
|
417
431
|
view_id = view.view.as_id()
|
|
@@ -446,9 +460,9 @@ class _DMSExporter:
|
|
|
446
460
|
@classmethod
|
|
447
461
|
def _update_with_properties(
|
|
448
462
|
cls,
|
|
449
|
-
selected_properties: Sequence[
|
|
450
|
-
container_properties_by_id: dict[dm.ContainerId, list[
|
|
451
|
-
view_properties_by_id: dict[dm.ViewId, list[
|
|
463
|
+
selected_properties: Sequence[PhysicalProperty],
|
|
464
|
+
container_properties_by_id: dict[dm.ContainerId, list[PhysicalProperty]],
|
|
465
|
+
view_properties_by_id: dict[dm.ViewId, list[PhysicalProperty]] | None,
|
|
452
466
|
include_new_containers: bool = False,
|
|
453
467
|
) -> None:
|
|
454
468
|
view_properties_by_id = view_properties_by_id or {}
|
|
@@ -472,7 +486,7 @@ class _DMSExporter:
|
|
|
472
486
|
def _create_view_filter(
|
|
473
487
|
self,
|
|
474
488
|
view: dm.ViewApply,
|
|
475
|
-
dms_view:
|
|
489
|
+
dms_view: PhysicalView | None,
|
|
476
490
|
) -> DMSFilter | None:
|
|
477
491
|
selected_filter_name = (dms_view and dms_view.filter_ and dms_view.filter_.name) or ""
|
|
478
492
|
|
|
@@ -497,8 +511,8 @@ class _DMSExporter:
|
|
|
497
511
|
@classmethod
|
|
498
512
|
def _create_view_property(
|
|
499
513
|
cls,
|
|
500
|
-
prop:
|
|
501
|
-
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[
|
|
514
|
+
prop: PhysicalProperty,
|
|
515
|
+
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
502
516
|
edge_types_by_view_property_id: dict[tuple[ViewEntity, str], dm.DirectRelationReference],
|
|
503
517
|
) -> ViewPropertyApply | None:
|
|
504
518
|
if prop.container and prop.container_property:
|
|
@@ -509,19 +523,20 @@ class _DMSExporter:
|
|
|
509
523
|
return cls._create_reverse_direct_relation(prop, view_properties_with_ancestors_by_id)
|
|
510
524
|
elif prop.view and prop.view_property and prop.connection:
|
|
511
525
|
warnings.warn(
|
|
512
|
-
NotSupportedWarning(f"{prop.connection} in {prop.view.as_id()!r}.{prop.view_property}"),
|
|
526
|
+
NotSupportedWarning(f"{prop.connection} in {prop.view.as_id()!r}.{prop.view_property}"),
|
|
527
|
+
stacklevel=2,
|
|
513
528
|
)
|
|
514
529
|
return None
|
|
515
530
|
|
|
516
531
|
@classmethod
|
|
517
|
-
def _create_mapped_property(cls, prop:
|
|
532
|
+
def _create_mapped_property(cls, prop: PhysicalProperty) -> dm.MappedPropertyApply:
|
|
518
533
|
container = cast(ContainerEntity, prop.container)
|
|
519
534
|
container_prop_identifier = cast(str, prop.container_property)
|
|
520
535
|
extra_args: dict[str, Any] = {}
|
|
521
536
|
if prop.connection == "direct":
|
|
522
537
|
if isinstance(prop.value_type, ViewEntity):
|
|
523
538
|
extra_args["source"] = prop.value_type.as_id()
|
|
524
|
-
elif isinstance(prop.value_type,
|
|
539
|
+
elif isinstance(prop.value_type, PhysicalUnknownEntity):
|
|
525
540
|
extra_args["source"] = None
|
|
526
541
|
else:
|
|
527
542
|
# Should have been validated.
|
|
@@ -545,7 +560,9 @@ class _DMSExporter:
|
|
|
545
560
|
|
|
546
561
|
@classmethod
|
|
547
562
|
def _create_edge_property(
|
|
548
|
-
cls,
|
|
563
|
+
cls,
|
|
564
|
+
prop: PhysicalProperty,
|
|
565
|
+
edge_types_by_view_property_id: dict[tuple[ViewEntity, str], dm.DirectRelationReference],
|
|
549
566
|
) -> dm.EdgeConnectionApply:
|
|
550
567
|
connection = cast(EdgeEntity, prop.connection)
|
|
551
568
|
if isinstance(prop.value_type, ViewEntity):
|
|
@@ -575,7 +592,9 @@ class _DMSExporter:
|
|
|
575
592
|
|
|
576
593
|
@classmethod
|
|
577
594
|
def _create_reverse_direct_relation(
|
|
578
|
-
cls,
|
|
595
|
+
cls,
|
|
596
|
+
prop: PhysicalProperty,
|
|
597
|
+
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[PhysicalProperty]],
|
|
579
598
|
) -> dm.MultiReverseDirectRelationApply | SingleReverseDirectRelationApply | None:
|
|
580
599
|
connection = cast(ReverseConnectionEntity, prop.connection)
|
|
581
600
|
reverse_prop_id = connection.property_
|
cognite/neat/core/{_rules/models/dms/_rules_input.py → _data_model/models/physical/_unverified.py}
RENAMED
|
@@ -14,23 +14,35 @@ from cognite.neat.core._constants import (
|
|
|
14
14
|
DEFAULT_NAMESPACE,
|
|
15
15
|
DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
|
|
16
16
|
)
|
|
17
|
-
from cognite.neat.core.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
from cognite.neat.core._data_model.models._base_unverified import (
|
|
18
|
+
UnverifiedComponent,
|
|
19
|
+
UnverifiedDataModel,
|
|
20
|
+
)
|
|
21
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
22
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
21
23
|
ContainerEntity,
|
|
22
24
|
DMSNodeEntity,
|
|
23
|
-
DMSUnknownEntity,
|
|
24
25
|
EdgeEntity,
|
|
26
|
+
PhysicalUnknownEntity,
|
|
25
27
|
ReverseConnectionEntity,
|
|
26
28
|
ViewEntity,
|
|
27
29
|
load_connection,
|
|
28
30
|
load_dms_value_type,
|
|
29
31
|
)
|
|
30
|
-
from cognite.neat.core.
|
|
32
|
+
from cognite.neat.core._data_model.models.entities._wrapped import DMSFilter
|
|
33
|
+
from cognite.neat.core._issues.warnings import DeprecatedWarning
|
|
31
34
|
from cognite.neat.core._utils.rdf_ import uri_display_name
|
|
32
35
|
|
|
33
|
-
from .
|
|
36
|
+
from ._verified import (
|
|
37
|
+
_DEFAULT_VERSION,
|
|
38
|
+
PhysicalContainer,
|
|
39
|
+
PhysicalDataModel,
|
|
40
|
+
PhysicalEnum,
|
|
41
|
+
PhysicalMetadata,
|
|
42
|
+
PhysicalNodeType,
|
|
43
|
+
PhysicalProperty,
|
|
44
|
+
PhysicalView,
|
|
45
|
+
)
|
|
34
46
|
|
|
35
47
|
if sys.version_info >= (3, 11):
|
|
36
48
|
from typing import Self
|
|
@@ -39,7 +51,7 @@ else:
|
|
|
39
51
|
|
|
40
52
|
|
|
41
53
|
@dataclass
|
|
42
|
-
class
|
|
54
|
+
class UnverifiedPhysicalMetadata(UnverifiedComponent[PhysicalMetadata]):
|
|
43
55
|
space: str
|
|
44
56
|
external_id: str
|
|
45
57
|
creator: str
|
|
@@ -48,12 +60,12 @@ class DMSInputMetadata(InputComponent[DMSMetadata]):
|
|
|
48
60
|
description: str | None = None
|
|
49
61
|
created: datetime | str | None = None
|
|
50
62
|
updated: datetime | str | None = None
|
|
51
|
-
|
|
63
|
+
conceptual: str | URIRef | None = None
|
|
52
64
|
source_id: str | URIRef | None = None
|
|
53
65
|
|
|
54
66
|
@classmethod
|
|
55
|
-
def _get_verified_cls(cls) -> type[
|
|
56
|
-
return
|
|
67
|
+
def _get_verified_cls(cls) -> type[PhysicalMetadata]:
|
|
68
|
+
return PhysicalMetadata
|
|
57
69
|
|
|
58
70
|
def dump(self) -> dict[str, Any]: # type: ignore[override]
|
|
59
71
|
output = super().dump()
|
|
@@ -64,7 +76,7 @@ class DMSInputMetadata(InputComponent[DMSMetadata]):
|
|
|
64
76
|
return output
|
|
65
77
|
|
|
66
78
|
@classmethod
|
|
67
|
-
def from_data_model(cls, data_model: dm.DataModelApply) -> "
|
|
79
|
+
def from_data_model(cls, data_model: dm.DataModelApply) -> "UnverifiedPhysicalMetadata":
|
|
68
80
|
description, creator = cls._get_description_and_creator(data_model.description)
|
|
69
81
|
return cls(
|
|
70
82
|
space=data_model.space,
|
|
@@ -110,10 +122,10 @@ class DMSInputMetadata(InputComponent[DMSMetadata]):
|
|
|
110
122
|
|
|
111
123
|
|
|
112
124
|
@dataclass
|
|
113
|
-
class
|
|
125
|
+
class UnverifiedPhysicalProperty(UnverifiedComponent[PhysicalProperty]):
|
|
114
126
|
view: str
|
|
115
127
|
view_property: str | None
|
|
116
|
-
value_type: str | DataType | ViewEntity |
|
|
128
|
+
value_type: str | DataType | ViewEntity | PhysicalUnknownEntity
|
|
117
129
|
name: str | None = None
|
|
118
130
|
description: str | None = None
|
|
119
131
|
connection: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | str | None = None
|
|
@@ -126,7 +138,7 @@ class DMSInputProperty(InputComponent[DMSProperty]):
|
|
|
126
138
|
index: str | list[str] | None = None
|
|
127
139
|
constraint: str | list[str] | None = None
|
|
128
140
|
neatId: str | URIRef | None = None
|
|
129
|
-
|
|
141
|
+
conceptual: str | URIRef | None = None
|
|
130
142
|
|
|
131
143
|
@property
|
|
132
144
|
def nullable(self) -> bool | None:
|
|
@@ -142,8 +154,8 @@ class DMSInputProperty(InputComponent[DMSProperty]):
|
|
|
142
154
|
)
|
|
143
155
|
|
|
144
156
|
@classmethod
|
|
145
|
-
def _get_verified_cls(cls) -> type[
|
|
146
|
-
return
|
|
157
|
+
def _get_verified_cls(cls) -> type[PhysicalProperty]:
|
|
158
|
+
return PhysicalProperty
|
|
147
159
|
|
|
148
160
|
def dump(self, default_space: str, default_version: str) -> dict[str, Any]: # type: ignore[override]
|
|
149
161
|
output = super().dump()
|
|
@@ -203,7 +215,7 @@ class DMSInputProperty(InputComponent[DMSProperty]):
|
|
|
203
215
|
|
|
204
216
|
|
|
205
217
|
@dataclass
|
|
206
|
-
class
|
|
218
|
+
class UnverifiedPhysicalContainer(UnverifiedComponent[PhysicalContainer]):
|
|
207
219
|
container: str
|
|
208
220
|
name: str | None = None
|
|
209
221
|
description: str | None = None
|
|
@@ -212,8 +224,8 @@ class DMSInputContainer(InputComponent[DMSContainer]):
|
|
|
212
224
|
used_for: Literal["node", "edge", "all"] | None = None
|
|
213
225
|
|
|
214
226
|
@classmethod
|
|
215
|
-
def _get_verified_cls(cls) -> type[
|
|
216
|
-
return
|
|
227
|
+
def _get_verified_cls(cls) -> type[PhysicalContainer]:
|
|
228
|
+
return PhysicalContainer
|
|
217
229
|
|
|
218
230
|
def dump(self, default_space: str) -> dict[str, Any]: # type: ignore[override]
|
|
219
231
|
output = super().dump()
|
|
@@ -229,7 +241,7 @@ class DMSInputContainer(InputComponent[DMSContainer]):
|
|
|
229
241
|
return ContainerEntity.load(self.container, strict=True, space=default_space)
|
|
230
242
|
|
|
231
243
|
@classmethod
|
|
232
|
-
def from_container(cls, container: dm.ContainerApply) -> "
|
|
244
|
+
def from_container(cls, container: dm.ContainerApply) -> "UnverifiedPhysicalContainer":
|
|
233
245
|
constraints: list[str] = []
|
|
234
246
|
for _, constraint_obj in (container.constraints or {}).items():
|
|
235
247
|
if isinstance(constraint_obj, dm.RequiresConstraint):
|
|
@@ -246,7 +258,7 @@ class DMSInputContainer(InputComponent[DMSContainer]):
|
|
|
246
258
|
|
|
247
259
|
|
|
248
260
|
@dataclass
|
|
249
|
-
class
|
|
261
|
+
class UnverifiedPhysicalView(UnverifiedComponent[PhysicalView]):
|
|
250
262
|
view: str
|
|
251
263
|
name: str | None = None
|
|
252
264
|
description: str | None = None
|
|
@@ -254,15 +266,15 @@ class DMSInputView(InputComponent[DMSView]):
|
|
|
254
266
|
filter_: Literal["hasData", "nodeType", "rawFilter"] | str | None = None
|
|
255
267
|
in_model: bool = True
|
|
256
268
|
neatId: str | URIRef | None = None
|
|
257
|
-
|
|
269
|
+
conceptual: str | URIRef | None = None
|
|
258
270
|
|
|
259
271
|
def __post_init__(self) -> None:
|
|
260
272
|
if self.in_model is None:
|
|
261
273
|
self.in_model = True
|
|
262
274
|
|
|
263
275
|
@classmethod
|
|
264
|
-
def _get_verified_cls(cls) -> type[
|
|
265
|
-
return
|
|
276
|
+
def _get_verified_cls(cls) -> type[PhysicalView]:
|
|
277
|
+
return PhysicalView
|
|
266
278
|
|
|
267
279
|
def dump(self, default_space: str, default_version: str) -> dict[str, Any]: # type: ignore[override]
|
|
268
280
|
output = super().dump()
|
|
@@ -289,7 +301,7 @@ class DMSInputView(InputComponent[DMSView]):
|
|
|
289
301
|
return self._load_implements(default_space, default_version) or []
|
|
290
302
|
|
|
291
303
|
@classmethod
|
|
292
|
-
def from_view(cls, view: dm.ViewApply, in_model: bool) -> "
|
|
304
|
+
def from_view(cls, view: dm.ViewApply, in_model: bool) -> "UnverifiedPhysicalView":
|
|
293
305
|
view_entity = ViewEntity.from_id(view.as_id())
|
|
294
306
|
|
|
295
307
|
return cls(
|
|
@@ -304,7 +316,7 @@ class DMSInputView(InputComponent[DMSView]):
|
|
|
304
316
|
|
|
305
317
|
|
|
306
318
|
@dataclass
|
|
307
|
-
class
|
|
319
|
+
class UnverifiedPhysicalNodeType(UnverifiedComponent[PhysicalNodeType]):
|
|
308
320
|
node: str
|
|
309
321
|
usage: Literal["type", "collocation"]
|
|
310
322
|
name: str | None = None
|
|
@@ -312,11 +324,11 @@ class DMSInputNode(InputComponent[DMSNode]):
|
|
|
312
324
|
neatId: str | URIRef | None = None
|
|
313
325
|
|
|
314
326
|
@classmethod
|
|
315
|
-
def _get_verified_cls(cls) -> type[
|
|
316
|
-
return
|
|
327
|
+
def _get_verified_cls(cls) -> type[PhysicalNodeType]:
|
|
328
|
+
return PhysicalNodeType
|
|
317
329
|
|
|
318
330
|
@classmethod
|
|
319
|
-
def from_node_type(cls, node_type: dm.NodeApply) -> "
|
|
331
|
+
def from_node_type(cls, node_type: dm.NodeApply) -> "UnverifiedPhysicalNodeType":
|
|
320
332
|
return cls(node=f"{node_type.space}:{node_type.external_id}", usage="type")
|
|
321
333
|
|
|
322
334
|
def dump(self, default_space: str, **_) -> dict[str, Any]: # type: ignore
|
|
@@ -326,7 +338,7 @@ class DMSInputNode(InputComponent[DMSNode]):
|
|
|
326
338
|
|
|
327
339
|
|
|
328
340
|
@dataclass
|
|
329
|
-
class
|
|
341
|
+
class UnverifiedPhysicalEnum(UnverifiedComponent[PhysicalEnum]):
|
|
330
342
|
collection: str
|
|
331
343
|
value: str
|
|
332
344
|
name: str | None = None
|
|
@@ -334,22 +346,22 @@ class DMSInputEnum(InputComponent[DMSEnum]):
|
|
|
334
346
|
neatId: str | URIRef | None = None
|
|
335
347
|
|
|
336
348
|
@classmethod
|
|
337
|
-
def _get_verified_cls(cls) -> type[
|
|
338
|
-
return
|
|
349
|
+
def _get_verified_cls(cls) -> type[PhysicalEnum]:
|
|
350
|
+
return PhysicalEnum
|
|
339
351
|
|
|
340
352
|
|
|
341
353
|
@dataclass
|
|
342
|
-
class
|
|
343
|
-
metadata:
|
|
344
|
-
properties: list[
|
|
345
|
-
views: list[
|
|
346
|
-
containers: list[
|
|
347
|
-
enum: list[
|
|
348
|
-
nodes: list[
|
|
354
|
+
class UnverifiedPhysicalDataModel(UnverifiedDataModel[PhysicalDataModel]):
|
|
355
|
+
metadata: UnverifiedPhysicalMetadata
|
|
356
|
+
properties: list[UnverifiedPhysicalProperty]
|
|
357
|
+
views: list[UnverifiedPhysicalView]
|
|
358
|
+
containers: list[UnverifiedPhysicalContainer] | None = None
|
|
359
|
+
enum: list[UnverifiedPhysicalEnum] | None = None
|
|
360
|
+
nodes: list[UnverifiedPhysicalNodeType] | None = None
|
|
349
361
|
|
|
350
362
|
@classmethod
|
|
351
|
-
def _get_verified_cls(cls) -> type[
|
|
352
|
-
return
|
|
363
|
+
def _get_verified_cls(cls) -> type[PhysicalDataModel]:
|
|
364
|
+
return PhysicalDataModel
|
|
353
365
|
|
|
354
366
|
def dump(self) -> dict[str, Any]:
|
|
355
367
|
default_space = self.metadata.space
|
|
@@ -366,7 +378,7 @@ class DMSInputRules(InputRules[DMSRules]):
|
|
|
366
378
|
|
|
367
379
|
@classmethod
|
|
368
380
|
def display_type_name(cls) -> str:
|
|
369
|
-
return "
|
|
381
|
+
return "UnverifiedPhysicalModel"
|
|
370
382
|
|
|
371
383
|
@property
|
|
372
384
|
def display_name(self) -> str:
|
|
@@ -375,7 +387,7 @@ class DMSInputRules(InputRules[DMSRules]):
|
|
|
375
387
|
def _repr_html_(self) -> str:
|
|
376
388
|
summary = {
|
|
377
389
|
"type": "Physical Data Model",
|
|
378
|
-
"intended for": "
|
|
390
|
+
"intended for": "Data Engineer",
|
|
379
391
|
"name": self.metadata.name,
|
|
380
392
|
"space": self.metadata.space,
|
|
381
393
|
"external_id": self.metadata.external_id,
|
|
@@ -21,6 +21,11 @@ from cognite.neat.core._constants import (
|
|
|
21
21
|
DMS_CONTAINER_PROPERTY_SIZE_LIMIT,
|
|
22
22
|
DMS_VIEW_CONTAINER_SIZE_LIMIT,
|
|
23
23
|
)
|
|
24
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
25
|
+
from cognite.neat.core._data_model.models.entities import ContainerEntity, RawFilter
|
|
26
|
+
from cognite.neat.core._data_model.models.entities._single_value import (
|
|
27
|
+
ViewEntity,
|
|
28
|
+
)
|
|
24
29
|
from cognite.neat.core._issues import IssueList, NeatError
|
|
25
30
|
from cognite.neat.core._issues.errors import (
|
|
26
31
|
CDFMissingClientError,
|
|
@@ -35,6 +40,7 @@ from cognite.neat.core._issues.errors._external import CDFMissingResourcesError
|
|
|
35
40
|
from cognite.neat.core._issues.warnings import (
|
|
36
41
|
NotSupportedHasDataFilterLimitWarning,
|
|
37
42
|
NotSupportedViewContainerLimitWarning,
|
|
43
|
+
ReversedConnectionNotFeasibleWarning,
|
|
38
44
|
UndefinedViewWarning,
|
|
39
45
|
user_modeling,
|
|
40
46
|
)
|
|
@@ -43,33 +49,28 @@ from cognite.neat.core._issues.warnings.user_modeling import (
|
|
|
43
49
|
DirectRelationMissingSourceWarning,
|
|
44
50
|
NotNeatSupportedFilterWarning,
|
|
45
51
|
)
|
|
46
|
-
from cognite.neat.core._rules.models.data_types import DataType
|
|
47
|
-
from cognite.neat.core._rules.models.entities import ContainerEntity, RawFilter
|
|
48
|
-
from cognite.neat.core._rules.models.entities._single_value import (
|
|
49
|
-
ViewEntity,
|
|
50
|
-
)
|
|
51
52
|
from cognite.neat.core._utils.spreadsheet import SpreadsheetRead
|
|
52
53
|
from cognite.neat.core._utils.text import humanize_collection
|
|
53
54
|
|
|
54
|
-
from .
|
|
55
|
+
from ._verified import PhysicalDataModel, PhysicalProperty
|
|
55
56
|
|
|
56
57
|
|
|
57
|
-
class
|
|
58
|
-
"""This class does all the validation of the
|
|
59
|
-
components."""
|
|
58
|
+
class PhysicalValidation:
|
|
59
|
+
"""This class does all the validation of the physical data model that
|
|
60
|
+
have dependencies between components."""
|
|
60
61
|
|
|
61
62
|
def __init__(
|
|
62
63
|
self,
|
|
63
|
-
|
|
64
|
+
data_model: PhysicalDataModel,
|
|
64
65
|
client: NeatClient | None = None,
|
|
65
66
|
read_info_by_spreadsheet: dict[str, SpreadsheetRead] | None = None,
|
|
66
67
|
) -> None:
|
|
67
|
-
self._rules =
|
|
68
|
+
self._rules = data_model
|
|
68
69
|
self._client = client
|
|
69
|
-
self._metadata =
|
|
70
|
-
self._properties =
|
|
71
|
-
self._containers =
|
|
72
|
-
self._views =
|
|
70
|
+
self._metadata = data_model.metadata
|
|
71
|
+
self._properties = data_model.properties
|
|
72
|
+
self._containers = data_model.containers
|
|
73
|
+
self._views = data_model.views
|
|
73
74
|
self._read_info_by_spreadsheet = read_info_by_spreadsheet or {}
|
|
74
75
|
|
|
75
76
|
def imported_views_and_containers_ids(
|
|
@@ -320,7 +321,9 @@ class DMSValidation:
|
|
|
320
321
|
return parents_by_view
|
|
321
322
|
|
|
322
323
|
def _consistent_container_properties(self) -> IssueList:
|
|
323
|
-
container_properties_by_id: dict[tuple[ContainerEntity, str], list[tuple[int,
|
|
324
|
+
container_properties_by_id: dict[tuple[ContainerEntity, str], list[tuple[int, PhysicalProperty]]] = defaultdict(
|
|
325
|
+
list
|
|
326
|
+
)
|
|
324
327
|
for prop_no, prop in enumerate(self._properties):
|
|
325
328
|
if prop.container and prop.container_property:
|
|
326
329
|
container_properties_by_id[(prop.container, prop.container_property)].append((prop_no, prop))
|
|
@@ -589,7 +592,7 @@ class DMSValidation:
|
|
|
589
592
|
)
|
|
590
593
|
):
|
|
591
594
|
issue_list.append(
|
|
592
|
-
|
|
595
|
+
ReversedConnectionNotFeasibleWarning(
|
|
593
596
|
view_id,
|
|
594
597
|
"reversed connection",
|
|
595
598
|
prop_id,
|