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
|
@@ -14,21 +14,21 @@ from pydantic import (
|
|
|
14
14
|
)
|
|
15
15
|
from pydantic.functional_serializers import PlainSerializer
|
|
16
16
|
|
|
17
|
-
from cognite.neat.core.
|
|
18
|
-
from cognite.neat.core._issues.warnings import RegexViolationWarning
|
|
19
|
-
from cognite.neat.core._rules._constants import (
|
|
17
|
+
from cognite.neat.core._data_model._constants import (
|
|
20
18
|
DATA_MODEL_COMPLIANCE_REGEX,
|
|
21
19
|
PATTERNS,
|
|
22
20
|
PREFIX_COMPLIANCE_REGEX,
|
|
23
21
|
VERSION_COMPLIANCE_REGEX,
|
|
24
22
|
EntityTypes,
|
|
25
23
|
)
|
|
26
|
-
from cognite.neat.core.
|
|
27
|
-
from cognite.neat.core.
|
|
24
|
+
from cognite.neat.core._data_model.models.entities._multi_value import MultiValueTypeInfo
|
|
25
|
+
from cognite.neat.core._data_model.models.entities._single_value import (
|
|
28
26
|
ClassEntity,
|
|
29
27
|
ContainerEntity,
|
|
30
28
|
ViewEntity,
|
|
31
29
|
)
|
|
30
|
+
from cognite.neat.core._issues.errors import RegexViolationError
|
|
31
|
+
from cognite.neat.core._issues.warnings import RegexViolationWarning
|
|
32
32
|
|
|
33
33
|
Entities: TypeAlias = ClassEntity | ViewEntity | ContainerEntity
|
|
34
34
|
T_Entities = TypeVar("T_Entities", bound=Entities)
|
|
@@ -135,9 +135,9 @@ SpaceType = Annotated[
|
|
|
135
135
|
AfterValidator(_external_id_validation_factory(EntityTypes.space, "")),
|
|
136
136
|
]
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
ConceptualPropertyType = Annotated[
|
|
139
139
|
str,
|
|
140
|
-
AfterValidator(_external_id_validation_factory(EntityTypes.
|
|
140
|
+
AfterValidator(_external_id_validation_factory(EntityTypes.conceptual_property, "Property column in properties")),
|
|
141
141
|
]
|
|
142
142
|
DmsPropertyType = Annotated[
|
|
143
143
|
str,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from ._unverified import (
|
|
2
|
+
UnverifiedConceptualClass,
|
|
3
|
+
UnverifiedConceptualDataModel,
|
|
4
|
+
UnverifiedConceptualMetadata,
|
|
5
|
+
UnverifiedConceptualProperty,
|
|
6
|
+
)
|
|
7
|
+
from ._validation import InformationValidation
|
|
8
|
+
from ._verified import (
|
|
9
|
+
ConceptualClass,
|
|
10
|
+
ConceptualDataModel,
|
|
11
|
+
ConceptualMetadata,
|
|
12
|
+
ConceptualProperty,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ConceptualClass",
|
|
17
|
+
"ConceptualDataModel",
|
|
18
|
+
"ConceptualMetadata",
|
|
19
|
+
"ConceptualProperty",
|
|
20
|
+
"InformationValidation",
|
|
21
|
+
"UnverifiedConceptualClass",
|
|
22
|
+
"UnverifiedConceptualDataModel",
|
|
23
|
+
"UnverifiedConceptualMetadata",
|
|
24
|
+
"UnverifiedConceptualProperty",
|
|
25
|
+
]
|
|
@@ -7,9 +7,12 @@ from cognite.client import data_modeling as dm
|
|
|
7
7
|
from rdflib import Namespace, URIRef
|
|
8
8
|
|
|
9
9
|
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
10
|
-
from cognite.neat.core.
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
from cognite.neat.core._data_model.models._base_unverified import (
|
|
11
|
+
UnverifiedComponent,
|
|
12
|
+
UnverifiedDataModel,
|
|
13
|
+
)
|
|
14
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
15
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
13
16
|
ClassEntity,
|
|
14
17
|
MultiValueTypeInfo,
|
|
15
18
|
UnknownEntity,
|
|
@@ -17,16 +20,16 @@ from cognite.neat.core._rules.models.entities import (
|
|
|
17
20
|
)
|
|
18
21
|
from cognite.neat.core._utils.rdf_ import uri_display_name
|
|
19
22
|
|
|
20
|
-
from .
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
from ._verified import (
|
|
24
|
+
ConceptualClass,
|
|
25
|
+
ConceptualDataModel,
|
|
26
|
+
ConceptualMetadata,
|
|
27
|
+
ConceptualProperty,
|
|
25
28
|
)
|
|
26
29
|
|
|
27
30
|
|
|
28
31
|
@dataclass
|
|
29
|
-
class
|
|
32
|
+
class UnverifiedConceptualMetadata(UnverifiedComponent[ConceptualMetadata]):
|
|
30
33
|
space: str
|
|
31
34
|
external_id: str
|
|
32
35
|
version: str
|
|
@@ -36,12 +39,11 @@ class InformationInputMetadata(InputComponent[InformationMetadata]):
|
|
|
36
39
|
created: datetime | str | None = None
|
|
37
40
|
updated: datetime | str | None = None
|
|
38
41
|
physical: str | URIRef | None = None
|
|
39
|
-
conceptual: str | URIRef | None = None
|
|
40
42
|
source_id: str | URIRef | None = None
|
|
41
43
|
|
|
42
44
|
@classmethod
|
|
43
|
-
def _get_verified_cls(cls) -> type[
|
|
44
|
-
return
|
|
45
|
+
def _get_verified_cls(cls) -> type[ConceptualMetadata]:
|
|
46
|
+
return ConceptualMetadata
|
|
45
47
|
|
|
46
48
|
def dump(self, **kwargs: Any) -> dict[str, Any]:
|
|
47
49
|
output = super().dump()
|
|
@@ -75,7 +77,7 @@ class InformationInputMetadata(InputComponent[InformationMetadata]):
|
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
@dataclass
|
|
78
|
-
class
|
|
80
|
+
class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
|
|
79
81
|
class_: ClassEntity | str
|
|
80
82
|
property_: str
|
|
81
83
|
value_type: DataType | ClassEntity | MultiValueTypeInfo | UnknownEntity | str
|
|
@@ -91,11 +93,10 @@ class InformationInputProperty(InputComponent[InformationProperty]):
|
|
|
91
93
|
|
|
92
94
|
# linking
|
|
93
95
|
physical: str | URIRef | None = None
|
|
94
|
-
conceptual: str | URIRef | None = None
|
|
95
96
|
|
|
96
97
|
@classmethod
|
|
97
|
-
def _get_verified_cls(cls) -> type[
|
|
98
|
-
return
|
|
98
|
+
def _get_verified_cls(cls) -> type[ConceptualProperty]:
|
|
99
|
+
return ConceptualProperty
|
|
99
100
|
|
|
100
101
|
def dump(self, default_prefix: str, **kwargs) -> dict[str, Any]: # type: ignore
|
|
101
102
|
output = super().dump()
|
|
@@ -103,12 +104,15 @@ class InformationInputProperty(InputComponent[InformationProperty]):
|
|
|
103
104
|
output["Value Type"] = load_value_type(self.value_type, default_prefix)
|
|
104
105
|
return output
|
|
105
106
|
|
|
106
|
-
def copy(self, update: dict[str, Any], default_prefix: str) -> "
|
|
107
|
-
return cast(
|
|
107
|
+
def copy(self, update: dict[str, Any], default_prefix: str) -> "UnverifiedConceptualProperty":
|
|
108
|
+
return cast(
|
|
109
|
+
UnverifiedConceptualProperty,
|
|
110
|
+
type(self)._load({**self.dump(default_prefix), **update}),
|
|
111
|
+
)
|
|
108
112
|
|
|
109
113
|
|
|
110
114
|
@dataclass
|
|
111
|
-
class
|
|
115
|
+
class UnverifiedConceptualClass(UnverifiedComponent[ConceptualClass]):
|
|
112
116
|
class_: ClassEntity | str
|
|
113
117
|
name: str | None = None
|
|
114
118
|
description: str | None = None
|
|
@@ -117,11 +121,10 @@ class InformationInputClass(InputComponent[InformationClass]):
|
|
|
117
121
|
neatId: str | URIRef | None = None
|
|
118
122
|
# linking
|
|
119
123
|
physical: str | URIRef | None = None
|
|
120
|
-
conceptual: str | URIRef | None = None
|
|
121
124
|
|
|
122
125
|
@classmethod
|
|
123
|
-
def _get_verified_cls(cls) -> type[
|
|
124
|
-
return
|
|
126
|
+
def _get_verified_cls(cls) -> type[ConceptualClass]:
|
|
127
|
+
return ConceptualClass
|
|
125
128
|
|
|
126
129
|
@property
|
|
127
130
|
def class_str(self) -> str:
|
|
@@ -141,15 +144,15 @@ class InformationInputClass(InputComponent[InformationClass]):
|
|
|
141
144
|
|
|
142
145
|
|
|
143
146
|
@dataclass
|
|
144
|
-
class
|
|
145
|
-
metadata:
|
|
146
|
-
properties: list[
|
|
147
|
-
classes: list[
|
|
147
|
+
class UnverifiedConceptualDataModel(UnverifiedDataModel[ConceptualDataModel]):
|
|
148
|
+
metadata: UnverifiedConceptualMetadata
|
|
149
|
+
properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
|
|
150
|
+
classes: list[UnverifiedConceptualClass] = field(default_factory=list)
|
|
148
151
|
prefixes: dict[str, Namespace] | None = None
|
|
149
152
|
|
|
150
153
|
@classmethod
|
|
151
|
-
def _get_verified_cls(cls) -> type[
|
|
152
|
-
return
|
|
154
|
+
def _get_verified_cls(cls) -> type[ConceptualDataModel]:
|
|
155
|
+
return ConceptualDataModel
|
|
153
156
|
|
|
154
157
|
def dump(self) -> dict[str, Any]:
|
|
155
158
|
default_prefix = self.metadata.prefix
|
cognite/neat/core/{_rules/models/information → _data_model/models/conceptual}/_validation.py
RENAMED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import itertools
|
|
2
2
|
from collections import Counter, defaultdict
|
|
3
3
|
|
|
4
|
+
from cognite.neat.core._data_model._constants import PATTERNS, EntityTypes
|
|
5
|
+
from cognite.neat.core._data_model.models.entities import ClassEntity, UnknownEntity
|
|
6
|
+
from cognite.neat.core._data_model.models.entities._multi_value import MultiValueTypeInfo
|
|
4
7
|
from cognite.neat.core._issues import IssueList
|
|
5
8
|
from cognite.neat.core._issues.errors import NeatValueError
|
|
6
9
|
from cognite.neat.core._issues.errors._resources import (
|
|
@@ -12,20 +15,21 @@ from cognite.neat.core._issues.warnings._resources import (
|
|
|
12
15
|
ResourceNotDefinedWarning,
|
|
13
16
|
ResourceRegexViolationWarning,
|
|
14
17
|
)
|
|
15
|
-
from cognite.neat.core._rules._constants import PATTERNS, EntityTypes
|
|
16
|
-
from cognite.neat.core._rules.models.entities import ClassEntity, UnknownEntity
|
|
17
|
-
from cognite.neat.core._rules.models.entities._multi_value import MultiValueTypeInfo
|
|
18
18
|
from cognite.neat.core._utils.spreadsheet import SpreadsheetRead
|
|
19
19
|
from cognite.neat.core._utils.text import humanize_collection
|
|
20
20
|
|
|
21
|
-
from .
|
|
21
|
+
from ._verified import ConceptualDataModel
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class InformationValidation:
|
|
25
25
|
"""This class does all the validation of the Information rules that have dependencies
|
|
26
26
|
between components."""
|
|
27
27
|
|
|
28
|
-
def __init__(
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
rules: ConceptualDataModel,
|
|
31
|
+
read_info_by_spreadsheet: dict[str, SpreadsheetRead] | None = None,
|
|
32
|
+
):
|
|
29
33
|
self.rules = rules
|
|
30
34
|
self._read_info_by_spreadsheet = read_info_by_spreadsheet or {}
|
|
31
35
|
self._metadata = rules.metadata
|
cognite/neat/core/{_rules/models/information/_rules.py → _data_model/models/conceptual/_verified.py}
RENAMED
|
@@ -8,52 +8,51 @@ from pydantic_core.core_schema import SerializationInfo
|
|
|
8
8
|
from rdflib import Namespace, URIRef
|
|
9
9
|
|
|
10
10
|
from cognite.neat.core._constants import get_default_prefixes_and_namespaces
|
|
11
|
-
from cognite.neat.core.
|
|
12
|
-
from cognite.neat.core.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
DataModelAspect,
|
|
11
|
+
from cognite.neat.core._data_model._constants import EntityTypes
|
|
12
|
+
from cognite.neat.core._data_model.models._base_verified import (
|
|
13
|
+
BaseVerifiedDataModel,
|
|
14
|
+
BaseVerifiedMetadata,
|
|
15
|
+
DataModelLevel,
|
|
17
16
|
RoleTypes,
|
|
18
17
|
SheetList,
|
|
19
18
|
SheetRow,
|
|
20
19
|
)
|
|
21
|
-
from cognite.neat.core.
|
|
20
|
+
from cognite.neat.core._data_model.models._types import (
|
|
22
21
|
ClassEntityType,
|
|
23
|
-
|
|
22
|
+
ConceptualPropertyType,
|
|
24
23
|
MultiValueTypeType,
|
|
25
24
|
URIRefType,
|
|
26
25
|
)
|
|
27
26
|
|
|
28
27
|
# NeatIdType,
|
|
29
|
-
from cognite.neat.core.
|
|
30
|
-
from cognite.neat.core.
|
|
28
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
29
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
31
30
|
ClassEntity,
|
|
32
31
|
ClassEntityList,
|
|
33
32
|
Entity,
|
|
34
33
|
UnknownEntity,
|
|
35
34
|
)
|
|
35
|
+
from cognite.neat.core._issues.errors import PropertyDefinitionError
|
|
36
36
|
|
|
37
37
|
if TYPE_CHECKING:
|
|
38
|
-
from cognite.neat.core.
|
|
38
|
+
from cognite.neat.core._data_model.models import DMSRules
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
class
|
|
41
|
+
class ConceptualMetadata(BaseVerifiedMetadata):
|
|
42
42
|
role: ClassVar[RoleTypes] = RoleTypes.information
|
|
43
|
-
|
|
43
|
+
level: ClassVar[DataModelLevel] = DataModelLevel.conceptual
|
|
44
44
|
|
|
45
45
|
# Linking to Conceptual and Physical data model aspects
|
|
46
46
|
physical: URIRef | str | None = Field(None, description="Link to the physical data model aspect")
|
|
47
|
-
conceptual: URIRef | str | None = Field(None, description="Link to the conceptual data model aspect")
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
def _get_metadata(context: Any) ->
|
|
51
|
-
if isinstance(context, dict) and isinstance(context.get("metadata"),
|
|
49
|
+
def _get_metadata(context: Any) -> ConceptualMetadata | None:
|
|
50
|
+
if isinstance(context, dict) and isinstance(context.get("metadata"), ConceptualMetadata):
|
|
52
51
|
return context["metadata"]
|
|
53
52
|
return None
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
class
|
|
55
|
+
class ConceptualClass(SheetRow):
|
|
57
56
|
"""
|
|
58
57
|
Class is a category of things that share a common set of attributes and relationships.
|
|
59
58
|
|
|
@@ -82,7 +81,6 @@ class InformationClass(SheetRow):
|
|
|
82
81
|
None,
|
|
83
82
|
description="Link to the class representation in the physical data model aspect",
|
|
84
83
|
)
|
|
85
|
-
conceptual: URIRefType | None = Field(None, description="Link to the conceptual data model aspect")
|
|
86
84
|
|
|
87
85
|
def _identifier(self) -> tuple[Hashable, ...]:
|
|
88
86
|
return (self.class_,)
|
|
@@ -107,7 +105,7 @@ class InformationClass(SheetRow):
|
|
|
107
105
|
return ",".join(str(value) for value in value)
|
|
108
106
|
|
|
109
107
|
|
|
110
|
-
class
|
|
108
|
+
class ConceptualProperty(SheetRow):
|
|
111
109
|
"""
|
|
112
110
|
A property is a characteristic of a class. It is a named attribute of a class that describes a range of values
|
|
113
111
|
or a relationship to another class.
|
|
@@ -127,8 +125,9 @@ class InformationProperty(SheetRow):
|
|
|
127
125
|
class_: ClassEntityType = Field(
|
|
128
126
|
alias="Class", description="Class id that the property is defined for, strongly advise `PascalCase` usage."
|
|
129
127
|
)
|
|
130
|
-
property_:
|
|
131
|
-
alias="Property",
|
|
128
|
+
property_: ConceptualPropertyType = Field(
|
|
129
|
+
alias="Property",
|
|
130
|
+
description="Property id, strongly advised to `camelCase` usage.",
|
|
132
131
|
)
|
|
133
132
|
name: str | None = Field(alias="Name", default=None, description="Human readable name of the property.")
|
|
134
133
|
description: str | None = Field(alias="Description", default=None, description="Short description of the property.")
|
|
@@ -168,7 +167,6 @@ class InformationProperty(SheetRow):
|
|
|
168
167
|
None,
|
|
169
168
|
description="Link to the class representation in the physical data model aspect",
|
|
170
169
|
)
|
|
171
|
-
conceptual: URIRefType | None = Field(None, description="Link to the conceptual data model aspect")
|
|
172
170
|
|
|
173
171
|
def _identifier(self) -> tuple[Hashable, ...]:
|
|
174
172
|
return self.class_, self.property_
|
|
@@ -239,14 +237,14 @@ class InformationProperty(SheetRow):
|
|
|
239
237
|
return EntityTypes.undefined
|
|
240
238
|
|
|
241
239
|
|
|
242
|
-
class
|
|
243
|
-
metadata:
|
|
244
|
-
properties: SheetList[
|
|
245
|
-
classes: SheetList[
|
|
240
|
+
class ConceptualDataModel(BaseVerifiedDataModel):
|
|
241
|
+
metadata: ConceptualMetadata = Field(alias="Metadata", description="Metadata for the conceptual data model")
|
|
242
|
+
properties: SheetList[ConceptualProperty] = Field(alias="Properties", description="List of properties")
|
|
243
|
+
classes: SheetList[ConceptualClass] = Field(alias="Classes", description="List of classes")
|
|
246
244
|
prefixes: dict[str, Namespace] = Field(
|
|
247
245
|
alias="Prefixes",
|
|
248
246
|
default_factory=get_default_prefixes_and_namespaces,
|
|
249
|
-
description="the definition of the prefixes that are used in the
|
|
247
|
+
description="the definition of the prefixes that are used in the conceptual data model",
|
|
250
248
|
)
|
|
251
249
|
|
|
252
250
|
@field_validator("prefixes", mode="before")
|
|
@@ -258,7 +256,7 @@ class InformationRules(BaseRules):
|
|
|
258
256
|
return values
|
|
259
257
|
|
|
260
258
|
@model_validator(mode="after")
|
|
261
|
-
def set_neat_id(self) -> "
|
|
259
|
+
def set_neat_id(self) -> "ConceptualDataModel":
|
|
262
260
|
namespace = self.metadata.namespace
|
|
263
261
|
|
|
264
262
|
for class_ in self.classes:
|
|
@@ -280,7 +278,7 @@ class InformationRules(BaseRules):
|
|
|
280
278
|
for property_ in self.properties:
|
|
281
279
|
property_.neatId = namespace[f"{property_.class_.suffix}/{property_.property_}"]
|
|
282
280
|
|
|
283
|
-
def
|
|
281
|
+
def sync_with_physical_data_model(self, dms_rules: "DMSRules") -> None:
|
|
284
282
|
# Sync at the metadata level
|
|
285
283
|
if dms_rules.metadata.logical == self.metadata.identifier:
|
|
286
284
|
self.metadata.physical = dms_rules.metadata.identifier
|
|
@@ -288,20 +286,20 @@ class InformationRules(BaseRules):
|
|
|
288
286
|
# if models are not linked to start with, we skip
|
|
289
287
|
return None
|
|
290
288
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
for neat_id, prop in
|
|
294
|
-
if prop.logical in
|
|
295
|
-
|
|
289
|
+
conceptual_properties_by_neat_id = {prop.neatId: prop for prop in self.properties}
|
|
290
|
+
physical_properties_by_neat_id = {prop.neatId: prop for prop in dms_rules.properties}
|
|
291
|
+
for neat_id, prop in physical_properties_by_neat_id.items():
|
|
292
|
+
if prop.logical in conceptual_properties_by_neat_id:
|
|
293
|
+
conceptual_properties_by_neat_id[prop.logical].physical = neat_id
|
|
296
294
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
for neat_id, view in
|
|
300
|
-
if view.logical in
|
|
301
|
-
|
|
295
|
+
classes_by_neat_id = {cls.neatId: cls for cls in self.classes}
|
|
296
|
+
views_by_neat_id = {view.neatId: view for view in dms_rules.views}
|
|
297
|
+
for neat_id, view in views_by_neat_id.items():
|
|
298
|
+
if view.logical in classes_by_neat_id:
|
|
299
|
+
classes_by_neat_id[view.logical].physical = neat_id
|
|
302
300
|
|
|
303
301
|
def as_dms_rules(self) -> "DMSRules":
|
|
304
|
-
from cognite.neat.core.
|
|
302
|
+
from cognite.neat.core._data_model.transformers._converters import (
|
|
305
303
|
_InformationRulesConverter,
|
|
306
304
|
)
|
|
307
305
|
|
|
@@ -309,11 +307,11 @@ class InformationRules(BaseRules):
|
|
|
309
307
|
|
|
310
308
|
@classmethod
|
|
311
309
|
def display_type_name(cls) -> str:
|
|
312
|
-
return "
|
|
310
|
+
return "VerifiedConceptualDataModel"
|
|
313
311
|
|
|
314
312
|
def _repr_html_(self) -> str:
|
|
315
313
|
summary = {
|
|
316
|
-
"type": "
|
|
314
|
+
"type": "Conceptual Data Model",
|
|
317
315
|
"intended for": "Information Architect",
|
|
318
316
|
"name": self.metadata.name,
|
|
319
317
|
"external_id": self.metadata.external_id,
|
|
@@ -11,11 +11,11 @@ from pydantic.functional_validators import ModelWrapValidatorHandler
|
|
|
11
11
|
from rdflib import URIRef
|
|
12
12
|
|
|
13
13
|
from cognite.neat.core._constants import XML_SCHEMA_NAMESPACE
|
|
14
|
-
from cognite.neat.core.
|
|
14
|
+
from cognite.neat.core._data_model._constants import (
|
|
15
15
|
SPLIT_ON_COMMA_PATTERN,
|
|
16
16
|
SPLIT_ON_EQUAL_PATTERN,
|
|
17
17
|
)
|
|
18
|
-
from cognite.neat.core.
|
|
18
|
+
from cognite.neat.core._data_model.models.entities._single_value import (
|
|
19
19
|
ClassEntity,
|
|
20
20
|
UnitEntity,
|
|
21
21
|
)
|
|
@@ -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
|
+
ClassEntity,
|
|
31
|
+
ContainerEntity,
|
|
32
|
+
DMSFilter,
|
|
33
|
+
DMSNodeEntity,
|
|
34
|
+
DMSUnknownEntity,
|
|
35
|
+
EdgeEntity,
|
|
36
|
+
HasDataFilter,
|
|
37
|
+
NodeTypeFilter,
|
|
38
|
+
ReverseConnectionEntity,
|
|
39
|
+
UnitEntity,
|
|
40
|
+
ViewEntity,
|
|
41
|
+
)
|
|
28
42
|
from cognite.neat.core._issues.errors import (
|
|
29
43
|
NeatTypeError,
|
|
30
44
|
NeatValueError,
|
|
@@ -38,20 +52,6 @@ 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
56
|
from ._rules import DMSEnum, DMSMetadata, DMSProperty, DMSRules, DMSView
|
|
57
57
|
|
|
@@ -10,20 +10,18 @@ from pydantic_core.core_schema import SerializationInfo, ValidationInfo
|
|
|
10
10
|
|
|
11
11
|
from cognite.neat.core._client.data_classes.schema import DMSSchema
|
|
12
12
|
from cognite.neat.core._constants import DMS_CONTAINER_LIST_MAX_LIMIT
|
|
13
|
-
from cognite.neat.core.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
BaseMetadata,
|
|
17
|
-
BaseRules,
|
|
13
|
+
from cognite.neat.core._data_model.models._base_verified import (
|
|
14
|
+
BaseVerifiedDataModel,
|
|
15
|
+
BaseVerifiedMetadata,
|
|
18
16
|
ContainerProperty,
|
|
19
|
-
|
|
17
|
+
DataModelLevel,
|
|
20
18
|
RoleTypes,
|
|
21
19
|
SheetList,
|
|
22
20
|
SheetRow,
|
|
23
21
|
ViewProperty,
|
|
24
22
|
ViewRef,
|
|
25
23
|
)
|
|
26
|
-
from cognite.neat.core.
|
|
24
|
+
from cognite.neat.core._data_model.models._types import (
|
|
27
25
|
ClassEntityType,
|
|
28
26
|
ContainerEntityType,
|
|
29
27
|
DmsPropertyType,
|
|
@@ -31,8 +29,8 @@ from cognite.neat.core._rules.models._types import (
|
|
|
31
29
|
URIRefType,
|
|
32
30
|
ViewEntityType,
|
|
33
31
|
)
|
|
34
|
-
from cognite.neat.core.
|
|
35
|
-
from cognite.neat.core.
|
|
32
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
33
|
+
from cognite.neat.core._data_model.models.entities import (
|
|
36
34
|
ContainerEntityList,
|
|
37
35
|
DMSEntity,
|
|
38
36
|
DMSNodeEntity,
|
|
@@ -46,16 +44,18 @@ from cognite.neat.core._rules.models.entities import (
|
|
|
46
44
|
ViewEntity,
|
|
47
45
|
ViewEntityList,
|
|
48
46
|
)
|
|
47
|
+
from cognite.neat.core._issues.errors import NeatValueError
|
|
48
|
+
from cognite.neat.core._issues.warnings._general import NeatValueWarning
|
|
49
49
|
|
|
50
50
|
if TYPE_CHECKING:
|
|
51
|
-
from cognite.neat.core.
|
|
51
|
+
from cognite.neat.core._data_model.models import ConceptualDataModel
|
|
52
52
|
|
|
53
53
|
_DEFAULT_VERSION = "1"
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
class DMSMetadata(
|
|
56
|
+
class DMSMetadata(BaseVerifiedMetadata):
|
|
57
57
|
role: ClassVar[RoleTypes] = RoleTypes.dms
|
|
58
|
-
|
|
58
|
+
level: ClassVar[DataModelLevel] = DataModelLevel.physical
|
|
59
59
|
logical: URIRefType | None = None
|
|
60
60
|
|
|
61
61
|
def as_space(self) -> dm.SpaceApply:
|
|
@@ -453,7 +453,7 @@ class DMSEnum(SheetRow):
|
|
|
453
453
|
return str(value)
|
|
454
454
|
|
|
455
455
|
|
|
456
|
-
class DMSRules(
|
|
456
|
+
class DMSRules(BaseVerifiedDataModel):
|
|
457
457
|
metadata: DMSMetadata = Field(alias="Metadata", description="Contains information about the data model.")
|
|
458
458
|
properties: SheetList[DMSProperty] = Field(
|
|
459
459
|
alias="Properties", description="Contains the properties of the data model."
|
|
@@ -494,7 +494,7 @@ class DMSRules(BaseRules):
|
|
|
494
494
|
for property_ in self.properties:
|
|
495
495
|
property_.neatId = namespace[f"{property_.view.suffix}/{property_.view_property}"]
|
|
496
496
|
|
|
497
|
-
def sync_with_info_rules(self, info_rules: "
|
|
497
|
+
def sync_with_info_rules(self, info_rules: "ConceptualDataModel") -> None:
|
|
498
498
|
# Sync at the metadata level
|
|
499
499
|
if info_rules.metadata.physical == self.metadata.identifier:
|
|
500
500
|
self.metadata.logical = info_rules.metadata.identifier
|
|
@@ -525,7 +525,7 @@ class DMSRules(BaseRules):
|
|
|
525
525
|
|
|
526
526
|
def _repr_html_(self) -> str:
|
|
527
527
|
summary = {
|
|
528
|
-
"aspect": self.metadata.
|
|
528
|
+
"aspect": self.metadata.level,
|
|
529
529
|
"intended for": "DMS Architect",
|
|
530
530
|
"name": self.metadata.name,
|
|
531
531
|
"space": self.metadata.space,
|
|
@@ -14,10 +14,12 @@ 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
25
|
DMSUnknownEntity,
|
|
@@ -27,7 +29,8 @@ from cognite.neat.core._rules.models.entities import (
|
|
|
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
36
|
from ._rules import _DEFAULT_VERSION, DMSContainer, DMSEnum, DMSMetadata, DMSNode, DMSProperty, DMSRules, DMSView
|
|
@@ -39,7 +42,7 @@ else:
|
|
|
39
42
|
|
|
40
43
|
|
|
41
44
|
@dataclass
|
|
42
|
-
class DMSInputMetadata(
|
|
45
|
+
class DMSInputMetadata(UnverifiedComponent[DMSMetadata]):
|
|
43
46
|
space: str
|
|
44
47
|
external_id: str
|
|
45
48
|
creator: str
|
|
@@ -110,7 +113,7 @@ class DMSInputMetadata(InputComponent[DMSMetadata]):
|
|
|
110
113
|
|
|
111
114
|
|
|
112
115
|
@dataclass
|
|
113
|
-
class DMSInputProperty(
|
|
116
|
+
class DMSInputProperty(UnverifiedComponent[DMSProperty]):
|
|
114
117
|
view: str
|
|
115
118
|
view_property: str | None
|
|
116
119
|
value_type: str | DataType | ViewEntity | DMSUnknownEntity
|
|
@@ -203,7 +206,7 @@ class DMSInputProperty(InputComponent[DMSProperty]):
|
|
|
203
206
|
|
|
204
207
|
|
|
205
208
|
@dataclass
|
|
206
|
-
class DMSInputContainer(
|
|
209
|
+
class DMSInputContainer(UnverifiedComponent[DMSContainer]):
|
|
207
210
|
container: str
|
|
208
211
|
name: str | None = None
|
|
209
212
|
description: str | None = None
|
|
@@ -246,7 +249,7 @@ class DMSInputContainer(InputComponent[DMSContainer]):
|
|
|
246
249
|
|
|
247
250
|
|
|
248
251
|
@dataclass
|
|
249
|
-
class DMSInputView(
|
|
252
|
+
class DMSInputView(UnverifiedComponent[DMSView]):
|
|
250
253
|
view: str
|
|
251
254
|
name: str | None = None
|
|
252
255
|
description: str | None = None
|
|
@@ -304,7 +307,7 @@ class DMSInputView(InputComponent[DMSView]):
|
|
|
304
307
|
|
|
305
308
|
|
|
306
309
|
@dataclass
|
|
307
|
-
class DMSInputNode(
|
|
310
|
+
class DMSInputNode(UnverifiedComponent[DMSNode]):
|
|
308
311
|
node: str
|
|
309
312
|
usage: Literal["type", "collocation"]
|
|
310
313
|
name: str | None = None
|
|
@@ -326,7 +329,7 @@ class DMSInputNode(InputComponent[DMSNode]):
|
|
|
326
329
|
|
|
327
330
|
|
|
328
331
|
@dataclass
|
|
329
|
-
class DMSInputEnum(
|
|
332
|
+
class DMSInputEnum(UnverifiedComponent[DMSEnum]):
|
|
330
333
|
collection: str
|
|
331
334
|
value: str
|
|
332
335
|
name: str | None = None
|
|
@@ -339,7 +342,7 @@ class DMSInputEnum(InputComponent[DMSEnum]):
|
|
|
339
342
|
|
|
340
343
|
|
|
341
344
|
@dataclass
|
|
342
|
-
class DMSInputRules(
|
|
345
|
+
class DMSInputRules(UnverifiedDataModel[DMSRules]):
|
|
343
346
|
metadata: DMSInputMetadata
|
|
344
347
|
properties: list[DMSInputProperty]
|
|
345
348
|
views: list[DMSInputView]
|