cognite-neat 0.88.3__py3-none-any.whl → 0.89.0__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/constants.py +3 -0
- cognite/neat/graph/extractors/_mock_graph_generator.py +2 -1
- cognite/neat/issues/_base.py +2 -1
- cognite/neat/issues/errors/__init__.py +2 -1
- cognite/neat/issues/errors/_general.py +7 -0
- cognite/neat/issues/warnings/_models.py +1 -1
- cognite/neat/issues/warnings/user_modeling.py +1 -1
- cognite/neat/rules/_shared.py +49 -6
- cognite/neat/rules/analysis/_base.py +1 -1
- cognite/neat/rules/exporters/_base.py +7 -18
- cognite/neat/rules/exporters/_rules2dms.py +8 -18
- cognite/neat/rules/exporters/_rules2excel.py +5 -12
- cognite/neat/rules/exporters/_rules2ontology.py +9 -19
- cognite/neat/rules/exporters/_rules2yaml.py +3 -6
- cognite/neat/rules/importers/_base.py +7 -52
- cognite/neat/rules/importers/_dms2rules.py +171 -115
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +26 -18
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +14 -30
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +7 -3
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +3 -3
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +18 -11
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2rules.py +9 -18
- cognite/neat/rules/importers/_rdf/_inference2rules.py +10 -33
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +9 -20
- cognite/neat/rules/importers/_rdf/_shared.py +1 -1
- cognite/neat/rules/importers/_spreadsheet2rules.py +22 -86
- cognite/neat/rules/importers/_yaml2rules.py +14 -41
- cognite/neat/rules/models/__init__.py +21 -5
- cognite/neat/rules/models/_base_input.py +162 -0
- cognite/neat/rules/models/{_base.py → _base_rules.py} +1 -12
- cognite/neat/rules/models/asset/__init__.py +5 -2
- cognite/neat/rules/models/asset/_rules.py +2 -20
- cognite/neat/rules/models/asset/_rules_input.py +40 -115
- cognite/neat/rules/models/asset/_validation.py +1 -1
- cognite/neat/rules/models/data_types.py +150 -44
- cognite/neat/rules/models/dms/__init__.py +19 -7
- cognite/neat/rules/models/dms/_exporter.py +72 -26
- cognite/neat/rules/models/dms/_rules.py +42 -155
- cognite/neat/rules/models/dms/_rules_input.py +186 -254
- cognite/neat/rules/models/dms/_serializer.py +44 -3
- cognite/neat/rules/models/dms/_validation.py +3 -4
- cognite/neat/rules/models/domain.py +52 -1
- cognite/neat/rules/models/entities/__init__.py +63 -0
- cognite/neat/rules/models/entities/_constants.py +73 -0
- cognite/neat/rules/models/entities/_loaders.py +76 -0
- cognite/neat/rules/models/entities/_multi_value.py +67 -0
- cognite/neat/rules/models/{entities.py → entities/_single_value.py} +74 -232
- cognite/neat/rules/models/entities/_types.py +86 -0
- cognite/neat/rules/models/{wrapped_entities.py → entities/_wrapped.py} +1 -1
- cognite/neat/rules/models/information/__init__.py +10 -2
- cognite/neat/rules/models/information/_rules.py +3 -14
- cognite/neat/rules/models/information/_rules_input.py +57 -204
- cognite/neat/rules/models/information/_validation.py +1 -1
- cognite/neat/rules/transformers/__init__.py +21 -0
- cognite/neat/rules/transformers/_base.py +69 -3
- cognite/neat/rules/{models/information/_converter.py → transformers/_converters.py} +216 -20
- cognite/neat/rules/transformers/_map_onto.py +97 -0
- cognite/neat/rules/transformers/_pipelines.py +61 -0
- cognite/neat/rules/transformers/_verification.py +136 -0
- cognite/neat/store/_provenance.py +10 -1
- cognite/neat/utils/cdf/data_classes.py +20 -0
- cognite/neat/utils/regex_patterns.py +6 -0
- cognite/neat/workflows/steps/lib/current/rules_exporter.py +106 -37
- cognite/neat/workflows/steps/lib/current/rules_importer.py +24 -22
- {cognite_neat-0.88.3.dist-info → cognite_neat-0.89.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.88.3.dist-info → cognite_neat-0.89.0.dist-info}/RECORD +71 -66
- cognite/neat/rules/models/_constants.py +0 -2
- cognite/neat/rules/models/_types/__init__.py +0 -19
- cognite/neat/rules/models/asset/_converter.py +0 -4
- cognite/neat/rules/models/dms/_converter.py +0 -143
- /cognite/neat/rules/models/{_types/_field.py → _types.py} +0 -0
- {cognite_neat-0.88.3.dist-info → cognite_neat-0.89.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.88.3.dist-info → cognite_neat-0.89.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.88.3.dist-info → cognite_neat-0.89.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from ._field import (
|
|
2
|
-
ExternalIdType,
|
|
3
|
-
NamespaceType,
|
|
4
|
-
PrefixType,
|
|
5
|
-
PropertyType,
|
|
6
|
-
StrListType,
|
|
7
|
-
StrOrListType,
|
|
8
|
-
VersionType,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
__all__ = [
|
|
12
|
-
"StrOrListType",
|
|
13
|
-
"StrListType",
|
|
14
|
-
"NamespaceType",
|
|
15
|
-
"PrefixType",
|
|
16
|
-
"ExternalIdType",
|
|
17
|
-
"VersionType",
|
|
18
|
-
"PropertyType",
|
|
19
|
-
]
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
from typing import TYPE_CHECKING, cast
|
|
3
|
-
|
|
4
|
-
from rdflib import Namespace
|
|
5
|
-
|
|
6
|
-
from cognite.neat.issues.warnings.user_modeling import ParentInDifferentSpaceWarning
|
|
7
|
-
from cognite.neat.rules.models._base import SheetList
|
|
8
|
-
from cognite.neat.rules.models.data_types import DataType
|
|
9
|
-
from cognite.neat.rules.models.domain import DomainRules
|
|
10
|
-
from cognite.neat.rules.models.entities import (
|
|
11
|
-
ClassEntity,
|
|
12
|
-
ContainerEntity,
|
|
13
|
-
DMSUnknownEntity,
|
|
14
|
-
ReferenceEntity,
|
|
15
|
-
UnknownEntity,
|
|
16
|
-
ViewEntity,
|
|
17
|
-
ViewPropertyEntity,
|
|
18
|
-
)
|
|
19
|
-
from cognite.neat.rules.models.information._rules import InformationRules
|
|
20
|
-
|
|
21
|
-
from ._rules import DMSMetadata, DMSProperty, DMSRules, DMSView
|
|
22
|
-
|
|
23
|
-
if TYPE_CHECKING:
|
|
24
|
-
from cognite.neat.rules.models.information._rules import InformationMetadata
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
class _DMSRulesConverter:
|
|
28
|
-
def __init__(self, dms: DMSRules):
|
|
29
|
-
self.dms = dms
|
|
30
|
-
|
|
31
|
-
def as_domain_rules(self) -> "DomainRules":
|
|
32
|
-
raise NotImplementedError("DomainRules not implemented yet")
|
|
33
|
-
|
|
34
|
-
def as_information_rules(
|
|
35
|
-
self,
|
|
36
|
-
) -> "InformationRules":
|
|
37
|
-
from cognite.neat.rules.models.information._rules import (
|
|
38
|
-
InformationClass,
|
|
39
|
-
InformationProperty,
|
|
40
|
-
InformationRules,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
dms = self.dms.metadata
|
|
44
|
-
|
|
45
|
-
metadata = self._convert_metadata_to_info(dms)
|
|
46
|
-
|
|
47
|
-
classes = [
|
|
48
|
-
InformationClass(
|
|
49
|
-
# we do not want a version in class as we use URI for the class
|
|
50
|
-
class_=ClassEntity(prefix=view.class_.prefix, suffix=view.class_.suffix),
|
|
51
|
-
description=view.description,
|
|
52
|
-
parent=[
|
|
53
|
-
# we do not want a version in class as we use URI for the class
|
|
54
|
-
implemented_view.as_class(skip_version=True)
|
|
55
|
-
# We only want parents in the same namespace, parent in a different namespace is a reference
|
|
56
|
-
for implemented_view in view.implements or []
|
|
57
|
-
if implemented_view.prefix == view.class_.prefix
|
|
58
|
-
],
|
|
59
|
-
reference=self._get_class_reference(view),
|
|
60
|
-
)
|
|
61
|
-
for view in self.dms.views
|
|
62
|
-
]
|
|
63
|
-
|
|
64
|
-
properties: list[InformationProperty] = []
|
|
65
|
-
value_type: DataType | ClassEntity | str
|
|
66
|
-
for property_ in self.dms.properties:
|
|
67
|
-
if isinstance(property_.value_type, DataType):
|
|
68
|
-
value_type = property_.value_type
|
|
69
|
-
elif isinstance(property_.value_type, ViewEntity | ViewPropertyEntity):
|
|
70
|
-
value_type = ClassEntity(
|
|
71
|
-
prefix=property_.value_type.prefix,
|
|
72
|
-
suffix=property_.value_type.suffix,
|
|
73
|
-
)
|
|
74
|
-
elif isinstance(property_.value_type, DMSUnknownEntity):
|
|
75
|
-
value_type = UnknownEntity()
|
|
76
|
-
else:
|
|
77
|
-
raise ValueError(f"Unsupported value type: {property_.value_type.type_}")
|
|
78
|
-
|
|
79
|
-
properties.append(
|
|
80
|
-
InformationProperty(
|
|
81
|
-
# Removing version
|
|
82
|
-
class_=ClassEntity(suffix=property_.class_.suffix, prefix=property_.class_.prefix),
|
|
83
|
-
property_=property_.view_property,
|
|
84
|
-
value_type=value_type,
|
|
85
|
-
description=property_.description,
|
|
86
|
-
min_count=0 if property_.nullable or property_.nullable is None else 1,
|
|
87
|
-
max_count=float("inf") if property_.is_list or property_.nullable is None else 1,
|
|
88
|
-
reference=self._get_property_reference(property_),
|
|
89
|
-
)
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
return InformationRules(
|
|
93
|
-
metadata=metadata,
|
|
94
|
-
properties=SheetList[InformationProperty](data=properties),
|
|
95
|
-
classes=SheetList[InformationClass](data=classes),
|
|
96
|
-
last=self.dms.last.as_information_rules() if self.dms.last else None,
|
|
97
|
-
reference=self.dms.reference.as_information_rules() if self.dms.reference else None,
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
@classmethod
|
|
101
|
-
def _convert_metadata_to_info(cls, metadata: DMSMetadata) -> "InformationMetadata":
|
|
102
|
-
from cognite.neat.rules.models.information._rules import InformationMetadata
|
|
103
|
-
|
|
104
|
-
prefix = metadata.space
|
|
105
|
-
return InformationMetadata(
|
|
106
|
-
schema_=metadata.schema_,
|
|
107
|
-
data_model_type=metadata.data_model_type,
|
|
108
|
-
extension=metadata.extension,
|
|
109
|
-
prefix=prefix,
|
|
110
|
-
namespace=Namespace(f"https://purl.orgl/neat/{prefix}/"),
|
|
111
|
-
version=metadata.version,
|
|
112
|
-
description=metadata.description,
|
|
113
|
-
name=metadata.name or metadata.external_id,
|
|
114
|
-
creator=metadata.creator,
|
|
115
|
-
created=metadata.created,
|
|
116
|
-
updated=metadata.updated,
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
@classmethod
|
|
120
|
-
def _get_class_reference(cls, view: DMSView) -> ReferenceEntity | None:
|
|
121
|
-
parents_other_namespace = [parent for parent in view.implements or [] if parent.prefix != view.class_.prefix]
|
|
122
|
-
if len(parents_other_namespace) == 0:
|
|
123
|
-
return None
|
|
124
|
-
if len(parents_other_namespace) > 1:
|
|
125
|
-
warnings.warn(
|
|
126
|
-
ParentInDifferentSpaceWarning(view.view.as_id()),
|
|
127
|
-
stacklevel=2,
|
|
128
|
-
)
|
|
129
|
-
other_parent = parents_other_namespace[0]
|
|
130
|
-
|
|
131
|
-
return ReferenceEntity(prefix=other_parent.prefix, suffix=other_parent.suffix)
|
|
132
|
-
|
|
133
|
-
@classmethod
|
|
134
|
-
def _get_property_reference(cls, property_: DMSProperty) -> ReferenceEntity | None:
|
|
135
|
-
has_container_other_namespace = property_.container and property_.container.prefix != property_.class_.prefix
|
|
136
|
-
if not has_container_other_namespace:
|
|
137
|
-
return None
|
|
138
|
-
container = cast(ContainerEntity, property_.container)
|
|
139
|
-
return ReferenceEntity(
|
|
140
|
-
prefix=container.prefix,
|
|
141
|
-
suffix=container.suffix,
|
|
142
|
-
property=property_.container_property,
|
|
143
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|