cognite-neat 0.88.1__py3-none-any.whl → 0.88.3__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.
Files changed (103) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/graph/__init__.py +0 -3
  3. cognite/neat/graph/loaders/_base.py +6 -6
  4. cognite/neat/graph/loaders/_rdf2asset.py +28 -31
  5. cognite/neat/graph/loaders/_rdf2dms.py +24 -15
  6. cognite/neat/issues/__init__.py +14 -0
  7. cognite/neat/issues/_base.py +415 -0
  8. cognite/neat/issues/errors/__init__.py +72 -0
  9. cognite/neat/issues/errors/_external.py +67 -0
  10. cognite/neat/issues/errors/_general.py +28 -0
  11. cognite/neat/issues/errors/_properties.py +62 -0
  12. cognite/neat/issues/errors/_resources.py +111 -0
  13. cognite/neat/issues/errors/_workflow.py +36 -0
  14. cognite/neat/{rules/issues → issues}/formatters.py +10 -10
  15. cognite/neat/issues/warnings/__init__.py +66 -0
  16. cognite/neat/issues/warnings/_external.py +40 -0
  17. cognite/neat/issues/warnings/_general.py +29 -0
  18. cognite/neat/issues/warnings/_models.py +92 -0
  19. cognite/neat/issues/warnings/_properties.py +44 -0
  20. cognite/neat/issues/warnings/_resources.py +55 -0
  21. cognite/neat/issues/warnings/user_modeling.py +113 -0
  22. cognite/neat/rules/_shared.py +10 -2
  23. cognite/neat/rules/exporters/_base.py +6 -6
  24. cognite/neat/rules/exporters/_rules2dms.py +19 -11
  25. cognite/neat/rules/exporters/_rules2excel.py +4 -4
  26. cognite/neat/rules/exporters/_rules2ontology.py +74 -51
  27. cognite/neat/rules/exporters/_rules2yaml.py +3 -3
  28. cognite/neat/rules/exporters/_validation.py +11 -96
  29. cognite/neat/rules/importers/__init__.py +7 -3
  30. cognite/neat/rules/importers/_base.py +9 -13
  31. cognite/neat/rules/importers/_dms2rules.py +42 -24
  32. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +49 -53
  33. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +31 -23
  34. cognite/neat/rules/importers/_dtdl2rules/spec.py +7 -0
  35. cognite/neat/rules/importers/_rdf/_imf2rules/__init__.py +3 -0
  36. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +82 -0
  37. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +34 -0
  38. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +123 -0
  39. cognite/neat/rules/importers/{_owl2rules/_owl2rules.py → _rdf/_imf2rules/_imf2rules.py} +24 -18
  40. cognite/neat/rules/importers/{_inference2rules.py → _rdf/_inference2rules.py} +9 -9
  41. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +58 -0
  42. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2metadata.py +68 -0
  43. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +60 -0
  44. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +76 -0
  45. cognite/neat/rules/importers/_rdf/_shared.py +586 -0
  46. cognite/neat/rules/importers/_spreadsheet2rules.py +35 -22
  47. cognite/neat/rules/importers/_yaml2rules.py +23 -21
  48. cognite/neat/rules/models/_constants.py +2 -1
  49. cognite/neat/rules/models/_rdfpath.py +4 -4
  50. cognite/neat/rules/models/_types/_field.py +9 -11
  51. cognite/neat/rules/models/asset/_rules.py +1 -3
  52. cognite/neat/rules/models/asset/_validation.py +14 -10
  53. cognite/neat/rules/models/dms/_converter.py +2 -4
  54. cognite/neat/rules/models/dms/_exporter.py +30 -8
  55. cognite/neat/rules/models/dms/_rules.py +23 -7
  56. cognite/neat/rules/models/dms/_schema.py +94 -62
  57. cognite/neat/rules/models/dms/_validation.py +105 -66
  58. cognite/neat/rules/models/entities.py +3 -0
  59. cognite/neat/rules/models/information/_converter.py +2 -2
  60. cognite/neat/rules/models/information/_rules.py +7 -8
  61. cognite/neat/rules/models/information/_validation.py +48 -25
  62. cognite/neat/rules/transformers/__init__.py +0 -0
  63. cognite/neat/rules/transformers/_base.py +15 -0
  64. cognite/neat/utils/auxiliary.py +2 -35
  65. cognite/neat/utils/text.py +17 -0
  66. cognite/neat/workflows/base.py +4 -4
  67. cognite/neat/workflows/cdf_store.py +3 -3
  68. cognite/neat/workflows/steps/data_contracts.py +1 -1
  69. cognite/neat/workflows/steps/lib/current/graph_extractor.py +3 -3
  70. cognite/neat/workflows/steps/lib/current/graph_loader.py +2 -2
  71. cognite/neat/workflows/steps/lib/current/graph_store.py +1 -1
  72. cognite/neat/workflows/steps/lib/current/rules_exporter.py +10 -10
  73. cognite/neat/workflows/steps/lib/current/rules_importer.py +78 -6
  74. cognite/neat/workflows/steps/lib/current/rules_validator.py +20 -9
  75. cognite/neat/workflows/steps/lib/io/io_steps.py +5 -5
  76. cognite/neat/workflows/steps_registry.py +4 -5
  77. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.3.dist-info}/METADATA +1 -1
  78. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.3.dist-info}/RECORD +86 -77
  79. cognite/neat/exceptions.py +0 -145
  80. cognite/neat/graph/exceptions.py +0 -90
  81. cognite/neat/graph/issues/loader.py +0 -104
  82. cognite/neat/issues.py +0 -158
  83. cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -215
  84. cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -209
  85. cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -203
  86. cognite/neat/rules/issues/__init__.py +0 -26
  87. cognite/neat/rules/issues/base.py +0 -82
  88. cognite/neat/rules/issues/dms.py +0 -683
  89. cognite/neat/rules/issues/fileread.py +0 -197
  90. cognite/neat/rules/issues/importing.py +0 -423
  91. cognite/neat/rules/issues/ontology.py +0 -298
  92. cognite/neat/rules/issues/spreadsheet.py +0 -563
  93. cognite/neat/rules/issues/spreadsheet_file.py +0 -151
  94. cognite/neat/rules/issues/tables.py +0 -72
  95. cognite/neat/workflows/_exceptions.py +0 -41
  96. /cognite/neat/{graph/issues → rules/importers/_rdf}/__init__.py +0 -0
  97. /cognite/neat/rules/importers/{_owl2rules → _rdf/_owl2rules}/__init__.py +0 -0
  98. /cognite/neat/{graph/stores → store}/__init__.py +0 -0
  99. /cognite/neat/{graph/stores → store}/_base.py +0 -0
  100. /cognite/neat/{graph/stores → store}/_provenance.py +0 -0
  101. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.3.dist-info}/LICENSE +0 -0
  102. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.3.dist-info}/WHEEL +0 -0
  103. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.3.dist-info}/entry_points.txt +0 -0
