cognite-neat 0.88.1__py3-none-any.whl → 0.88.2__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.

Files changed (62) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/exceptions.py +2 -2
  3. cognite/neat/graph/loaders/_base.py +4 -4
  4. cognite/neat/graph/loaders/_rdf2asset.py +12 -14
  5. cognite/neat/graph/loaders/_rdf2dms.py +14 -10
  6. cognite/neat/issues/__init__.py +16 -0
  7. cognite/neat/{issues.py → issues/_base.py} +73 -5
  8. cognite/neat/issues/errors/external.py +21 -0
  9. cognite/neat/issues/errors/properties.py +75 -0
  10. cognite/neat/issues/errors/resources.py +123 -0
  11. cognite/neat/issues/errors/schema.py +0 -0
  12. cognite/neat/{rules/issues → issues}/formatters.py +9 -9
  13. cognite/neat/issues/neat_warnings/__init__.py +2 -0
  14. cognite/neat/issues/neat_warnings/identifier.py +27 -0
  15. cognite/neat/issues/neat_warnings/models.py +22 -0
  16. cognite/neat/issues/neat_warnings/properties.py +77 -0
  17. cognite/neat/issues/neat_warnings/resources.py +125 -0
  18. cognite/neat/rules/exporters/_rules2dms.py +3 -2
  19. cognite/neat/rules/exporters/_validation.py +2 -2
  20. cognite/neat/rules/importers/__init__.py +7 -3
  21. cognite/neat/rules/importers/_base.py +3 -3
  22. cognite/neat/rules/importers/_dms2rules.py +39 -18
  23. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +44 -53
  24. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +6 -5
  25. cognite/neat/rules/importers/_rdf/__init__.py +0 -0
  26. cognite/neat/rules/importers/_rdf/_imf2rules/__init__.py +3 -0
  27. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +82 -0
  28. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +34 -0
  29. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +123 -0
  30. cognite/neat/rules/importers/{_owl2rules/_owl2rules.py → _rdf/_imf2rules/_imf2rules.py} +15 -11
  31. cognite/neat/rules/importers/{_inference2rules.py → _rdf/_inference2rules.py} +1 -1
  32. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +57 -0
  33. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2metadata.py +68 -0
  34. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +59 -0
  35. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +76 -0
  36. cognite/neat/rules/importers/_rdf/_shared.py +586 -0
  37. cognite/neat/rules/importers/_spreadsheet2rules.py +1 -1
  38. cognite/neat/rules/importers/_yaml2rules.py +2 -1
  39. cognite/neat/rules/issues/__init__.py +1 -5
  40. cognite/neat/rules/issues/base.py +2 -21
  41. cognite/neat/rules/issues/dms.py +0 -134
  42. cognite/neat/rules/issues/spreadsheet.py +3 -3
  43. cognite/neat/rules/models/_types/_field.py +5 -2
  44. cognite/neat/rules/models/asset/_validation.py +1 -1
  45. cognite/neat/rules/models/dms/_schema.py +53 -30
  46. cognite/neat/rules/models/dms/_validation.py +2 -2
  47. cognite/neat/rules/models/entities.py +3 -0
  48. cognite/neat/rules/models/information/_validation.py +1 -1
  49. cognite/neat/workflows/steps/lib/current/rules_importer.py +73 -1
  50. cognite/neat/workflows/steps/lib/current/rules_validator.py +19 -7
  51. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.2.dist-info}/METADATA +1 -1
  52. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.2.dist-info}/RECORD +57 -42
  53. cognite/neat/graph/issues/loader.py +0 -104
  54. cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -215
  55. cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -209
  56. cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -203
  57. cognite/neat/rules/issues/importing.py +0 -423
  58. /cognite/neat/{graph/issues → issues/errors}/__init__.py +0 -0
  59. /cognite/neat/rules/importers/{_owl2rules → _rdf/_owl2rules}/__init__.py +0 -0
  60. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.2.dist-info}/LICENSE +0 -0
  61. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.2.dist-info}/WHEEL +0 -0
  62. {cognite_neat-0.88.1.dist-info → cognite_neat-0.88.2.dist-info}/entry_points.txt +0 -0
@@ -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
- )