cognite-neat 0.121.0__py3-none-any.whl → 0.121.1__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/_constants.py +2 -2
- cognite/neat/core/{_rules → _data_model}/_constants.py +2 -2
- cognite/neat/core/{_rules → _data_model}/_shared.py +9 -9
- cognite/neat/core/{_rules → _data_model}/analysis/_base.py +33 -29
- cognite/neat/core/{_rules → _data_model}/exporters/_base.py +1 -1
- cognite/neat/core/{_rules → _data_model}/exporters/_rules2dms.py +1 -1
- cognite/neat/core/{_rules → _data_model}/exporters/_rules2excel.py +15 -10
- cognite/neat/core/{_rules → _data_model}/exporters/_rules2instance_template.py +9 -7
- cognite/neat/core/{_rules → _data_model}/exporters/_rules2ontology.py +24 -21
- cognite/neat/core/{_rules → _data_model}/exporters/_rules2yaml.py +1 -1
- cognite/neat/core/{_rules → _data_model}/exporters/_validation.py +5 -5
- cognite/neat/core/{_rules → _data_model}/importers/__init__.py +1 -3
- cognite/neat/core/{_rules → _data_model}/importers/_base.py +1 -1
- cognite/neat/core/{_rules → _data_model}/importers/_dms2rules.py +37 -33
- cognite/neat/core/{_rules → _data_model}/importers/_dtdl2rules/dtdl_converter.py +25 -25
- cognite/neat/core/{_rules → _data_model}/importers/_dtdl2rules/dtdl_importer.py +14 -14
- cognite/neat/core/{_rules → _data_model}/importers/_dtdl2rules/spec.py +1 -1
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_base.py +11 -9
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_imf2rules.py +2 -2
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_inference2rules.py +24 -24
- cognite/neat/core/{_rules → _data_model}/importers/_rdf/_owl2rules.py +2 -2
- cognite/neat/core/{_rules → _data_model}/importers/_spreadsheet2rules.py +7 -36
- cognite/neat/core/{_rules → _data_model}/importers/_yaml2rules.py +2 -2
- cognite/neat/core/_data_model/models/__init__.py +36 -0
- cognite/neat/core/{_rules/models/_base_input.py → _data_model/models/_base_unverified.py} +11 -11
- cognite/neat/core/{_rules/models/_base_rules.py → _data_model/models/_base_verified.py} +10 -10
- cognite/neat/core/{_rules → _data_model}/models/_types.py +7 -7
- 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} +31 -28
- cognite/neat/core/{_rules/models/information → _data_model/models/conceptual}/_validation.py +9 -5
- cognite/neat/core/{_rules/models/information/_rules.py → _data_model/models/conceptual/_verified.py} +40 -42
- cognite/neat/core/{_rules → _data_model}/models/data_types.py +2 -2
- cognite/neat/core/{_rules → _data_model}/models/dms/_exporter.py +14 -14
- cognite/neat/core/{_rules → _data_model}/models/dms/_rules.py +15 -15
- cognite/neat/core/{_rules → _data_model}/models/dms/_rules_input.py +15 -12
- cognite/neat/core/{_rules → _data_model}/models/dms/_validation.py +7 -6
- cognite/neat/core/{_rules → _data_model}/models/entities/_loaders.py +1 -1
- cognite/neat/core/{_rules → _data_model}/models/entities/_multi_value.py +2 -2
- cognite/neat/core/{_rules → _data_model}/models/entities/_single_value.py +1 -1
- cognite/neat/core/{_rules → _data_model}/models/mapping/_classic2core.py +4 -4
- cognite/neat/core/{_rules → _data_model}/transformers/_base.py +6 -3
- cognite/neat/core/{_rules → _data_model}/transformers/_converters.py +117 -103
- cognite/neat/core/{_rules → _data_model}/transformers/_mapping.py +8 -8
- cognite/neat/core/{_rules → _data_model}/transformers/_verification.py +14 -14
- 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 +13 -7
- cognite/neat/core/{_graph → _instances}/extractors/_dms_graph.py +10 -10
- cognite/neat/core/{_graph → _instances}/extractors/_mock_graph_generator.py +14 -14
- cognite/neat/core/{_graph → _instances}/extractors/_rdf_file.py +2 -2
- cognite/neat/core/{_graph → _instances}/loaders/_rdf2dms.py +12 -10
- cognite/neat/core/{_graph → _instances}/transformers/_classic_cdf.py +1 -1
- cognite/neat/core/_issues/_base.py +2 -2
- cognite/neat/core/_issues/warnings/__init__.py +2 -0
- cognite/neat/core/_issues/warnings/_properties.py +7 -0
- cognite/neat/core/_store/_graph_store.py +4 -4
- cognite/neat/core/_store/_rules_store.py +31 -31
- cognite/neat/core/_store/exceptions.py +3 -3
- cognite/neat/core/_utils/spreadsheet.py +1 -1
- cognite/neat/core/_utils/text.py +1 -1
- cognite/neat/session/_base.py +10 -8
- cognite/neat/session/_drop.py +1 -1
- cognite/neat/session/_fix.py +2 -2
- cognite/neat/session/_mapping.py +3 -3
- cognite/neat/session/_prepare.py +4 -4
- cognite/neat/session/_read.py +13 -13
- cognite/neat/session/_set.py +3 -3
- cognite/neat/session/_show.py +1 -1
- cognite/neat/session/_state.py +6 -6
- cognite/neat/session/_subset.py +3 -3
- cognite/neat/session/_template.py +10 -10
- cognite/neat/session/_to.py +8 -8
- cognite/neat/session/_wizard.py +1 -1
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.1.dist-info}/METADATA +1 -1
- cognite_neat-0.121.1.dist-info/RECORD +187 -0
- cognite/neat/core/_rules/models/__init__.py +0 -34
- cognite/neat/core/_rules/models/information/__init__.py +0 -20
- 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}/analysis/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/classic_model.xlsx +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/hello_world_pump.xlsx +0 -0
- /cognite/neat/core/{_rules → _data_model}/catalog/info-rules-imf.xlsx +0 -0
- /cognite/neat/core/{_rules → _data_model}/exporters/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/importers/_dtdl2rules/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/importers/_dtdl2rules/_unit_lookup.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/importers/_rdf/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/importers/_rdf/_shared.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/dms/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/entities/__init__.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/entities/_constants.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/entities/_types.py +0 -0
- /cognite/neat/core/{_rules → _data_model}/models/entities/_wrapped.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/{_rules → _data_model}/transformers/__init__.py +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}/loaders/_base.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/_base.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/core/{_graph → _instances}/transformers/_value_type.py +0 -0
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.1.dist-info}/WHEEL +0 -0
- {cognite_neat-0.121.0.dist-info → cognite_neat-0.121.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -29,33 +29,30 @@ from cognite.neat.core._constants import (
|
|
|
29
29
|
DMS_RESERVED_PROPERTIES,
|
|
30
30
|
get_default_prefixes_and_namespaces,
|
|
31
31
|
)
|
|
32
|
-
from cognite.neat.core.
|
|
33
|
-
from cognite.neat.core.
|
|
34
|
-
from cognite.neat.core._issues.errors import CDFMissingClientError, NeatValueError
|
|
35
|
-
from cognite.neat.core._issues.warnings import (
|
|
36
|
-
NeatValueWarning,
|
|
37
|
-
PropertyOverwritingWarning,
|
|
38
|
-
)
|
|
39
|
-
from cognite.neat.core._issues.warnings._models import (
|
|
40
|
-
SolutionModelBuildOnTopOfCDMWarning,
|
|
41
|
-
)
|
|
42
|
-
from cognite.neat.core._rules._constants import PATTERNS, get_reserved_words
|
|
43
|
-
from cognite.neat.core._rules._shared import (
|
|
32
|
+
from cognite.neat.core._data_model._constants import PATTERNS, get_reserved_words
|
|
33
|
+
from cognite.neat.core._data_model._shared import (
|
|
44
34
|
ReadInputRules,
|
|
45
35
|
ReadRules,
|
|
46
36
|
VerifiedRules,
|
|
47
37
|
)
|
|
48
|
-
from cognite.neat.core.
|
|
49
|
-
from cognite.neat.core.
|
|
50
|
-
from cognite.neat.core.
|
|
38
|
+
from cognite.neat.core._data_model.analysis import RulesAnalysis
|
|
39
|
+
from cognite.neat.core._data_model.importers import DMSImporter
|
|
40
|
+
from cognite.neat.core._data_model.models import (
|
|
41
|
+
ConceptualDataModel,
|
|
51
42
|
DMSInputRules,
|
|
52
43
|
DMSRules,
|
|
53
|
-
InformationInputRules,
|
|
54
|
-
InformationRules,
|
|
55
44
|
SheetList,
|
|
45
|
+
UnverifiedConceptualDataModel,
|
|
56
46
|
data_types,
|
|
57
47
|
)
|
|
58
|
-
from cognite.neat.core.
|
|
48
|
+
from cognite.neat.core._data_model.models.conceptual import (
|
|
49
|
+
ConceptualClass,
|
|
50
|
+
ConceptualMetadata,
|
|
51
|
+
ConceptualProperty,
|
|
52
|
+
UnverifiedConceptualClass,
|
|
53
|
+
UnverifiedConceptualProperty,
|
|
54
|
+
)
|
|
55
|
+
from cognite.neat.core._data_model.models.data_types import (
|
|
59
56
|
AnyURI,
|
|
60
57
|
DataType,
|
|
61
58
|
Enum,
|
|
@@ -63,14 +60,14 @@ from cognite.neat.core._rules.models.data_types import (
|
|
|
63
60
|
String,
|
|
64
61
|
Timeseries,
|
|
65
62
|
)
|
|
66
|
-
from cognite.neat.core.
|
|
63
|
+
from cognite.neat.core._data_model.models.dms import (
|
|
67
64
|
DMSMetadata,
|
|
68
65
|
DMSProperty,
|
|
69
66
|
DMSValidation,
|
|
70
67
|
DMSView,
|
|
71
68
|
)
|
|
72
|
-
from cognite.neat.core.
|
|
73
|
-
from cognite.neat.core.
|
|
69
|
+
from cognite.neat.core._data_model.models.dms._rules import DMSContainer, DMSEnum, DMSNode
|
|
70
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
74
71
|
ClassEntity,
|
|
75
72
|
ContainerEntity,
|
|
76
73
|
DMSUnknownEntity,
|
|
@@ -81,12 +78,15 @@ from cognite.neat.core._rules.models.entities import (
|
|
|
81
78
|
UnknownEntity,
|
|
82
79
|
ViewEntity,
|
|
83
80
|
)
|
|
84
|
-
from cognite.neat.core.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
from cognite.neat.core._issues import IssueList
|
|
82
|
+
from cognite.neat.core._issues._factory import from_pydantic_errors
|
|
83
|
+
from cognite.neat.core._issues.errors import CDFMissingClientError, NeatValueError
|
|
84
|
+
from cognite.neat.core._issues.warnings import (
|
|
85
|
+
NeatValueWarning,
|
|
86
|
+
PropertyOverwritingWarning,
|
|
87
|
+
)
|
|
88
|
+
from cognite.neat.core._issues.warnings._models import (
|
|
89
|
+
SolutionModelBuildOnTopOfCDMWarning,
|
|
90
90
|
)
|
|
91
91
|
from cognite.neat.core._utils.rdf_ import get_inheritance_path
|
|
92
92
|
from cognite.neat.core._utils.spreadsheet import SpreadsheetRead
|
|
@@ -111,7 +111,12 @@ class ConversionTransformer(VerifiedRulesTransformer[T_VerifiedIn, T_VerifiedOut
|
|
|
111
111
|
...
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
class ToDMSCompliantEntities(
|
|
114
|
+
class ToDMSCompliantEntities(
|
|
115
|
+
RulesTransformer[
|
|
116
|
+
ReadRules[UnverifiedConceptualDataModel],
|
|
117
|
+
ReadRules[UnverifiedConceptualDataModel],
|
|
118
|
+
]
|
|
119
|
+
):
|
|
115
120
|
"""Converts input rules to rules that is compliant with the Information Model.
|
|
116
121
|
|
|
117
122
|
This is typically used with importers from arbitrary sources to ensure that classes and properties have valid
|
|
@@ -130,13 +135,13 @@ class ToDMSCompliantEntities(RulesTransformer[ReadRules[InformationInputRules],
|
|
|
130
135
|
def description(self) -> str:
|
|
131
136
|
return "Ensures that all entities are compliant with the Information Model."
|
|
132
137
|
|
|
133
|
-
def transform(self, rules: ReadRules[
|
|
138
|
+
def transform(self, rules: ReadRules[UnverifiedConceptualDataModel]) -> ReadRules[UnverifiedConceptualDataModel]:
|
|
134
139
|
if rules.rules is None:
|
|
135
140
|
return rules
|
|
136
141
|
# Doing dump to obtain a copy, and ensure that all entities are created. Input allows
|
|
137
142
|
# string for entities, the dump call will convert these to entities.
|
|
138
143
|
dumped = rules.rules.dump()
|
|
139
|
-
copy =
|
|
144
|
+
copy = UnverifiedConceptualDataModel.load(dumped)
|
|
140
145
|
|
|
141
146
|
new_by_old_class_suffix: dict[str, str] = {}
|
|
142
147
|
for cls in copy.classes:
|
|
@@ -267,7 +272,7 @@ class StandardizeSpaceAndVersion(VerifiedRulesTransformer[DMSRules, DMSRules]):
|
|
|
267
272
|
return properties
|
|
268
273
|
|
|
269
274
|
|
|
270
|
-
class ToCompliantEntities(VerifiedRulesTransformer[
|
|
275
|
+
class ToCompliantEntities(VerifiedRulesTransformer[ConceptualDataModel, ConceptualDataModel]): # type: ignore[misc]
|
|
271
276
|
"""Converts input rules to rules with compliant entity IDs that match regex patters used
|
|
272
277
|
by DMS schema components."""
|
|
273
278
|
|
|
@@ -275,7 +280,7 @@ class ToCompliantEntities(VerifiedRulesTransformer[InformationRules, Information
|
|
|
275
280
|
def description(self) -> str:
|
|
276
281
|
return "Ensures externalIDs are compliant with CDF"
|
|
277
282
|
|
|
278
|
-
def transform(self, rules:
|
|
283
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
279
284
|
copy = rules.model_copy(deep=True)
|
|
280
285
|
copy.classes = self._fix_classes(copy.classes)
|
|
281
286
|
copy.properties = self._fix_properties(copy.properties)
|
|
@@ -328,16 +333,16 @@ class ToCompliantEntities(VerifiedRulesTransformer[InformationRules, Information
|
|
|
328
333
|
return fixed_value_type
|
|
329
334
|
|
|
330
335
|
@classmethod
|
|
331
|
-
def _fix_classes(cls, definitions: SheetList[
|
|
332
|
-
fixed_definitions = SheetList[
|
|
336
|
+
def _fix_classes(cls, definitions: SheetList[ConceptualClass]) -> SheetList[ConceptualClass]:
|
|
337
|
+
fixed_definitions = SheetList[ConceptualClass]()
|
|
333
338
|
for definition in definitions:
|
|
334
339
|
definition.class_ = cls._fix_class(definition.class_)
|
|
335
340
|
fixed_definitions.append(definition)
|
|
336
341
|
return fixed_definitions
|
|
337
342
|
|
|
338
343
|
@classmethod
|
|
339
|
-
def _fix_properties(cls, definitions: SheetList[
|
|
340
|
-
fixed_definitions = SheetList[
|
|
344
|
+
def _fix_properties(cls, definitions: SheetList[ConceptualProperty]) -> SheetList[ConceptualProperty]:
|
|
345
|
+
fixed_definitions = SheetList[ConceptualProperty]()
|
|
341
346
|
for definition in definitions:
|
|
342
347
|
definition.class_ = cls._fix_class(definition.class_)
|
|
343
348
|
definition.property_ = cls._fix_entity(definition.property_)
|
|
@@ -360,13 +365,13 @@ class PrefixEntities(ConversionTransformer): # type: ignore[type-var]
|
|
|
360
365
|
def transform(self, rules: DMSRules) -> DMSRules: ...
|
|
361
366
|
|
|
362
367
|
@overload
|
|
363
|
-
def transform(self, rules:
|
|
368
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel: ...
|
|
364
369
|
|
|
365
|
-
def transform(self, rules:
|
|
366
|
-
copy:
|
|
370
|
+
def transform(self, rules: ConceptualDataModel | DMSRules) -> ConceptualDataModel | DMSRules:
|
|
371
|
+
copy: ConceptualDataModel | DMSRules = rules.model_copy(deep=True)
|
|
367
372
|
|
|
368
373
|
# Case: Prefix Information Rules
|
|
369
|
-
if isinstance(copy,
|
|
374
|
+
if isinstance(copy, ConceptualDataModel):
|
|
370
375
|
# prefix classes
|
|
371
376
|
for cls in copy.classes:
|
|
372
377
|
if cls.class_.prefix == copy.metadata.prefix:
|
|
@@ -453,17 +458,17 @@ class StandardizeNaming(ConversionTransformer):
|
|
|
453
458
|
def transform(self, rules: DMSRules) -> DMSRules: ...
|
|
454
459
|
|
|
455
460
|
@overload
|
|
456
|
-
def transform(self, rules:
|
|
461
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel: ...
|
|
457
462
|
|
|
458
|
-
def transform(self, rules:
|
|
463
|
+
def transform(self, rules: ConceptualDataModel | DMSRules) -> ConceptualDataModel | DMSRules:
|
|
459
464
|
output = rules.model_copy(deep=True)
|
|
460
|
-
if isinstance(output,
|
|
465
|
+
if isinstance(output, ConceptualDataModel):
|
|
461
466
|
return self._standardize_information_rules(output)
|
|
462
467
|
elif isinstance(output, DMSRules):
|
|
463
468
|
return self._standardize_dms_rules(output)
|
|
464
469
|
raise NeatValueError(f"Unsupported rules type: {type(output)}")
|
|
465
470
|
|
|
466
|
-
def _standardize_information_rules(self, rules:
|
|
471
|
+
def _standardize_information_rules(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
467
472
|
new_by_old_class_suffix: dict[str, str] = {}
|
|
468
473
|
for cls in rules.classes:
|
|
469
474
|
new_suffix = NamingStandardization.standardize_class_str(cls.class_.suffix)
|
|
@@ -552,7 +557,7 @@ class StandardizeNaming(ConversionTransformer):
|
|
|
552
557
|
return rules
|
|
553
558
|
|
|
554
559
|
|
|
555
|
-
class InformationToDMS(ConversionTransformer[
|
|
560
|
+
class InformationToDMS(ConversionTransformer[ConceptualDataModel, DMSRules]):
|
|
556
561
|
"""Converts InformationRules to DMSRules."""
|
|
557
562
|
|
|
558
563
|
def __init__(
|
|
@@ -565,19 +570,19 @@ class InformationToDMS(ConversionTransformer[InformationRules, DMSRules]):
|
|
|
565
570
|
self.reserved_properties = reserved_properties
|
|
566
571
|
self.client = client
|
|
567
572
|
|
|
568
|
-
def transform(self, rules:
|
|
573
|
+
def transform(self, rules: ConceptualDataModel) -> DMSRules:
|
|
569
574
|
return _InformationRulesConverter(rules, self.client).as_dms_rules(
|
|
570
575
|
self.ignore_undefined_value_types, self.reserved_properties
|
|
571
576
|
)
|
|
572
577
|
|
|
573
578
|
|
|
574
|
-
class DMSToInformation(ConversionTransformer[DMSRules,
|
|
579
|
+
class DMSToInformation(ConversionTransformer[DMSRules, ConceptualDataModel]):
|
|
575
580
|
"""Converts DMSRules to InformationRules."""
|
|
576
581
|
|
|
577
582
|
def __init__(self, instance_namespace: Namespace | None = None):
|
|
578
583
|
self.instance_namespace = instance_namespace
|
|
579
584
|
|
|
580
|
-
def transform(self, rules: DMSRules) ->
|
|
585
|
+
def transform(self, rules: DMSRules) -> ConceptualDataModel:
|
|
581
586
|
return _DMSRulesConverter(rules, self.instance_namespace).as_information_rules()
|
|
582
587
|
|
|
583
588
|
|
|
@@ -590,9 +595,9 @@ class ConvertToRules(ConversionTransformer[VerifiedRules, VerifiedRules]):
|
|
|
590
595
|
def transform(self, rules: VerifiedRules) -> VerifiedRules:
|
|
591
596
|
if isinstance(rules, self._out_cls):
|
|
592
597
|
return rules
|
|
593
|
-
if isinstance(rules,
|
|
598
|
+
if isinstance(rules, ConceptualDataModel) and self._out_cls is DMSRules:
|
|
594
599
|
return InformationToDMS().transform(rules)
|
|
595
|
-
if isinstance(rules, DMSRules) and self._out_cls is
|
|
600
|
+
if isinstance(rules, DMSRules) and self._out_cls is ConceptualDataModel:
|
|
596
601
|
return DMSToInformation().transform(rules)
|
|
597
602
|
raise ValueError(f"Unsupported conversion from {type(rules)} to {self._out_cls}")
|
|
598
603
|
|
|
@@ -1203,12 +1208,12 @@ class IncludeReferenced(VerifiedRulesTransformer[DMSRules, DMSRules]):
|
|
|
1203
1208
|
return "Included referenced views and containers in the data model."
|
|
1204
1209
|
|
|
1205
1210
|
|
|
1206
|
-
class AddClassImplements(VerifiedRulesTransformer[
|
|
1211
|
+
class AddClassImplements(VerifiedRulesTransformer[ConceptualDataModel, ConceptualDataModel]):
|
|
1207
1212
|
def __init__(self, implements: str, suffix: str):
|
|
1208
1213
|
self.implements = implements
|
|
1209
1214
|
self.suffix = suffix
|
|
1210
1215
|
|
|
1211
|
-
def transform(self, rules:
|
|
1216
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
1212
1217
|
info_rules = rules
|
|
1213
1218
|
output = info_rules.model_copy(deep=True)
|
|
1214
1219
|
for class_ in output.classes:
|
|
@@ -1221,7 +1226,7 @@ class AddClassImplements(VerifiedRulesTransformer[InformationRules, InformationR
|
|
|
1221
1226
|
return f"Added implements property to classes with suffix {self.suffix}"
|
|
1222
1227
|
|
|
1223
1228
|
|
|
1224
|
-
class ClassicPrepareCore(VerifiedRulesTransformer[
|
|
1229
|
+
class ClassicPrepareCore(VerifiedRulesTransformer[ConceptualDataModel, ConceptualDataModel]):
|
|
1225
1230
|
"""Update the classic data model with the following:
|
|
1226
1231
|
|
|
1227
1232
|
This is a special purpose transformer that is only intended to be used with when reading
|
|
@@ -1250,14 +1255,14 @@ class ClassicPrepareCore(VerifiedRulesTransformer[InformationRules, InformationR
|
|
|
1250
1255
|
def description(self) -> str:
|
|
1251
1256
|
return "Update the classic data model to the data types in Cognite Core."
|
|
1252
1257
|
|
|
1253
|
-
def transform(self, rules:
|
|
1258
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
1254
1259
|
output = rules.model_copy(deep=True)
|
|
1255
1260
|
for prop in output.properties:
|
|
1256
1261
|
if prop.class_.suffix == "Timeseries" and prop.property_ == "isString":
|
|
1257
1262
|
prop.value_type = String()
|
|
1258
1263
|
prefix = output.metadata.prefix
|
|
1259
1264
|
namespace = output.metadata.namespace
|
|
1260
|
-
source_system_class =
|
|
1265
|
+
source_system_class = ConceptualClass(
|
|
1261
1266
|
class_=ClassEntity(prefix=prefix, suffix="ClassicSourceSystem"),
|
|
1262
1267
|
description="A source system that provides data to the data model.",
|
|
1263
1268
|
neatId=namespace["ClassicSourceSystem"],
|
|
@@ -1284,7 +1289,7 @@ class ClassicPrepareCore(VerifiedRulesTransformer[InformationRules, InformationR
|
|
|
1284
1289
|
raise NeatValueError("Instance namespace not found in the prefixes.")
|
|
1285
1290
|
|
|
1286
1291
|
output.properties.append(
|
|
1287
|
-
|
|
1292
|
+
ConceptualProperty(
|
|
1288
1293
|
neatId=namespace["ClassicSourceSystem/name"],
|
|
1289
1294
|
property_="name",
|
|
1290
1295
|
value_type=String(),
|
|
@@ -1363,11 +1368,11 @@ class MergeDMSRules(VerifiedRulesTransformer[DMSRules, DMSRules]):
|
|
|
1363
1368
|
return f"Merged with {self.extra.metadata.as_data_model_id()}"
|
|
1364
1369
|
|
|
1365
1370
|
|
|
1366
|
-
class MergeInformationRules(VerifiedRulesTransformer[
|
|
1367
|
-
def __init__(self, extra:
|
|
1371
|
+
class MergeInformationRules(VerifiedRulesTransformer[ConceptualDataModel, ConceptualDataModel]):
|
|
1372
|
+
def __init__(self, extra: ConceptualDataModel) -> None:
|
|
1368
1373
|
self.extra = extra
|
|
1369
1374
|
|
|
1370
|
-
def transform(self, rules:
|
|
1375
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
1371
1376
|
output = rules.model_copy(deep=True)
|
|
1372
1377
|
existing_classes = {cls.class_ for cls in output.classes}
|
|
1373
1378
|
for cls in self.extra.classes:
|
|
@@ -1386,7 +1391,7 @@ class MergeInformationRules(VerifiedRulesTransformer[InformationRules, Informati
|
|
|
1386
1391
|
class _InformationRulesConverter:
|
|
1387
1392
|
_start_or_end_node: ClassVar[frozenset[str]] = frozenset({"endNode", "end_node", "startNode", "start_node"})
|
|
1388
1393
|
|
|
1389
|
-
def __init__(self, information:
|
|
1394
|
+
def __init__(self, information: ConceptualDataModel, client: NeatClient | None = None):
|
|
1390
1395
|
self.rules = information
|
|
1391
1396
|
self.property_count_by_container: dict[ContainerEntity, int] = defaultdict(int)
|
|
1392
1397
|
self.client = client
|
|
@@ -1394,7 +1399,7 @@ class _InformationRulesConverter:
|
|
|
1394
1399
|
def as_dms_rules(
|
|
1395
1400
|
self, ignore_undefined_value_types: bool = False, reserved_properties: Literal["error", "warning"] = "error"
|
|
1396
1401
|
) -> "DMSRules":
|
|
1397
|
-
from cognite.neat.core.
|
|
1402
|
+
from cognite.neat.core._data_model.models.dms._rules import (
|
|
1398
1403
|
DMSContainer,
|
|
1399
1404
|
DMSProperty,
|
|
1400
1405
|
DMSRules,
|
|
@@ -1545,7 +1550,7 @@ class _InformationRulesConverter:
|
|
|
1545
1550
|
containers=SheetList[DMSContainer](containers),
|
|
1546
1551
|
)
|
|
1547
1552
|
|
|
1548
|
-
self.rules.
|
|
1553
|
+
self.rules.sync_with_physical_data_model(dms_rules)
|
|
1549
1554
|
|
|
1550
1555
|
return dms_rules
|
|
1551
1556
|
|
|
@@ -1582,7 +1587,7 @@ class _InformationRulesConverter:
|
|
|
1582
1587
|
def _create_container_constraint(
|
|
1583
1588
|
class_entities: Counter[ClassEntity],
|
|
1584
1589
|
default_space: str,
|
|
1585
|
-
class_by_entity: dict[ClassEntity,
|
|
1590
|
+
class_by_entity: dict[ClassEntity, ConceptualClass],
|
|
1586
1591
|
referenced_containers: Collection[ContainerEntity],
|
|
1587
1592
|
) -> list[ContainerEntity]:
|
|
1588
1593
|
constrains: list[ContainerEntity] = []
|
|
@@ -1595,8 +1600,8 @@ class _InformationRulesConverter:
|
|
|
1595
1600
|
return constrains
|
|
1596
1601
|
|
|
1597
1602
|
@classmethod
|
|
1598
|
-
def _convert_metadata_to_dms(cls, metadata:
|
|
1599
|
-
from cognite.neat.core.
|
|
1603
|
+
def _convert_metadata_to_dms(cls, metadata: ConceptualMetadata) -> "DMSMetadata":
|
|
1604
|
+
from cognite.neat.core._data_model.models.dms._rules import (
|
|
1600
1605
|
DMSMetadata,
|
|
1601
1606
|
)
|
|
1602
1607
|
|
|
@@ -1615,14 +1620,14 @@ class _InformationRulesConverter:
|
|
|
1615
1620
|
|
|
1616
1621
|
def _as_dms_property(
|
|
1617
1622
|
self,
|
|
1618
|
-
info_property:
|
|
1623
|
+
info_property: ConceptualProperty,
|
|
1619
1624
|
default_space: str,
|
|
1620
1625
|
default_version: str,
|
|
1621
1626
|
edge_classes: set[ClassEntity],
|
|
1622
1627
|
edge_value_types_by_class_property_pair: dict[tuple[ClassEntity, str], ClassEntity],
|
|
1623
1628
|
end_node_by_edge: dict[ClassEntity, ClassEntity],
|
|
1624
1629
|
) -> "DMSProperty":
|
|
1625
|
-
from cognite.neat.core.
|
|
1630
|
+
from cognite.neat.core._data_model.models.dms._rules import DMSProperty
|
|
1626
1631
|
|
|
1627
1632
|
# returns property type, which can be ObjectProperty or DatatypeProperty
|
|
1628
1633
|
value_type = self._get_value_type(
|
|
@@ -1674,7 +1679,7 @@ class _InformationRulesConverter:
|
|
|
1674
1679
|
|
|
1675
1680
|
@staticmethod
|
|
1676
1681
|
def _customize_cognite_property(
|
|
1677
|
-
prop:
|
|
1682
|
+
prop: ConceptualProperty,
|
|
1678
1683
|
cognite_prop: DMSProperty,
|
|
1679
1684
|
class_: ClassEntity,
|
|
1680
1685
|
default_space: str,
|
|
@@ -1742,7 +1747,7 @@ class _InformationRulesConverter:
|
|
|
1742
1747
|
|
|
1743
1748
|
@staticmethod
|
|
1744
1749
|
def _get_connection(
|
|
1745
|
-
prop:
|
|
1750
|
+
prop: ConceptualProperty,
|
|
1746
1751
|
value_type: DataType | ViewEntity | DMSUnknownEntity,
|
|
1747
1752
|
edge_value_types_by_class_property_pair: dict[tuple[ClassEntity, str], ClassEntity],
|
|
1748
1753
|
default_space: str,
|
|
@@ -1767,7 +1772,7 @@ class _InformationRulesConverter:
|
|
|
1767
1772
|
|
|
1768
1773
|
def _get_value_type(
|
|
1769
1774
|
self,
|
|
1770
|
-
prop:
|
|
1775
|
+
prop: ConceptualProperty,
|
|
1771
1776
|
default_space: str,
|
|
1772
1777
|
default_version: str,
|
|
1773
1778
|
edge_classes: set[ClassEntity],
|
|
@@ -1832,7 +1837,7 @@ class _InformationRulesConverter:
|
|
|
1832
1837
|
prefix = f"{prefix[:-1]}1"
|
|
1833
1838
|
return prefix
|
|
1834
1839
|
|
|
1835
|
-
def _get_container(self, prop:
|
|
1840
|
+
def _get_container(self, prop: ConceptualProperty, default_space: str) -> tuple[ContainerEntity, str]:
|
|
1836
1841
|
container_entity = prop.class_.as_container_entity(default_space)
|
|
1837
1842
|
|
|
1838
1843
|
while self.property_count_by_container[container_entity] >= DMS_CONTAINER_PROPERTY_SIZE_LIMIT:
|
|
@@ -1841,7 +1846,7 @@ class _InformationRulesConverter:
|
|
|
1841
1846
|
self.property_count_by_container[container_entity] += 1
|
|
1842
1847
|
return container_entity, prop.property_
|
|
1843
1848
|
|
|
1844
|
-
def _get_view_implements(self, cls_:
|
|
1849
|
+
def _get_view_implements(self, cls_: ConceptualClass, metadata: ConceptualMetadata) -> list[ViewEntity]:
|
|
1845
1850
|
implements = []
|
|
1846
1851
|
for parent in cls_.implements or []:
|
|
1847
1852
|
view_entity = parent.as_view_entity(metadata.prefix, metadata.version)
|
|
@@ -1930,20 +1935,20 @@ class _DMSRulesConverter:
|
|
|
1930
1935
|
|
|
1931
1936
|
def as_information_rules(
|
|
1932
1937
|
self,
|
|
1933
|
-
) -> "
|
|
1934
|
-
from cognite.neat.core.
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
+
) -> "ConceptualDataModel":
|
|
1939
|
+
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
1940
|
+
ConceptualClass,
|
|
1941
|
+
ConceptualDataModel,
|
|
1942
|
+
ConceptualProperty,
|
|
1938
1943
|
)
|
|
1939
1944
|
|
|
1940
1945
|
dms = self.dms.metadata
|
|
1941
1946
|
|
|
1942
1947
|
metadata = self._convert_metadata_to_info(dms)
|
|
1943
1948
|
|
|
1944
|
-
classes: list[
|
|
1949
|
+
classes: list[ConceptualClass] = []
|
|
1945
1950
|
for view in self.dms.views:
|
|
1946
|
-
info_class =
|
|
1951
|
+
info_class = ConceptualClass(
|
|
1947
1952
|
# we do not want a version in class as we use URI for the class
|
|
1948
1953
|
class_=ClassEntity(prefix=view.view.prefix, suffix=view.view.suffix),
|
|
1949
1954
|
description=view.description,
|
|
@@ -1967,7 +1972,7 @@ class _DMSRulesConverter:
|
|
|
1967
1972
|
instance_prefix = f"prefix_{len(prefixes) + 1}"
|
|
1968
1973
|
prefixes[instance_prefix] = self.instance_namespace
|
|
1969
1974
|
|
|
1970
|
-
properties: list[
|
|
1975
|
+
properties: list[ConceptualProperty] = []
|
|
1971
1976
|
value_type: DataType | ClassEntity | str
|
|
1972
1977
|
for property_ in self.dms.properties:
|
|
1973
1978
|
if isinstance(property_.value_type, DataType):
|
|
@@ -1982,7 +1987,7 @@ class _DMSRulesConverter:
|
|
|
1982
1987
|
else:
|
|
1983
1988
|
raise ValueError(f"Unsupported value type: {property_.value_type.type_}")
|
|
1984
1989
|
|
|
1985
|
-
info_property =
|
|
1990
|
+
info_property = ConceptualProperty(
|
|
1986
1991
|
# Removing version
|
|
1987
1992
|
class_=ClassEntity(suffix=property_.view.suffix, prefix=property_.view.prefix),
|
|
1988
1993
|
property_=property_.view_property,
|
|
@@ -1998,10 +2003,10 @@ class _DMSRulesConverter:
|
|
|
1998
2003
|
|
|
1999
2004
|
properties.append(info_property)
|
|
2000
2005
|
|
|
2001
|
-
info_rules =
|
|
2006
|
+
info_rules = ConceptualDataModel(
|
|
2002
2007
|
metadata=metadata,
|
|
2003
|
-
properties=SheetList[
|
|
2004
|
-
classes=SheetList[
|
|
2008
|
+
properties=SheetList[ConceptualProperty](properties),
|
|
2009
|
+
classes=SheetList[ConceptualClass](classes),
|
|
2005
2010
|
prefixes=prefixes,
|
|
2006
2011
|
)
|
|
2007
2012
|
|
|
@@ -2010,12 +2015,12 @@ class _DMSRulesConverter:
|
|
|
2010
2015
|
return info_rules
|
|
2011
2016
|
|
|
2012
2017
|
@classmethod
|
|
2013
|
-
def _convert_metadata_to_info(cls, metadata: DMSMetadata) -> "
|
|
2014
|
-
from cognite.neat.core.
|
|
2015
|
-
|
|
2018
|
+
def _convert_metadata_to_info(cls, metadata: DMSMetadata) -> "ConceptualMetadata":
|
|
2019
|
+
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
2020
|
+
ConceptualMetadata,
|
|
2016
2021
|
)
|
|
2017
2022
|
|
|
2018
|
-
return
|
|
2023
|
+
return ConceptualMetadata(
|
|
2019
2024
|
space=metadata.space,
|
|
2020
2025
|
external_id=metadata.external_id,
|
|
2021
2026
|
version=metadata.version,
|
|
@@ -2167,13 +2172,13 @@ class SubsetDMSRules(VerifiedRulesTransformer[DMSRules, DMSRules]):
|
|
|
2167
2172
|
raise NeatValueError(f"Cannot subset rules: {e}") from e
|
|
2168
2173
|
|
|
2169
2174
|
|
|
2170
|
-
class SubsetInformationRules(VerifiedRulesTransformer[
|
|
2175
|
+
class SubsetInformationRules(VerifiedRulesTransformer[ConceptualDataModel, ConceptualDataModel]):
|
|
2171
2176
|
"""Subsets InformationRules to only include the specified classes."""
|
|
2172
2177
|
|
|
2173
2178
|
def __init__(self, classes: set[ClassEntity]):
|
|
2174
2179
|
self._classes = classes
|
|
2175
2180
|
|
|
2176
|
-
def transform(self, rules:
|
|
2181
|
+
def transform(self, rules: ConceptualDataModel) -> ConceptualDataModel:
|
|
2177
2182
|
analysis = RulesAnalysis(information=rules)
|
|
2178
2183
|
|
|
2179
2184
|
class_by_class_entity = analysis.class_by_class_entity
|
|
@@ -2203,8 +2208,8 @@ class SubsetInformationRules(VerifiedRulesTransformer[InformationRules, Informat
|
|
|
2203
2208
|
subsetted_rules: dict[str, Any] = {
|
|
2204
2209
|
"metadata": rules.metadata.model_copy(),
|
|
2205
2210
|
"prefixes": (rules.prefixes or {}).copy(),
|
|
2206
|
-
"classes": SheetList[
|
|
2207
|
-
"properties": SheetList[
|
|
2211
|
+
"classes": SheetList[ConceptualClass](),
|
|
2212
|
+
"properties": SheetList[ConceptualProperty](),
|
|
2208
2213
|
}
|
|
2209
2214
|
|
|
2210
2215
|
for class_ in subset:
|
|
@@ -2233,12 +2238,17 @@ class SubsetInformationRules(VerifiedRulesTransformer[InformationRules, Informat
|
|
|
2233
2238
|
)
|
|
2234
2239
|
|
|
2235
2240
|
try:
|
|
2236
|
-
return
|
|
2241
|
+
return ConceptualDataModel.model_validate(subsetted_rules)
|
|
2237
2242
|
except ValidationError as e:
|
|
2238
2243
|
raise NeatValueError(f"Cannot subset rules: {e}") from e
|
|
2239
2244
|
|
|
2240
2245
|
|
|
2241
|
-
class AddCogniteProperties(
|
|
2246
|
+
class AddCogniteProperties(
|
|
2247
|
+
RulesTransformer[
|
|
2248
|
+
ReadRules[UnverifiedConceptualDataModel],
|
|
2249
|
+
ReadRules[UnverifiedConceptualDataModel],
|
|
2250
|
+
]
|
|
2251
|
+
):
|
|
2242
2252
|
"""This transformer looks at the implements of the classes and adds all properties
|
|
2243
2253
|
from the parent (and ancestors) classes that are not already included in the data model.
|
|
2244
2254
|
|
|
@@ -2257,7 +2267,7 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2257
2267
|
"""Get the description of the transformer."""
|
|
2258
2268
|
return "Add Cognite properties for all concepts that implements a Cognite concept."
|
|
2259
2269
|
|
|
2260
|
-
def transform(self, rules: ReadRules[
|
|
2270
|
+
def transform(self, rules: ReadRules[UnverifiedConceptualDataModel]) -> ReadRules[UnverifiedConceptualDataModel]:
|
|
2261
2271
|
input_ = rules.rules
|
|
2262
2272
|
if input_ is None:
|
|
2263
2273
|
raise NeatValueError("Rule read failed. Cannot add cognite properties to None rules.")
|
|
@@ -2283,7 +2293,7 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2283
2293
|
except CycleError as e:
|
|
2284
2294
|
raise NeatValueError(f"Cycle detected in the class hierarchy: {e}") from e
|
|
2285
2295
|
|
|
2286
|
-
new_properties: list[
|
|
2296
|
+
new_properties: list[UnverifiedConceptualProperty] = input_.properties.copy()
|
|
2287
2297
|
for class_entity in topological_order:
|
|
2288
2298
|
if class_entity not in dependencies_by_class:
|
|
2289
2299
|
continue
|
|
@@ -2296,7 +2306,7 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2296
2306
|
|
|
2297
2307
|
if self._dummy_property:
|
|
2298
2308
|
new_properties.append(
|
|
2299
|
-
|
|
2309
|
+
UnverifiedConceptualProperty(
|
|
2300
2310
|
class_=class_entity,
|
|
2301
2311
|
property_=f"{to_camel_case(class_entity.suffix)}{self._dummy_property}",
|
|
2302
2312
|
value_type=String(),
|
|
@@ -2305,7 +2315,7 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2305
2315
|
)
|
|
2306
2316
|
)
|
|
2307
2317
|
|
|
2308
|
-
new_classes: list[
|
|
2318
|
+
new_classes: list[UnverifiedConceptualClass] = input_.classes.copy()
|
|
2309
2319
|
existing_classes = {cls.class_ for cls in input_.classes}
|
|
2310
2320
|
for class_entity, view in views_by_class_entity.items():
|
|
2311
2321
|
if class_entity not in existing_classes:
|
|
@@ -2313,7 +2323,7 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2313
2323
|
existing_classes.add(class_entity)
|
|
2314
2324
|
|
|
2315
2325
|
return ReadRules(
|
|
2316
|
-
rules=
|
|
2326
|
+
rules=UnverifiedConceptualDataModel(
|
|
2317
2327
|
metadata=input_.metadata,
|
|
2318
2328
|
properties=new_properties,
|
|
2319
2329
|
classes=new_classes,
|
|
@@ -2324,10 +2334,12 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2324
2334
|
|
|
2325
2335
|
@staticmethod
|
|
2326
2336
|
def _get_properties_by_class(
|
|
2327
|
-
properties: list[
|
|
2328
|
-
|
|
2337
|
+
properties: list[UnverifiedConceptualProperty],
|
|
2338
|
+
read_context: dict[str, SpreadsheetRead],
|
|
2339
|
+
default_space: str,
|
|
2340
|
+
) -> dict[ClassEntity, dict[str, UnverifiedConceptualProperty]]:
|
|
2329
2341
|
issues = IssueList()
|
|
2330
|
-
properties_by_class: dict[ClassEntity, dict[str,
|
|
2342
|
+
properties_by_class: dict[ClassEntity, dict[str, UnverifiedConceptualProperty]] = defaultdict(dict)
|
|
2331
2343
|
for prop in properties:
|
|
2332
2344
|
try:
|
|
2333
2345
|
dumped = prop.dump(default_prefix=default_space)
|
|
@@ -2342,7 +2354,9 @@ class AddCogniteProperties(RulesTransformer[ReadRules[InformationInputRules], Re
|
|
|
2342
2354
|
|
|
2343
2355
|
@staticmethod
|
|
2344
2356
|
def _get_dependencies_by_class(
|
|
2345
|
-
classes: list[
|
|
2357
|
+
classes: list[UnverifiedConceptualClass],
|
|
2358
|
+
read_context: dict[str, SpreadsheetRead],
|
|
2359
|
+
default_space: str,
|
|
2346
2360
|
) -> dict[ClassEntity, set[ClassEntity]]:
|
|
2347
2361
|
dependencies_by_class: dict[ClassEntity, set[ClassEntity]] = {}
|
|
2348
2362
|
issues = IssueList()
|
|
@@ -6,20 +6,20 @@ from typing import Any, ClassVar, Literal
|
|
|
6
6
|
from cognite.client import data_modeling as dm
|
|
7
7
|
|
|
8
8
|
from cognite.neat.core._client import NeatClient
|
|
9
|
+
from cognite.neat.core._data_model.models import DMSRules, SheetList
|
|
10
|
+
from cognite.neat.core._data_model.models.data_types import Enum
|
|
11
|
+
from cognite.neat.core._data_model.models.dms import DMSContainer, DMSEnum, DMSProperty
|
|
12
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
13
|
+
ClassEntity,
|
|
14
|
+
ContainerEntity,
|
|
15
|
+
ViewEntity,
|
|
16
|
+
)
|
|
9
17
|
from cognite.neat.core._issues.errors import (
|
|
10
18
|
CDFMissingClientError,
|
|
11
19
|
NeatValueError,
|
|
12
20
|
ResourceNotFoundError,
|
|
13
21
|
)
|
|
14
22
|
from cognite.neat.core._issues.warnings import PropertyOverwritingWarning
|
|
15
|
-
from cognite.neat.core._rules.models import DMSRules, SheetList
|
|
16
|
-
from cognite.neat.core._rules.models.data_types import Enum
|
|
17
|
-
from cognite.neat.core._rules.models.dms import DMSContainer, DMSEnum, DMSProperty
|
|
18
|
-
from cognite.neat.core._rules.models.entities import (
|
|
19
|
-
ClassEntity,
|
|
20
|
-
ContainerEntity,
|
|
21
|
-
ViewEntity,
|
|
22
|
-
)
|
|
23
23
|
|
|
24
24
|
from ._base import VerifiedRulesTransformer
|
|
25
25
|
|