@@ -1,197 +0,0 @@
1
- from abc import ABC
2
- from dataclasses import dataclass
3
- from pathlib import Path
4
-
5
- from .base import NeatValidationError, ValidationWarning
6
-
7
- __all__ = [
8
- "FileReadWarning",
9
- "InvalidFileFormatWarning",
10
- "UnsupportedSpecWarning",
11
- "UnknownItemWarning",
12
- "FailedLoadWarning",
13
- "BugInImporterWarning",
14
- "FileReadError",
15
- "FileNotFoundError",
16
- "FileNotAFileError",
17
- "InvalidFileFormatError",
18
- "FailedStringLoadError",
19
- ]
20
-
21
-
22
- @dataclass(frozen=True)
23
- class FileReadError(NeatValidationError, ABC):
24
- description = "An error was raised during reading."
25
- fix = "No fix is available."
26
-
27
- filepath: Path
28
-
29
- def dump(self) -> dict[str, str | None]:
30
- output = super().dump()
31
- output["filepath"] = str(self.filepath)
32
- return output
33
-
34
-
35
- @dataclass(frozen=True)
36
- class FileReadWarning(ValidationWarning, ABC):
37
- description = "A warning was raised during reading."
38
- fix = "No fix is available."
39
-
40
- filepath: Path
41
-
42
- def dump(self) -> dict[str, str | None]:
43
- output = super().dump()
44
- output["filepath"] = str(self.filepath)
45
- return output
46
-
47
-
48
- @dataclass(frozen=True)
49
- class InvalidFileFormatWarning(FileReadWarning):
50
- description = "The file format is invalid"
51
- fix = "Check if the file format is supported."
52
-
53
- reason: str
54
-
55
- def message(self) -> str:
56
- return f"Skipping invalid file {self.filepath.name}: {self.reason}"
57
-
58
- def dump(self) -> dict[str, str | None]:
59
- output = super().dump()
60
- output["reason"] = self.reason
61
- return output
62
-
63
-
64
- @dataclass(frozen=True)
65
- class UnsupportedSpecWarning(FileReadWarning):
66
- description = "The spec in the file is not supported"
67
- fix = "Change to an supported spec"
68
-
69
- spec_name: str
70
- version: str | None = None
71
-
72
- def message(self) -> str:
73
- if self.version:
74
- suffix = f"{self.spec_name} v{self.version} is not supported."
75
- else:
76
- suffix = f"{self.spec_name} is not supported."
77
- return f"Skipping file {self.filepath.name}: {suffix}. {self.fix}"
78
-
79
- def dump(self) -> dict[str, str | None]:
80
- output = super().dump()
81
- output["spec_name"] = self.spec_name
82
- output["version"] = self.version
83
- return output
84
-
85
-
86
- @dataclass(frozen=True)
87
- class UnknownItemWarning(FileReadWarning):
88
- description = "The file is missing an implementation"
89
- fix = "Check if the file is supported. If not, contact the neat team on Github."
90
-
91
- reason: str
92
-
93
- def message(self) -> str:
94
- return f"Skipping file {self.filepath.name}: {self.reason}. {self.fix}"
95
-
96
- def dump(self) -> dict[str, str | None]:
97
- output = super().dump()
98
- output["reason"] = self.reason
99
- return output
100
-
101
-
102
- @dataclass(frozen=True)
103
- class FailedLoadWarning(FileReadWarning):
104
- description = "The file content is invalid"
105
- fix = "Check if the file content is valid"
106
-
107
- expected_format: str
108
- error_message: str
109
-
110
- def message(self) -> str:
111
- return (
112
- f"Failed to load {self.filepath.name}. Expected format: {self.expected_format}. Error: {self.error_message}"
113
- )
114
-
115
- def dump(self) -> dict[str, str | None]:
116
- output = super().dump()
117
- output["expected_format"] = self.expected_format
118
- output["error_message"] = self.error_message
119
- return output
120
-
121
-
122
- @dataclass(frozen=True)
123
- class BugInImporterWarning(FileReadWarning):
124
- description = "A bug was raised during reading."
125
- fix = "No fix is available. Contact the neat team on Github"
126
-
127
- importer_name: str
128
- error: str
129
-
130
- def message(self) -> str:
131
- return f"Bug in importer {self.importer_name} when reading {self.filepath.name}: {self.error}"
132
-
133
- def dump(self) -> dict[str, str | None]:
134
- output = super().dump()
135
- output["importer_name"] = self.importer_name
136
- output["error"] = self.error
137
- return output
138
-
139
-
140
- @dataclass(frozen=True)
141
- class FileNotFoundError(FileReadError):
142
- description = "The file was not found"
143
- fix = "Check if the file exists."
144
-
145
- def message(self) -> str:
146
- return f"File {self.filepath} was not found. {self.fix}"
147
-
148
-
149
- @dataclass(frozen=True)
150
- class FileNotAFileError(FileReadError):
151
- description = "The file is not a file"
152
- fix = "Check if the file exists."
153
-
154
- def message(self) -> str:
155
- return f"{self.filepath} is not a file. {self.fix}"
156
-
157
-
158
- @dataclass(frozen=True)
159
- class InvalidFileFormatError(FileReadError):
160
- description = "The file is not in the expected format"
161
- fix = "Check if the file is in the expected format"
162
-
163
- expected_format: list[str]
164
-
165
- def message(self) -> str:
166
- return f"{self.filepath} is not in the expected format. Expected format: {self.expected_format}."
167
-
168
-
169
- @dataclass(frozen=True)
170
- class FailedStringLoadError(NeatValidationError):
171
- description = "The file content is invalid"
172
- fix = "Check if the file content is valid"
173
-
174
- expected_format: str
175
- error_message: str
176
-
177
- def message(self) -> str:
178
- return f"Failed to load string. Expected format: {self.expected_format}. Error: {self.error_message}"
179
-
180
- def dump(self) -> dict[str, str | None]:
181
- output = super().dump()
182
- output["expected_format"] = self.expected_format
183
- output["error_message"] = self.error_message
184
- return output
185
-
186
-
187
- @dataclass(frozen=True)
188
- class NoFilesFoundError(FileReadError):
189
- description = "No files were found in the directory"
190
- fix = "Check if the directory contains files"
191
-
192
- expected_formats: list[str] | None = None
193
-
194
- def message(self) -> str:
195
- if self.expected_formats:
196
- return f"No files were found in {self.filepath.name}. Expected format: {self.expected_formats}. {self.fix}"
197
- return f"No files were found in {self.filepath.name}. {self.fix}"
@@ -1,423 +0,0 @@
1
- from abc import ABC
2
- from dataclasses import dataclass
3
- from typing import Any
4
-
5
- from .base import NeatValidationError, ValidationWarning
6
-
7
- __all__ = [
8
- "ModelImportWarning",
9
- "UnknownComponentWarning",
10
- "UnknownSubComponentWarning",
11
- "IgnoredComponentWarning",
12
- "UnknownPropertyWarning",
13
- "UnknownValueTypeWarning",
14
- "MissingContainerWarning",
15
- "MissingContainerPropertyWarning",
16
- "MultipleDataModelsWarning",
17
- "UnknownPropertyTypeWarning",
18
- "FailedToInferValueTypeWarning",
19
- "MoreThanOneNonAlphanumericCharacterWarning",
20
- "UnknownContainerConstraintWarning",
21
- "NoDataModelError",
22
- "ModelImportError",
23
- "InvalidComponentError",
24
- "MissingParentDefinitionError",
25
- "MissingIdentifierError",
26
- "UnsupportedPropertyTypeError",
27
- "APIError",
28
- "FailedImportWarning",
29
- ]
30
-
31
-
32
- @dataclass(frozen=True)
33
- class ModelImportWarning(ValidationWarning, ABC):
34
- description = "A warning was raised during importing."
35
-
36
-
37
- @dataclass(frozen=True)
38
- class UnknownComponentWarning(ModelImportWarning):
39
- description = "Unknown component this will be ignored in the imports."
40
- fix = "Check if the component is defined in the source file."
41
-
42
- component_type: str
43
- instance_name: str | None = None
44
- instance_id: str | None = None
45
-
46
- def dump(self) -> dict[str, str | None]:
47
- output = super().dump()
48
- output["component_type"] = self.component_type
49
- output["instance_name"] = self.instance_name
50
- output["instance_id"] = self.instance_id
51
- return output
52
-
53
- def message(self) -> str:
54
- if self.instance_name:
55
- prefix = f"Unknown component of type'{self.component_type}' with name '{self.instance_name}'."
56
- else:
57
- prefix = f"Unknown component '{self.component_type}'"
58
- return f"{prefix} This will be ignored in the imports."
59
-
60
-
61
- @dataclass(frozen=True)
62
- class UnknownSubComponentWarning(UnknownComponentWarning):
63
- sub_component: str | None = None
64
-
65
- def dump(self) -> dict[str, str | None]:
66
- output = super().dump()
67
- output["sub_component"] = self.sub_component
68
- return output
69
-
70
- def message(self) -> str:
71
- if self.instance_name:
72
- prefix = f"Unknown sub-component of type'{self.component_type}' with name '{self.instance_name}'."
73
- else:
74
- prefix = f"Unknown sub-component '{self.component_type}'"
75
- return f"{prefix} This will be ignored in the imports."
76
-
77
-
78
- @dataclass(frozen=True)
79
- class IgnoredComponentWarning(ModelImportWarning):
80
- description = "This will be ignored in the imports."
81
- fix = "No fix is available. "
82
-
83
- reason: str
84
- identifier: str | None = None
85
-
86
- def dump(self) -> dict[str, str | None]:
87
- output = super().dump()
88
- output["reason"] = self.reason
89
- output["identifier"] = self.identifier
90
- return output
91
-
92
- def message(self) -> str:
93
- if self.identifier:
94
- prefix = f"Identifier '{self.identifier}.' is ignored."
95
- else:
96
- prefix = "This is ignored."
97
- return f"{prefix} {self.reason}"
98
-
99
-
100
- @dataclass(frozen=True)
101
- class UnknownPropertyWarning(ValidationWarning):
102
- description = "Unknown property this will be ignored in the imports."
103
- fix = "Check if the property is defined in the DTDL file."
104
-
105
- component_type: str
106
- property_name: str
107
- instance_name: str | None = None
108
- instance_id: str | None = None
109
-
110
- def dump(self) -> dict[str, str | None]:
111
- output = super().dump()
112
- output["component_type"] = self.component_type
113
- output["property_name"] = self.property_name
114
- output["instance_name"] = self.instance_name
115
- output["instance_id"] = self.instance_id
116
- return output
117
-
118
- def message(self) -> str:
119
- if self.instance_name:
120
- prefix = (
121
- f"Unknown property '{self.property_name}' of component "
122
- f"'{self.component_type}' with name '{self.instance_name}'."
123
- )
124
- else:
125
- prefix = f"Unknown property '{self.property_name}' of component '{self.component_type}'"
126
- return f"{prefix} This will be ignored in the imports."
127
-
128
-
129
- @dataclass(frozen=True)
130
- class PropertyRedefinedWarning(ValidationWarning):
131
- description = "Property, {property}, redefined in {class_}. This will be ignored in the imports."
132
- fix = "Check if the property is defined only once."
133
-
134
- property_id: str
135
- class_id: str
136
-
137
- def dump(self) -> dict[str, str]:
138
- return {"property_id": self.property_id, "class_id": self.class_id}
139
-
140
- def message(self) -> str:
141
- return self.description.format(property=self.property_id, class_=self.class_id)
142
-
143
-
144
- @dataclass(frozen=True)
145
- class UnknownValueTypeWarning(ModelImportWarning):
146
- description = "Unknown value type. This limits validation done by NEAT. "
147
- fix = "Set the value type"
148
- class_id: str
149
- property_id: str
150
-
151
- def dump(self) -> dict[str, str]:
152
- return {"class_id": self.class_id, "property_id": self.property_id}
153
-
154
- def message(self) -> str:
155
- return (
156
- f"Unknown value type for property '{self.property_id}' of class '{self.class_id}'. "
157
- "This limits validation done by NEAT."
158
- )
159
-
160
-
161
- @dataclass(frozen=True)
162
- class MultipleDataModelsWarning(ModelImportWarning):
163
- description = "Multiple data models detected. This is not supported."
164
- fix = "Remove the extra data models."
165
-
166
- data_models: list[str]
167
-
168
- def message(self) -> str:
169
- return f"Multiple data models detected: {self.data_models}. Will only import the first one."
170
-
171
- def dump(self) -> dict[str, list[str]]:
172
- return {"data_models": self.data_models}
173
-
174
-
175
- @dataclass(frozen=True)
176
- class MissingContainerWarning(ModelImportWarning):
177
- description = "Missing container definition."
178
- fix = "Add a container definition."
179
-
180
- view_id: str
181
- property_: str
182
- container_id: str
183
-
184
- def message(self) -> str:
185
- return (
186
- f"Container '{self.container_id}' is missing. "
187
- f"Will skip property '{self.property_}' of view '{self.view_id}'."
188
- )
189
-
190
- def dump(self) -> dict[str, str]:
191
- return {"view_id": self.view_id, "property": self.property_, "container_id": self.container_id}
192
-
193
-
194
- @dataclass(frozen=True)
195
- class MissingContainerPropertyWarning(ModelImportWarning):
196
- description = "Missing container property definition."
197
- fix = "Add a container property definition."
198
-
199
- view_id: str
200
- property_: str
201
- container_id: str
202
-
203
- def message(self) -> str:
204
- return (
205
- f"Container '{self.container_id}' is missing property '{self.property_}'. "
206
- f"This property will be skipped for view '{self.view_id}'."
207
- )
208
-
209
- def dump(self) -> dict[str, str]:
210
- return {"view_id": self.view_id, "property": self.property_, "container_id": self.container_id}
211
-
212
-
213
- @dataclass(frozen=True)
214
- class UnknownPropertyTypeWarning(ModelImportWarning):
215
- description = "Unknown property type. This will be ignored in the imports."
216
- fix = "Set to a supported property type."
217
- view_id: str
218
- property_id: str
219
- property_type: str
220
-
221
- def message(self) -> str:
222
- return (
223
- f"Unknown property type '{self.property_type}' for property '{self.property_id}' "
224
- f"of view '{self.view_id}'. This will be ignored in the imports."
225
- )
226
-
227
- def dump(self) -> dict[str, str]:
228
- return {"view_id": self.view_id, "property_id": self.property_id, "property_type": self.property_type}
229
-
230
-
231
- @dataclass(frozen=True)
232
- class UnknownContainerConstraintWarning(ModelImportWarning):
233
- description = "Unknown container constraint. This will be ignored in the imports."
234
- fix = "Set to a supported container constraint."
235
- container_id: str
236
- property_id: str
237
- constraint: str
238
-
239
- def message(self) -> str:
240
- return (
241
- f"Unknown container constraint '{self.constraint}' for property '{self.property_id}' of container "
242
- f"'{self.container_id}'. This will be ignored in the imports."
243
- )
244
-
245
- def dump(self) -> dict[str, str]:
246
- return {"container_id": self.container_id, "property_id": self.property_id, "constraint": self.constraint}
247
-
248
-
249
- @dataclass(frozen=True)
250
- class FailedToInferValueTypeWarning(ModelImportWarning):
251
- description = "Failed to infer value type. This will be ignored in the imports."
252
- fix = "Set to a supported value type."
253
- view_id: str
254
- property_id: str
255
-
256
- def message(self) -> str:
257
- return (
258
- f"Failed to infer value type for property '{self.property_id}' of view '{self.view_id}'. "
259
- f"This will be ignored in the imports."
260
- )
261
-
262
- def dump(self) -> dict[str, str]:
263
- return {"view_id": self.view_id, "property_id": self.property_id}
264
-
265
-
266
- @dataclass(frozen=True)
267
- class APIWarning(ModelImportWarning):
268
- description = "An error was raised."
269
- fix = "No fix is available."
270
-
271
- error_message: str
272
-
273
- def message(self) -> str:
274
- return self.error_message
275
-
276
- def dump(self) -> dict[str, str]:
277
- return {"error_message": self.error_message}
278
-
279
-
280
- @dataclass(frozen=True)
281
- class FailedImportWarning(ModelImportWarning):
282
- description = "Failed to import part of the model."
283
- fix = "No fix is available."
284
-
285
- identifier: set[str]
286
-
287
- def message(self) -> str:
288
- return f"Failed to import: {self.identifier}. This will be skipped."
289
-
290
- def dump(self) -> dict[str, Any]:
291
- return {"identifier": list(self.identifier)}
292
-
293
-
294
- @dataclass(frozen=True)
295
- class MoreThanOneNonAlphanumericCharacterWarning(ModelImportWarning):
296
- description = """This warning is raised when doing regex validation of strings which either represent class ids,
297
- property ids, prefix, data model name, that contain more than one non-alphanumeric character,
298
- such as for example '_' or '-'."""
299
-
300
- field_name: str
301
- value: str
302
-
303
- def message(self) -> str:
304
- return f"Field {self.field_name} with value {self.value} contains more than one non-alphanumeric character!"
305
-
306
- def dump(self) -> dict[str, str]:
307
- return {"field_name": self.field_name, "value": self.value}
308
-
309
-
310
- @dataclass(frozen=True)
311
- class ModelImportError(NeatValidationError, ABC):
312
- description = "An error was raised during importing."
313
- fix = "No fix is available."
314
-
315
-
316
- @dataclass(frozen=True)
317
- class NoDataModelError(ModelImportError):
318
- description = "No data model found.."
319
- fix = "Check if the data model exists in the source."
320
-
321
- error_message: str
322
-
323
- def message(self) -> str:
324
- return self.error_message
325
-
326
- def dump(self) -> dict[str, str]:
327
- return {"error_message": self.error_message}
328
-
329
-
330
- @dataclass(frozen=True)
331
- class APIError(ModelImportError):
332
- description = "An error was raised during importing."
333
- fix = "No fix is available."
334
-
335
- error_message: str
336
-
337
- def message(self) -> str:
338
- return self.error_message
339
-
340
- def dump(self) -> dict[str, str]:
341
- return {"error_message": self.error_message}
342
-
343
-
344
- @dataclass(frozen=True)
345
- class InvalidComponentError(ModelImportError, ABC):
346
- description = "This is a base class for all errors related invalid component definitions"
347
- fix = "Check if the component is defined in the DTDL file."
348
-
349
- component_type: str
350
- instance_name: str | None = None
351
- instance_id: str | None = None
352
-
353
- def dump(self) -> dict[str, str | None]:
354
- output = super().dump()
355
- output["component_type"] = self.component_type
356
- output["instance_name"] = self.instance_name
357
- output["instance_id"] = self.instance_id
358
- return output
359
-
360
-
361
- @dataclass(frozen=True)
362
- class MissingParentDefinitionError(InvalidComponentError):
363
- description = "The parent component is missing"
364
- fix = "Check if the parent component is defined in the DTDL file."
365
-
366
- def message(self) -> str:
367
- if self.instance_name:
368
- return f"Parent component '{self.component_type}' with name '{self.instance_name}' is missing."
369
- else:
370
- return f"Parent component '{self.component_type}' is missing."
371
-
372
-
373
- @dataclass(frozen=True)
374
- class MissingIdentifierError(InvalidComponentError):
375
- description = "The identifier is missing"
376
- fix = "Check if the identifier is defined in the DTDL file."
377
-
378
- component_type: str
379
- instance_name: str | None = None
380
-
381
- def dump(self) -> dict[str, str | None]:
382
- output = super().dump()
383
- output["component_type"] = self.component_type
384
- output["instance_name"] = self.instance_name
385
- return output
386
-
387
- def message(self) -> str:
388
- if self.instance_name:
389
- return f"Identifier for component '{self.component_type}' with name '{self.instance_name}' is missing."
390
- else:
391
- return f"Identifier for component '{self.component_type}' is missing."
392
-
393
-
394
- @dataclass(frozen=True)
395
- class UnsupportedPropertyTypeError(ModelImportError):
396
- description = "The property type is not supported"
397
- fix = "Check if the property type is defined in the DTDL file."
398
- component_type: str
399
- property_name: str
400
- property_type: str
401
- instance_name: str | None = None
402
- instance_id: str | None = None
403
-
404
- def dump(self) -> dict[str, str | None]:
405
- output = super().dump()
406
- output["component_type"] = self.component_type
407
- output["property_name"] = self.property_name
408
- output["property_type"] = self.property_type
409
- output["instance_name"] = self.instance_name
410
- output["instance_id"] = self.instance_id
411
- return output
412
-
413
- def message(self) -> str:
414
- if self.instance_name:
415
- return (
416
- f"Property '{self.property_name}' of type '{self.property_type}' "
417
- f"of instance '{self.instance_name}' ({self.component_type}) is not supported."
418
- )
419
- else:
420
- return (
421
- f"Property '{self.property_name}' of type '{self.property_type}' "
422
- f"of instance '{self.instance_id}' ({self.component_type}) is not supported."
423
- )