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
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
from abc import ABC
|
|
2
2
|
|
|
3
3
|
from cognite.neat.core._client import NeatClient
|
|
4
|
-
from cognite.neat.core.
|
|
5
|
-
from cognite.neat.core._issues.errors import NeatTypeError, NeatValueError
|
|
6
|
-
from cognite.neat.core._rules._shared import (
|
|
4
|
+
from cognite.neat.core._data_model._shared import (
|
|
7
5
|
ReadRules,
|
|
8
6
|
T_ReadInputRules,
|
|
9
7
|
T_VerifiedRules,
|
|
10
8
|
VerifiedRules,
|
|
11
9
|
)
|
|
12
|
-
from cognite.neat.core.
|
|
10
|
+
from cognite.neat.core._data_model.models import (
|
|
11
|
+
ConceptualDataModel,
|
|
13
12
|
DMSInputRules,
|
|
14
13
|
DMSRules,
|
|
15
|
-
|
|
16
|
-
InformationRules,
|
|
14
|
+
UnverifiedConceptualDataModel,
|
|
17
15
|
)
|
|
18
|
-
from cognite.neat.core.
|
|
19
|
-
from cognite.neat.core.
|
|
16
|
+
from cognite.neat.core._data_model.models.conceptual import InformationValidation
|
|
17
|
+
from cognite.neat.core._data_model.models.dms import DMSValidation
|
|
18
|
+
from cognite.neat.core._issues import MultiValueError, catch_issues
|
|
19
|
+
from cognite.neat.core._issues.errors import NeatTypeError, NeatValueError
|
|
20
20
|
|
|
21
21
|
from ._base import RulesTransformer
|
|
22
22
|
|
|
@@ -81,13 +81,13 @@ class VerifyDMSRules(VerificationTransformer[ReadRules[DMSInputRules], DMSRules]
|
|
|
81
81
|
return super().transform(rules)
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
class VerifyInformationRules(VerificationTransformer[ReadRules[
|
|
84
|
+
class VerifyInformationRules(VerificationTransformer[ReadRules[UnverifiedConceptualDataModel], ConceptualDataModel]):
|
|
85
85
|
"""Class to verify Information rules."""
|
|
86
86
|
|
|
87
|
-
_rules_cls =
|
|
87
|
+
_rules_cls = ConceptualDataModel
|
|
88
88
|
_validation_cls = InformationValidation
|
|
89
89
|
|
|
90
|
-
def transform(self, rules: ReadRules[
|
|
90
|
+
def transform(self, rules: ReadRules[UnverifiedConceptualDataModel]) -> ConceptualDataModel:
|
|
91
91
|
return super().transform(rules)
|
|
92
92
|
|
|
93
93
|
|
|
@@ -95,15 +95,15 @@ class VerifyAnyRules(VerificationTransformer[T_ReadInputRules, VerifiedRules]):
|
|
|
95
95
|
"""Class to verify arbitrary rules"""
|
|
96
96
|
|
|
97
97
|
def _get_rules_cls(self, in_: T_ReadInputRules) -> type[VerifiedRules]:
|
|
98
|
-
if isinstance(in_.rules,
|
|
99
|
-
return
|
|
98
|
+
if isinstance(in_.rules, UnverifiedConceptualDataModel):
|
|
99
|
+
return ConceptualDataModel
|
|
100
100
|
elif isinstance(in_.rules, DMSInputRules):
|
|
101
101
|
return DMSRules
|
|
102
102
|
else:
|
|
103
103
|
raise NeatTypeError(f"Unsupported rules type: {type(in_)}")
|
|
104
104
|
|
|
105
105
|
def _get_validation_cls(self, rules: VerifiedRules) -> type:
|
|
106
|
-
if isinstance(rules,
|
|
106
|
+
if isinstance(rules, ConceptualDataModel):
|
|
107
107
|
return InformationValidation
|
|
108
108
|
elif isinstance(rules, DMSRules):
|
|
109
109
|
return DMSValidation
|
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
|
|
5
5
|
from rdflib import URIRef
|
|
6
6
|
|
|
7
7
|
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
8
|
-
from cognite.neat.core.
|
|
8
|
+
from cognite.neat.core._data_model.models import ConceptualDataModel
|
|
9
9
|
from cognite.neat.core._shared import Triple
|
|
10
10
|
from cognite.neat.core._utils.auxiliary import class_html_doc
|
|
11
11
|
|
|
@@ -38,7 +38,7 @@ class KnowledgeGraphExtractor(BaseExtractor):
|
|
|
38
38
|
"""A knowledge graph extractor extracts triples with a schema"""
|
|
39
39
|
|
|
40
40
|
@abstractmethod
|
|
41
|
-
def get_information_rules(self) ->
|
|
41
|
+
def get_information_rules(self) -> ConceptualDataModel:
|
|
42
42
|
"""Returns the information rules that the extractor uses."""
|
|
43
43
|
raise NotImplementedError()
|
|
44
44
|
|
|
@@ -18,7 +18,7 @@ from rdflib import RDF, XSD, Literal, Namespace, URIRef
|
|
|
18
18
|
from typing_extensions import Self
|
|
19
19
|
|
|
20
20
|
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
21
|
-
from cognite.neat.core.
|
|
21
|
+
from cognite.neat.core._instances.extractors._base import BaseExtractor
|
|
22
22
|
from cognite.neat.core._issues.errors import NeatValueError
|
|
23
23
|
from cognite.neat.core._issues.warnings import CDFAuthWarning, NeatValueWarning
|
|
24
24
|
from cognite.neat.core._shared import Triple
|
|
@@ -14,12 +14,15 @@ from cognite.neat.core._constants import (
|
|
|
14
14
|
DEFAULT_NAMESPACE,
|
|
15
15
|
get_default_prefixes_and_namespaces,
|
|
16
16
|
)
|
|
17
|
-
from cognite.neat.core.
|
|
17
|
+
from cognite.neat.core._data_model._shared import ReadRules
|
|
18
|
+
from cognite.neat.core._data_model.catalog import classic_model
|
|
19
|
+
from cognite.neat.core._data_model.models import (
|
|
20
|
+
ConceptualDataModel,
|
|
21
|
+
UnverifiedConceptualDataModel,
|
|
22
|
+
)
|
|
23
|
+
from cognite.neat.core._instances.extractors._base import KnowledgeGraphExtractor
|
|
18
24
|
from cognite.neat.core._issues.errors import NeatValueError, ResourceNotFoundError
|
|
19
25
|
from cognite.neat.core._issues.warnings import CDFAuthWarning, NeatValueWarning
|
|
20
|
-
from cognite.neat.core._rules._shared import ReadRules
|
|
21
|
-
from cognite.neat.core._rules.catalog import classic_model
|
|
22
|
-
from cognite.neat.core._rules.models import InformationInputRules, InformationRules
|
|
23
26
|
from cognite.neat.core._shared import Triple
|
|
24
27
|
from cognite.neat.core._utils.collection_ import chunker, iterate_progress_bar
|
|
25
28
|
from cognite.neat.core._utils.rdf_ import remove_namespace_from_uri
|
|
@@ -205,11 +208,14 @@ class ClassicGraphExtractor(KnowledgeGraphExtractor):
|
|
|
205
208
|
|
|
206
209
|
yield from self._extract_asset_parent_data_sets()
|
|
207
210
|
|
|
208
|
-
def get_information_rules(self) ->
|
|
211
|
+
def get_information_rules(self) -> ConceptualDataModel:
|
|
209
212
|
# To avoid circular imports
|
|
210
|
-
from cognite.neat.core.
|
|
213
|
+
from cognite.neat.core._data_model.importers import ExcelImporter
|
|
211
214
|
|
|
212
|
-
unverified = cast(
|
|
215
|
+
unverified = cast(
|
|
216
|
+
ReadRules[UnverifiedConceptualDataModel],
|
|
217
|
+
ExcelImporter(classic_model).to_rules(),
|
|
218
|
+
)
|
|
213
219
|
if unverified.rules is None:
|
|
214
220
|
raise NeatValueError(f"Could not read the classic model rules from {classic_model}.")
|
|
215
221
|
|
|
@@ -7,18 +7,18 @@ from rdflib import Namespace, URIRef
|
|
|
7
7
|
|
|
8
8
|
from cognite.neat.core._client import NeatClient
|
|
9
9
|
from cognite.neat.core._constants import COGNITE_SPACES, DEFAULT_NAMESPACE
|
|
10
|
+
from cognite.neat.core._data_model.importers import DMSImporter
|
|
11
|
+
from cognite.neat.core._data_model.models import ConceptualDataModel, DMSRules
|
|
12
|
+
from cognite.neat.core._data_model.models.conceptual import ConceptualProperty
|
|
13
|
+
from cognite.neat.core._data_model.models.data_types import Json
|
|
14
|
+
from cognite.neat.core._data_model.models.entities import UnknownEntity
|
|
15
|
+
from cognite.neat.core._data_model.transformers import DMSToInformation, VerifyDMSRules
|
|
10
16
|
from cognite.neat.core._issues import IssueList, NeatIssue, catch_warnings
|
|
11
17
|
from cognite.neat.core._issues.warnings import (
|
|
12
18
|
CDFAuthWarning,
|
|
13
19
|
ResourceNotFoundWarning,
|
|
14
20
|
ResourceRetrievalWarning,
|
|
15
21
|
)
|
|
16
|
-
from cognite.neat.core._rules.importers import DMSImporter
|
|
17
|
-
from cognite.neat.core._rules.models import DMSRules, InformationRules
|
|
18
|
-
from cognite.neat.core._rules.models.data_types import Json
|
|
19
|
-
from cognite.neat.core._rules.models.entities import UnknownEntity
|
|
20
|
-
from cognite.neat.core._rules.models.information import InformationProperty
|
|
21
|
-
from cognite.neat.core._rules.transformers import DMSToInformation, VerifyDMSRules
|
|
22
22
|
from cognite.neat.core._shared import Triple
|
|
23
23
|
|
|
24
24
|
from ._base import KnowledgeGraphExtractor
|
|
@@ -47,7 +47,7 @@ class DMSGraphExtractor(KnowledgeGraphExtractor):
|
|
|
47
47
|
self._str_to_ideal_type = str_to_ideal_type
|
|
48
48
|
|
|
49
49
|
self._views: list[dm.View] | None = None
|
|
50
|
-
self._information_rules:
|
|
50
|
+
self._information_rules: ConceptualDataModel | None = None
|
|
51
51
|
self._dms_rules: DMSRules | None = None
|
|
52
52
|
|
|
53
53
|
@classmethod
|
|
@@ -164,7 +164,7 @@ class DMSGraphExtractor(KnowledgeGraphExtractor):
|
|
|
164
164
|
self._issues.append(ResourceNotFoundWarning(dm_view, "view", data_model_id, "data model"))
|
|
165
165
|
return views
|
|
166
166
|
|
|
167
|
-
def get_information_rules(self) ->
|
|
167
|
+
def get_information_rules(self) -> ConceptualDataModel:
|
|
168
168
|
"""Returns the information rules that the extractor uses."""
|
|
169
169
|
if self._information_rules is None:
|
|
170
170
|
self._information_rules, self._dms_rules = self._create_rules()
|
|
@@ -180,7 +180,7 @@ class DMSGraphExtractor(KnowledgeGraphExtractor):
|
|
|
180
180
|
"""Returns the issues that occurred during the extraction."""
|
|
181
181
|
return self._issues
|
|
182
182
|
|
|
183
|
-
def _create_rules(self) -> tuple[
|
|
183
|
+
def _create_rules(self) -> tuple[ConceptualDataModel, DMSRules]:
|
|
184
184
|
# The DMS and Information rules must be created together to link them property.
|
|
185
185
|
importer = DMSImporter.from_data_model(self._client, self._data_model)
|
|
186
186
|
unverified_dms = importer.to_rules()
|
|
@@ -217,7 +217,7 @@ class DMSGraphExtractor(KnowledgeGraphExtractor):
|
|
|
217
217
|
cls_ = classes_by_prefix[view.external_id]
|
|
218
218
|
for property_ in ("startNode", "endNode"):
|
|
219
219
|
information_rules.properties.append(
|
|
220
|
-
|
|
220
|
+
ConceptualProperty(
|
|
221
221
|
class_=cls_.class_,
|
|
222
222
|
property_=property_,
|
|
223
223
|
value_type=UnknownEntity(),
|
|
@@ -11,13 +11,13 @@ import numpy
|
|
|
11
11
|
import pandas as pd
|
|
12
12
|
from rdflib import RDF, Literal, Namespace, URIRef
|
|
13
13
|
|
|
14
|
-
from cognite.neat.core.
|
|
15
|
-
from cognite.neat.core.
|
|
16
|
-
from cognite.neat.core.
|
|
17
|
-
from cognite.neat.core.
|
|
18
|
-
from cognite.neat.core.
|
|
19
|
-
from cognite.neat.core.
|
|
20
|
-
from cognite.neat.core.
|
|
14
|
+
from cognite.neat.core._data_model._constants import EntityTypes
|
|
15
|
+
from cognite.neat.core._data_model.analysis import RulesAnalysis
|
|
16
|
+
from cognite.neat.core._data_model.models import ConceptualDataModel, DMSRules
|
|
17
|
+
from cognite.neat.core._data_model.models.conceptual import ConceptualProperty
|
|
18
|
+
from cognite.neat.core._data_model.models.data_types import DataType
|
|
19
|
+
from cognite.neat.core._data_model.models.entities import ClassEntity
|
|
20
|
+
from cognite.neat.core._data_model.transformers import SubsetInformationRules
|
|
21
21
|
from cognite.neat.core._shared import Triple
|
|
22
22
|
from cognite.neat.core._utils.rdf_ import remove_namespace_from_uri
|
|
23
23
|
|
|
@@ -38,17 +38,17 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
38
38
|
|
|
39
39
|
def __init__(
|
|
40
40
|
self,
|
|
41
|
-
rules:
|
|
41
|
+
rules: ConceptualDataModel | DMSRules,
|
|
42
42
|
class_count: dict[str | ClassEntity, int] | None = None,
|
|
43
43
|
stop_on_exception: bool = False,
|
|
44
44
|
allow_isolated_classes: bool = True,
|
|
45
45
|
):
|
|
46
46
|
if isinstance(rules, DMSRules):
|
|
47
47
|
# fixes potential issues with circular dependencies
|
|
48
|
-
from cognite.neat.core.
|
|
48
|
+
from cognite.neat.core._data_model.transformers import DMSToInformation
|
|
49
49
|
|
|
50
50
|
self.rules = DMSToInformation().transform(rules)
|
|
51
|
-
elif isinstance(rules,
|
|
51
|
+
elif isinstance(rules, ConceptualDataModel):
|
|
52
52
|
self.rules = rules
|
|
53
53
|
else:
|
|
54
54
|
raise ValueError("Rules must be of type InformationRules or DMSRules!")
|
|
@@ -85,7 +85,7 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
def generate_triples(
|
|
88
|
-
rules:
|
|
88
|
+
rules: ConceptualDataModel,
|
|
89
89
|
class_count: dict[ClassEntity, int],
|
|
90
90
|
stop_on_exception: bool = False,
|
|
91
91
|
allow_isolated_classes: bool = True,
|
|
@@ -294,8 +294,8 @@ def _generate_mock_data_property_triples(
|
|
|
294
294
|
|
|
295
295
|
def _generate_mock_object_property_triples(
|
|
296
296
|
class_: ClassEntity,
|
|
297
|
-
property_definition:
|
|
298
|
-
class_property_pairs: dict[ClassEntity, list[
|
|
297
|
+
property_definition: ConceptualProperty,
|
|
298
|
+
class_property_pairs: dict[ClassEntity, list[ConceptualProperty]],
|
|
299
299
|
sym_pairs: set[tuple[ClassEntity, ClassEntity]],
|
|
300
300
|
instance_ids: dict[ClassEntity, list[URIRef]],
|
|
301
301
|
namespace: Namespace,
|
|
@@ -365,7 +365,7 @@ def _generate_mock_object_property_triples(
|
|
|
365
365
|
|
|
366
366
|
def _generate_triples_per_class(
|
|
367
367
|
class_: ClassEntity,
|
|
368
|
-
class_properties_pairs: dict[ClassEntity, list[
|
|
368
|
+
class_properties_pairs: dict[ClassEntity, list[ConceptualProperty]],
|
|
369
369
|
sym_pairs: set[tuple[ClassEntity, ClassEntity]],
|
|
370
370
|
instance_ids: dict[ClassEntity, list[URIRef]],
|
|
371
371
|
namespace: Namespace,
|
|
@@ -8,8 +8,8 @@ from rdflib.util import guess_format
|
|
|
8
8
|
from typing_extensions import Self
|
|
9
9
|
|
|
10
10
|
from cognite.neat.core._constants import DEFAULT_BASE_URI
|
|
11
|
-
from cognite.neat.core.
|
|
12
|
-
from cognite.neat.core.
|
|
11
|
+
from cognite.neat.core._instances._shared import RDFTypes
|
|
12
|
+
from cognite.neat.core._instances.extractors._base import BaseExtractor
|
|
13
13
|
from cognite.neat.core._issues._base import IssueList
|
|
14
14
|
from cognite.neat.core._issues.errors import (
|
|
15
15
|
FileNotFoundNeatError,
|
|
@@ -25,6 +25,17 @@ from cognite.neat.core._constants import (
|
|
|
25
25
|
DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
|
|
26
26
|
is_readonly_property,
|
|
27
27
|
)
|
|
28
|
+
from cognite.neat.core._data_model.analysis import RulesAnalysis
|
|
29
|
+
from cognite.neat.core._data_model.analysis._base import ViewQuery, ViewQueryDict
|
|
30
|
+
from cognite.neat.core._data_model.models import DMSRules
|
|
31
|
+
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
32
|
+
ConceptualDataModel,
|
|
33
|
+
)
|
|
34
|
+
from cognite.neat.core._data_model.models.data_types import (
|
|
35
|
+
_DATA_TYPE_BY_DMS_TYPE,
|
|
36
|
+
Json,
|
|
37
|
+
String,
|
|
38
|
+
)
|
|
28
39
|
from cognite.neat.core._issues import IssueList, NeatError, NeatIssue, catch_issues
|
|
29
40
|
from cognite.neat.core._issues.errors import (
|
|
30
41
|
AuthorizationError,
|
|
@@ -39,15 +50,6 @@ from cognite.neat.core._issues.warnings import (
|
|
|
39
50
|
PropertyTypeNotSupportedWarning,
|
|
40
51
|
ResourceNeatWarning,
|
|
41
52
|
)
|
|
42
|
-
from cognite.neat.core._rules.analysis import RulesAnalysis
|
|
43
|
-
from cognite.neat.core._rules.analysis._base import ViewQuery, ViewQueryDict
|
|
44
|
-
from cognite.neat.core._rules.models import DMSRules
|
|
45
|
-
from cognite.neat.core._rules.models.data_types import (
|
|
46
|
-
_DATA_TYPE_BY_DMS_TYPE,
|
|
47
|
-
Json,
|
|
48
|
-
String,
|
|
49
|
-
)
|
|
50
|
-
from cognite.neat.core._rules.models.information._rules import InformationRules
|
|
51
53
|
from cognite.neat.core._shared import InstanceType
|
|
52
54
|
from cognite.neat.core._store import NeatGraphStore
|
|
53
55
|
from cognite.neat.core._utils.auxiliary import create_sha256_hash
|
|
@@ -114,7 +116,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
114
116
|
def __init__(
|
|
115
117
|
self,
|
|
116
118
|
dms_rules: DMSRules,
|
|
117
|
-
info_rules:
|
|
119
|
+
info_rules: ConceptualDataModel,
|
|
118
120
|
graph_store: NeatGraphStore,
|
|
119
121
|
instance_space: str,
|
|
120
122
|
space_property: str | None = None,
|
|
@@ -9,7 +9,7 @@ from rdflib import RDF, Graph, Literal, Namespace, URIRef
|
|
|
9
9
|
from rdflib.query import ResultRow
|
|
10
10
|
|
|
11
11
|
from cognite.neat.core._constants import CLASSIC_CDF_NAMESPACE, DEFAULT_NAMESPACE
|
|
12
|
-
from cognite.neat.core.
|
|
12
|
+
from cognite.neat.core._instances import extractors
|
|
13
13
|
from cognite.neat.core._issues.errors import NeatValueError
|
|
14
14
|
from cognite.neat.core._issues.warnings import ResourceNotFoundWarning
|
|
15
15
|
from cognite.neat.core._utils.collection_ import iterate_progress_bar
|
|
@@ -119,7 +119,7 @@ class NeatIssue:
|
|
|
119
119
|
|
|
120
120
|
@classmethod
|
|
121
121
|
def _dump_value(cls, value: Any) -> list | int | bool | float | str | dict:
|
|
122
|
-
from cognite.neat.core.
|
|
122
|
+
from cognite.neat.core._data_model.models.entities import Entity
|
|
123
123
|
|
|
124
124
|
if isinstance(value, str | int | bool | float):
|
|
125
125
|
return value
|
|
@@ -173,7 +173,7 @@ class NeatIssue:
|
|
|
173
173
|
|
|
174
174
|
@classmethod
|
|
175
175
|
def _load_value(cls, type_: Any, value: Any) -> Any:
|
|
176
|
-
from cognite.neat.core.
|
|
176
|
+
from cognite.neat.core._data_model.models.entities import Entity
|
|
177
177
|
|
|
178
178
|
if isinstance(type_, UnionType) or get_origin(type_) is UnionType:
|
|
179
179
|
args = get_args(type_)
|
|
@@ -40,6 +40,7 @@ from ._properties import (
|
|
|
40
40
|
PropertyOverwritingWarning,
|
|
41
41
|
PropertyTypeNotSupportedWarning,
|
|
42
42
|
PropertyValueTypeUndefinedWarning,
|
|
43
|
+
ReversedConnectionNotFeasibleWarning,
|
|
43
44
|
)
|
|
44
45
|
from ._resources import (
|
|
45
46
|
ResourceNeatWarning,
|
|
@@ -85,6 +86,7 @@ __all__ = [
|
|
|
85
86
|
"ResourceTypeNotSupportedWarning",
|
|
86
87
|
"ResourceUnknownWarning",
|
|
87
88
|
"ResourcesDuplicatedWarning",
|
|
89
|
+
"ReversedConnectionNotFeasibleWarning",
|
|
88
90
|
"UndefinedViewWarning",
|
|
89
91
|
"UserModelingWarning",
|
|
90
92
|
"user_modeling",
|
|
@@ -88,3 +88,10 @@ class PropertyMultipleValueWarning(PropertyWarning[T_Identifier]):
|
|
|
88
88
|
Selecting the first value {value}, the rest will be ignored."""
|
|
89
89
|
|
|
90
90
|
value: str
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(unsafe_hash=True)
|
|
94
|
+
class ReversedConnectionNotFeasibleWarning(PropertyWarning[T_Identifier]):
|
|
95
|
+
"""The {resource_type} {identifier}.{property_name} cannot be created: {reason}"""
|
|
96
|
+
|
|
97
|
+
reason: str
|
|
@@ -12,10 +12,10 @@ from rdflib import Dataset, Graph, Namespace, URIRef
|
|
|
12
12
|
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID
|
|
13
13
|
from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
|
|
14
14
|
|
|
15
|
-
from cognite.neat.core.
|
|
16
|
-
from cognite.neat.core.
|
|
17
|
-
from cognite.neat.core.
|
|
18
|
-
from cognite.neat.core.
|
|
15
|
+
from cognite.neat.core._instances._shared import quad_formats, rdflib_to_oxi_type
|
|
16
|
+
from cognite.neat.core._instances.extractors import RdfFileExtractor, TripleExtractors
|
|
17
|
+
from cognite.neat.core._instances.queries import Queries
|
|
18
|
+
from cognite.neat.core._instances.transformers import Transformers
|
|
19
19
|
from cognite.neat.core._issues import IssueList, catch_issues
|
|
20
20
|
from cognite.neat.core._issues.errors import NeatValueError, OxigraphStorageLockedError
|
|
21
21
|
from cognite.neat.core._shared import InstanceType, Triple
|
|
@@ -12,22 +12,22 @@ from rdflib import URIRef
|
|
|
12
12
|
|
|
13
13
|
from cognite.neat.core._client import NeatClient
|
|
14
14
|
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
15
|
-
from cognite.neat.core.
|
|
15
|
+
from cognite.neat.core._data_model._shared import T_VerifiedRules, VerifiedRules
|
|
16
|
+
from cognite.neat.core._data_model.exporters import BaseExporter
|
|
17
|
+
from cognite.neat.core._data_model.exporters._base import CDFExporter, T_Export
|
|
18
|
+
from cognite.neat.core._data_model.importers import BaseImporter
|
|
19
|
+
from cognite.neat.core._data_model.models import ConceptualDataModel, DMSRules
|
|
20
|
+
from cognite.neat.core._data_model.transformers import (
|
|
21
|
+
DMSToInformation,
|
|
22
|
+
VerifiedRulesTransformer,
|
|
23
|
+
VerifyAnyRules,
|
|
24
|
+
)
|
|
25
|
+
from cognite.neat.core._instances.extractors import (
|
|
16
26
|
DMSGraphExtractor,
|
|
17
27
|
KnowledgeGraphExtractor,
|
|
18
28
|
)
|
|
19
29
|
from cognite.neat.core._issues import IssueList, catch_issues
|
|
20
30
|
from cognite.neat.core._issues.errors import NeatValueError
|
|
21
|
-
from cognite.neat.core._rules._shared import T_VerifiedRules, VerifiedRules
|
|
22
|
-
from cognite.neat.core._rules.exporters import BaseExporter
|
|
23
|
-
from cognite.neat.core._rules.exporters._base import CDFExporter, T_Export
|
|
24
|
-
from cognite.neat.core._rules.importers import BaseImporter
|
|
25
|
-
from cognite.neat.core._rules.models import DMSRules, InformationRules
|
|
26
|
-
from cognite.neat.core._rules.transformers import (
|
|
27
|
-
DMSToInformation,
|
|
28
|
-
VerifiedRulesTransformer,
|
|
29
|
-
VerifyAnyRules,
|
|
30
|
-
)
|
|
31
31
|
from cognite.neat.core._utils.upload import UploadResultList
|
|
32
32
|
|
|
33
33
|
from ._provenance import (
|
|
@@ -43,7 +43,7 @@ from .exceptions import EmptyStore, InvalidActivityInput
|
|
|
43
43
|
|
|
44
44
|
@dataclass(frozen=True)
|
|
45
45
|
class RulesEntity(Entity):
|
|
46
|
-
information:
|
|
46
|
+
information: ConceptualDataModel
|
|
47
47
|
dms: DMSRules | None = None
|
|
48
48
|
|
|
49
49
|
@property
|
|
@@ -85,11 +85,11 @@ class NeatRulesStore:
|
|
|
85
85
|
importer: BaseImporter,
|
|
86
86
|
validate: bool,
|
|
87
87
|
client: NeatClient | None = None,
|
|
88
|
-
) -> tuple[
|
|
88
|
+
) -> tuple[ConceptualDataModel, DMSRules | None]:
|
|
89
89
|
"""Action that imports rules, verifies them and optionally converts them."""
|
|
90
90
|
read_rules = importer.to_rules()
|
|
91
91
|
verified = VerifyAnyRules(validate, client).transform(read_rules) # type: ignore[arg-type]
|
|
92
|
-
if isinstance(verified,
|
|
92
|
+
if isinstance(verified, ConceptualDataModel):
|
|
93
93
|
return verified, None
|
|
94
94
|
elif isinstance(verified, DMSRules):
|
|
95
95
|
return DMSToInformation().transform(verified), verified
|
|
@@ -100,7 +100,7 @@ class NeatRulesStore:
|
|
|
100
100
|
def _graph_import_verify_convert(
|
|
101
101
|
self,
|
|
102
102
|
extractor: KnowledgeGraphExtractor,
|
|
103
|
-
) -> tuple[
|
|
103
|
+
) -> tuple[ConceptualDataModel, DMSRules | None]:
|
|
104
104
|
info = extractor.get_information_rules()
|
|
105
105
|
dms: DMSRules | None = None
|
|
106
106
|
if isinstance(extractor, DMSGraphExtractor):
|
|
@@ -229,12 +229,12 @@ class NeatRulesStore:
|
|
|
229
229
|
|
|
230
230
|
def action(
|
|
231
231
|
transformer_item: VerifiedRulesTransformer = agent_tool,
|
|
232
|
-
) -> tuple[
|
|
232
|
+
) -> tuple[ConceptualDataModel, DMSRules | None]:
|
|
233
233
|
last_change = self.provenance[-1]
|
|
234
234
|
source_entity = last_change.target_entity
|
|
235
235
|
transformer_input = self._get_transformer_input(source_entity, transformer_item)
|
|
236
236
|
transformer_output = transformer_item.transform(transformer_input)
|
|
237
|
-
if isinstance(transformer_output,
|
|
237
|
+
if isinstance(transformer_output, ConceptualDataModel):
|
|
238
238
|
return transformer_output, None
|
|
239
239
|
return last_change.target_entity.information, transformer_output
|
|
240
240
|
|
|
@@ -260,7 +260,7 @@ class NeatRulesStore:
|
|
|
260
260
|
|
|
261
261
|
def do_activity(
|
|
262
262
|
self,
|
|
263
|
-
action: Callable[[], tuple[
|
|
263
|
+
action: Callable[[], tuple[ConceptualDataModel, DMSRules | None]],
|
|
264
264
|
agent_tool: BaseImporter | VerifiedRulesTransformer | KnowledgeGraphExtractor,
|
|
265
265
|
) -> IssueList:
|
|
266
266
|
result, issue_list, start, end = self._do_activity(action)
|
|
@@ -273,7 +273,7 @@ class NeatRulesStore:
|
|
|
273
273
|
def _update_provenance(
|
|
274
274
|
self,
|
|
275
275
|
agent_tool: BaseImporter | VerifiedRulesTransformer | KnowledgeGraphExtractor,
|
|
276
|
-
result: tuple[
|
|
276
|
+
result: tuple[ConceptualDataModel, DMSRules | None],
|
|
277
277
|
issue_list: IssueList,
|
|
278
278
|
activity_start: datetime,
|
|
279
279
|
activity_end: datetime,
|
|
@@ -318,11 +318,11 @@ class NeatRulesStore:
|
|
|
318
318
|
|
|
319
319
|
def _do_activity(
|
|
320
320
|
self,
|
|
321
|
-
action: Callable[[], tuple[
|
|
322
|
-
) -> tuple[tuple[
|
|
321
|
+
action: Callable[[], tuple[ConceptualDataModel, DMSRules | None]],
|
|
322
|
+
) -> tuple[tuple[ConceptualDataModel, DMSRules | None], IssueList, datetime, datetime]:
|
|
323
323
|
"""This private method is used to execute an activity and return the result and issues."""
|
|
324
324
|
start = datetime.now(timezone.utc)
|
|
325
|
-
result: tuple[
|
|
325
|
+
result: tuple[ConceptualDataModel, DMSRules | None] | None = None
|
|
326
326
|
with catch_issues() as issue_list:
|
|
327
327
|
result = action()
|
|
328
328
|
end = datetime.now(timezone.utc)
|
|
@@ -340,7 +340,7 @@ class NeatRulesStore:
|
|
|
340
340
|
elif isinstance(source_entity.information, expected_types):
|
|
341
341
|
input_ = cast(VerifiedRules, source_entity.information).model_copy(deep=True)
|
|
342
342
|
else:
|
|
343
|
-
available: list[type] = [
|
|
343
|
+
available: list[type] = [ConceptualDataModel]
|
|
344
344
|
if source_entity.dms is not None:
|
|
345
345
|
available.append(DMSRules)
|
|
346
346
|
raise InvalidActivityInput(expected=expected_types, have=tuple(available))
|
|
@@ -390,19 +390,19 @@ class NeatRulesStore:
|
|
|
390
390
|
@staticmethod
|
|
391
391
|
def _get_transformer_input(
|
|
392
392
|
source_entity: RulesEntity, transformer: VerifiedRulesTransformer
|
|
393
|
-
) ->
|
|
393
|
+
) -> ConceptualDataModel | DMSRules:
|
|
394
394
|
# Case 1: We only have information rules
|
|
395
395
|
if source_entity.dms is None:
|
|
396
396
|
if transformer.is_valid_input(source_entity.information):
|
|
397
397
|
return source_entity.information
|
|
398
|
-
raise InvalidActivityInput(expected=(DMSRules,), have=(
|
|
398
|
+
raise InvalidActivityInput(expected=(DMSRules,), have=(ConceptualDataModel,))
|
|
399
399
|
# Case 2: We have both information and dms rules and the transformer is compatible with dms rules
|
|
400
400
|
elif isinstance(source_entity.dms, DMSRules) and transformer.is_valid_input(source_entity.dms):
|
|
401
401
|
return source_entity.dms
|
|
402
402
|
# Case 3: We have both information and dms rules and the transformer is compatible with information rules
|
|
403
|
-
raise InvalidActivityInput(expected=(
|
|
403
|
+
raise InvalidActivityInput(expected=(ConceptualDataModel,), have=(DMSRules,))
|
|
404
404
|
|
|
405
|
-
def _get_source_id(self, result: tuple[
|
|
405
|
+
def _get_source_id(self, result: tuple[ConceptualDataModel, DMSRules | None]) -> rdflib.URIRef | None:
|
|
406
406
|
"""Return the source of the result.
|
|
407
407
|
|
|
408
408
|
!!! note
|
|
@@ -411,7 +411,7 @@ class NeatRulesStore:
|
|
|
411
411
|
info, dms = result
|
|
412
412
|
return dms.metadata.source_id if dms else info.metadata.source_id
|
|
413
413
|
|
|
414
|
-
def _create_id(self, info:
|
|
414
|
+
def _create_id(self, info: ConceptualDataModel, dms: DMSRules | None) -> rdflib.URIRef:
|
|
415
415
|
if dms is None:
|
|
416
416
|
identifier = info.metadata.identifier
|
|
417
417
|
else:
|
|
@@ -437,7 +437,7 @@ class NeatRulesStore:
|
|
|
437
437
|
return self.provenance[-1].target_entity.dms
|
|
438
438
|
|
|
439
439
|
@property
|
|
440
|
-
def try_get_last_information_rules(self) ->
|
|
440
|
+
def try_get_last_information_rules(self) -> ConceptualDataModel | None:
|
|
441
441
|
if not self.provenance:
|
|
442
442
|
return None
|
|
443
443
|
return self.provenance[-1].target_entity.information
|
|
@@ -451,13 +451,13 @@ class NeatRulesStore:
|
|
|
451
451
|
return self.provenance[-1].target_entity.dms
|
|
452
452
|
|
|
453
453
|
@property
|
|
454
|
-
def last_verified_information_rules(self) ->
|
|
454
|
+
def last_verified_information_rules(self) -> ConceptualDataModel:
|
|
455
455
|
if not self.provenance:
|
|
456
456
|
raise EmptyStore()
|
|
457
457
|
return self.provenance[-1].target_entity.information
|
|
458
458
|
|
|
459
459
|
@property
|
|
460
|
-
def last_verified_rules(self) ->
|
|
460
|
+
def last_verified_rules(self) -> ConceptualDataModel | DMSRules | None:
|
|
461
461
|
if not self.provenance:
|
|
462
462
|
return None
|
|
463
463
|
last_entity = self.provenance[-1].target_entity
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
|
|
5
|
-
from cognite.neat.core.
|
|
5
|
+
from cognite.neat.core._data_model.importers import BaseImporter
|
|
6
|
+
from cognite.neat.core._data_model.transformers import VerifiedRulesTransformer
|
|
7
|
+
from cognite.neat.core._instances.extractors import KnowledgeGraphExtractor
|
|
6
8
|
from cognite.neat.core._issues import IssueList
|
|
7
|
-
from cognite.neat.core._rules.importers import BaseImporter
|
|
8
|
-
from cognite.neat.core._rules.transformers import VerifiedRulesTransformer
|
|
9
9
|
|
|
10
10
|
from ._provenance import Activity
|
|
11
11
|
|
|
@@ -8,7 +8,7 @@ from openpyxl import load_workbook
|
|
|
8
8
|
from openpyxl.worksheet.datavalidation import DataValidation
|
|
9
9
|
from openpyxl.worksheet.worksheet import Worksheet
|
|
10
10
|
|
|
11
|
-
from cognite.neat.core.
|
|
11
|
+
from cognite.neat.core._data_model._constants import get_internal_properties
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@dataclass
|
cognite/neat/core/_utils/text.py
CHANGED
|
@@ -4,7 +4,7 @@ from collections.abc import Collection, Set
|
|
|
4
4
|
from re import Pattern
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
from cognite.neat.core.
|
|
7
|
+
from cognite.neat.core._data_model._constants import get_reserved_words
|
|
8
8
|
|
|
9
9
|
PREPOSITIONS = frozenset(
|
|
10
10
|
{
|
cognite/neat/session/_base.py
CHANGED
|
@@ -6,19 +6,21 @@ from cognite.client import data_modeling as dm
|
|
|
6
6
|
|
|
7
7
|
from cognite.neat import _version
|
|
8
8
|
from cognite.neat.core._client import NeatClient
|
|
9
|
-
from cognite.neat.core.
|
|
10
|
-
from cognite.neat.core.
|
|
11
|
-
from cognite.neat.core.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
from cognite.neat.core.
|
|
15
|
-
from cognite.neat.core._rules.transformers import (
|
|
9
|
+
from cognite.neat.core._data_model import importers
|
|
10
|
+
from cognite.neat.core._data_model.models import DMSRules
|
|
11
|
+
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
12
|
+
ConceptualDataModel,
|
|
13
|
+
)
|
|
14
|
+
from cognite.neat.core._data_model.transformers import (
|
|
16
15
|
InformationToDMS,
|
|
17
16
|
MergeDMSRules,
|
|
18
17
|
MergeInformationRules,
|
|
19
18
|
ToDMSCompliantEntities,
|
|
20
19
|
VerifyInformationRules,
|
|
21
20
|
)
|
|
21
|
+
from cognite.neat.core._issues import IssueList
|
|
22
|
+
from cognite.neat.core._issues.errors import RegexViolationError
|
|
23
|
+
from cognite.neat.core._issues.errors._general import NeatImportError
|
|
22
24
|
from cognite.neat.core._store._rules_store import RulesEntity
|
|
23
25
|
from cognite.neat.core._utils.auxiliary import local_import
|
|
24
26
|
|
|
@@ -242,7 +244,7 @@ class NeatSession:
|
|
|
242
244
|
data_model_id=dm.DataModelId.load(model_id) if last_entity is None else None,
|
|
243
245
|
)
|
|
244
246
|
|
|
245
|
-
def action() -> tuple[
|
|
247
|
+
def action() -> tuple[ConceptualDataModel, DMSRules | None]:
|
|
246
248
|
unverified_information = importer.to_rules()
|
|
247
249
|
unverified_information = ToDMSCompliantEntities(rename_warning="raise").transform(unverified_information)
|
|
248
250
|
|
cognite/neat/session/_drop.py
CHANGED
|
@@ -6,8 +6,8 @@ from cognite.client.utils.useful_types import SequenceNotStr
|
|
|
6
6
|
from rdflib import URIRef
|
|
7
7
|
|
|
8
8
|
from cognite.neat.core._constants import COGNITE_MODELS
|
|
9
|
+
from cognite.neat.core._data_model.transformers import DropModelViews
|
|
9
10
|
from cognite.neat.core._issues import IssueList
|
|
10
|
-
from cognite.neat.core._rules.transformers import DropModelViews
|
|
11
11
|
|
|
12
12
|
from ._state import SessionState
|
|
13
13
|
from .exceptions import NeatSessionError, session_class_wrapper
|