cognite-neat 0.88.2__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/__init__.py +0 -3
- cognite/neat/graph/extractors/_mock_graph_generator.py +2 -1
- cognite/neat/graph/loaders/_base.py +3 -3
- cognite/neat/graph/loaders/_rdf2asset.py +24 -25
- cognite/neat/graph/loaders/_rdf2dms.py +20 -15
- cognite/neat/issues/__init__.py +1 -3
- cognite/neat/issues/_base.py +261 -71
- cognite/neat/issues/errors/__init__.py +73 -0
- cognite/neat/issues/errors/_external.py +67 -0
- cognite/neat/issues/errors/_general.py +35 -0
- cognite/neat/issues/errors/_properties.py +62 -0
- cognite/neat/issues/errors/_resources.py +111 -0
- cognite/neat/issues/errors/_workflow.py +36 -0
- cognite/neat/issues/formatters.py +1 -1
- cognite/neat/issues/warnings/__init__.py +66 -0
- cognite/neat/issues/warnings/_external.py +40 -0
- cognite/neat/issues/warnings/_general.py +29 -0
- cognite/neat/issues/warnings/_models.py +92 -0
- cognite/neat/issues/warnings/_properties.py +44 -0
- cognite/neat/issues/warnings/_resources.py +55 -0
- cognite/neat/issues/warnings/user_modeling.py +113 -0
- cognite/neat/rules/_shared.py +53 -2
- cognite/neat/rules/analysis/_base.py +1 -1
- cognite/neat/rules/exporters/_base.py +7 -18
- cognite/neat/rules/exporters/_rules2dms.py +17 -20
- cognite/neat/rules/exporters/_rules2excel.py +9 -16
- cognite/neat/rules/exporters/_rules2ontology.py +77 -64
- cognite/neat/rules/exporters/_rules2yaml.py +6 -9
- cognite/neat/rules/exporters/_validation.py +11 -96
- cognite/neat/rules/importers/_base.py +9 -58
- cognite/neat/rules/importers/_dms2rules.py +188 -135
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +48 -35
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +36 -45
- cognite/neat/rules/importers/_dtdl2rules/spec.py +7 -0
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +8 -4
- 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 +12 -19
- cognite/neat/rules/importers/_rdf/_inference2rules.py +14 -37
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +1 -0
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +1 -0
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +9 -20
- cognite/neat/rules/importers/_rdf/_shared.py +4 -4
- cognite/neat/rules/importers/_spreadsheet2rules.py +46 -97
- cognite/neat/rules/importers/_yaml2rules.py +32 -58
- 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/_rdfpath.py +4 -4
- cognite/neat/rules/models/{_types/_field.py → _types.py} +5 -10
- cognite/neat/rules/models/asset/__init__.py +5 -2
- cognite/neat/rules/models/asset/_rules.py +3 -23
- cognite/neat/rules/models/asset/_rules_input.py +40 -115
- cognite/neat/rules/models/asset/_validation.py +14 -10
- 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 +102 -34
- cognite/neat/rules/models/dms/_rules.py +65 -162
- cognite/neat/rules/models/dms/_rules_input.py +186 -254
- cognite/neat/rules/models/dms/_schema.py +87 -78
- cognite/neat/rules/models/dms/_serializer.py +44 -3
- cognite/neat/rules/models/dms/_validation.py +106 -68
- 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 +10 -22
- cognite/neat/rules/models/information/_rules_input.py +57 -204
- cognite/neat/rules/models/information/_validation.py +48 -25
- cognite/neat/rules/transformers/__init__.py +21 -0
- cognite/neat/rules/transformers/_base.py +81 -0
- cognite/neat/rules/{models/information/_converter.py → transformers/_converters.py} +217 -21
- 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/{graph/stores → store}/_provenance.py +10 -1
- cognite/neat/utils/auxiliary.py +2 -35
- cognite/neat/utils/cdf/data_classes.py +20 -0
- cognite/neat/utils/regex_patterns.py +6 -0
- cognite/neat/utils/text.py +17 -0
- cognite/neat/workflows/base.py +4 -4
- cognite/neat/workflows/cdf_store.py +3 -3
- cognite/neat/workflows/steps/data_contracts.py +1 -1
- cognite/neat/workflows/steps/lib/current/graph_extractor.py +3 -3
- cognite/neat/workflows/steps/lib/current/graph_loader.py +2 -2
- cognite/neat/workflows/steps/lib/current/graph_store.py +1 -1
- cognite/neat/workflows/steps/lib/current/rules_exporter.py +116 -47
- cognite/neat/workflows/steps/lib/current/rules_importer.py +30 -28
- cognite/neat/workflows/steps/lib/current/rules_validator.py +5 -6
- cognite/neat/workflows/steps/lib/io/io_steps.py +5 -5
- cognite/neat/workflows/steps_registry.py +4 -5
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/RECORD +105 -106
- cognite/neat/exceptions.py +0 -145
- cognite/neat/graph/exceptions.py +0 -90
- cognite/neat/issues/errors/external.py +0 -21
- cognite/neat/issues/errors/properties.py +0 -75
- cognite/neat/issues/errors/resources.py +0 -123
- cognite/neat/issues/errors/schema.py +0 -0
- cognite/neat/issues/neat_warnings/__init__.py +0 -2
- cognite/neat/issues/neat_warnings/identifier.py +0 -27
- cognite/neat/issues/neat_warnings/models.py +0 -22
- cognite/neat/issues/neat_warnings/properties.py +0 -77
- cognite/neat/issues/neat_warnings/resources.py +0 -125
- cognite/neat/rules/issues/__init__.py +0 -22
- cognite/neat/rules/issues/base.py +0 -63
- cognite/neat/rules/issues/dms.py +0 -549
- cognite/neat/rules/issues/fileread.py +0 -197
- cognite/neat/rules/issues/ontology.py +0 -298
- cognite/neat/rules/issues/spreadsheet.py +0 -563
- cognite/neat/rules/issues/spreadsheet_file.py +0 -151
- cognite/neat/rules/issues/tables.py +0 -72
- cognite/neat/rules/models/_constants.py +0 -1
- 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 -145
- cognite/neat/workflows/_exceptions.py +0 -41
- /cognite/neat/{graph/stores → store}/__init__.py +0 -0
- /cognite/neat/{graph/stores → store}/_base.py +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
from abc import ABC
|
|
2
|
-
from dataclasses import dataclass
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
from typing import Any, ClassVar
|
|
5
|
-
|
|
6
|
-
from .base import NeatValidationError
|
|
7
|
-
|
|
8
|
-
__all__ = [
|
|
9
|
-
"SpreadsheetFileError",
|
|
10
|
-
"SpreadsheetNotFoundError",
|
|
11
|
-
"MetadataSheetMissingOrFailedError",
|
|
12
|
-
"SheetMissingError",
|
|
13
|
-
"ReadSpreadsheetsError",
|
|
14
|
-
"InvalidRoleError",
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
@dataclass(frozen=True)
|
|
19
|
-
class SpreadsheetFileError(NeatValidationError, ABC):
|
|
20
|
-
description = "Error when reading spreadsheet"
|
|
21
|
-
filepath: Path
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@dataclass(frozen=True)
|
|
25
|
-
class SpreadsheetNotFoundError(SpreadsheetFileError):
|
|
26
|
-
description: ClassVar[str] = "Spreadsheet not found"
|
|
27
|
-
fix: ClassVar[str] = "Make sure to provide a valid spreadsheet"
|
|
28
|
-
|
|
29
|
-
def message(self) -> str:
|
|
30
|
-
return f"Spreadsheet {self.filepath.name} not found"
|
|
31
|
-
|
|
32
|
-
def dump(self) -> dict[str, Any]:
|
|
33
|
-
output = super().dump()
|
|
34
|
-
output["spreadsheet_name"] = str(self.filepath)
|
|
35
|
-
return output
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@dataclass(frozen=True)
|
|
39
|
-
class MetadataSheetMissingOrFailedError(SpreadsheetFileError):
|
|
40
|
-
description: ClassVar[str] = "Metadata sheet is missing or it failed validation for one or more fields"
|
|
41
|
-
fix: ClassVar[str] = "Make sure to define compliant Metadata sheet before proceeding"
|
|
42
|
-
hint: str | None = None
|
|
43
|
-
sheet_name: str = "Metadata"
|
|
44
|
-
|
|
45
|
-
def message(self) -> str:
|
|
46
|
-
output = (
|
|
47
|
-
f" {self.sheet_name} sheet is missing or it failed"
|
|
48
|
-
+ f" validation for one or more fields in {self.filepath.name}. "
|
|
49
|
-
+ self.fix
|
|
50
|
-
)
|
|
51
|
-
if self.hint:
|
|
52
|
-
output += f" Hint: {self.hint}"
|
|
53
|
-
return output
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@dataclass(frozen=True)
|
|
57
|
-
class RoleMissingOrUnsupportedError(SpreadsheetFileError):
|
|
58
|
-
description: ClassVar[str] = "Role field in Metadata sheet is missing or its value is unsupported"
|
|
59
|
-
fix: ClassVar[str] = "Make sure to define compliant role in Metadata sheet before proceeding"
|
|
60
|
-
|
|
61
|
-
hint: str | None = None
|
|
62
|
-
|
|
63
|
-
def message(self) -> str:
|
|
64
|
-
output = (
|
|
65
|
-
f"Role field in Metadata sheet is missing or its value is unsupported {self.filepath.name}. " + self.fix
|
|
66
|
-
)
|
|
67
|
-
if self.hint:
|
|
68
|
-
output += f" Hint: {self.hint}"
|
|
69
|
-
return output
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@dataclass(frozen=True)
|
|
73
|
-
class RoleMismatchError(SpreadsheetFileError):
|
|
74
|
-
description: ClassVar[str] = "Roles between user and reference Metadata sheets do not match"
|
|
75
|
-
fix: ClassVar[str] = "Make sure that both user and reference Metadata sheets have the same role defined"
|
|
76
|
-
|
|
77
|
-
hint: str | None = None
|
|
78
|
-
|
|
79
|
-
def message(self) -> str:
|
|
80
|
-
output = f"Roles between user and reference Metadata sheets do not match {self.filepath.name}. " + self.fix
|
|
81
|
-
if self.hint:
|
|
82
|
-
output += f" Hint: {self.hint}"
|
|
83
|
-
return output
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
@dataclass(frozen=True)
|
|
87
|
-
class SchemaMissingOrUnsupportedError(SpreadsheetFileError):
|
|
88
|
-
description: ClassVar[str] = "Schema field in Metadata sheet is missing or its value unsupported"
|
|
89
|
-
fix: ClassVar[str] = "Make sure to define compliant schema in Metadata sheet before proceeding"
|
|
90
|
-
|
|
91
|
-
hint: str | None = None
|
|
92
|
-
|
|
93
|
-
def message(self) -> str:
|
|
94
|
-
output = (
|
|
95
|
-
f"Schema field in Metadata sheet is missing or its value unsupported in file {self.filepath.name}. "
|
|
96
|
-
+ self.fix
|
|
97
|
-
)
|
|
98
|
-
if self.hint:
|
|
99
|
-
output += f" Hint: {self.hint}"
|
|
100
|
-
return output
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
@dataclass(frozen=True)
|
|
104
|
-
class SheetMissingError(SpreadsheetFileError):
|
|
105
|
-
description: ClassVar[str] = "Spreadsheet(s) is missing"
|
|
106
|
-
fix: ClassVar[str] = "Make sure to provide compliant spreadsheet(s) before proceeding"
|
|
107
|
-
|
|
108
|
-
missing_spreadsheets: list[str]
|
|
109
|
-
|
|
110
|
-
def message(self) -> str:
|
|
111
|
-
if len(self.missing_spreadsheets) == 1:
|
|
112
|
-
return f"Spreadsheet {self.missing_spreadsheets[0]} is missing"
|
|
113
|
-
else:
|
|
114
|
-
return f"Spreadsheets {', '.join(self.missing_spreadsheets)} are missing"
|
|
115
|
-
|
|
116
|
-
def dump(self) -> dict[str, Any]:
|
|
117
|
-
output = super().dump()
|
|
118
|
-
output["missing_spreadsheets"] = self.missing_spreadsheets
|
|
119
|
-
return output
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@dataclass(frozen=True)
|
|
123
|
-
class ReadSpreadsheetsError(SpreadsheetFileError):
|
|
124
|
-
description: ClassVar[str] = "Error reading spreadsheet(s)"
|
|
125
|
-
fix: ClassVar[str] = "Is the excel document open in another program? Is the file corrupted?"
|
|
126
|
-
|
|
127
|
-
error_message: str
|
|
128
|
-
|
|
129
|
-
def message(self) -> str:
|
|
130
|
-
return f"Error reading spreadsheet {self.filepath.name}: {self.error_message}"
|
|
131
|
-
|
|
132
|
-
def dump(self) -> dict[str, Any]:
|
|
133
|
-
output = super().dump()
|
|
134
|
-
output["error_message"] = self.error_message
|
|
135
|
-
return output
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
@dataclass(frozen=True)
|
|
139
|
-
class InvalidRoleError(NeatValidationError):
|
|
140
|
-
description: ClassVar[str] = "Invalid role"
|
|
141
|
-
fix: ClassVar[str] = "Make sure to provide a valid role"
|
|
142
|
-
|
|
143
|
-
provided_role: str
|
|
144
|
-
|
|
145
|
-
def message(self) -> str:
|
|
146
|
-
return f"Invalid role: {self.provided_role}"
|
|
147
|
-
|
|
148
|
-
def dump(self) -> dict[str, Any]:
|
|
149
|
-
output = super().dump()
|
|
150
|
-
output["provided_role"] = self.provided_role
|
|
151
|
-
return output
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
|
|
3
|
-
from .base import NeatValidationError
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@dataclass(frozen=True)
|
|
7
|
-
class NotValidRDFPathError(NeatValidationError):
|
|
8
|
-
"""Provided `rdfpath` is not valid, i.e. it cannot be converted to SPARQL query.
|
|
9
|
-
|
|
10
|
-
Args:
|
|
11
|
-
rdf_path: `rdfpath` that raised exception
|
|
12
|
-
|
|
13
|
-
Notes:
|
|
14
|
-
Get familiar with `rdfpath` to avoid this exception.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
description = "Provided `rdfpath` is not valid, i.e. it cannot be converted to SPARQL query"
|
|
18
|
-
fix = "Get familiar with `rdfpath` and check if provided path is valid!"
|
|
19
|
-
rdf_path: str
|
|
20
|
-
|
|
21
|
-
def message(self) -> str:
|
|
22
|
-
message = f"{self.rdf_path} is not a valid rdfpath!"
|
|
23
|
-
|
|
24
|
-
message += f"\nDescription: {self.description}"
|
|
25
|
-
message += f"\nFix: {self.fix}"
|
|
26
|
-
return message
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
@dataclass(frozen=True)
|
|
30
|
-
class NotValidTableLookUpError(NeatValidationError):
|
|
31
|
-
"""Provided `table lookup` is not valid, i.e. it cannot be converted to CDF lookup.
|
|
32
|
-
|
|
33
|
-
Args:
|
|
34
|
-
table_look_up: `table_look_up`, a part of `rawlookup`, that raised exception
|
|
35
|
-
|
|
36
|
-
Notes:
|
|
37
|
-
Get familiar with `rawlookup` and `rdfpath` to avoid this exception.
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
description = "Provided table lookup is not valid, i.e. it cannot be converted to CDF lookup"
|
|
41
|
-
fix = "Get familiar with RAW look up and RDF paths and check if provided rawlookup is valid"
|
|
42
|
-
table_look_up: str
|
|
43
|
-
|
|
44
|
-
def message(self) -> str:
|
|
45
|
-
message = f"{self.table_look_up} is not a valid table lookup"
|
|
46
|
-
|
|
47
|
-
message += f"\nDescription: {self.description}"
|
|
48
|
-
message += f"\nFix: {self.fix}"
|
|
49
|
-
return message
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
@dataclass(frozen=True)
|
|
53
|
-
class NotValidRAWLookUpError(NeatValidationError):
|
|
54
|
-
"""Provided `rawlookup` is not valid, i.e. it cannot be converted to SPARQL query and CDF lookup
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
raw_look_up: `rawlookup` rule that raised exception
|
|
58
|
-
|
|
59
|
-
Notes:
|
|
60
|
-
Get familiar with `rawlookup` and `rdfpath` to avoid this exception.
|
|
61
|
-
"""
|
|
62
|
-
|
|
63
|
-
description = "Provided rawlookup is not valid, i.e. it cannot be converted to SPARQL query and CDF lookup"
|
|
64
|
-
fix = "Get familiar with `rawlookup` and `rdfpath` to avoid this exception"
|
|
65
|
-
raw_look_up: str
|
|
66
|
-
|
|
67
|
-
def message(self):
|
|
68
|
-
message = f"Invalid rawlookup expected traversal | table lookup, got {self.raw_look_up}"
|
|
69
|
-
|
|
70
|
-
message += f"\nDescription: {self.description}"
|
|
71
|
-
message += f"\nFix: {self.fix}"
|
|
72
|
-
return message
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
DMS_CONTAINER_SIZE_LIMIT = 100
|
|
@@ -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,145 +0,0 @@
|
|
|
1
|
-
import warnings
|
|
2
|
-
from typing import TYPE_CHECKING, cast
|
|
3
|
-
|
|
4
|
-
from rdflib import Namespace
|
|
5
|
-
|
|
6
|
-
from cognite.neat.rules import issues
|
|
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
|
-
issues.dms.MultipleReferenceWarning(
|
|
127
|
-
view_id=view.view.as_id(), implements=[v.as_id() for v in parents_other_namespace]
|
|
128
|
-
),
|
|
129
|
-
stacklevel=2,
|
|
130
|
-
)
|
|
131
|
-
other_parent = parents_other_namespace[0]
|
|
132
|
-
|
|
133
|
-
return ReferenceEntity(prefix=other_parent.prefix, suffix=other_parent.suffix)
|
|
134
|
-
|
|
135
|
-
@classmethod
|
|
136
|
-
def _get_property_reference(cls, property_: DMSProperty) -> ReferenceEntity | None:
|
|
137
|
-
has_container_other_namespace = property_.container and property_.container.prefix != property_.class_.prefix
|
|
138
|
-
if not has_container_other_namespace:
|
|
139
|
-
return None
|
|
140
|
-
container = cast(ContainerEntity, property_.container)
|
|
141
|
-
return ReferenceEntity(
|
|
142
|
-
prefix=container.prefix,
|
|
143
|
-
suffix=container.suffix,
|
|
144
|
-
property=property_.container_property,
|
|
145
|
-
)
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
from cognite.neat.exceptions import NeatException
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class InvalidStepOutputException(NeatException):
|
|
5
|
-
type_ = "invalid_step_output"
|
|
6
|
-
code = 400
|
|
7
|
-
description = "The step output is invalid."
|
|
8
|
-
example = "The step output must be a dictionary."
|
|
9
|
-
|
|
10
|
-
def __init__(self, step_type: str):
|
|
11
|
-
self.message = f"Object type {step_type} is not supported as step output"
|
|
12
|
-
super().__init__(self.message)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class ConfigurationNotSet(NeatException):
|
|
16
|
-
type_ = "configuration_not_set"
|
|
17
|
-
code = 400
|
|
18
|
-
description = "The configuration is not set."
|
|
19
|
-
example = "The configuration must be set before running the workflow."
|
|
20
|
-
|
|
21
|
-
def __init__(self, config_variable: str):
|
|
22
|
-
self.message = (
|
|
23
|
-
f"The configuration variable '{config_variable}' is not set. "
|
|
24
|
-
f"Please set the configuration before running the workflow."
|
|
25
|
-
)
|
|
26
|
-
super().__init__(self.message)
|
|
27
|
-
|
|
28
|
-
def __str__(self):
|
|
29
|
-
return self.message
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class StepNotInitialized(NeatException):
|
|
33
|
-
def __init__(self, step_name: str):
|
|
34
|
-
self.message = f"Step {step_name} has not been initialized."
|
|
35
|
-
super().__init__(self.message)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class StepFlowContextNotInitialized(NeatException):
|
|
39
|
-
def __init__(self, step_name: str):
|
|
40
|
-
self.message = f"Step {step_name} requires flow context which is missing."
|
|
41
|
-
super().__init__(self.message)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|