cognite-neat 0.73.4__py3-none-any.whl → 0.75.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/app/api/routers/core.py +1 -2
- cognite/neat/app/api/routers/data_exploration.py +1 -1
- cognite/neat/app/api/routers/rules.py +71 -37
- cognite/neat/app/ui/neat-app/build/asset-manifest.json +3 -3
- cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +116 -0
- cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +112 -0
- cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +34 -0
- cognite/neat/app/ui/neat-app/build/index.html +1 -1
- cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js → main.25d27396.js} +3 -3
- cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js.map → main.25d27396.js.map} +1 -1
- cognite/neat/constants.py +2 -2
- cognite/neat/graph/extractors/_mock_graph_generator.py +4 -4
- cognite/neat/graph/stores/_base.py +2 -23
- cognite/neat/legacy/graph/__init__.py +3 -0
- cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +20182 -0
- cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +20163 -0
- cognite/neat/legacy/graph/examples/__init__.py +7 -0
- cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- cognite/neat/legacy/graph/exceptions.py +91 -0
- cognite/neat/{graph/extractor → legacy/graph/extractors}/_base.py +1 -1
- cognite/neat/{graph/extractor → legacy/graph/extractors}/_dexpi.py +2 -2
- cognite/neat/{graph/extractor → legacy/graph/extractors}/_graph_capturing_sheet.py +6 -6
- cognite/neat/{graph/extractor → legacy/graph/extractors}/_mock_graph_generator.py +6 -5
- cognite/neat/{graph/loader → legacy/graph/loaders}/__init__.py +1 -1
- cognite/neat/{graph/loader → legacy/graph/loaders}/_asset_loader.py +3 -3
- cognite/neat/{graph/loader → legacy/graph/loaders}/_base.py +4 -4
- cognite/neat/{graph/loader → legacy/graph/loaders}/core/labels.py +2 -2
- cognite/neat/{graph/loader → legacy/graph/loaders}/core/models.py +1 -1
- cognite/neat/{graph/loader → legacy/graph/loaders}/core/rdf_to_assets.py +3 -3
- cognite/neat/{graph/loader → legacy/graph/loaders}/core/rdf_to_relationships.py +5 -5
- cognite/neat/{graph/loader → legacy/graph/loaders}/rdf_to_dms.py +5 -5
- cognite/neat/legacy/graph/models.py +6 -0
- cognite/neat/legacy/graph/stores/__init__.py +13 -0
- cognite/neat/legacy/graph/stores/_base.py +384 -0
- cognite/neat/legacy/graph/stores/_graphdb_store.py +51 -0
- cognite/neat/legacy/graph/stores/_memory_store.py +43 -0
- cognite/neat/legacy/graph/stores/_oxigraph_store.py +147 -0
- cognite/neat/legacy/graph/stores/_oxrdflib.py +247 -0
- cognite/neat/legacy/graph/stores/_rdf_to_graph.py +40 -0
- cognite/neat/{graph/transformation → legacy/graph/transformations}/entity_matcher.py +1 -1
- cognite/neat/{graph/transformation → legacy/graph/transformations}/query_generator/sparql.py +9 -7
- cognite/neat/{graph/transformation → legacy/graph/transformations}/transformer.py +12 -5
- cognite/neat/legacy/rules/__init__.py +0 -0
- cognite/neat/{rules → legacy/rules}/analysis.py +2 -2
- cognite/neat/legacy/rules/examples/__init__.py +18 -0
- cognite/neat/legacy/rules/examples/wind-energy.owl +1511 -0
- cognite/neat/legacy/rules/exceptions.py +2972 -0
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_base.py +2 -2
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_core/rules2labels.py +1 -1
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2dms.py +6 -6
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2excel.py +1 -1
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2graphql.py +5 -5
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2ontology.py +6 -6
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2pydantic_models.py +8 -8
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2rules.py +3 -2
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2triples.py +3 -2
- cognite/neat/{rules/exporter → legacy/rules/exporters}/_validation.py +2 -2
- cognite/neat/{rules/importer → legacy/rules/importers}/_base.py +2 -2
- cognite/neat/{rules/importer → legacy/rules/importers}/_dict2rules.py +1 -1
- cognite/neat/{rules/importer → legacy/rules/importers}/_dms2rules.py +2 -2
- cognite/neat/{rules/importer → legacy/rules/importers}/_graph2rules.py +5 -4
- cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2metadata.py +11 -7
- cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2rules.py +5 -5
- cognite/neat/{rules/importer → legacy/rules/importers}/_spreadsheet2rules.py +2 -2
- cognite/neat/{rules/importer → legacy/rules/importers}/_xsd2rules.py +1 -1
- cognite/neat/{rules/importer → legacy/rules/importers}/_yaml2rules.py +1 -1
- cognite/neat/{rules → legacy/rules}/models/raw_rules.py +4 -4
- cognite/neat/legacy/rules/models/rdfpath.py +238 -0
- cognite/neat/{rules → legacy/rules}/models/rules.py +4 -4
- cognite/neat/{rules → legacy/rules}/models/value_types.py +1 -1
- cognite/neat/rules/_shared.py +1 -1
- cognite/neat/rules/analysis/__init__.py +3 -0
- cognite/neat/rules/{_analysis → analysis}/_base.py +1 -1
- cognite/neat/rules/{_analysis → analysis}/_information_rules.py +3 -3
- cognite/neat/rules/examples/__init__.py +0 -9
- cognite/neat/rules/exporters/_base.py +1 -1
- cognite/neat/rules/exporters/_rules2dms.py +4 -4
- cognite/neat/rules/exporters/_rules2excel.py +2 -2
- cognite/neat/rules/exporters/_rules2ontology.py +4 -4
- cognite/neat/rules/exporters/_rules2yaml.py +1 -1
- cognite/neat/rules/exporters/_validation.py +2 -2
- cognite/neat/rules/importers/_base.py +1 -1
- cognite/neat/rules/importers/_dms2rules.py +10 -10
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +2 -2
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +3 -3
- cognite/neat/rules/importers/_dtdl2rules/spec.py +1 -1
- cognite/neat/rules/importers/_owl2rules/_owl2classes.py +1 -1
- cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +6 -6
- cognite/neat/rules/importers/_owl2rules/_owl2properties.py +1 -1
- cognite/neat/rules/importers/_owl2rules/_owl2rules.py +2 -2
- cognite/neat/rules/importers/_spreadsheet2rules.py +2 -2
- cognite/neat/rules/importers/_yaml2rules.py +1 -1
- cognite/neat/rules/models/_entity.py +142 -0
- cognite/neat/rules/models/rdfpath.py +6 -8
- cognite/neat/rules/models/{_rules → rules}/__init__.py +5 -5
- cognite/neat/rules/models/{_rules/base.py → rules/_base.py} +1 -1
- cognite/neat/rules/models/{_rules/dms_architect_rules.py → rules/_dms_architect_rules.py} +5 -5
- cognite/neat/rules/models/{_rules/dms_schema.py → rules/_dms_schema.py} +1 -1
- cognite/neat/rules/models/{_rules/domain_rules.py → rules/_domain_rules.py} +2 -2
- cognite/neat/rules/models/{_rules/information_rules.py → rules/_information_rules.py} +18 -15
- cognite/neat/rules/models/{_rules → rules}/_types/_base.py +18 -134
- cognite/neat/workflows/steps/data_contracts.py +4 -4
- cognite/neat/workflows/steps/lib/graph_store.py +1 -1
- cognite/neat/workflows/steps/lib/rules_exporter.py +18 -5
- cognite/neat/workflows/steps/lib/rules_importer.py +2 -2
- cognite/neat/workflows/steps/lib/rules_validator.py +2 -2
- cognite/neat/workflows/steps/lib/v1/graph_contextualization.py +1 -1
- cognite/neat/workflows/steps/lib/v1/graph_extractor.py +5 -5
- cognite/neat/workflows/steps/lib/v1/graph_loader.py +7 -7
- cognite/neat/workflows/steps/lib/v1/graph_store.py +7 -1
- cognite/neat/workflows/steps/lib/v1/graph_transformer.py +2 -2
- cognite/neat/workflows/steps/lib/v1/rules_exporter.py +7 -7
- cognite/neat/workflows/steps/lib/v1/rules_importer.py +13 -13
- {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/METADATA +1 -1
- cognite_neat-0.75.1.dist-info/RECORD +258 -0
- cognite_neat-0.73.4.dist-info/RECORD +0 -234
- /cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js.LICENSE.txt → main.25d27396.js.LICENSE.txt} +0 -0
- /cognite/neat/{graph/loader/core → legacy}/__init__.py +0 -0
- /cognite/neat/{graph/extractor → legacy/graph/extractors}/__init__.py +0 -0
- /cognite/neat/{graph/loader → legacy/graph/loaders}/_exceptions.py +0 -0
- /cognite/neat/{graph/transformation → legacy/graph/loaders/core}/__init__.py +0 -0
- /cognite/neat/{graph/loader → legacy/graph/loaders}/validator.py +0 -0
- /cognite/neat/{rules/_analysis → legacy/graph/transformations}/__init__.py +0 -0
- /cognite/neat/{graph/transformation → legacy/graph/transformations}/query_generator/__init__.py +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/Rules-Nordic44-to-TNT.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/power-grid-containers.yaml +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/power-grid-example.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/power-grid-model.yaml +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/rules-template.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/skos-rules.xlsx +0 -0
- /cognite/neat/{rules → legacy/rules}/examples/source-to-solution-mapping-rules.xlsx +0 -0
- /cognite/neat/{rules/exporter → legacy/rules/exporters}/__init__.py +0 -0
- /cognite/neat/{rules/exporter → legacy/rules/exporters}/_core/__init__.py +0 -0
- /cognite/neat/{rules/importer → legacy/rules/importers}/__init__.py +0 -0
- /cognite/neat/{rules/importer → legacy/rules/importers}/_json2rules.py +0 -0
- /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/__init__.py +0 -0
- /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2classes.py +0 -0
- /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2properties.py +0 -0
- /cognite/neat/{rules → legacy/rules}/models/__init__.py +0 -0
- /cognite/neat/{rules → legacy/rules}/models/_base.py +0 -0
- /cognite/neat/{rules → legacy/rules}/models/tables.py +0 -0
- /cognite/neat/rules/models/{_rules → rules}/_types/__init__.py +0 -0
- /cognite/neat/rules/models/{_rules → rules}/_types/_field.py +0 -0
- /cognite/neat/rules/models/{_rules → rules}/_types/_value.py +0 -0
- /cognite/neat/workflows/examples/{Export DMS → Export_DMS}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Export Rules to Ontology → Export_Rules_to_Ontology}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Extract DEXPI Graph and Export Rules → Extract_DEXPI_Graph_and_Export_Rules}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Extract RDF Graph and Generate Assets → Extract_RDF_Graph_and_Generate_Assets}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Import DMS → Import_DMS}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Ontology to Data Model → Ontology_to_Data_Model}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Validate Rules → Validate_Rules}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Validate Solution Model → Validate_Solution_Model}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Visualize Data Model Using Mock Graph → Visualize_Data_Model_Using_Mock_Graph}/workflow.yaml +0 -0
- /cognite/neat/workflows/examples/{Visualize Semantic Data Model → Visualize_Semantic_Data_Model}/workflow.yaml +0 -0
- {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/LICENSE +0 -0
- {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/WHEEL +0 -0
- {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import sys
|
|
3
|
-
from functools import total_ordering
|
|
4
3
|
from typing import Any, ClassVar, Literal, cast, overload
|
|
5
4
|
|
|
6
5
|
from cognite.client.data_classes.data_modeling import ContainerId, DataModelId, PropertyId, ViewId
|
|
7
|
-
from pydantic import BaseModel
|
|
8
6
|
|
|
7
|
+
from cognite.neat.rules.models._entity import (
|
|
8
|
+
ENTITY_ID_REGEX_COMPILED,
|
|
9
|
+
PREFIX_REGEX,
|
|
10
|
+
PROPERTY_REGEX,
|
|
11
|
+
SUFFIX_REGEX,
|
|
12
|
+
VERSION_REGEX,
|
|
13
|
+
VERSIONED_ENTITY_REGEX_COMPILED,
|
|
14
|
+
Entity,
|
|
15
|
+
EntityTypes,
|
|
16
|
+
Undefined,
|
|
17
|
+
Unknown,
|
|
18
|
+
)
|
|
9
19
|
from cognite.neat.rules.models.rdfpath import (
|
|
10
20
|
SINGLE_PROPERTY_REGEX_COMPILED,
|
|
11
21
|
AllReferences,
|
|
@@ -16,56 +26,20 @@ from cognite.neat.rules.models.rdfpath import (
|
|
|
16
26
|
)
|
|
17
27
|
|
|
18
28
|
if sys.version_info >= (3, 11):
|
|
19
|
-
from enum import StrEnum
|
|
20
29
|
from typing import Self
|
|
21
30
|
else:
|
|
22
|
-
from backports.strenum import StrEnum
|
|
23
31
|
from typing_extensions import Self
|
|
24
32
|
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
object = "object"
|
|
30
|
-
class_ = "class"
|
|
31
|
-
parent_class = "parent_class"
|
|
32
|
-
property_ = "property"
|
|
33
|
-
object_property = "ObjectProperty"
|
|
34
|
-
data_property = "DatatypeProperty"
|
|
35
|
-
annotation_property = "AnnotationProperty"
|
|
36
|
-
object_value_type = "object_value_type"
|
|
37
|
-
data_value_type = "data_value_type" # these are strings, floats, ...
|
|
38
|
-
xsd_value_type = "xsd_value_type"
|
|
39
|
-
dms_value_type = "dms_value_type"
|
|
40
|
-
view = "view"
|
|
41
|
-
view_prop = "view_prop"
|
|
42
|
-
reference_entity = "reference_entity"
|
|
43
|
-
container = "container"
|
|
44
|
-
datamodel = "datamodel"
|
|
45
|
-
undefined = "undefined"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# ALLOWED
|
|
49
|
-
ALLOWED_PATTERN = r"[^a-zA-Z0-9-_.]"
|
|
50
|
-
|
|
51
|
-
# FOR PARSING STRINGS:
|
|
52
|
-
PREFIX_REGEX = r"[a-zA-Z]+[a-zA-Z0-9-_.]*[a-zA-Z0-9]+"
|
|
53
|
-
SUFFIX_REGEX = r"[a-zA-Z0-9-_.]+[a-zA-Z0-9]|[-_.]*[a-zA-Z0-9]+"
|
|
54
|
-
VERSION_REGEX = r"[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?"
|
|
55
|
-
PROPERTY_REGEX = r"[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]?"
|
|
56
|
-
ENTITY_ID_REGEX = rf"{PREFIX_REGEX}:({SUFFIX_REGEX})"
|
|
57
|
-
ENTITY_ID_REGEX_COMPILED = re.compile(rf"^(?P<prefix>{PREFIX_REGEX}):(?P<suffix>{SUFFIX_REGEX})$")
|
|
58
|
-
VERSIONED_ENTITY_REGEX_COMPILED = re.compile(
|
|
59
|
-
rf"^(?P<prefix>{PREFIX_REGEX}):(?P<suffix>{SUFFIX_REGEX})\(version=(?P<version>{VERSION_REGEX})\)$"
|
|
60
|
-
)
|
|
34
|
+
VERSION_ID_REGEX = rf"\(version=(?P<version>{VERSION_REGEX})\)"
|
|
35
|
+
|
|
36
|
+
|
|
61
37
|
PROPERTY_ENTITY_REGEX_COMPILED = re.compile(
|
|
62
38
|
rf"^((?P<prefix>{PREFIX_REGEX}):)?(?P<suffix>{SUFFIX_REGEX})"
|
|
63
39
|
rf"\((version=(?P<version>{VERSION_REGEX}), )?property=(?P<property>{PROPERTY_REGEX})\)$"
|
|
64
40
|
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
PROPERTY_ID_REGEX = rf"\((?P<{EntityTypes.property_}>{ENTITY_ID_REGEX})\)"
|
|
68
|
-
VERSION_ID_REGEX = rf"\(version=(?P<version>{VERSION_REGEX})\)"
|
|
41
|
+
|
|
42
|
+
|
|
69
43
|
MORE_THAN_ONE_NONE_ALPHANUMERIC_REGEX = r"([_-]{2,})"
|
|
70
44
|
PREFIX_COMPLIANCE_REGEX = r"^([a-zA-Z]+)([a-zA-Z0-9]*[_-]{0,1}[a-zA-Z0-9_-]*)([a-zA-Z0-9]*)$"
|
|
71
45
|
DATA_MODEL_ID_COMPLIANCE_REGEX = r"^[a-zA-Z]([a-zA-Z0-9_]{0,253}[a-zA-Z0-9])?$"
|
|
@@ -87,96 +61,6 @@ PROPERTY_ID_COMPLIANCE_REGEX = r"^(\*)|(?!^(Property|property)$)(^[a-zA-Z][a-zA-
|
|
|
87
61
|
VERSION_COMPLIANCE_REGEX = r"^[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?$"
|
|
88
62
|
|
|
89
63
|
|
|
90
|
-
Undefined = type(object())
|
|
91
|
-
Unknown = type(object())
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# mypy does not like the sentinel value, and it is not possible to ignore only the line with it below.
|
|
95
|
-
# so we ignore all errors beyond this point.
|
|
96
|
-
# mypy: ignore-errors
|
|
97
|
-
@total_ordering
|
|
98
|
-
class Entity(BaseModel, arbitrary_types_allowed=True):
|
|
99
|
-
"""Entity is a class or property in OWL/RDF sense."""
|
|
100
|
-
|
|
101
|
-
type_: ClassVar[EntityTypes] = EntityTypes.undefined
|
|
102
|
-
prefix: str | Undefined = Undefined
|
|
103
|
-
suffix: str | Unknown
|
|
104
|
-
version: str | None = None
|
|
105
|
-
name: str | None = None
|
|
106
|
-
description: str | None = None
|
|
107
|
-
|
|
108
|
-
def __lt__(self, other: object) -> bool:
|
|
109
|
-
if type(self) is not type(other) or not isinstance(other, Entity):
|
|
110
|
-
return NotImplemented
|
|
111
|
-
return self.versioned_id < other.versioned_id
|
|
112
|
-
|
|
113
|
-
def __eq__(self, other: object) -> bool:
|
|
114
|
-
if type(self) is not type(other) or not isinstance(other, Entity):
|
|
115
|
-
return NotImplemented
|
|
116
|
-
return self.versioned_id == other.versioned_id
|
|
117
|
-
|
|
118
|
-
def __hash__(self) -> int:
|
|
119
|
-
return hash(self.versioned_id)
|
|
120
|
-
|
|
121
|
-
def as_non_versioned_entity(self) -> Self:
|
|
122
|
-
return self.from_string(f"{self.prefix}:{self.suffix}")
|
|
123
|
-
|
|
124
|
-
@property
|
|
125
|
-
def id(self) -> str:
|
|
126
|
-
if self.suffix is Unknown:
|
|
127
|
-
return "#N/A"
|
|
128
|
-
elif self.prefix is Undefined:
|
|
129
|
-
return self.suffix
|
|
130
|
-
else:
|
|
131
|
-
return f"{self.prefix}:{self.suffix}"
|
|
132
|
-
|
|
133
|
-
@property
|
|
134
|
-
def versioned_id(self) -> str:
|
|
135
|
-
if self.version is None:
|
|
136
|
-
return self.id
|
|
137
|
-
else:
|
|
138
|
-
return f"{self.id}(version={self.version})"
|
|
139
|
-
|
|
140
|
-
@property
|
|
141
|
-
def space(self) -> str:
|
|
142
|
-
"""Returns entity space in CDF."""
|
|
143
|
-
return self.prefix
|
|
144
|
-
|
|
145
|
-
@property
|
|
146
|
-
def external_id(self) -> str:
|
|
147
|
-
"""Returns entity external id in CDF."""
|
|
148
|
-
return self.suffix
|
|
149
|
-
|
|
150
|
-
def __repr__(self):
|
|
151
|
-
return self.versioned_id
|
|
152
|
-
|
|
153
|
-
def __str__(self):
|
|
154
|
-
return self.versioned_id
|
|
155
|
-
|
|
156
|
-
@classmethod
|
|
157
|
-
def from_string(cls, entity_string: str, base_prefix: str | None = None) -> Self:
|
|
158
|
-
if entity_string == "#N/A":
|
|
159
|
-
return cls(prefix=Undefined, suffix=Unknown)
|
|
160
|
-
elif result := VERSIONED_ENTITY_REGEX_COMPILED.match(entity_string):
|
|
161
|
-
return cls(
|
|
162
|
-
prefix=result.group("prefix"),
|
|
163
|
-
suffix=result.group("suffix"),
|
|
164
|
-
version=result.group("version"),
|
|
165
|
-
)
|
|
166
|
-
elif result := ENTITY_ID_REGEX_COMPILED.match(entity_string):
|
|
167
|
-
return cls(prefix=result.group("prefix"), suffix=result.group("suffix"))
|
|
168
|
-
elif base_prefix and re.match(SUFFIX_REGEX, entity_string) and re.match(PREFIX_REGEX, base_prefix):
|
|
169
|
-
return cls(prefix=base_prefix, suffix=entity_string)
|
|
170
|
-
else:
|
|
171
|
-
raise ValueError(f"{cls.__name__} is expected to be prefix:suffix, got {entity_string}")
|
|
172
|
-
|
|
173
|
-
@classmethod
|
|
174
|
-
def from_list(cls, entity_strings: list[str], base_prefix: str | None = None) -> list[Self]:
|
|
175
|
-
return [
|
|
176
|
-
cls.from_string(entity_string=entity_string, base_prefix=base_prefix) for entity_string in entity_strings
|
|
177
|
-
]
|
|
178
|
-
|
|
179
|
-
|
|
180
64
|
class ContainerEntity(Entity):
|
|
181
65
|
type_: ClassVar[EntityTypes] = EntityTypes.container
|
|
182
66
|
|
|
@@ -293,7 +177,7 @@ class ViewPropEntity(ViewEntity):
|
|
|
293
177
|
return ViewPropEntity(
|
|
294
178
|
prefix=prop_id.source.space,
|
|
295
179
|
suffix=prop_id.source.external_id,
|
|
296
|
-
version=prop_id.source.version,
|
|
180
|
+
version=cast(ViewId, prop_id.source).version,
|
|
297
181
|
property_=prop_id.property,
|
|
298
182
|
)
|
|
299
183
|
|
|
@@ -4,10 +4,10 @@ from cognite.client import CogniteClient
|
|
|
4
4
|
from cognite.client.data_classes import Asset, AssetUpdate, Relationship, RelationshipUpdate
|
|
5
5
|
from cognite.client.data_classes.data_modeling import EdgeApply, NodeApply
|
|
6
6
|
|
|
7
|
-
from cognite.neat.graph.stores import NeatGraphStoreBase
|
|
8
|
-
from cognite.neat.rules.
|
|
9
|
-
from cognite.neat.rules.models.
|
|
10
|
-
from cognite.neat.rules.models.rules import
|
|
7
|
+
from cognite.neat.legacy.graph.stores import NeatGraphStoreBase
|
|
8
|
+
from cognite.neat.legacy.rules.exporters._rules2dms import DMSSchemaComponents
|
|
9
|
+
from cognite.neat.legacy.rules.models.rules import Rules
|
|
10
|
+
from cognite.neat.rules.models.rules import DMSRules, DomainRules, InformationRules
|
|
11
11
|
from cognite.neat.workflows.steps.step_model import DataContract
|
|
12
12
|
|
|
13
13
|
|
|
@@ -3,7 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
from typing import ClassVar, cast
|
|
4
4
|
|
|
5
5
|
from cognite.neat.constants import PREFIXES
|
|
6
|
-
from cognite.neat.graph import stores
|
|
6
|
+
from cognite.neat.legacy.graph import stores
|
|
7
7
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
8
8
|
from cognite.neat.workflows.model import FlowMessage
|
|
9
9
|
from cognite.neat.workflows.steps.data_contracts import RulesData, SolutionGraph, SourceGraph
|
|
@@ -4,7 +4,7 @@ from typing import ClassVar, Literal, cast
|
|
|
4
4
|
|
|
5
5
|
from cognite.neat.rules import exporters
|
|
6
6
|
from cognite.neat.rules._shared import DMSRules, InformationRules, Rules
|
|
7
|
-
from cognite.neat.rules.models.
|
|
7
|
+
from cognite.neat.rules.models.rules import RoleTypes
|
|
8
8
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
9
9
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
10
10
|
from cognite.neat.workflows.steps.data_contracts import CogniteClient, MultiRuleData
|
|
@@ -98,9 +98,11 @@ class RulesToDMS(Step):
|
|
|
98
98
|
|
|
99
99
|
dms_exporter = exporters.DMSExporter(
|
|
100
100
|
export_components=frozenset(components_to_create),
|
|
101
|
-
include_space=
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
include_space=(
|
|
102
|
+
None
|
|
103
|
+
if multi_space_components_create
|
|
104
|
+
else {input_rules.metadata.space if isinstance(input_rules, DMSRules) else input_rules.metadata.prefix}
|
|
105
|
+
),
|
|
104
106
|
existing_handling=existing_components_handling,
|
|
105
107
|
)
|
|
106
108
|
|
|
@@ -169,6 +171,11 @@ class RulesToExcel(Step):
|
|
|
169
171
|
"rules will be used.",
|
|
170
172
|
options=["input", *RoleTypes.__members__.keys()],
|
|
171
173
|
),
|
|
174
|
+
Configurable(
|
|
175
|
+
name="File path",
|
|
176
|
+
value="",
|
|
177
|
+
label="File path to the generated Excel file.For example: 'staging/exported-rules.xlsx'",
|
|
178
|
+
),
|
|
172
179
|
]
|
|
173
180
|
|
|
174
181
|
def run(self, rules: MultiRuleData) -> FlowMessage: # type: ignore[override, syntax]
|
|
@@ -200,12 +207,18 @@ class RulesToExcel(Step):
|
|
|
200
207
|
output_dir.mkdir(parents=True, exist_ok=True)
|
|
201
208
|
file_name = f"exported_rules_{output_role.value}.xlsx"
|
|
202
209
|
filepath = output_dir / file_name
|
|
210
|
+
if self.configs.get("File path", ""):
|
|
211
|
+
file_name = self.configs["File path"]
|
|
212
|
+
filepath = Path(self.data_store_path) / Path(file_name)
|
|
213
|
+
else:
|
|
214
|
+
file_name = f"staging/{file_name}"
|
|
215
|
+
|
|
203
216
|
excel_exporter.export_to_file(rule_instance, filepath)
|
|
204
217
|
|
|
205
218
|
output_text = (
|
|
206
219
|
"<p></p>"
|
|
207
220
|
f"Download Excel Exported {output_role.value} rules: "
|
|
208
|
-
f'- <a href="/data/
|
|
221
|
+
f'- <a href="/data/{file_name}?{time.time()}" '
|
|
209
222
|
f'target="_blank">{file_name}</a>'
|
|
210
223
|
)
|
|
211
224
|
|
|
@@ -6,8 +6,8 @@ from cognite.client import CogniteClient
|
|
|
6
6
|
|
|
7
7
|
from cognite.neat.rules import importers
|
|
8
8
|
from cognite.neat.rules.issues.formatters import FORMATTER_BY_NAME
|
|
9
|
-
from cognite.neat.rules.models.
|
|
10
|
-
from cognite.neat.rules.models.
|
|
9
|
+
from cognite.neat.rules.models.rules import RoleTypes
|
|
10
|
+
from cognite.neat.rules.models.rules._types import DataModelEntity, Undefined
|
|
11
11
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
12
12
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
13
13
|
from cognite.neat.workflows.steps.data_contracts import MultiRuleData
|
|
@@ -8,8 +8,8 @@ from cognite.client import CogniteClient
|
|
|
8
8
|
from cognite.neat.rules.issues import IssueList
|
|
9
9
|
from cognite.neat.rules.issues.dms import MissingContainerError, MissingSpaceError, MissingViewError
|
|
10
10
|
from cognite.neat.rules.issues.formatters import FORMATTER_BY_NAME
|
|
11
|
-
from cognite.neat.rules.models.
|
|
12
|
-
from cognite.neat.rules.models.
|
|
11
|
+
from cognite.neat.rules.models.rules import DMSRules
|
|
12
|
+
from cognite.neat.rules.models.rules._base import SchemaCompleteness
|
|
13
13
|
from cognite.neat.utils import cdf_loaders
|
|
14
14
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
15
15
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from typing import ClassVar, cast
|
|
2
2
|
|
|
3
|
-
from cognite.neat.graph.
|
|
3
|
+
from cognite.neat.legacy.graph.transformations.entity_matcher import simple_entity_matcher
|
|
4
4
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
5
5
|
from cognite.neat.workflows.model import FlowMessage
|
|
6
6
|
from cognite.neat.workflows.steps.data_contracts import SolutionGraph, SourceGraph
|
|
@@ -9,9 +9,9 @@ from typing import ClassVar, cast
|
|
|
9
9
|
from rdflib import RDF, XSD, Literal, Namespace, URIRef
|
|
10
10
|
|
|
11
11
|
from cognite.neat.constants import PREFIXES
|
|
12
|
-
from cognite.neat.graph import
|
|
13
|
-
from cognite.neat.graph.
|
|
14
|
-
from cognite.neat.rules.
|
|
12
|
+
from cognite.neat.legacy.graph import extractors
|
|
13
|
+
from cognite.neat.legacy.graph.extractors._mock_graph_generator import generate_triples as generate_mock_triples
|
|
14
|
+
from cognite.neat.legacy.rules.exporters._rules2triples import get_instances_as_triples
|
|
15
15
|
from cognite.neat.utils.utils import create_sha256_hash
|
|
16
16
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
17
17
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
@@ -114,7 +114,7 @@ class ExtractGraphFromDexpiFile(Step):
|
|
|
114
114
|
base_namespace = self.configs.get("base_namespace", None)
|
|
115
115
|
|
|
116
116
|
if file_path:
|
|
117
|
-
triples =
|
|
117
|
+
triples = extractors.DexpiXML(self.data_store_path / Path(file_path), base_namespace).extract()
|
|
118
118
|
source_graph.graph.add_triples(triples, verbose=True)
|
|
119
119
|
|
|
120
120
|
logging.info(f"Loaded {file_path} into source graph.")
|
|
@@ -162,7 +162,7 @@ class ExtractGraphFromGraphCapturingSheet(Step):
|
|
|
162
162
|
if file_path:
|
|
163
163
|
logging.info(f"Processing graph capture sheet {self.data_store_path / Path(file_path)}")
|
|
164
164
|
|
|
165
|
-
triples =
|
|
165
|
+
triples = extractors.GraphCapturingSheet(
|
|
166
166
|
rules=rules.rules,
|
|
167
167
|
filepath=self.data_store_path / Path(file_path),
|
|
168
168
|
namespace=self.configs.get("base_namespace", None),
|
|
@@ -8,9 +8,9 @@ from cognite.client import CogniteClient
|
|
|
8
8
|
from cognite.client.data_classes import Asset, AssetFilter
|
|
9
9
|
from prometheus_client import Gauge
|
|
10
10
|
|
|
11
|
-
from cognite.neat.graph import
|
|
12
|
-
from cognite.neat.graph.
|
|
13
|
-
from cognite.neat.graph.
|
|
11
|
+
from cognite.neat.legacy.graph import loaders as graph_loader
|
|
12
|
+
from cognite.neat.legacy.graph.loaders import upload_labels
|
|
13
|
+
from cognite.neat.legacy.graph.loaders.core.rdf_to_assets import (
|
|
14
14
|
NeatMetadataKeys,
|
|
15
15
|
categorize_assets,
|
|
16
16
|
rdf2assets,
|
|
@@ -18,14 +18,14 @@ from cognite.neat.graph.loader.core.rdf_to_assets import (
|
|
|
18
18
|
unique_asset_labels,
|
|
19
19
|
upload_assets,
|
|
20
20
|
)
|
|
21
|
-
from cognite.neat.graph.
|
|
21
|
+
from cognite.neat.legacy.graph.loaders.core.rdf_to_relationships import (
|
|
22
22
|
categorize_relationships,
|
|
23
23
|
rdf2relationships,
|
|
24
24
|
upload_relationships,
|
|
25
25
|
)
|
|
26
|
-
from cognite.neat.graph.
|
|
27
|
-
from cognite.neat.graph.
|
|
28
|
-
from cognite.neat.rules.models.rdfpath import TransformationRuleType
|
|
26
|
+
from cognite.neat.legacy.graph.loaders.rdf_to_dms import upload_edges, upload_nodes
|
|
27
|
+
from cognite.neat.legacy.graph.loaders.validator import validate_asset_hierarchy
|
|
28
|
+
from cognite.neat.legacy.rules.models.rdfpath import TransformationRuleType
|
|
29
29
|
from cognite.neat.utils.utils import generate_exception_report
|
|
30
30
|
from cognite.neat.workflows._exceptions import StepFlowContextNotInitialized, StepNotInitialized
|
|
31
31
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
@@ -3,7 +3,7 @@ from pathlib import Path
|
|
|
3
3
|
from typing import ClassVar, cast
|
|
4
4
|
|
|
5
5
|
from cognite.neat.constants import PREFIXES
|
|
6
|
-
from cognite.neat.graph import stores
|
|
6
|
+
from cognite.neat.legacy.graph import stores
|
|
7
7
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
8
8
|
from cognite.neat.workflows.model import FlowMessage
|
|
9
9
|
from cognite.neat.workflows.steps.data_contracts import RulesData, SolutionGraph, SourceGraph
|
|
@@ -262,6 +262,12 @@ class ConfigureGraphStore(Step):
|
|
|
262
262
|
"neat-tnt",
|
|
263
263
|
internal_storage_dir=store_dir,
|
|
264
264
|
)
|
|
265
|
+
logging.info(50 * "*")
|
|
266
|
+
logging.info(50 * "*")
|
|
267
|
+
logging.info(50 * "*")
|
|
268
|
+
logging.info(type(new_graph_store))
|
|
269
|
+
logging.info(50 * "*")
|
|
270
|
+
logging.info(50 * "*")
|
|
265
271
|
|
|
266
272
|
return (
|
|
267
273
|
FlowMessage(output_text="Graph store configured successfully"),
|
|
@@ -2,8 +2,8 @@ from typing import ClassVar
|
|
|
2
2
|
|
|
3
3
|
from cognite.client import CogniteClient
|
|
4
4
|
|
|
5
|
-
from cognite.neat.graph.
|
|
6
|
-
from cognite.neat.rules.
|
|
5
|
+
from cognite.neat.legacy.graph.transformations.transformer import RuleProcessingReport, domain2app_knowledge_graph
|
|
6
|
+
from cognite.neat.legacy.rules.exporters._rules2triples import get_instances_as_triples
|
|
7
7
|
from cognite.neat.workflows.model import FlowMessage
|
|
8
8
|
from cognite.neat.workflows.steps.data_contracts import RulesData, SolutionGraph, SourceGraph
|
|
9
9
|
from cognite.neat.workflows.steps.step_model import Configurable, Step
|
|
@@ -6,12 +6,12 @@ from typing import ClassVar, Literal, cast
|
|
|
6
6
|
|
|
7
7
|
from cognite.client import data_modeling as dm
|
|
8
8
|
|
|
9
|
-
import cognite.neat.graph.
|
|
9
|
+
import cognite.neat.legacy.graph.extractors._graph_capturing_sheet
|
|
10
10
|
from cognite.neat.exceptions import wrangle_warnings
|
|
11
|
-
from cognite.neat.rules import
|
|
12
|
-
from cognite.neat.rules.
|
|
13
|
-
from cognite.neat.rules.
|
|
14
|
-
from cognite.neat.rules.
|
|
11
|
+
from cognite.neat.legacy.rules import exporters
|
|
12
|
+
from cognite.neat.legacy.rules.exporters._rules2dms import DMSSchemaComponents
|
|
13
|
+
from cognite.neat.legacy.rules.exporters._rules2graphql import GraphQLSchema
|
|
14
|
+
from cognite.neat.legacy.rules.exporters._rules2ontology import Ontology
|
|
15
15
|
from cognite.neat.utils.utils import generate_exception_report
|
|
16
16
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
17
17
|
from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
|
|
@@ -485,7 +485,7 @@ class ExportRulesToGraphCapturingSheet(Step):
|
|
|
485
485
|
|
|
486
486
|
data_capture_sheet_path = staging_dir / sheet_name
|
|
487
487
|
|
|
488
|
-
cognite.neat.graph.
|
|
488
|
+
cognite.neat.legacy.graph.extractors._graph_capturing_sheet.rules2graph_capturing_sheet(
|
|
489
489
|
rules.rules, data_capture_sheet_path, auto_identifier_type=auto_identifier_type
|
|
490
490
|
)
|
|
491
491
|
|
|
@@ -509,5 +509,5 @@ class ExportRulesToExcel(Step):
|
|
|
509
509
|
|
|
510
510
|
def run(self, rules_data: RulesData) -> FlowMessage: # type: ignore[override, syntax]
|
|
511
511
|
full_path = Path(self.data_store_path) / Path(self.configs["output_file_path"])
|
|
512
|
-
|
|
512
|
+
exporters.ExcelExporter.from_rules(rules=rules_data.rules).export_to_file(filepath=full_path)
|
|
513
513
|
return FlowMessage(output_text="Generated Excel file from rules")
|
|
@@ -9,10 +9,10 @@ import yaml
|
|
|
9
9
|
from prometheus_client import Gauge
|
|
10
10
|
from rdflib import Namespace
|
|
11
11
|
|
|
12
|
-
from cognite.neat.rules import
|
|
13
|
-
from cognite.neat.rules.models.rdfpath import TransformationRuleType
|
|
14
|
-
from cognite.neat.rules.models.rules import Class, Classes, Metadata, Properties, Property, Rules
|
|
15
|
-
from cognite.neat.rules.models.value_types import ValueType
|
|
12
|
+
from cognite.neat.legacy.rules import exporters, importers
|
|
13
|
+
from cognite.neat.legacy.rules.models.rdfpath import TransformationRuleType
|
|
14
|
+
from cognite.neat.legacy.rules.models.rules import Class, Classes, Metadata, Properties, Property, Rules
|
|
15
|
+
from cognite.neat.legacy.rules.models.value_types import ValueType
|
|
16
16
|
from cognite.neat.utils.utils import generate_exception_report
|
|
17
17
|
from cognite.neat.workflows import utils
|
|
18
18
|
from cognite.neat.workflows._exceptions import StepNotInitialized
|
|
@@ -93,7 +93,7 @@ class ImportExcelToRules(Step):
|
|
|
93
93
|
else:
|
|
94
94
|
store.load_rules_file_from_cdf(str(rules_file), version)
|
|
95
95
|
|
|
96
|
-
raw_rules =
|
|
96
|
+
raw_rules = importers.ExcelImporter(rules_file_path).to_raw_rules()
|
|
97
97
|
rules, errors, _ = raw_rules.to_rules(return_report=True, skip_validation=False)
|
|
98
98
|
report = "# RULES VALIDATION REPORT\n\n" + generate_exception_report(errors, "Errors")
|
|
99
99
|
|
|
@@ -157,15 +157,15 @@ class ImportOntologyToRules(Step):
|
|
|
157
157
|
|
|
158
158
|
make_compliant = self.configs["make_compliant"] == "True"
|
|
159
159
|
try:
|
|
160
|
-
rules =
|
|
160
|
+
rules = importers.OWLImporter(ontology_file_path).to_rules(make_compliant=make_compliant)
|
|
161
161
|
except Exception:
|
|
162
|
-
rules =
|
|
162
|
+
rules = importers.OWLImporter(ontology_file_path).to_rules(
|
|
163
163
|
skip_validation=True, make_compliant=make_compliant
|
|
164
164
|
)
|
|
165
165
|
assert isinstance(rules, Rules)
|
|
166
|
-
|
|
166
|
+
exporters.ExcelExporter.from_rules(rules).export_to_file(excel_file_path)
|
|
167
167
|
|
|
168
|
-
if report :=
|
|
168
|
+
if report := importers.ExcelImporter(filepath=excel_file_path).to_raw_rules().validate_rules():
|
|
169
169
|
report_file_path.write_text(report)
|
|
170
170
|
|
|
171
171
|
relative_excel_file_path = str(excel_file_path).split("/data/")[1]
|
|
@@ -581,18 +581,18 @@ class ImportGraphToRules(Step):
|
|
|
581
581
|
report_file_path = excel_file_path.parent / f"report_{excel_file_path.stem}.txt"
|
|
582
582
|
|
|
583
583
|
try:
|
|
584
|
-
rules =
|
|
584
|
+
rules = importers.GraphImporter(
|
|
585
585
|
graph_store.graph.graph, int(self.configs["max_number_of_instances"])
|
|
586
586
|
).to_rules()
|
|
587
587
|
except Exception:
|
|
588
|
-
rules =
|
|
588
|
+
rules = importers.GraphImporter(
|
|
589
589
|
graph_store.graph.graph, int(self.configs["max_number_of_instances"])
|
|
590
590
|
).to_rules(skip_validation=True)
|
|
591
591
|
|
|
592
592
|
assert isinstance(rules, Rules)
|
|
593
|
-
|
|
593
|
+
exporters.ExcelExporter.from_rules(rules).export_to_file(excel_file_path)
|
|
594
594
|
|
|
595
|
-
if report :=
|
|
595
|
+
if report := importers.ExcelImporter(filepath=excel_file_path).to_raw_rules().validate_rules():
|
|
596
596
|
report_file_path.write_text(report)
|
|
597
597
|
|
|
598
598
|
relative_excel_file_path = str(excel_file_path).split("/data/")[1]
|