cognite-neat 0.88.0__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 (99) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/app/api/routers/configuration.py +1 -1
  3. cognite/neat/app/ui/neat-app/build/asset-manifest.json +7 -7
  4. cognite/neat/app/ui/neat-app/build/index.html +1 -1
  5. cognite/neat/app/ui/neat-app/build/static/css/{main.38a62222.css → main.72e3d92e.css} +2 -2
  6. cognite/neat/app/ui/neat-app/build/static/css/main.72e3d92e.css.map +1 -0
  7. cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js +3 -0
  8. cognite/neat/app/ui/neat-app/build/static/js/{main.ec7f72e2.js.LICENSE.txt → main.5a52cf09.js.LICENSE.txt} +0 -9
  9. cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js.map +1 -0
  10. cognite/neat/config.py +44 -27
  11. cognite/neat/exceptions.py +8 -2
  12. cognite/neat/graph/extractors/_classic_cdf/_assets.py +21 -73
  13. cognite/neat/graph/extractors/_classic_cdf/_base.py +102 -0
  14. cognite/neat/graph/extractors/_classic_cdf/_events.py +46 -42
  15. cognite/neat/graph/extractors/_classic_cdf/_files.py +41 -45
  16. cognite/neat/graph/extractors/_classic_cdf/_labels.py +75 -52
  17. cognite/neat/graph/extractors/_classic_cdf/_relationships.py +49 -27
  18. cognite/neat/graph/extractors/_classic_cdf/_sequences.py +47 -50
  19. cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +47 -49
  20. cognite/neat/graph/loaders/_base.py +4 -4
  21. cognite/neat/graph/loaders/_rdf2asset.py +12 -14
  22. cognite/neat/graph/loaders/_rdf2dms.py +14 -10
  23. cognite/neat/graph/queries/_base.py +22 -29
  24. cognite/neat/graph/queries/_shared.py +1 -1
  25. cognite/neat/graph/stores/_base.py +19 -11
  26. cognite/neat/graph/transformers/_rdfpath.py +3 -2
  27. cognite/neat/issues/__init__.py +16 -0
  28. cognite/neat/{issues.py → issues/_base.py} +78 -2
  29. cognite/neat/issues/errors/external.py +21 -0
  30. cognite/neat/issues/errors/properties.py +75 -0
  31. cognite/neat/issues/errors/resources.py +123 -0
  32. cognite/neat/issues/errors/schema.py +0 -0
  33. cognite/neat/{rules/issues → issues}/formatters.py +9 -9
  34. cognite/neat/issues/neat_warnings/__init__.py +2 -0
  35. cognite/neat/issues/neat_warnings/identifier.py +27 -0
  36. cognite/neat/issues/neat_warnings/models.py +22 -0
  37. cognite/neat/issues/neat_warnings/properties.py +77 -0
  38. cognite/neat/issues/neat_warnings/resources.py +125 -0
  39. cognite/neat/rules/exporters/_rules2dms.py +3 -2
  40. cognite/neat/rules/exporters/_rules2ontology.py +28 -20
  41. cognite/neat/rules/exporters/_validation.py +15 -21
  42. cognite/neat/rules/importers/__init__.py +7 -3
  43. cognite/neat/rules/importers/_base.py +3 -3
  44. cognite/neat/rules/importers/_dms2rules.py +39 -18
  45. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +44 -53
  46. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +6 -5
  47. cognite/neat/rules/importers/_rdf/__init__.py +0 -0
  48. cognite/neat/rules/importers/_rdf/_imf2rules/__init__.py +3 -0
  49. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +82 -0
  50. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +34 -0
  51. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +123 -0
  52. cognite/neat/rules/importers/{_owl2rules/_owl2rules.py → _rdf/_imf2rules/_imf2rules.py} +15 -11
  53. cognite/neat/rules/importers/{_inference2rules.py → _rdf/_inference2rules.py} +1 -1
  54. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +57 -0
  55. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2metadata.py +68 -0
  56. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +59 -0
  57. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +76 -0
  58. cognite/neat/rules/importers/_rdf/_shared.py +586 -0
  59. cognite/neat/rules/importers/_spreadsheet2rules.py +31 -28
  60. cognite/neat/rules/importers/_yaml2rules.py +2 -1
  61. cognite/neat/rules/issues/__init__.py +1 -5
  62. cognite/neat/rules/issues/base.py +2 -21
  63. cognite/neat/rules/issues/dms.py +20 -134
  64. cognite/neat/rules/issues/ontology.py +298 -0
  65. cognite/neat/rules/issues/spreadsheet.py +51 -3
  66. cognite/neat/rules/issues/tables.py +72 -0
  67. cognite/neat/rules/models/_rdfpath.py +4 -4
  68. cognite/neat/rules/models/_types/_field.py +14 -21
  69. cognite/neat/rules/models/asset/_validation.py +1 -1
  70. cognite/neat/rules/models/dms/_schema.py +53 -30
  71. cognite/neat/rules/models/dms/_validation.py +2 -2
  72. cognite/neat/rules/models/entities.py +3 -0
  73. cognite/neat/rules/models/information/_rules.py +5 -4
  74. cognite/neat/rules/models/information/_validation.py +1 -1
  75. cognite/neat/utils/rdf_.py +17 -9
  76. cognite/neat/utils/regex_patterns.py +52 -0
  77. cognite/neat/workflows/steps/lib/current/rules_importer.py +73 -1
  78. cognite/neat/workflows/steps/lib/current/rules_validator.py +19 -7
  79. {cognite_neat-0.88.0.dist-info → cognite_neat-0.88.2.dist-info}/METADATA +2 -6
  80. {cognite_neat-0.88.0.dist-info → cognite_neat-0.88.2.dist-info}/RECORD +85 -72
  81. cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -1
  82. cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js +0 -3
  83. cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.map +0 -1
  84. cognite/neat/graph/issues/loader.py +0 -104
  85. cognite/neat/graph/stores/_oxrdflib.py +0 -247
  86. cognite/neat/rules/exceptions.py +0 -2972
  87. cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -215
  88. cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -213
  89. cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -203
  90. cognite/neat/rules/issues/importing.py +0 -408
  91. cognite/neat/rules/models/_types/_base.py +0 -16
  92. cognite/neat/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -152
  93. cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -139
  94. cognite/neat/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -116
  95. /cognite/neat/{graph/issues → issues/errors}/__init__.py +0 -0
  96. /cognite/neat/rules/importers/{_owl2rules → _rdf/_owl2rules}/__init__.py +0 -0
  97. {cognite_neat-0.88.0.dist-info → cognite_neat-0.88.2.dist-info}/LICENSE +0 -0
  98. {cognite_neat-0.88.0.dist-info → cognite_neat-0.88.2.dist-info}/WHEEL +0 -0
  99. {cognite_neat-0.88.0.dist-info → cognite_neat-0.88.2.dist-info}/entry_points.txt +0 -0
@@ -1,2972 +0,0 @@
1
- """This module contains the definition of errors and warnings raised when dealing
2
- with TransformationRules object. This includes underlying pydantic model, actual transformation rules
3
- handling (such `rdfpath`), and rules loaders, parsers and exporters.
4
-
5
- \nThe errors and warning are grouped by means of error codes:\n
6
- - 0 - 99: errors and warnings raised when dealing with TransformationRules pydantic model
7
- - 100 - 199: errors and warnings raised when parsing actual transformation rules, i.e. `rdfpath`
8
- - 200 - 299: errors and warnings raised when dealing TransformationRules importers
9
- - 300 - 399: errors and warnings raised when dealing TransformationRules parsers
10
- - 400 - 499: errors and warnings raised when dealing TransformationRules exporters
11
-
12
- """
13
-
14
- from typing import Any
15
-
16
- from cognite.client.data_classes.data_modeling import ContainerId, DataModelId, ViewId
17
- from rdflib import Namespace, URIRef
18
-
19
- from cognite.neat.constants import DEFAULT_DOCS_URL
20
- from cognite.neat.exceptions import NeatException, NeatWarning
21
-
22
- DOCS_BASE_URL = f"{DEFAULT_DOCS_URL}api/exceptions.html#{__name__}"
23
-
24
-
25
- class MultipleExceptions(NeatException):
26
- """This is used to gather multiple errors."""
27
-
28
- def __init__(self, errors: list[NeatException], verbose: bool = False):
29
- self.errors = errors
30
- self.message = f"Multiple errors occurred: {self.errors}"
31
- if verbose:
32
- self.message += f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
33
- super().__init__(self.message)
34
-
35
-
36
- ################################################################################################
37
- # RULES MODEL REPRESENTATION: 100 - 199 ########################################################
38
- ################################################################################################
39
-
40
- # Exceptions:
41
-
42
-
43
- class PrefixRegexViolation(NeatException):
44
- """Prefix, which is in the 'Metadata' sheet, does not respect defined regex expression
45
-
46
- Args:
47
- prefix: prefix that raised exception
48
- regex_expression: regex expression against which prefix is validated
49
- verbose: flag that indicates whether to provide enhanced exception message, by default False
50
-
51
- Notes:
52
- Check if prefix in the 'Metadata' sheet contains any illegal characters and
53
- respects the regex expression.
54
-
55
- """
56
-
57
- type_: str = "PrefixRegexViolation"
58
- code: int = 0
59
- description: str = "Prefix, which is in the 'Metadata' sheet, does not respect defined regex expression"
60
- example: str = (
61
- "If prefix is set to 'power grid', while regex expression does not "
62
- "allow spaces, the expression will be violated thus raising this error"
63
- )
64
- fix: str = (
65
- "Check if prefix in the 'Metadata' sheet contains any illegal characters and respects the regex expression"
66
- )
67
-
68
- def __init__(self, prefix: str, regex_expression: str, verbose: bool = False):
69
- self.prefix = prefix
70
- self.regex_expression = regex_expression
71
-
72
- self.message = (
73
- f"Invalid prefix '{self.prefix}' stored in 'Metadata' sheet, it must obey regex {self.regex_expression}!"
74
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
75
- )
76
- if verbose:
77
- self.message += f"\nDescription: {self.description}"
78
- self.message += f"\nExample: {self.example}"
79
- self.message += f"\nFix: {self.fix}"
80
- super().__init__(self.message)
81
-
82
-
83
- class PrefixMissing(NeatException):
84
- """Prefix, which is in the 'Metadata' sheet, is missing.
85
-
86
- Args:
87
- verbose: flag that indicates whether to provide enhanced exception message, by default False
88
-
89
- """
90
-
91
- type_: str = "PrefixMissing"
92
- code: int = 0
93
- description: str = "Prefix is missing from the 'Metadata' sheet."
94
- example: str = "There is no prefix in the 'Metadata' sheet."
95
- fix: str = "Specify the prefix if prefix in the 'Metadata' sheet."
96
-
97
- def __init__(self, verbose: bool = False):
98
- self.message = (
99
- f"Missing prefix stored in 'Metadata' sheet."
100
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
101
- )
102
- if verbose:
103
- self.message += f"\nDescription: {self.description}"
104
- self.message += f"\nExample: {self.example}"
105
- self.message += f"\nFix: {self.fix}"
106
- super().__init__(self.message)
107
-
108
-
109
- class CDFSpaceRegexViolation(NeatException):
110
- """cdfSpaceName, which is in the 'Metadata' sheet, does not respect defined regex expression
111
-
112
- Args:
113
- cdf_space_name: cdf_space_name that raised exception
114
- regex_expression: regex expression against which cdf_space_name is validated
115
- verbose: flag that indicates whether to provide enhanced exception message, by default False
116
-
117
- Notes:
118
- Check if cdfSpaceName in the 'Metadata' sheet contains any illegal characters and
119
- respects the regex expression.
120
-
121
- """
122
-
123
- type_: str = "CDFSpaceRegexViolation"
124
- code: int = 1
125
- description: str = "cdfSpaceName, which is in the 'Metadata' sheet, does not respect defined regex expression"
126
- example: str = (
127
- "If cdfSpaceName is set to 'power grid', while regex expression does not "
128
- "allow spaces, the expression will be violated thus raising this error"
129
- )
130
- fix: str = (
131
- "Check if cdfSpaceName in the 'Metadata' sheet "
132
- "contains any illegal characters and respects the regex expression"
133
- )
134
-
135
- def __init__(self, cdf_space_name: str, regex_expression: str, verbose: bool = False):
136
- self.cdf_space_name = cdf_space_name
137
- self.regex_expression = regex_expression
138
-
139
- self.message = (
140
- f"Invalid cdfSpaceName '{self.cdf_space_name}' stored in 'Metadata' sheet, "
141
- f"it must obey regex {self.regex_expression}!"
142
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
143
- )
144
- if verbose:
145
- self.message += f"\nDescription: {self.description}"
146
- self.message += f"\nExample: {self.example}"
147
- self.message += f"\nFix: {self.fix}"
148
- super().__init__(self.message)
149
-
150
-
151
- class MetadataSheetNamespaceNotValidURL(NeatException):
152
- """namespace, which is in the 'Metadata' sheet, does not respect defined regex expression
153
-
154
- Args:
155
- namespace: namespace that raised exception
156
- verbose: flag that indicates whether to provide enhanced exception message, by default False
157
-
158
- Notes:
159
- Check if `namespace` in the `Metadata` sheet is properly constructed as valid URL
160
- containing only allowed characters.
161
-
162
- """
163
-
164
- type_: str = "MetadataSheetNamespaceNotValidURL"
165
- code: int = 2
166
- description: str = "namespace, which is in the 'Metadata' sheet, is not valid URL"
167
- example: str = "If we have 'authority:namespace' as namespace as it is not a valid URL this error will be raised"
168
- fix: str = (
169
- "Check if 'namespace' in the 'Metadata' sheet is properly "
170
- "constructed as valid URL containing only allowed characters"
171
- )
172
-
173
- def __init__(self, namespace: str, verbose: bool = False):
174
- self.namespace = namespace
175
-
176
- self.message = (
177
- f"Invalid namespace '{self.namespace}' stored in 'Metadata' sheet, it must be valid URL!"
178
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
179
- )
180
- if verbose:
181
- self.message += f"\nDescription: {self.description}"
182
- self.message += f"\nExample: {self.example}"
183
- self.message += f"\nFix: {self.fix}"
184
- super().__init__(self.message)
185
-
186
-
187
- class MetadataSheetNamespaceNotDefined(NeatException):
188
- """namespace, which is in the 'Metadata' sheet, is not defined
189
-
190
- Args:
191
- namespace: namespace that raised exception
192
- verbose: flag that indicates whether to provide enhanced exception message, by default False
193
-
194
- Notes:
195
- Check if `namespace` in the `Metadata` sheet is properly constructed as valid URL
196
- containing only allowed characters.
197
-
198
- """
199
-
200
- type_ = "MetadataSheetNamespaceNotDefined"
201
- code: int = 2
202
- description: str = "namespace, which is in the 'Metadata' sheet, is missing"
203
- example: str = "Example of a valid namespace 'http://www.w3.org/ns/sparql#'"
204
- fix: str = "Define the 'namespace' in the 'Metadata' sheet."
205
-
206
- def __init__(self, verbose: bool = False):
207
- self.message = (
208
- f"Missing namespace in 'Metadata' sheet." f"\nFor more information visit: {DOCS_BASE_URL}.{self.type_}"
209
- )
210
- if verbose:
211
- self.message += f"\nDescription: {self.description}"
212
- self.message += f"\nExample: {self.example}"
213
- self.message += f"\nFix: {self.fix}"
214
- super().__init__(self.message)
215
-
216
-
217
- class DataModelIdRegexViolation(NeatException):
218
- """dataModelName, which is in the 'Metadata' sheet, does not respect defined regex expression
219
-
220
- Args:
221
- data_model_name: data_model_name that raised exception
222
- regex_expression: regex expression against which data_model_name is validated
223
- verbose: flag that indicates whether to provide enhanced exception message, by default False
224
-
225
- Notes:
226
- Check if `dataModelName` in the `Metadata` sheet contains any illegal
227
- characters and respects the regex expression
228
-
229
- """
230
-
231
- type_: str = "DataModelIdRegexViolation"
232
- code: int = 3
233
- description: str = "external_id, which is in the 'Metadata' sheet, does not respect defined regex expression"
234
- example: str = (
235
- "If external_id is set to 'power grid data model', while regex expression does not "
236
- "allow spaces, the expression will be violated thus raising this error"
237
- )
238
- fix: str = (
239
- "Check if external_id in the 'Metadata' sheet contains any illegal "
240
- "characters and respects the regex expression"
241
- )
242
-
243
- def __init__(self, data_model_id: str, regex_expression: str, verbose: bool = False):
244
- self.data_model_id = data_model_id
245
- self.regex_expression = regex_expression
246
-
247
- self.message = (
248
- f"Invalid data model external_id '{self.data_model_id}' stored in 'Metadata' sheet, "
249
- f"it must obey regex {self.regex_expression}!"
250
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
251
- )
252
- if verbose:
253
- self.message += f"\nDescription: {self.description}"
254
- self.message += f"\nExample: {self.example}"
255
- self.message += f"\nFix: {self.fix}"
256
- super().__init__(self.message)
257
-
258
-
259
- class VersionRegexViolation(NeatException):
260
- """version, which is in the 'Metadata' sheet, does not respect defined regex expression
261
-
262
- Args:
263
- version: version that raised exception
264
- regex_expression: regex expression against which version is validated
265
- verbose: flag that indicates whether to provide enhanced exception message, by default False
266
-
267
- Notes:
268
- Check if `version` in the `Metadata` sheet contains any illegal
269
- characters and respects the regex expression
270
-
271
- """
272
-
273
- type_: str = "VersionRegexViolation"
274
- code: int = 4
275
- description: str = "version, which is in the 'Metadata' sheet, does not respect defined regex expression"
276
- example: str = (
277
- "If version is set to '1.2.3 alpha4443', while regex expression does not "
278
- "allow spaces, the expression will be violated thus raising this error"
279
- )
280
- fix: str = (
281
- "Check if version in the 'Metadata' sheet contains any illegal characters and respects the regex expression"
282
- )
283
-
284
- def __init__(self, version: str, regex_expression: str, verbose: bool = False):
285
- self.version = version
286
- self.regex_expression = regex_expression
287
-
288
- self.message = (
289
- f"Invalid version '{self.version}' stored in 'Metadata' sheet, it must obey regex {self.regex_expression}!"
290
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
291
- )
292
- if verbose:
293
- self.message += f"\nDescription: {self.description}"
294
- self.message += f"\nExample: {self.example}"
295
- self.message += f"\nFix: {self.fix}"
296
- super().__init__(self.message)
297
-
298
-
299
- class ClassSheetClassIDRegexViolation(NeatException):
300
- """Class ID, which is stored in the column 'Class' in the 'Classes' sheet, does not
301
- respect defined regex expression
302
-
303
- Args:
304
- class_id: class_id that raised exception
305
- regex_expression: regex expression against which class_id is validated
306
- verbose: flag that indicates whether to provide enhanced exception message, by default False
307
-
308
- Notes:
309
- Check definition of class ids in 'Class' column in 'Classes' sheet and
310
- make sure to respect the regex expression by removing any illegal characters
311
-
312
- """
313
-
314
- type_: str = "ClassSheetClassIDRegexViolation"
315
- code: int = 5
316
- description: str = (
317
- "Class ID, which is stored in the column 'Class' in the 'Classes' sheet, "
318
- "does not respect defined regex expression"
319
- )
320
- example: str = (
321
- "If class id is set to 'Class 1', while regex expression does not allow spaces,"
322
- " the expression will be violated thus raising this error"
323
- )
324
- fix: str = (
325
- "Check definition of class ids in 'Class' column in 'Classes' sheet and "
326
- "make sure to respect the regex expression by removing any illegal characters"
327
- )
328
-
329
- def __init__(self, class_id: str, regex_expression: str, verbose: bool = False):
330
- self.class_id = class_id
331
- self.regex_expression = regex_expression
332
-
333
- self.message = (
334
- f"Class id '{self.class_id}' stored in 'Class' column in 'Classes' "
335
- f"sheet violates regex {self.regex_expression}!"
336
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
337
- )
338
- if verbose:
339
- self.message += f"\nDescription: {self.description}"
340
- self.message += f"\nExample: {self.example}"
341
- self.message += f"\nFix: {self.fix}"
342
- super().__init__(self.message)
343
-
344
-
345
- class ClassIDMissing(NeatException):
346
- """Class ID, which is stored in the column 'Class' in the 'Classes' sheet, is either
347
- missing or did not satisfied regex expression
348
-
349
- Args:
350
- verbose: flag that indicates whether to provide enhanced exception message, by default False
351
-
352
- Notes:
353
- Make sure that class id is provided and respects regex expression
354
- """
355
-
356
- type_: str = "ClassIDMissing"
357
- code: int = 6
358
- description: str = (
359
- "Class ID, which is stored in the column 'Class' in the 'Classes' sheet,"
360
- " is either missing or did not satisfied regex expression"
361
- )
362
- example: str = ""
363
- fix: str = "Make sure that class id is provided and respects regex expression"
364
-
365
- def __init__(self, verbose: bool = False):
366
- self.message = (
367
- "Class id is missing, it failed validation either because it has"
368
- " not been provided or because it did not respect regex expression!"
369
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
370
- )
371
- if verbose:
372
- self.message += f"\nDescription: {self.description}"
373
- self.message += f"\nExample: {self.example}"
374
- self.message += f"\nFix: {self.fix}"
375
- super().__init__(self.message)
376
-
377
-
378
- class PropertiesSheetClassIDRegexViolation(NeatException):
379
- """Class ID, which is stored in the column 'Class' in the 'Properties' sheet, does
380
- not respect defined regex expression
381
-
382
- Args:
383
- verbose: flag that indicates whether to provide enhanced exception message, by default False
384
- class_id: class id that raised exception
385
- regex_expression: regex expression against which class id is checked
386
-
387
- Notes:
388
- Check definition of class ids in `Class` column in `Properties` sheet and make
389
- sure to respect the regex expression by removing any illegal characters
390
- """
391
-
392
- type_: str = "PropertiesSheetClassIDRegexViolation"
393
- code: int = 7
394
- description: str = (
395
- "Class ID, which is stored in the column 'Class' in the 'Properties' sheet, "
396
- "does not respect defined regex expression"
397
- )
398
- example: str = (
399
- "If class id is set to 'Class 1', while regex expression does not allow spaces,"
400
- " the expression will be violated thus raising this error"
401
- )
402
- fix: str = (
403
- "Check definition of class ids in 'Class' column in 'Properties' sheet "
404
- "and make sure to respect the regex expression by removing any illegal characters"
405
- )
406
-
407
- def __init__(self, class_id: str, regex_expression: str, verbose: bool = False):
408
- self.class_id = class_id
409
- self.regex_expression = regex_expression
410
-
411
- self.message = (
412
- f"Class id '{self.class_id}' stored in 'Class' column in 'Properties' "
413
- f"sheet violates regex {self.regex_expression}!"
414
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
415
- )
416
- if verbose:
417
- self.message += f"\nDescription: {self.description}"
418
- self.message += f"\nExample: {self.example}"
419
- self.message += f"\nFix: {self.fix}"
420
- super().__init__(self.message)
421
-
422
-
423
- class PropertyIDRegexViolation(NeatException):
424
- """Property ID, which is stored in the column 'Property' in the 'Properties' sheet, does
425
- not respect defined regex expression
426
-
427
- Args:
428
- verbose: flag that indicates whether to provide enhanced exception message, by default False
429
- property_id: property id that raised exception
430
- regex_expression: regex expression against which property id is checked
431
-
432
- Notes:
433
- Check definition of class ids in `Property` column in `Properties` sheet and make
434
- sure to respect the regex expression by removing any illegal characters
435
- """
436
-
437
- type_: str = "PropertyIDRegexViolation"
438
- code: int = 8
439
- description: str = (
440
- "Property ID, which is stored in the column 'Property' "
441
- "in the 'Properties' sheet, does not respect defined regex expression"
442
- )
443
- example: str = (
444
- "If property id is set to 'property 1', while regex expression does not allow spaces,"
445
- " the expression will be violated thus raising this error"
446
- )
447
- fix: str = (
448
- "Check definition of property ids in 'Property' column in 'Properties' sheet"
449
- " and make sure to respect the regex expression by removing any illegal characters"
450
- )
451
-
452
- def __init__(self, property_id: str, regex_expression: str, verbose: bool = False):
453
- self.property_id = property_id
454
- self.regex_expression = regex_expression
455
-
456
- self.message = (
457
- f"Property id '{self.property_id}' stored in 'Property' "
458
- f"column in 'Properties' sheet violates regex {self.regex_expression}!"
459
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
460
- )
461
- if verbose:
462
- self.message += f"\nDescription: {self.description}"
463
- self.message += f"\nExample: {self.example}"
464
- self.message += f"\nFix: {self.fix}"
465
- super().__init__(self.message)
466
-
467
-
468
- class ValueTypeIDRegexViolation(NeatException):
469
- """Value type, which is stored in the column 'Type' in the 'Properties' sheet, does
470
- not respect defined regex expression
471
-
472
- Args:
473
- verbose: flag that indicates whether to provide enhanced exception message, by default False
474
- value_type: value type that raised exception
475
- regex_expression: regex expression against which value type is checked
476
-
477
- Notes:
478
- Check definition of class ids in `Type` column in `Properties` sheet and make
479
- sure to respect the regex expression by removing any illegal characters
480
- """
481
-
482
- type_: str = "ValueTypeIDRegexViolation"
483
- code: int = 9
484
- description: str = (
485
- "Value type, which is stored in the column 'Type' in the 'Properties' sheet, "
486
- "does not respect defined regex expression"
487
- )
488
- example: str = (
489
- "If value type is set to 'date time', while regex expression does not"
490
- " allow spaces, the expression will be violated thus raising this error"
491
- )
492
- fix: str = (
493
- "Check definition of value types in 'Type' column in 'Properties' sheet"
494
- " and make sure to respect the regex expression by removing any illegal characters"
495
- )
496
-
497
- def __init__(self, value_type: str, regex_expression: str, verbose: bool = False):
498
- self.value_type = value_type
499
- self.regex_expression = regex_expression
500
-
501
- self.message = (
502
- f"Value type '{self.value_type}' stored in 'Type' column in "
503
- f"'Properties' sheet violates regex {self.regex_expression}!"
504
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
505
- )
506
- if verbose:
507
- self.message += f"\nDescription: {self.description}"
508
- self.message += f"\nExample: {self.example}"
509
- self.message += f"\nFix: {self.fix}"
510
- super().__init__(self.message)
511
-
512
-
513
- class MissingTypeValue(NeatException):
514
- """Value type, which is stored in the column 'Type' in the 'Properties' sheet, is missing
515
-
516
- Args:
517
- verbose: flag that indicates whether to provide enhanced exception message, by default False
518
-
519
- Notes:
520
- Make sure to define value type in `Type` column in `Properties` sheet
521
- """
522
-
523
- type_: str = "MissingTypeValue"
524
- code: int = 10
525
- description: str = "Value type, which is stored in the column 'Type' in the 'Properties' sheet, is missing"
526
- example: str = "If value type is not set, this error will be raised"
527
- fix: str = "Make sure to define value type in 'Type' column in 'Properties' sheet"
528
-
529
- def __init__(self, verbose: bool = False):
530
- self.message = (
531
- "Value type, which is stored in the column 'Type' in the 'Properties' sheet, is missing"
532
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
533
- )
534
- if verbose:
535
- self.message += f"\nDescription: {self.description}"
536
- self.message += f"\nExample: {self.example}"
537
- self.message += f"\nFix: {self.fix}"
538
- super().__init__(self.message)
539
-
540
-
541
- class PropertyIDMissing(NeatException):
542
- """Property ID, which is stored in the column 'Property' in the 'Properties' sheet,
543
- is either missing or did not satisfied regex expression
544
-
545
- Args:
546
- verbose: flag that indicates whether to provide enhanced exception message, by default False
547
-
548
- Notes:
549
- Make sure to define value type in `Type` column in `Properties` sheet
550
- """
551
-
552
- type_: str = "PropertyIDMissing"
553
- code: int = 11
554
- description: str = (
555
- "Property ID, which is stored in the column 'Property' in the 'Properties' sheet,"
556
- " is either missing or did not satisfied regex expression"
557
- )
558
- example: str = ""
559
- fix: str = "Make sure that property id is provided and respects regex expression"
560
-
561
- def __init__(self, verbose: bool = False):
562
- self.message = (
563
- "Property id is missing, validator for property id failed either"
564
- " due to lack of property id or due to not respecting regex expression!"
565
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
566
- )
567
- if verbose:
568
- self.message += f"\nDescription: {self.description}"
569
- self.message += f"\nExample: {self.example}"
570
- self.message += f"\nFix: {self.fix}"
571
- super().__init__(self.message)
572
-
573
-
574
- class RuleTypeProvidedButRuleMissing(NeatException):
575
- """This error occurs when transformation rule type is provided but actual
576
- transformation rule is missing
577
-
578
- Args:
579
- verbose: flag that indicates whether to provide enhanced exception message, by default False
580
- property_id: property id which is missing transformation rule
581
- class_id: class id for which property id is defined
582
- rule_type: rule type that is provided for property id
583
-
584
- Notes:
585
- If you provide rule type you must provide rule as well! Otherwise remove rule
586
- type if no transformation rule is needed
587
- """
588
-
589
- type_: str = "RuleTypeProvidedButRuleMissing"
590
- code: int = 12
591
- description: str = (
592
- "This error occurs when transformation rule type is provided but actual transformation rule is missing"
593
- )
594
- example: str = ""
595
- fix: str = (
596
- "If you provide rule type you must provide rule as well! "
597
- "Otherwise remove rule type if no transformation rule is needed"
598
- )
599
-
600
- def __init__(self, property_id: str, class_id: str, rule_type: str, verbose: bool = False):
601
- self.message = (
602
- f"Rule type '{rule_type}' provided for property '{property_id}' "
603
- f"in class '{class_id}' but rule is not provided!"
604
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
605
- )
606
- if verbose:
607
- self.message += f"\nDescription: {self.description}"
608
- self.message += f"\nExample: {self.example}"
609
- self.message += f"\nFix: {self.fix}"
610
- super().__init__(self.message)
611
-
612
-
613
- class PropertyDefinedForUndefinedClass(NeatException):
614
- """Property defined for a class that has not been defined in the 'Classes' sheet
615
-
616
- Args:
617
- property_id: property id that is defined for undefined class
618
- class_id: class id that is undefined
619
- verbose: flag that indicates whether to provide enhanced exception message, by default False
620
-
621
- Notes:
622
- Make sure to define all classes in the 'Classes' sheet before defining properties
623
- for them in the `Properties` sheet
624
- """
625
-
626
- type_: str = "PropertyDefinedForUndefinedClass"
627
- code: int = 13
628
- description: str = "Property defined for a class that has not been defined in the 'Classes' sheet"
629
- example: str = (
630
- "If property 'someProperty' is defined for class 'Class 1' in the 'Properties' sheet, "
631
- "while 'Class 1' has not been defined in the 'Classes' sheet,"
632
- " this error will be raised"
633
- )
634
- fix: str = (
635
- "Make sure to define all classes in the 'Classes' sheet before defining properties for them"
636
- " in the 'Properties' sheet"
637
- )
638
-
639
- def __init__(self, property_id: str, class_id: str, verbose: bool = False):
640
- self.property_id = property_id
641
- self.class_id = class_id
642
-
643
- self.message = (
644
- f"Class <{self.class_id}> to which property {self.property_id}> is being defined"
645
- " is not define in the 'Classes' sheet!"
646
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
647
- )
648
- if verbose:
649
- self.message += f"\nDescription: {self.description}"
650
- self.message += f"\nExample: {self.example}"
651
- self.message += f"\nFix: {self.fix}"
652
- super().__init__(self.message)
653
-
654
-
655
- class MetadataSheetMissingOrFailedValidation(NeatException):
656
- """Metadata sheet is missing or it failed validation for one or more fields
657
-
658
- Args:
659
- verbose: flag that indicates whether to provide enhanced exception message, by default False
660
-
661
- Notes:
662
- Make sure to define compliant Metadata sheet before proceeding
663
- """
664
-
665
- type_: str = "MetadataSheetMissingOrFailedValidation"
666
- code: int = 14
667
- description: str = "Metadata sheet is missing or it failed validation for one or more fields"
668
- example: str = ""
669
- fix: str = "Make sure to define compliant Metadata sheet before proceeding"
670
-
671
- def __init__(self, verbose: bool = False):
672
- self.message = (
673
- "Metadata sheet is missing or it failed validation for one or more fields!"
674
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
675
- )
676
- if verbose:
677
- self.message += f"\nDescription: {self.description}"
678
- self.message += f"\nExample: {self.example}"
679
- self.message += f"\nFix: {self.fix}"
680
- super().__init__(self.message)
681
-
682
-
683
- class FiledInMetadataSheetMissingOrFailedValidation(NeatException):
684
- """One of the mandatory fields in Metadata sheet is missing or it failed validation
685
-
686
- Args:
687
- verbose: flag that indicates whether to provide enhanced exception message, by default False
688
-
689
- Notes:
690
- Make sure to define compliant field in Metadata sheet before proceeding
691
- """
692
-
693
- type_: str = "FiledInMetadataSheetMissingOrFailedValidation"
694
- code: int = 15
695
- description: str = "One of the mandatory fields in Metadata sheet is missing or it failed validation"
696
- example: str = ""
697
- fix: str = "Make sure to define compliant field in Metadata sheet before proceeding"
698
-
699
- def __init__(self, missing_field: str, verbose: bool = False):
700
- self.message = (
701
- f"Field {missing_field} is missing in the 'Metadata' sheet or it failed validation!"
702
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
703
- )
704
- if verbose:
705
- self.message += f"\nDescription: {self.description}"
706
- self.message += f"\nExample: {self.example}"
707
- self.message += f"\nFix: {self.fix}"
708
- super().__init__(self.message)
709
-
710
-
711
- class PrefixesRegexViolation(NeatException):
712
- """Prefix(es), which are in the 'Prefixes' sheet, do(es) not respect defined regex expression
713
-
714
- Args:
715
- prefixes: list of prefixes that violate regex expression
716
- regex_expression: regex expression that is violated
717
- verbose: flag that indicates whether to provide enhanced exception message, by default False
718
-
719
- Notes:
720
- Check if prefixes in the `Prefixes` sheet contains any illegal characters and respects the regex expression
721
- """
722
-
723
- type_: str = "PrefixesRegexViolation"
724
- code: int = 16
725
- description: str = "Prefix(es), which are in the 'Prefixes' sheet, do(es) not respect defined regex expression"
726
- example: str = (
727
- "If prefix is set to 'power grid', while regex expression does not "
728
- "allow spaces, the expression will be violated thus raising this error"
729
- )
730
- fix: str = (
731
- "Check if prefixes in the 'Prefixes' sheet contains any illegal characters and respects the regex expression"
732
- )
733
-
734
- def __init__(self, prefixes: list[str], regex_expression: str, verbose: bool = False):
735
- self.prefixes = prefixes
736
- self.regex_expression = regex_expression
737
-
738
- self.message = (
739
- f"Invalid prefix(es) {', '.join(self.prefixes)} stored in the 'Prefixes' sheet, "
740
- f"it/they must obey regex {self.regex_expression}!"
741
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
742
- )
743
- if verbose:
744
- self.message += f"\nDescription: {self.description}"
745
- self.message += f"\nExample: {self.example}"
746
- self.message += f"\nFix: {self.fix}"
747
- super().__init__(self.message)
748
-
749
-
750
- class PrefixesSheetNamespaceNotValidURL(NeatException):
751
- """Namespace(es), which are/is in the 'Prefixes' sheet, are/is not valid URL(s)
752
-
753
- Args:
754
- namespaces: list of namespaces that raised exception
755
- verbose: flag that indicates whether to provide enhanced exception message, by default False
756
-
757
- Notes:
758
- Check if `namespaces` in the `Prefixes` sheet are properly constructed as valid
759
- URLs containing only allowed characters
760
- """
761
-
762
- type_: str = "PrefixesSheetNamespaceNotValidURL"
763
- code: int = 17
764
- description: str = "Namespace(es), which are/is in the 'Prefixes' sheet, are/is not valid URLs"
765
- example: str = "If we have 'authority:namespace' as namespace as it is not a valid URL this error will be raised"
766
- fix: str = (
767
- "Check if 'namespaces' in the 'Prefixes' sheet are properly "
768
- "constructed as valid URLs containing only allowed characters"
769
- )
770
-
771
- def __init__(self, namespaces: list[str], verbose: bool = False):
772
- self.namespaces = namespaces
773
-
774
- self.message = (
775
- f"Invalid namespace(es) {', '.join(self.namespaces)} stored in the 'Prefixes' sheet, "
776
- f"it/they must be valid URLs!"
777
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
778
- )
779
- if verbose:
780
- self.message += f"\nDescription: {self.description}"
781
- self.message += f"\nExample: {self.example}"
782
- self.message += f"\nFix: {self.fix}"
783
- super().__init__(self.message)
784
-
785
-
786
- class ValueTypeNotDefinedAsClass(NeatException):
787
- """Expected value type, which is stored in the column 'Type' in the 'Properties' sheet,
788
- is not defined in the 'Classes' sheet. This error occurs when property is defined as
789
- an edge between two classes, of which one is not defined
790
-
791
- Args:
792
- expected_value_type: expected value type that raised exception
793
- property_id: property id that has expected value type that raised exception
794
- class_id: class id for which property is defined
795
- verbose: flag that indicates whether to provide enhanced exception message, by default False
796
-
797
- Notes:
798
- Make sure to define all of the classes in the `Classes` sheet before defining
799
- properties that expect them as value types
800
- """
801
-
802
- type_: str = "ValueTypeNotDefinedAsClass"
803
- code: int = 18
804
- description: str = (
805
- "Expected value type, which is stored in the column 'Type' in the 'Properties'"
806
- " sheet, is not defined in the 'Classes' sheet. "
807
- "This error occurs when property is defined as an edge between two classes, of which one is not defined"
808
- )
809
- example: str = (
810
- "We have 'Class1' which has property 'edgeClass1Class2' linking it to 'Class2', thus"
811
- "expected value of 'edgeClass1Class2' is 'Class2'. However, 'Classes' sheet only contains"
812
- " 'Class1', while 'Class2' is not defined. Under this given circumstance, this error will be raised!"
813
- )
814
-
815
- fix: str = (
816
- "Make sure to define all of the classes in the 'Classes' sheet before defining "
817
- "properties that expect them as value types"
818
- )
819
-
820
- def __init__(self, class_id: str, property_id: str, expected_value_type: str, verbose: bool = False):
821
- self.message = (
822
- f"Property {property_id} defined for class {class_id} has"
823
- f" value type {expected_value_type} which is not defined as a class in the 'Classes' sheet!"
824
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
825
- )
826
- if verbose:
827
- self.message += f"\nDescription: {self.description}"
828
- self.message += f"\nExample: {self.example}"
829
- self.message += f"\nFix: {self.fix}"
830
- super().__init__(self.message)
831
-
832
-
833
- class UndefinedObjectsAsExpectedValueTypes(NeatException):
834
- """Expected value types, which are stored in the column 'Type' in the 'Properties'
835
- sheet, are classes that exist in the 'Classes' sheet but for which no properties are defined
836
- in the 'Properties' sheet.
837
-
838
- Args:
839
- undefined_objects: list of undefined objects that raised exception
840
- verbose: flag that indicates whether to provide enhanced exception message, by default False
841
-
842
- Notes:
843
- Make sure to define properties for classes from 'Classes' sheet before defining
844
- properties that expect them as value types
845
- """
846
-
847
- type_: str = "UndefinedObjectsAsExpectedValueTypes"
848
- code: int = 19
849
- description: str = (
850
- "Expected value types, which are stored in the column 'Type' in the 'Properties'"
851
- " sheet, are classes that exist in the 'Classes' sheet but for which no properties are defined "
852
- "in the 'Properties' sheet. "
853
- )
854
- example: str = (
855
- "We have 'Class1' which has property 'edgeClass1Class2' linking it to 'Class2', thus"
856
- "expected value of 'edgeClass1Class2' is 'Class2'. "
857
- "Both 'Class1' and 'Class2' are defined in the 'Classes' sheet"
858
- "However, only 'Class1' has properties defined in the 'Properties' sheet, making 'Class2' an undefined object"
859
- " leading to this error being raised!"
860
- )
861
-
862
- fix: str = (
863
- "Make sure to define properties for classes from 'Classes' "
864
- "sheet before defining properties that expect them as value types"
865
- )
866
-
867
- def __init__(self, undefined_objects: list[str], verbose: bool = False):
868
- self.message = (
869
- f"Following classes {', '.join(undefined_objects)} defined as classes in the 'Classes' sheet"
870
- f" have no properties defined in the 'Properties' sheet or their validation as objects failed!"
871
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
872
- )
873
- if verbose:
874
- self.message += f"\nDescription: {self.description}"
875
- self.message += f"\nExample: {self.example}"
876
- self.message += f"\nFix: {self.fix}"
877
- super().__init__(self.message)
878
-
879
-
880
- class ClassSheetParentClassIDRegexViolation(NeatException):
881
- """Parent ID, which is stored in the column 'Parent Class' in the 'Classes' sheet,
882
- does not respect defined regex expression
883
-
884
- Args:
885
- parent_ids: parent_ids that raised exception
886
- regex_expression: regex expression against which parent_id is validated
887
- verbose: flag that indicates whether to provide enhanced exception message, by default False
888
-
889
- Notes:
890
- Check definition of parent ids in `Parent Class` column in `Classes` sheet and
891
- make sure to respect the regex expression by removing any illegal characters
892
-
893
- """
894
-
895
- type_: str = "ClassSheetParentClassIDRegexViolation"
896
- code: int = 20
897
- description: str = (
898
- "Parent ID, which is stored in the column 'Parent Class' in the 'Classes' sheet, "
899
- "does not respect defined regex expression"
900
- )
901
- example: str = (
902
- "If parent class is set to 'Class 1', while regex expression does not allow spaces,"
903
- " the expression will be violated thus raising this error"
904
- )
905
- fix: str = (
906
- "Check definition of class ids in 'Parent Class' column in 'Classes' sheet and "
907
- "make sure to respect the regex expression by removing any illegal characters"
908
- )
909
-
910
- def __init__(self, parent_ids: list[str], regex_expression: str, verbose: bool = False):
911
- self.parent_ids = parent_ids
912
- self.regex_expression = regex_expression
913
-
914
- self.message = (
915
- f"Parents ids: [{', '.join(parent_ids or [])}], stored in 'Parent Class' column in 'Classes' "
916
- f"sheet violates regex {self.regex_expression}!"
917
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
918
- )
919
- if verbose:
920
- self.message += f"\nDescription: {self.description}"
921
- self.message += f"\nExample: {self.example}"
922
- self.message += f"\nFix: {self.fix}"
923
-
924
-
925
- class MoreThanOneNonAlphanumericCharacter(NeatException):
926
- """This exceptions is raised when doing regex validation of strings which either
927
- represent class ids, property ids, prefix, data model name, that contain more than
928
- one non-alphanumeric character, such as for example '_' or '-'.
929
-
930
- Args:
931
- field_name: filed on which regex validation failed
932
- value: value that failed regex validation
933
- verbose: flag that indicates whether to provide enhanced exception message, by default False
934
-
935
- Notes:
936
- Make sure not to use more than non-alphanumeric character in the row
937
-
938
- """
939
-
940
- type_: str = "MoreThanOneNonAlphanumericCharacter"
941
- code: int = 21
942
- description: str = (
943
- "This exceptions is raised when doing regex validation of strings which either"
944
- "represent class ids, property ids, prefix, data model name, that contain more than"
945
- "one non-alphanumeric character, such as for example '_' or '-'."
946
- )
947
- example: str = ""
948
- fix: str = ""
949
-
950
- def __init__(self, field_name: str, value: str, verbose: bool = False):
951
- self.field_name = field_name
952
- self.value = value
953
-
954
- self.message = (
955
- f"Field {field_name} with value {value} contains more than one non-alphanumeric character!"
956
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
957
- )
958
- if verbose:
959
- self.message += f"\nDescription: {self.description}"
960
- self.message += f"\nExample: {self.example}"
961
- self.message += f"\nFix: {self.fix}"
962
- super().__init__(self.message)
963
-
964
-
965
- class ViewExternalIdNotDefined(NeatException):
966
- """This exceptions is raised when external id of View is not defined.
967
-
968
- Args:
969
- field_name: filed on which regex validation failed
970
- value: value that failed regex validation
971
- verbose: flag that indicates whether to provide enhanced exception message, by default False
972
-
973
- """
974
-
975
- type_: str = "ViewExternalIdNotDefined"
976
- code: int = 22
977
- description: str = "This exceptions is raised when external id of View is not defined"
978
- example: str = ""
979
- fix: str = ""
980
-
981
- def __init__(self, verbose: bool = False):
982
- self.message = (
983
- f"Missing View external id!" f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
984
- )
985
- if verbose:
986
- self.message += f"\nDescription: {self.description}"
987
- self.message += f"\nExample: {self.example}"
988
- self.message += f"\nFix: {self.fix}"
989
- super().__init__(self.message)
990
-
991
-
992
- class SpaceNotDefined(NeatException):
993
- """This exceptions is raised when CDF space name is missing.
994
-
995
- Args:
996
- verbose: flag that indicates whether to provide enhanced exception message, by default False
997
-
998
- """
999
-
1000
- type_: str = "SpaceNotDefined"
1001
- code: int = 23
1002
- description: str = "This exceptions is raised when CDF space name is missing"
1003
- example: str = ""
1004
- fix: str = ""
1005
-
1006
- def __init__(self, verbose: bool = False):
1007
- self.message = (
1008
- f"Missing CDF space name!" f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1009
- )
1010
- if verbose:
1011
- self.message += f"\nDescription: {self.description}"
1012
- self.message += f"\nExample: {self.example}"
1013
- self.message += f"\nFix: {self.fix}"
1014
- super().__init__(self.message)
1015
-
1016
-
1017
- class ViewVersionNotDefined(NeatException):
1018
- """This exceptions is raised when View version is not provided.
1019
-
1020
- Args:
1021
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1022
-
1023
- """
1024
-
1025
- type_: str = "ViewVersionNotDefined"
1026
- code: int = 24
1027
- description: str = "This exceptions is raised when View version is not provided"
1028
- example: str = ""
1029
- fix: str = ""
1030
-
1031
- def __init__(self, verbose: bool = False):
1032
- self.message = (
1033
- f"Missing View version!" f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1034
- )
1035
- if verbose:
1036
- self.message += f"\nDescription: {self.description}"
1037
- self.message += f"\nExample: {self.example}"
1038
- self.message += f"\nFix: {self.fix}"
1039
- super().__init__(self.message)
1040
-
1041
-
1042
- class DefaultValueTypeNotProper(NeatException):
1043
- """This exceptions is raised when default value type is not proper, i.e. it is not
1044
- according to the expected value type set in Rules.
1045
-
1046
-
1047
- Args:
1048
- default_value_type: default value type that raised exception
1049
- expected_value_type: expected value type that raised exception
1050
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1051
-
1052
- """
1053
-
1054
- type_: str = "DefaultValueTypeNotProper"
1055
- code: int = 25
1056
- description: str = (
1057
- "This exceptions is raised when default value type is not proper, i.e. it is not "
1058
- "according to the expected value type set in Rules."
1059
- )
1060
- example: str = ""
1061
- fix: str = ""
1062
-
1063
- def __init__(self, property_id: str, default_value_type: str, expected_value_type: str, verbose: bool = False):
1064
- self.default_value_type = default_value_type
1065
- self.expected_value_type = expected_value_type
1066
-
1067
- self.message = (
1068
- f"Default value for property {property_id} is of type {default_value_type} which is different from "
1069
- f"the expected value type {expected_value_type}!"
1070
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1071
- )
1072
- if verbose:
1073
- self.message += f"\nDescription: {self.description}"
1074
- self.message += f"\nExample: {self.example}"
1075
- self.message += f"\nFix: {self.fix}"
1076
- super().__init__(self.message)
1077
-
1078
-
1079
- class ClassToAssetMappingNotDefined(NeatException):
1080
- """This exceptions is raised when deriving class to asset mapping when there is no
1081
- mapping available.
1082
-
1083
-
1084
- Args:
1085
- class_id: Id of the class that raised exception
1086
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1087
-
1088
- """
1089
-
1090
- type_: str = "ClassToAssetMappingNotDefined"
1091
- code: int = 26
1092
- description: str = (
1093
- "This exceptions is raised when deriving class to asset mapping when there is no mapping available"
1094
- )
1095
- example: str = ""
1096
- fix: str = ""
1097
-
1098
- def __init__(self, class_id: str, verbose: bool = False):
1099
- self.class_id = class_id
1100
-
1101
- self.message = (
1102
- f"Requested serialization from pydantic model instance of class {class_id} is"
1103
- " not possible since there is no class to asset mapping available!"
1104
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1105
- )
1106
- if verbose:
1107
- self.message += f"\nDescription: {self.description}"
1108
- self.message += f"\nExample: {self.example}"
1109
- self.message += f"\nFix: {self.fix}"
1110
- super().__init__(self.message)
1111
-
1112
-
1113
- class PrefixAlreadyInUse(NeatException):
1114
- """This exceptions is raised when trying to update base prefix/space of Rules object
1115
-
1116
-
1117
- Args:
1118
- class_id: Id of the class that raised exception
1119
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1120
-
1121
- """
1122
-
1123
- type_: str = "PrefixAlreadyInUse"
1124
- code: int = 27
1125
- description: str = "This exceptions is raised when trying to update base prefix/space of Rules object"
1126
- example: str = ""
1127
- fix: str = ""
1128
-
1129
- def __init__(self, prefix: str, verbose: bool = False):
1130
- self.prefix = prefix
1131
-
1132
- self.message = (
1133
- f"Prefix {prefix} exist in self.prefixes, please use another prefix!"
1134
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1135
- )
1136
- if verbose:
1137
- self.message += f"\nDescription: {self.description}"
1138
- self.message += f"\nExample: {self.example}"
1139
- self.message += f"\nFix: {self.fix}"
1140
- super().__init__(self.message)
1141
-
1142
-
1143
- class IncompleteSchema(NeatException):
1144
- """This exceptions is raised when schema is not complete, meaning defined properties
1145
- are pointing to non-existing classes or value types
1146
-
1147
-
1148
- Args:
1149
- missing_classes: list of classes ids that are not defined in the sheet
1150
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1151
-
1152
- """
1153
-
1154
- type_: str = "IncompleteSchema"
1155
- code: int = 28
1156
- description: str = (
1157
- "This exceptions is raised when schema is not complete, meaning "
1158
- "defined properties are pointing to non-existing classes or value types"
1159
- )
1160
- example: str = ""
1161
- fix: str = ""
1162
-
1163
- def __init__(self, missing_classes: set, verbose: bool = False):
1164
- self.message = (
1165
- f"Classes {missing_classes} are not defined in the Class sheet!"
1166
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1167
- )
1168
- if verbose:
1169
- self.message += f"\nDescription: {self.description}"
1170
- self.message += f"\nExample: {self.example}"
1171
- self.message += f"\nFix: {self.fix}"
1172
- super().__init__(self.message)
1173
-
1174
-
1175
- # Warnings:
1176
-
1177
-
1178
- class ClassNameNotProvided(NeatWarning):
1179
- """This warning is raised when class name is not provided in the 'Classes' sheet
1180
- under 'name' column, which will be then set the class id stored in the 'Class' column
1181
-
1182
- Args:
1183
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1184
- class_id: class id that raised warning, and which is used as class name
1185
-
1186
- Notes:
1187
- If you want to have differentiation between the class name and class id, then
1188
- provide class name in the `name` column
1189
- """
1190
-
1191
- type_: str = "ClassNameNotProvided"
1192
- code: int = 1
1193
- description: str = (
1194
- "This warning is raised when class name is not provided in the 'Classes' sheet"
1195
- "under 'name' column, which will be then set the class id stored in the 'Class' column"
1196
- )
1197
- example: str = ""
1198
- fix: str = (
1199
- "If you want to have differentiation between the class name"
1200
- " and class id, then provide class name in the `name` column"
1201
- )
1202
-
1203
- # need to have default value set to arguments
1204
- # otherwise it will raise TypeError
1205
- def __init__(self, class_id: str = "", verbose: bool = False):
1206
- self.message = (
1207
- f"Class id {class_id} set as Class name!"
1208
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1209
- )
1210
- if verbose:
1211
- self.message += f"\nDescription: {self.description}"
1212
- self.message += f"\nExample: {self.example}"
1213
- self.message += f"\nFix: {self.fix}"
1214
-
1215
-
1216
- class EntityIDNotDMSCompliant(NeatWarning):
1217
- """Warning raise when entity id being class, property or value type is not DMS compliant
1218
-
1219
- Args:
1220
- entity_type: type of entity that raised warning
1221
- entity_id: id of entity that raised warning
1222
- loc: location of entity in the Transformation Rules sheet that raised warning
1223
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1224
-
1225
- Notes:
1226
- DMS ready means that entity id must only use following characters [a-zA-Z0-9_],
1227
- where it can only start with letter! Also there are reserved words that cannot be used.
1228
-
1229
- Reserved words for views: `Query`, `Mutation`, `Subscription`, `String`, `Int32`, `Int64`, `Int`,
1230
- `Float32`, `Float64`, `Float`, `Timestamp`, `JSONObject`, `Date`, `Numeric`, `Boolean`, `PageInfo`,
1231
- `File`, `Sequence`, `TimeSeries`
1232
-
1233
- Reserved words for properties: `space`, `externalId`, `createdTime`, `lastUpdatedTime`,
1234
- `deletedTime`, `edge_id`, `node_id`, `project_id`, `property_group`, `seq`, `tg_table_name`, `extensions`
1235
-
1236
- Reserved words for spaces: `space`, `cdf`, `dms`, `pg3`, `shared`, `system`, `node`, `edge`
1237
- """
1238
-
1239
- type_: str = "EntityIDNotDMSCompliant"
1240
- code: int = 2
1241
- description: str = "Warning raise when entity id being class, property or value type is not DMS compliant"
1242
- example: str = ""
1243
- fix: str = (
1244
- "DMS ready means that entity id must only use following"
1245
- " characters [a-zA-Z0-9_], where it can only start with letter!"
1246
- )
1247
-
1248
- # See ClassNameNotProvided for explanation why default values are set
1249
- def __init__(self, entity_type: str = "", entity_id: str = "", loc: str = "", verbose: bool = False):
1250
- self.message = (
1251
- f"'{entity_id}' {entity_type.lower()}"
1252
- " use character(s) outside of range of allowed characters [a-zA-Z0-9_] or "
1253
- f"it starts with non-letter character or it is reserved word! {loc}"
1254
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1255
- )
1256
- if verbose:
1257
- self.message += f"\nDescription: {self.description}"
1258
- self.message += f"\nExample: {self.example}"
1259
- self.message += f"\nFix: {self.fix}"
1260
-
1261
-
1262
- class PropertyRedefined(NeatWarning):
1263
- """Warning raise when same property is defined multiple times for same class, this
1264
- typically occurs if there are multiple ways to extract certain information from the
1265
- NeatGraph.
1266
-
1267
- Args:
1268
- property_id: property id that is redefined
1269
- class_id: class id for which property is redefined
1270
- loc: location of property redefinition in the 'Properties' sheet of Transformation Rules Excel file
1271
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1272
-
1273
- Notes:
1274
- If possible, have only single definition of a particular property for a class, otherwise
1275
- transformation rules will not be DMS compliant.
1276
- """
1277
-
1278
- type_: str = "PropertyRedefined"
1279
- code: int = 3
1280
- description: str = "Warning raise when same property is defined multiple times for same class"
1281
- example: str = ""
1282
- fix: str = "Have only single definition of a particular property for a class"
1283
-
1284
- # See Warning302 for explanation why default values are set
1285
- def __init__(self, property_id: str = "", class_id: str = "", loc: str = "", verbose: bool = False):
1286
- self.message = (
1287
- f"Not DMS compliant! Property '{property_id}' for class '{class_id}' redefined! {loc}"
1288
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1289
- )
1290
- if verbose:
1291
- self.message += f"\nDescription: {self.description}"
1292
- self.message += f"\nExample: {self.example}"
1293
- self.message += f"\nFix: {self.fix}"
1294
- # hint on a specific web docs page
1295
-
1296
-
1297
- class PropertyNameNotProvided(NeatWarning):
1298
- """If property name is not provided in the 'Property' sheet under 'name' column, it
1299
- will be set to corresponding value from 'Property' column, thus property id
1300
-
1301
- Args:
1302
- property_id: property id that is set as property name
1303
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1304
- Notes:
1305
- If you want to have different property name then property id, provide it in the 'name' column
1306
- """
1307
-
1308
- type_: str = "PropertyNameNotProvided"
1309
- code: int = 4
1310
- description: str = (
1311
- "If property name is not provided in the 'Property' sheet under 'name' column,"
1312
- " it will be set to corresponding value from 'Property' column, thus property id"
1313
- )
1314
- example: str = ""
1315
- fix: str = "If you want to have different property name then property id, provide it in the 'name' column"
1316
-
1317
- def __init__(self, property_id: str = "", verbose: bool = False):
1318
- self.message = (
1319
- f"Property id {property_id} set as Property name!"
1320
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1321
- )
1322
- if verbose:
1323
- self.message += f"\nDescription: {self.description}"
1324
- self.message += f"\nExample: {self.example}"
1325
- self.message += f"\nFix: {self.fix}"
1326
-
1327
-
1328
- class MissingLabel(NeatWarning):
1329
- """If property maps to CDF relationship, and it does not have label explicitly stated
1330
- under 'Label' column in the 'Property' sheet under 'name' column, it will be set
1331
- to corresponding value from 'Property' column, thus property id
1332
-
1333
- Args:
1334
- property_id: property id that which is missing label
1335
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1336
-
1337
-
1338
- Notes:
1339
- If you want to have control over relationship labels make sure to define one
1340
- in the `Label` column in the `Properties` sheet
1341
- """
1342
-
1343
- type_: str = "MissingLabel"
1344
- code: int = 5
1345
- description: str = (
1346
- "If property maps to CDF relationship, and it does not have label explicitly stated under 'Label' column"
1347
- " in the 'Property' sheet under 'name' column,"
1348
- " it will be set to corresponding value from 'Property' column, thus property id"
1349
- )
1350
- example: str = ""
1351
- fix: str = (
1352
- "If you want to have control over relationship labels make sure to define one"
1353
- " in the 'Label' column in the 'Properties' sheet."
1354
- )
1355
-
1356
- def __init__(self, property_id: str = "", verbose: bool = False):
1357
- self.message = (
1358
- f"Property id {property_id} set as CDF relationship label!"
1359
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1360
- )
1361
- if verbose:
1362
- self.message += f"\nDescription: {self.description}"
1363
- self.message += f"\nExample: {self.example}"
1364
- self.message += f"\nFix: {self.fix}"
1365
-
1366
-
1367
- class NoTransformationRules(NeatWarning):
1368
- """This warning is raised if there are no transformation rules defined for given
1369
- property and class
1370
-
1371
- Args:
1372
- property_id: property id that which is missing transformation rules
1373
- class_id: class id for which property is missing transformation rules
1374
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1375
-
1376
- Notes:
1377
- One can omit this warning if the Transformation Rules spreadsheet is used solely
1378
- for defining the data model and not for performing knowledge graph transformation.
1379
- """
1380
-
1381
- type_: str = "NoTransformationRules"
1382
- code: int = 6
1383
- description: str = (
1384
- "This warning is raised if there are no transformation rules "
1385
- "defined in the 'Transformation' sheet for given property"
1386
- )
1387
- example: str = ""
1388
- fix: str = "No fix is provided for this warning"
1389
-
1390
- def __init__(self, property_id: str = "", class_id: str = "", verbose: bool = False):
1391
- self.message = (
1392
- f"There is no transformation rule configured for class '{class_id}' property '{property_id}'!"
1393
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1394
- )
1395
- if verbose:
1396
- self.message += f"\nDescription: {self.description}"
1397
- self.message += f"\nExample: {self.example}"
1398
- self.message += f"\nFix: {self.fix}"
1399
-
1400
-
1401
- class NamespaceEndingFixed(NeatWarning):
1402
- """This warning occurs when namespace does not end with '/' or '#'
1403
-
1404
- Args:
1405
- namespace: namespace that raised warning due to improper ending
1406
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1407
-
1408
- Notes:
1409
- Make sure that namespace ends with `/` or `#`, if not it will be fixed by adding
1410
- `#` at the end !
1411
- """
1412
-
1413
- type_: str = "NamespaceEndingFixed"
1414
- code: int = 7
1415
- description: str = "This warning occurs when namespace does not end with '/' or '#'"
1416
- example: str = "If namespace is set to http://purl.org/cognite, it will be converted to http://purl.org/cognite#"
1417
- fix: str = "Make sure that namespace ends with '/' or '#'"
1418
-
1419
- def __init__(self, namespace: Namespace, verbose: bool = False):
1420
- self.message = (
1421
- f"Namespace {namespace} ending fixed by adding '#' at its end!"
1422
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1423
- )
1424
- if verbose:
1425
- self.message += f"\nDescription: {self.description}"
1426
- self.message += f"\nExample: {self.example}"
1427
- self.message += f"\nFix: {self.fix}"
1428
- # hint on a specific web docs page
1429
-
1430
-
1431
- class DataModelIdMissing(NeatWarning):
1432
- """This warning occurs when data model name is not provided in 'Metadata' sheet
1433
-
1434
- Args:
1435
- prefix: prefix to which data model name will be set if not provided
1436
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1437
-
1438
- Notes:
1439
- Make sure that namespace ends with `/` or `#`, if not it will be fixed by adding
1440
- `#` at the end !
1441
- """
1442
-
1443
- type_: str = "DataModelIdMissing"
1444
- code: int = 8
1445
- description: str = "This warning occurs when data model id is not provided in 'Metadata' sheet"
1446
- example: str = ""
1447
- fix: str = (
1448
- "Provide data model id by setting value for `external_id`,"
1449
- " to avoid this warning and otherwise it will default to prefix"
1450
- )
1451
-
1452
- def __init__(self, prefix: str, verbose: bool = False):
1453
- self.message = (
1454
- f"Data model id not provided, defaulting to prefix {prefix}!"
1455
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1456
- )
1457
- if verbose:
1458
- self.message += f"\nDescription: {self.description}"
1459
- self.message += f"\nExample: {self.example}"
1460
- self.message += f"\nFix: {self.fix}"
1461
-
1462
-
1463
- class VersionDotsConvertedToUnderscores(NeatWarning):
1464
- """This warning occurs when converting version from dot notation to use of underscores
1465
- in order to achieve version format that is accepted by CDF/DMS
1466
-
1467
- Args:
1468
- prefix: prefix to which data model name will be set if not provided
1469
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1470
-
1471
- Notes:
1472
- Typically version is expressed in classical form with dots major.minor.patch, while
1473
- CDF accepts underscores major_minor_patch, thus this warning occurs when converting
1474
- version from dot notation to use of underscores in order to achieve version format
1475
- that is accepted by CDF/DMS
1476
- """
1477
-
1478
- type_: str = "VersionDotsConvertedToUnderscores"
1479
- code: int = 9
1480
- description: str = (
1481
- "This warning occurs when converting version from dot notation to use of underscores"
1482
- " in order to achieve version format that is accepted by CDF/DMS"
1483
- )
1484
- example: str = "If version is provided as 1.2.3, this will be converted to 1_2_3 to be accepted by CDF"
1485
- fix: str = "Convert version to underscore notation major_minor_patch"
1486
-
1487
- def __init__(self, verbose: bool = False):
1488
- self.message = (
1489
- "Data model version expressed with '.' which is not acceptable for CDF."
1490
- " All '.' are converted to '_'!"
1491
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1492
- )
1493
- if verbose:
1494
- self.message += f"\nDescription: {self.description}"
1495
- self.message += f"\nExample: {self.example}"
1496
- self.message += f"\nFix: {self.fix}"
1497
- # hint on a specific web docs page
1498
-
1499
-
1500
- class DefaultValueTypeConverted(NeatWarning):
1501
- """This exceptions is warning is raised when default value type is being converted to
1502
- the expected value type set in Rules.
1503
-
1504
-
1505
- Args:
1506
- default_value_type: default value type that raised exception
1507
- expected_value_type: expected value type that raised exception
1508
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1509
-
1510
- Notes:
1511
- Make sure not to use more than non-alphanumeric character in the row
1512
-
1513
- """
1514
-
1515
- type_: str = "DefaultValueTypeConverted"
1516
- code: int = 10
1517
- description: str = (
1518
- "This exceptions is warning is raised when default value type is being converted to "
1519
- "the expected value type set in Rules."
1520
- )
1521
- example: str = ""
1522
- fix: str = ""
1523
-
1524
- def __init__(
1525
- self, property_id: str = "", default_value_type: str = "", expected_value_type: str = "", verbose: bool = False
1526
- ):
1527
- self.default_value_type = default_value_type
1528
- self.expected_value_type = expected_value_type
1529
-
1530
- self.message = (
1531
- f"Default value for property {property_id} is of type {default_value_type} "
1532
- f"has been converted to the expected value type {expected_value_type}!"
1533
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1534
- )
1535
- if verbose:
1536
- self.message += f"\nDescription: {self.description}"
1537
- self.message += f"\nExample: {self.example}"
1538
- self.message += f"\nFix: {self.fix}"
1539
- super().__init__(self.message)
1540
-
1541
-
1542
- class DefaultValueNotList(NeatWarning):
1543
- """This exceptions is warning is raised when default value is not a list while it is
1544
- expected to be due to set maximum cardinality being different than 1.
1545
-
1546
-
1547
- Args:
1548
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1549
-
1550
- Notes:
1551
- Make sure not to use more than non-alphanumeric character in the row
1552
-
1553
- """
1554
-
1555
- type_: str = "DefaultValueNotList"
1556
- code: int = 11
1557
- description: str = (
1558
- "This exceptions is warning is raised when default value is not a list while it is "
1559
- "expected to be due to set maximum cardinality being different than 1"
1560
- )
1561
- example: str = ""
1562
- fix: str = ""
1563
-
1564
- def __init__(self, property_id: str, verbose: bool = False):
1565
- self.message = (
1566
- f"Default value for property {property_id} is not a list, "
1567
- "while it is expected to be due to set maximum cardinality being different than 1!"
1568
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1569
- )
1570
- if verbose:
1571
- self.message += f"\nDescription: {self.description}"
1572
- self.message += f"\nExample: {self.example}"
1573
- self.message += f"\nFix: {self.fix}"
1574
- super().__init__(self.message)
1575
-
1576
-
1577
- ################################################################################################
1578
- # RULES PROCESSING: 100 - 199 ##################################################################
1579
- ################################################################################################
1580
-
1581
-
1582
- class NotValidRDFPath(NeatException):
1583
- """Provided `rdfpath` is not valid, i.e. it cannot be converted to SPARQL query.
1584
-
1585
- Args:
1586
- rdf_path: `rdfpath` that raised exception
1587
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1588
-
1589
- Notes:
1590
- Get familiar with `rdfpath` to avoid this exception.
1591
- """
1592
-
1593
- type_: str = "NotValidRDFPath"
1594
- code: int = 100
1595
- description: str = "Provided `rdfpath` is not valid, i.e. it cannot be converted to SPARQL query"
1596
- example: str = ""
1597
- fix: str = "Get familiar with `rdfpath` and check if provided path is valid!"
1598
-
1599
- def __init__(self, rdf_path: str, verbose: bool = False):
1600
- self.rdf_path = rdf_path
1601
-
1602
- self.message = (
1603
- f"{self.rdf_path} is not a valid rdfpath!"
1604
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1605
- )
1606
-
1607
- if verbose:
1608
- self.message += f"\nDescription: {self.description}"
1609
- self.message += f"\nExample: {self.example}"
1610
- self.message += f"\nFix: {self.fix}"
1611
- super().__init__(self.message)
1612
-
1613
-
1614
- class NotValidTableLookUp(NeatException):
1615
- """Provided `table lookup` is not valid, i.e. it cannot be converted to CDF lookup.
1616
-
1617
- Args:
1618
- table_look_up: `table_look_up`, a part of `rawlookup`, that raised exception
1619
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1620
-
1621
- Notes:
1622
- Get familiar with `rawlookup` and `rdfpath` to avoid this exception.
1623
- """
1624
-
1625
- type_: str = "NotValidTableLookUp"
1626
- code: int = 101
1627
- description: str = "Provided table lookup is not valid, i.e. it cannot be converted to CDF lookup"
1628
- example: str = ""
1629
- fix: str = "Get familiar with RAW look up and RDF paths and check if provided rawlookup is valid"
1630
-
1631
- def __init__(self, table_look_up: str, verbose: bool = False):
1632
- self.table_look_up = table_look_up
1633
-
1634
- self.message = (
1635
- f"{self.table_look_up} is not a valid table lookup"
1636
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1637
- )
1638
-
1639
- if verbose:
1640
- self.message += f"\nDescription: {self.description}"
1641
- self.message += f"\nExample: {self.example}"
1642
- self.message += f"\nFix: {self.fix}"
1643
- super().__init__(self.message)
1644
-
1645
-
1646
- class NotValidRAWLookUp(NeatException):
1647
- """Provided `rawlookup` is not valid, i.e. it cannot be converted to SPARQL query and CDF lookup
1648
-
1649
- Args:
1650
- raw_look_up: `rawlookup` rule that raised exception
1651
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1652
-
1653
- Notes:
1654
- Get familiar with `rawlookup` and `rdfpath` to avoid this exception.
1655
- """
1656
-
1657
- type_: str = "NotValidRAWLookUp"
1658
- code: int = 102
1659
- description: str = "Provided rawlookup is not valid, i.e. it cannot be converted to SPARQL query and CDF lookup"
1660
- example: str = ""
1661
- fix: str = "Get familiar with `rawlookup` and `rdfpath` to avoid this exception"
1662
-
1663
- def __init__(self, raw_look_up: str, verbose: bool = False):
1664
- self.raw_look_up = raw_look_up
1665
-
1666
- self.message = (
1667
- f"Invalid rawlookup expected traversal | table lookup, got {raw_look_up}"
1668
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1669
- )
1670
-
1671
- if verbose:
1672
- self.message += f"\nDescription: {self.description}"
1673
- self.message += f"\nExample: {self.example}"
1674
- self.message += f"\nFix: {self.fix}"
1675
- super().__init__(self.message)
1676
-
1677
-
1678
- ################################################################################################
1679
- # RULES IMPORTERS: 200 - 299 ###################################################################
1680
- ################################################################################################
1681
- class RulesHasErrors(NeatWarning):
1682
- """This warning occurs when generated transformation rules are invalid/incomplete.
1683
-
1684
- Args:
1685
- importer_type: type of importer that is used to generate transformation rules
1686
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1687
-
1688
- Notes:
1689
- Generated transformation rules are not guaranteed to be valid and complete.
1690
- Go through the generated report file and fix the errors and warnings.
1691
- """
1692
-
1693
- type_: str = "GeneratedTransformationRulesHasErrors"
1694
- code: int = 200
1695
- description: str = (
1696
- "This warning occurs when transformation rules generated using an importer are invalid/incomplete."
1697
- )
1698
- example: str = ""
1699
- fix: str = "Go through the generated report file and fix the warnings in generated Transformation Rules."
1700
-
1701
- def __init__(self, importer_type: str = "OWL ontology", verbose: bool = False):
1702
- self.message = (
1703
- f"Rules generated using {importer_type} are invalid!"
1704
- " Consult generated validation report for details on the errors and fix them"
1705
- " before using the rules file."
1706
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1707
- )
1708
- if verbose:
1709
- self.message += f"\nDescription: {self.description}"
1710
- self.message += f"\nExample: {self.example}"
1711
- self.message += f"\nFix: {self.fix}"
1712
-
1713
-
1714
- class RulesHasWarnings(NeatWarning):
1715
- """This warning occurs when th generated transformation rules are invalid/incomplete.
1716
-
1717
- Args:
1718
- importer_type: type of importer that is used to generate transformation rules
1719
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1720
-
1721
- Notes:
1722
- OWL ontology is not guaranteed to contain all information needed to generate
1723
- transformation rules. In such cases, transformation rules generated from OWL ontology
1724
- will be incomplete and invalid. Go through the generated report file and fix the warnings
1725
- """
1726
-
1727
- type_: str = "GeneratedTransformationRulesHasWarnings"
1728
- code: int = 201
1729
- description: str = (
1730
- "This warning occurs when transformation rules generated using an importer are invalid/incomplete."
1731
- )
1732
- example: str = ""
1733
- fix: str = "Go through the generated report file and fix the warnings in generated Transformation Rules."
1734
-
1735
- def __init__(self, importer_type: str = "OWL ontology", verbose: bool = False):
1736
- self.message = (
1737
- f"Rules generated using {importer_type} raised warnings!"
1738
- " Consult generated validation report for details on the warnings and optionally fix them"
1739
- " before using the rules file."
1740
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1741
- )
1742
- if verbose:
1743
- self.message += f"\nDescription: {self.description}"
1744
- self.message += f"\nExample: {self.example}"
1745
- self.message += f"\nFix: {self.fix}"
1746
-
1747
-
1748
- class GraphClassNameCollision(NeatWarning):
1749
- """This warning occurs when graph contains instances of classes with same name, but
1750
- belonging to different namespaces.
1751
-
1752
- Args:
1753
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1754
-
1755
- Notes:
1756
- Since the RDF graph is fully flexible and based on URIs, it is possible to have
1757
- instances of classes with same name, but belonging to different namespaces. This
1758
- warning is raised when such collision occurs.
1759
- """
1760
-
1761
- type_: str = "GraphClassNameCollision"
1762
- code: int = 202
1763
- description: str = (
1764
- "This warning occurs when graph contains instances of classes with same name, but"
1765
- " belonging to different namespaces."
1766
- )
1767
- example: str = ""
1768
- fix: str = "Be caution when reviewing the generated transformation rules."
1769
-
1770
- def __init__(self, class_name: str, verbose: bool = False):
1771
- self.message = f"Class name collision detected in the graph for class name {class_name}!"
1772
- if verbose:
1773
- self.message += f"\nDescription: {self.description}"
1774
- self.message += f"\nExample: {self.example}"
1775
- self.message += f"\nFix: {self.fix}"
1776
-
1777
-
1778
- class GraphClassPropertyMultiValueTypes(NeatWarning):
1779
- """This warning occurs when a same property is define for two object/classes where
1780
- its expected value type is different in one definition, e.g. acts as an edge, while in
1781
- other definition acts as and attribute
1782
-
1783
- Args:
1784
- class_id: class id that raised warning due to multi type definition
1785
- property_id: property id that raised warning due to multi type definition
1786
- types: list of types of property
1787
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1788
-
1789
- Notes:
1790
- If a property takes different value types for different objects, simply define
1791
- new property. It is bad practice to have multi type property!
1792
- """
1793
-
1794
- type_: str = "GraphClassPropertyMultiValueTypes"
1795
- code: int = 203
1796
- description: str = (
1797
- "This warning occurs when a same property is define for two object/classes where"
1798
- " its expected value type is different in one definition, e.g. acts as an edge, while in "
1799
- "other definition acts as and attribute"
1800
- )
1801
- example: str = ""
1802
- fix: str = "If a property takes different value types for different objects, simply define new property"
1803
-
1804
- def __init__(
1805
- self, class_name: str = "", property_name: str = "", types: list[str] | None = None, verbose: bool = False
1806
- ):
1807
- self.message = (
1808
- "It is bad practice to have multi type property! "
1809
- f"Currently property '{property_name}' for class {class_name} has"
1810
- f" multi type property: {', '.join(types or [])}"
1811
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1812
- )
1813
- if verbose:
1814
- self.message += f"\nDescription: {self.description}"
1815
- self.message += f"\nExample: {self.example}"
1816
- self.message += f"\nFix: {self.fix}"
1817
-
1818
-
1819
- class GraphClassPropertyMultiOccurrence(NeatWarning):
1820
- """This warning occurs when there is multiple different occurrences of the same property
1821
- across various class instances.
1822
-
1823
- Args:
1824
- class_id: class id that raised warning due to multi type definition
1825
- property_id: property id that raised warning due to multi type definition
1826
- occurrences: list of property occurrences
1827
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1828
-
1829
- Notes:
1830
- If a property takes different value types for different objects, simply define
1831
- new property. It is bad practice to have multi type property!
1832
- """
1833
-
1834
- type_: str = "GraphClassPropertyMultiOccurrence"
1835
- code: int = 204
1836
- description: str = (
1837
- "This warning occurs when there is multiple different occurrences of the same property "
1838
- " across various class instances"
1839
- )
1840
- example: str = ""
1841
- fix: str = "There"
1842
-
1843
- def __init__(self, class_name: str = "", property_name: str = "", verbose: bool = False):
1844
- self.message = (
1845
- f"Currently property '{property_name}' for class {class_name} has multi occurrences"
1846
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1847
- )
1848
- if verbose:
1849
- self.message += f"\nDescription: {self.description}"
1850
- self.message += f"\nExample: {self.example}"
1851
- self.message += f"\nFix: {self.fix}"
1852
-
1853
-
1854
- ################################################################################################
1855
- # RULES PARSERS: 300 - 399 #####################################################################
1856
- ################################################################################################
1857
- class SourceObjectDoesNotProduceMandatorySheets(NeatException):
1858
- """Given object (e.g., Excel file) does not produce one or more mandatory sheets
1859
-
1860
- Args:
1861
- missing_mandatory_sheets: set of missing mandatory sheets
1862
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1863
-
1864
- Notes:
1865
- This exception is raised when source object converted to is missing one or more mandatory sheets.
1866
- The mandatory sheets are: `Metadata`, `Classes`, `Properties`.
1867
- """
1868
-
1869
- type_: str = "SourceObjectDoesProduceMandatorySheets"
1870
- code: int = 300
1871
- description: str = "Given Excel file is missing one or more mandatory sheets"
1872
- example: str = "An Excel file is missing sheet named 'Metadata'"
1873
- fix: str = "Make sure that Excel file contains all mandatory sheets, i.e. 'Metadata', 'Classes', 'Properties'"
1874
-
1875
- def __init__(self, missing_mandatory_sheets: set[str], verbose: bool = False):
1876
- self.missing_fields = missing_mandatory_sheets
1877
-
1878
- self.message = (
1879
- "Given Excel file is not compliant Transformation Rules file."
1880
- f" It is missing mandatory sheets: {', '.join(missing_mandatory_sheets)}."
1881
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1882
- )
1883
-
1884
- if verbose:
1885
- self.message += f"\nDescription: {self.description}"
1886
- self.message += f"\nExample: {self.example}"
1887
- self.message += f"\nFix: {self.fix}"
1888
- super().__init__(self.message)
1889
-
1890
-
1891
- class UnableToDownloadExcelFile(NeatException):
1892
- """This error is raised during loading of byte representation of a Excel file from
1893
- Github, when given file cannot be downloaded.
1894
-
1895
- Args:
1896
- filepath: file path to Excel file that cannot be downloaded from Github
1897
- loc: URL of Excel file from Github repository
1898
- reason: reason why file cannot be downloaded (e.g., Forbidden, Not Found, etc.)
1899
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1900
-
1901
- Notes:
1902
- Make sure you provided correct parameters to download Excel file from github repository.
1903
- """
1904
-
1905
- type_: str = "UnableToDownloadExcelFile"
1906
- code: int = 301
1907
- description: str = (
1908
- "This error is raised during loading of byte representation of"
1909
- " a Excel file from Github when given file cannot be downloaded."
1910
- )
1911
- example: str = ""
1912
- fix: str = "Make sure you provided correct parameters to download Excel file from github repository"
1913
-
1914
- def __init__(self, filepath: str, loc: str, reason: str, verbose: bool = False):
1915
- self.message = (
1916
- f"File '{filepath}' from '{loc}' cannot be downloaded! Reason: {reason}"
1917
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1918
- )
1919
-
1920
- if verbose:
1921
- self.message += f"\nDescription: {self.description}"
1922
- self.message += f"\nExample: {self.example}"
1923
- self.message += f"\nFix: {self.fix}"
1924
- super().__init__(self.message)
1925
-
1926
-
1927
- class NotExcelFile(NeatException):
1928
- """This error is raised during loading of byte representation of a file from Github
1929
- into `openpyxl` `Workbook` object in case when byte representation is not Excel file.
1930
-
1931
- Args:
1932
- filepath: file path to Excel file that cannot be downloaded from Github
1933
- loc: URL of Excel file from Github repository
1934
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1935
-
1936
- Notes:
1937
- Make sure you that byte representation of a file is Excel file.
1938
- """
1939
-
1940
- type_: str = "NotExcelFile"
1941
- code: int = 302
1942
- description: str = (
1943
- "This error is raised during loading of byte representation of a file from Github"
1944
- " into `openpyxl` `Workbook` object in case when byte representation is not Excel file."
1945
- )
1946
- example: str = ""
1947
- fix: str = "Make sure you that byte representation of a file is Excel file!"
1948
-
1949
- def __init__(self, filepath: str, loc: str, verbose: bool = False):
1950
- self.message = (
1951
- f"File '{filepath}' from '{loc}' is not a valid excel file!"
1952
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1953
- )
1954
-
1955
- if verbose:
1956
- self.message += f"\nDescription: {self.description}"
1957
- self.message += f"\nExample: {self.example}"
1958
- self.message += f"\nFix: {self.fix}"
1959
- super().__init__(self.message)
1960
-
1961
-
1962
- class MetadataSheetMissingMandatoryFields(NeatException):
1963
- """Metadata sheet, which is part of Transformation Rules Excel file, is missing
1964
- mandatory rows (i.e., fields)
1965
-
1966
- Args:
1967
- missing_fields: Fields/rows that are missing in Metadata sheet
1968
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1969
- """
1970
-
1971
- type_: str = "MetadataSheetMissingMandatoryFields"
1972
- code: int = 303
1973
- description: str = "Metadata sheet, which is part of Transformation Rules Excel file, is missing mandatory rows"
1974
- example: str = ""
1975
- fix: str = ""
1976
-
1977
- def __init__(self, missing_fields: set[str], verbose: bool = False):
1978
- self.missing_fields = missing_fields
1979
-
1980
- self.message = (
1981
- f"Metadata sheet is missing following mandatory fields: {', '.join(missing_fields)}"
1982
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
1983
- )
1984
-
1985
- if verbose:
1986
- self.message += f"\nDescription: {self.description}"
1987
- self.message += f"\nExample: {self.example}"
1988
- self.message += f"\nFix: {self.fix}"
1989
- super().__init__(self.message)
1990
-
1991
-
1992
- class ClassesSheetMissingMandatoryColumns(NeatException):
1993
- """Classes sheet, which is a mandatory part of Transformation Rules Excel file, is
1994
- missing mandatory columns at row 2
1995
-
1996
- Args:
1997
- missing_fields: Fields/columns that are missing in Classes sheet
1998
- verbose: flag that indicates whether to provide enhanced exception message, by default False
1999
- """
2000
-
2001
- type_: str = "ClassesSheetMissingMandatoryColumns"
2002
- code: int = 304
2003
- description: str = (
2004
- "Classes sheet, which is a mandatory part of Transformation Rules Excel file, "
2005
- "is missing mandatory columns at row 2"
2006
- )
2007
- example: str = ""
2008
- fix: str = ""
2009
-
2010
- def __init__(self, missing_fields: set[str], verbose: bool = False):
2011
- self.missing_fields = missing_fields
2012
-
2013
- self.message = (
2014
- f"Classes sheet is missing following mandatory columns: {', '.join(missing_fields)} at row 2"
2015
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2016
- )
2017
-
2018
- if verbose:
2019
- self.message += f"\nDescription: {self.description}"
2020
- self.message += f"\nExample: {self.example}"
2021
- self.message += f"\nFix: {self.fix}"
2022
- super().__init__(self.message)
2023
-
2024
-
2025
- class PropertiesSheetMissingMandatoryColumns(NeatException):
2026
- """Properties sheet, which is a mandatory part of Transformation Rules Excel file, is
2027
- missing mandatory columns at row 2
2028
-
2029
- Args:
2030
- missing_fields: Fields/columns that are missing in Properties sheet
2031
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2032
- """
2033
-
2034
- type_: str = "PropertiesSheetMissingMandatoryColumns"
2035
- code: int = 305
2036
- description: str = (
2037
- "Properties sheet, which is a mandatory part of Transformation Rules Excel file, "
2038
- "is missing mandatory columns at row 2"
2039
- )
2040
- example: str = ""
2041
- fix: str = ""
2042
-
2043
- def __init__(self, missing_fields: set[str], verbose: bool = False):
2044
- self.missing_fields = missing_fields
2045
-
2046
- self.message = (
2047
- f"Properties sheet is missing following mandatory columns: {', '.join(missing_fields)} at row 2"
2048
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2049
- )
2050
-
2051
- if verbose:
2052
- self.message += f"\nDescription: {self.description}"
2053
- self.message += f"\nExample: {self.example}"
2054
- self.message += f"\nFix: {self.fix}"
2055
- super().__init__(self.message)
2056
-
2057
-
2058
- class PrefixesSheetMissingMandatoryColumns(NeatException):
2059
- """Prefixes sheet, which is part of Transformation Rules Excel file, is missing
2060
- mandatory columns at row 1
2061
-
2062
- Args:
2063
- missing_fields: Fields/columns that are missing in Prefixes sheet
2064
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2065
- """
2066
-
2067
- type_: str = "PrefixesSheetMissingMandatoryColumns"
2068
- code: int = 306
2069
- description: str = (
2070
- "Prefixes sheet, which is part of Transformation Rules Excel file, is missing mandatory columns at row 1"
2071
- )
2072
- example: str = ""
2073
- fix: str = ""
2074
-
2075
- def __init__(self, missing_fields: set[str], verbose: bool = False):
2076
- self.missing_fields = missing_fields
2077
-
2078
- self.message = (
2079
- f"Prefixes sheet is missing following mandatory columns: {', '.join(missing_fields)} at row 1"
2080
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2081
- )
2082
-
2083
- if verbose:
2084
- self.message += f"\nDescription: {self.description}"
2085
- self.message += f"\nExample: {self.example}"
2086
- self.message += f"\nFix: {self.fix}"
2087
- super().__init__(self.message)
2088
-
2089
-
2090
- class InstancesSheetMissingMandatoryColumns(NeatException):
2091
- """Instances sheet, which is part of Transformation Rules Excel file, is missing
2092
- mandatory columns at row 1
2093
-
2094
- Args:
2095
- missing_fields: Fields/columns that are missing in Instances sheet
2096
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2097
- """
2098
-
2099
- type_: str = "InstancesSheetMissingMandatoryColumns"
2100
- code: int = 307
2101
- description: str = (
2102
- "Instances sheet, which is part of Transformation Rules Excel file, is missing mandatory columns at row 1"
2103
- )
2104
- example: str = ""
2105
- fix: str = ""
2106
-
2107
- def __init__(self, missing_fields: set[str], verbose: bool = False):
2108
- self.missing_fields = missing_fields
2109
-
2110
- self.message = (
2111
- f"Instances sheet is missing following mandatory columns: {', '.join(missing_fields)} at row 1"
2112
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2113
- )
2114
-
2115
- if verbose:
2116
- self.message += f"\nDescription: {self.description}"
2117
- self.message += f"\nExample: {self.example}"
2118
- self.message += f"\nFix: {self.fix}"
2119
- super().__init__(self.message)
2120
-
2121
-
2122
- # Warnings
2123
- class MissingDataModelPrefixOrNamespace(NeatWarning):
2124
- """Prefix and/or namespace are missing in the 'Metadata' sheet
2125
-
2126
- Args:
2127
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2128
-
2129
- Notes:
2130
- Add missing prefix and/or namespace in the 'Metadata' sheet
2131
- """
2132
-
2133
- type_: str = "MissingDataModelPrefixOrNamespace"
2134
- code: int = 300
2135
- description: str = "Either prefix or namespace or both are missing in the 'Metadata' sheet"
2136
- example: str = ""
2137
- fix: str = "Add missing prefix and/or namespace in the 'Metadata' sheet"
2138
-
2139
- def __init__(self, verbose: bool = False):
2140
- self.message = (
2141
- "Instances sheet is present but prefix and/or namespace are missing in 'Metadata' sheet."
2142
- "Instances sheet will not be processed!"
2143
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2144
- )
2145
- if verbose:
2146
- self.message += f"\nDescription: {self.description}"
2147
- self.message += f"\nExample: {self.example}"
2148
- self.message += f"\nFix: {self.fix}"
2149
- # hint on a specific web docs page
2150
-
2151
-
2152
- ################################################################################################
2153
- # RULES EXPORTERS 400-499#######################################################################
2154
- ################################################################################################
2155
-
2156
-
2157
- class EntitiesContainNonDMSCompliantCharacters(NeatException):
2158
- """This error is raised during export of Transformation Rules to DMS schema when
2159
- entities (e.g., types and fields) ids contain non DMS compliant characters.
2160
-
2161
- Args:
2162
- report: report of entities that contain non DMS compliant characters
2163
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2164
-
2165
- Notes:
2166
- Make sure to check validation report of Transformation Rules and fix DMS related exceptions.
2167
- """
2168
-
2169
- type_: str = "EntitiesContainNonDMSCompliantCharacters"
2170
- code: int = 400
2171
- description: str = (
2172
- "This error is raised during export of Transformation Rules to"
2173
- " DMS schema when entities contain non DMS compliant characters."
2174
- )
2175
- example: str = ""
2176
- fix: str = "Make sure to check validation report of Transformation Rules and fix DMS related exceptions."
2177
-
2178
- def __init__(self, report: str = "", verbose: bool = False):
2179
- self.message = (
2180
- f"Following entities contain non DMS compliant characters: {report}"
2181
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2182
- )
2183
-
2184
- if verbose:
2185
- self.message += f"\nDescription: {self.description}"
2186
- self.message += f"\nExample: {self.example}"
2187
- self.message += f"\nFix: {self.fix}"
2188
- super().__init__(self.message)
2189
-
2190
-
2191
- class PropertiesDefinedMultipleTimes(NeatException):
2192
- """This error is raised during export of Transformation Rules to DMS schema when
2193
- when properties are defined multiple times for the same class.
2194
-
2195
- Args:
2196
- report: report on properties which are defined multiple times
2197
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2198
-
2199
- Notes:
2200
- Make sure to check validation report of Transformation Rules and fix DMS related warnings.
2201
- """
2202
-
2203
- type_: str = "PropertiesDefinedMultipleTimes"
2204
- code: int = 401
2205
- description: str = (
2206
- "This error is raised during export of Transformation Rules to "
2207
- "DMS schema when properties are defined multiple times for the same class."
2208
- )
2209
- example: str = ""
2210
- fix: str = "Make sure to check validation report of Transformation Rules and fix DMS related warnings."
2211
-
2212
- def __init__(self, report: str = "", verbose: bool = False):
2213
- self.message = (
2214
- f"Following properties defined multiple times for the same class(es): {report}"
2215
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2216
- )
2217
-
2218
- if verbose:
2219
- self.message += f"\nDescription: {self.description}"
2220
- self.message += f"\nExample: {self.example}"
2221
- self.message += f"\nFix: {self.fix}"
2222
- super().__init__(self.message)
2223
-
2224
-
2225
- class PropertyDefinitionsNotForSameProperty(NeatException):
2226
- """This error is raised if property definitions are not for linked to the same
2227
- property id when exporting rules to ontological representation.
2228
-
2229
- Args:
2230
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2231
- """
2232
-
2233
- type_: str = "PropertyDefinitionsNotForSameProperty"
2234
- code: int = 402
2235
- description: str = "This error is raised if property definitions are not for linked to the same property id"
2236
- example: str = ""
2237
- fix: str = ""
2238
-
2239
- def __init__(self, verbose: bool = False):
2240
- self.message = (
2241
- "All definitions should have the same property_id! Aborting."
2242
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2243
- )
2244
-
2245
- if verbose:
2246
- self.message += f"\nDescription: {self.description}"
2247
- self.message += f"\nExample: {self.example}"
2248
- self.message += f"\nFix: {self.fix}"
2249
- super().__init__(self.message)
2250
-
2251
-
2252
- class FieldValueOfUnknownType(NeatException):
2253
- """This error is raised when generating in-memory pydantic model from Transformation
2254
- Rules from model, when field definitions are not provided as dictionary of field names
2255
- ('str') and their types ('tuple' or 'dict').
2256
-
2257
- Args:
2258
- field: field name that raised exception due to unknown type
2259
- definition: definition of field that raised exception
2260
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2261
- """
2262
-
2263
- type_: str = "FieldValueOfUnknownType"
2264
- code: int = 403
2265
- description: str = (
2266
- "This error is raised when generating in-memory pydantic model"
2267
- " from Transformation Rules from model, when field definitions are not"
2268
- " provided as dictionary of field names ('str') and their types ('tuple' or 'dict')."
2269
- )
2270
- example: str = ""
2271
- fix: str = ""
2272
-
2273
- def __init__(self, field: str, definition: Any, verbose: bool = False):
2274
- self.message = (
2275
- f"Field {field} has definition of type {type(definition)}"
2276
- " which is not acceptable! Only definition in form of dict or tuple is acceptable!"
2277
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2278
- )
2279
-
2280
- if verbose:
2281
- self.message += f"\nDescription: {self.description}"
2282
- self.message += f"\nExample: {self.example}"
2283
- self.message += f"\nFix: {self.fix}"
2284
- super().__init__(self.message)
2285
-
2286
-
2287
- class MissingInstanceTriples(NeatException):
2288
- """This error is raised when queried RDF class instance does not return any triples that define it.
2289
-
2290
- Args:
2291
- id_: instance id
2292
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2293
- """
2294
-
2295
- type_: str = "MissingInstanceTriples"
2296
- code: int = 404
2297
- description: str = (
2298
- "This error is raised when queried RDF class instance " " does not return any triples that define it."
2299
- )
2300
- example: str = ""
2301
- fix: str = "Make sure that RDF class instance holds necessary triples that define it."
2302
-
2303
- def __init__(self, id_: str | URIRef, verbose: bool = False):
2304
- self.message = (
2305
- f"Instance {id_} does not contain triples that would define it!"
2306
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2307
- )
2308
-
2309
- if verbose:
2310
- self.message += f"\nDescription: {self.description}"
2311
- self.message += f"\nExample: {self.example}"
2312
- self.message += f"\nFix: {self.fix}"
2313
- super().__init__(self.message)
2314
-
2315
-
2316
- class PropertyRequiredButNotProvided(NeatException):
2317
- """This error is raised when instantiating in-memory pydantic model from graph class
2318
- instance which is missing required property.
2319
-
2320
- Args:
2321
- id_: instance id
2322
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2323
- """
2324
-
2325
- type_: str = "PropertyRequiredButNotProvided"
2326
- code: int = 405
2327
- description: str = (
2328
- "This error is raised when instantiating in-memory pydantic model"
2329
- " from graph class instance which is missing required property."
2330
- )
2331
- example: str = ""
2332
- fix: str = "Either make field optional or add missing property to graph instance."
2333
-
2334
- def __init__(self, property: str, id_: str | URIRef, verbose: bool = False):
2335
- self.message = (
2336
- f"Property {property} is not present in graph instance {id_}!"
2337
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2338
- )
2339
-
2340
- if verbose:
2341
- self.message += f"\nDescription: {self.description}"
2342
- self.message += f"\nExample: {self.example}"
2343
- self.message += f"\nFix: {self.fix}"
2344
- super().__init__(self.message)
2345
-
2346
-
2347
- class DataModelOrItsComponentsAlreadyExist(NeatException):
2348
- """This error is raised when attempting to create data model which already exist in DMS
2349
-
2350
- Args:
2351
- existing_data_model: external_id of model that already exist in DMS
2352
- existing_containers: set of external_ids of containers that already exist in DMS
2353
- existing_views: set of external_ids of views that already exist in DMS
2354
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2355
-
2356
- Notes:
2357
- Remove existing data model and underlying views and/or containers, or bump
2358
- version of data model and views and/ir optionally delete containers.
2359
- """
2360
-
2361
- type_: str = "DataModelOrItsComponentsAlreadyExist"
2362
- code: int = 406
2363
- description: str = "This error is raised when attempting to create data model which already exist in DMS."
2364
- example: str = ""
2365
- fix: str = (
2366
- "Remove existing data model and underlying views and/or containers, or bump "
2367
- "version of data model and views and optionally delete containers."
2368
- )
2369
-
2370
- def __init__(
2371
- self,
2372
- existing_spaces: set[str] | None,
2373
- existing_data_model: DataModelId | None,
2374
- existing_containers: set[str],
2375
- existing_views: set[str],
2376
- verbose: bool = False,
2377
- ):
2378
- self.existing_spaces = existing_spaces
2379
- self.existing_data_model = existing_data_model
2380
- self.existing_containers = existing_containers
2381
- self.existing_views = existing_views
2382
-
2383
- self.message = "Aborting data model creation!"
2384
- if self.existing_spaces:
2385
- self.message += (
2386
- f"\nSpaces {self.existing_spaces} already exists in DMS! Delete them or skip their creation! "
2387
- )
2388
- if self.existing_data_model:
2389
- self.message += (
2390
- f"\nData model {self.existing_data_model} already exists in DMS! Delete it first or bump its version! "
2391
- )
2392
- if self.existing_views:
2393
- self.message += (
2394
- f"\nViews {self.existing_views} already exist in DMS! Delete them first or bump their versions! "
2395
- )
2396
- if self.existing_containers:
2397
- self.message += f"\nContainers {self.existing_containers} already exist in DMS! Delete them first! "
2398
-
2399
- self.message += (
2400
- "\nTo remove existing data model and its components, use `self.remove_data_model(client)` method."
2401
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2402
- )
2403
-
2404
- if verbose:
2405
- self.message += f"\nDescription: {self.description}"
2406
- self.message += f"\nExample: {self.example}"
2407
- self.message += f"\nFix: {self.fix}"
2408
- super().__init__(self.message)
2409
-
2410
-
2411
- class InstancePropertiesNotMatchingViewProperties(NeatException):
2412
- """This error is raised when an instance of a class has properties which are not
2413
- defined in the DMS container
2414
-
2415
- Args:
2416
- class_name: class name of instance that raised exception
2417
- class_properties: list of mandatory properties of class
2418
- container_properties: list of properties of container
2419
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2420
-
2421
- Notes:
2422
- Make sure that all properties of a class are defined in the DMS container.
2423
- """
2424
-
2425
- type_: str = "InstancePropertiesNotMatchingViewProperties"
2426
- code: int = 407
2427
- description: str = "Instance of a class has properties which are not defined in the DMS view"
2428
- example: str = ""
2429
- fix: str = "Make sure that all properties of a class are defined in the DMS view"
2430
-
2431
- def __init__(self, class_name: str, class_properties: list[str], view_properties: list[str], verbose: bool = False):
2432
- self.message = (
2433
- f"Instance of class {class_name} has properties {class_properties}"
2434
- f" while DMS view {class_name} has properties {view_properties}!"
2435
- f" Cannot create instance in DMS as properties do not match!"
2436
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2437
- )
2438
-
2439
- if verbose:
2440
- self.message += f"\nDescription: {self.description}"
2441
- self.message += f"\nExample: {self.example}"
2442
- self.message += f"\nFix: {self.fix}"
2443
- super().__init__(self.message)
2444
-
2445
-
2446
- class ContainerPropertyValueTypeRedefinition(NeatException):
2447
- """This error is raised when building up container where a property being redefined
2448
- with different value type
2449
-
2450
- Args:
2451
- container_id: container id that raised exception
2452
- property_id: container property id that raised exception
2453
- value_type: value type of container property that raised exception
2454
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2455
-
2456
- Notes:
2457
- Make sure that when redefining property in container, value type is the same
2458
- """
2459
-
2460
- type_: str = "ContainerPropertyValueTypeRedefinition"
2461
- code: int = 408
2462
- description: str = "Container property value type is being redefined"
2463
- example: str = ""
2464
- fix: str = "Make sure that when redefining property in container, value type remains the same"
2465
-
2466
- def __init__(
2467
- self,
2468
- container_id: str,
2469
- property_id: str,
2470
- current_value_type: str,
2471
- redefined_value_type: str,
2472
- loc: str,
2473
- verbose: bool = False,
2474
- ):
2475
- self.message = (
2476
- f"Container {container_id} property {property_id}"
2477
- f" value type {current_value_type} redefined to {redefined_value_type}!"
2478
- f"{loc}"
2479
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2480
- )
2481
-
2482
- if verbose:
2483
- self.message += f"\nDescription: {self.description}"
2484
- self.message += f"\nExample: {self.example}"
2485
- self.message += f"\nFix: {self.fix}"
2486
- super().__init__(self.message)
2487
-
2488
-
2489
- class ViewPropertyRedefinition(NeatException):
2490
- """This error is raised when building up views where a property being redefined differently
2491
-
2492
- Args:
2493
- view_id: view id that raised exception
2494
- property_id: view property id that raised exception
2495
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2496
-
2497
- Notes:
2498
- Avoid redefining property in the same view
2499
- """
2500
-
2501
- type_: str = "ViewPropertyRedefinition"
2502
- code: int = 409
2503
- description: str = "View property is being redefined in the same view but differently"
2504
- example: str = ""
2505
- fix: str = "Avoid redefining property in the same view"
2506
-
2507
- def __init__(
2508
- self,
2509
- view_id: str,
2510
- property_id: str,
2511
- loc: str,
2512
- verbose: bool = False,
2513
- ):
2514
- self.message = (
2515
- f"View {view_id} property {property_id} has been redefined in the same view!"
2516
- f"{loc}"
2517
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2518
- )
2519
-
2520
- if verbose:
2521
- self.message += f"\nDescription: {self.description}"
2522
- self.message += f"\nExample: {self.example}"
2523
- self.message += f"\nFix: {self.fix}"
2524
- super().__init__(self.message)
2525
-
2526
-
2527
- # Warnings
2528
- class OntologyMultiTypeProperty(NeatWarning):
2529
- """This warning occurs when a same property is define for two object/classes where
2530
- its expected value type is different in one definition, e.g. acts as an edge, while in
2531
- other definition acts as and attribute
2532
-
2533
- Args:
2534
- property_id: property id that raised warning due to multi type definition
2535
- types: list of types of property
2536
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2537
-
2538
- Notes:
2539
- If a property takes different value types for different objects, simply define
2540
- new property. It is bad practice to have multi type property!
2541
- """
2542
-
2543
- type_: str = "OntologyMultiTypeProperty"
2544
- code: int = 400
2545
- description: str = (
2546
- "This warning occurs when a same property is define for two object/classes where"
2547
- " its expected value type is different in one definition, e.g. acts as an edge, while in "
2548
- "other definition acts as and attribute"
2549
- )
2550
- example: str = ""
2551
- fix: str = "If a property takes different value types for different objects, simply define new property"
2552
-
2553
- def __init__(self, property_id: str = "", types: list[str] | None = None, verbose: bool = False):
2554
- self.message = (
2555
- "It is bad practice to have multi type property! "
2556
- f"Currently property '{property_id}' is defined as multi type property: {', '.join(types or [])}"
2557
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2558
- )
2559
- if verbose:
2560
- self.message += f"\nDescription: {self.description}"
2561
- self.message += f"\nExample: {self.example}"
2562
- self.message += f"\nFix: {self.fix}"
2563
-
2564
-
2565
- class OntologyMultiRangeProperty(NeatWarning):
2566
- """This warning occurs when a property takes range of values which consists of union
2567
- of multiple value types
2568
-
2569
- Args:
2570
- property_id: property id that raised warning due to multi range definition
2571
- range_of_values: list of ranges that property takes
2572
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2573
-
2574
- Notes:
2575
- If a property takes different range of values, simply define new property.
2576
- """
2577
-
2578
- type_: str = "OntologyMultiRangeProperty"
2579
- code: int = 401
2580
- description: str = (
2581
- "This warning occurs when a property takes range of values which consists of union of multiple value types."
2582
- )
2583
- example: str = ""
2584
- fix: str = "If a property takes different range of values, simply define new property"
2585
-
2586
- def __init__(self, property_id: str = "", range_of_values: list[str] | None = None, verbose: bool = False):
2587
- self.message = (
2588
- "It is bad practice to have property that take various range of values! "
2589
- f"Currently property '{property_id}' has multiple ranges: {', '.join(range_of_values or [])}"
2590
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2591
- )
2592
- if verbose:
2593
- self.message += f"\nDescription: {self.description}"
2594
- self.message += f"\nExample: {self.example}"
2595
- self.message += f"\nFix: {self.fix}"
2596
-
2597
-
2598
- class OntologyMultiDomainProperty(NeatWarning):
2599
- """This warning occurs when a property is reused for more than one classes
2600
-
2601
- Args:
2602
- property_id: property id that raised warning due to reuse definition
2603
- classes: list of classes that use the same property
2604
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2605
-
2606
- Notes:
2607
- No need to fix this, but make sure that property type is consistent across different
2608
- classes and that ideally takes the same range of values
2609
- """
2610
-
2611
- type_: str = "OntologyMultiDomainProperty"
2612
- code: int = 402
2613
- description: str = "This warning occurs when a property is reused for more than one classes."
2614
- example: str = ""
2615
- fix: str = (
2616
- "No need to fix this, but make sure that property type is consistent"
2617
- " across different classes and that ideally takes the same range of values"
2618
- )
2619
-
2620
- def __init__(self, property_id: str = "", classes: list[str] | None = None, verbose: bool = False):
2621
- self.message = (
2622
- f"Currently property '{property_id}' is defined for multiple classes: {', '.join(classes or [])}"
2623
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2624
- )
2625
- if verbose:
2626
- self.message += f"\nDescription: {self.description}"
2627
- self.message += f"\nExample: {self.example}"
2628
- self.message += f"\nFix: {self.fix}"
2629
-
2630
-
2631
- class OntologyMultiLabeledProperty(NeatWarning):
2632
- """This warning occurs when a property is given multiple labels, typically if the
2633
- same property is defined for different classes but different name is given
2634
-
2635
- Args:
2636
- property_id: property id that raised warning due to multiple labels
2637
- names: list of names of property
2638
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2639
-
2640
- Notes:
2641
- This would be automatically fixed by taking the first label (aka name) of the property.
2642
- """
2643
-
2644
- type_: str = "OntologyMultiLabeledProperty"
2645
- code: int = 403
2646
- description: str = (
2647
- "This warning occurs when a property is given multiple labels,"
2648
- " typically if the same property is defined for different "
2649
- "classes but different name is given."
2650
- )
2651
- example: str = ""
2652
- fix: str = "This would be automatically fixed by taking the first label (aka name) of the property."
2653
-
2654
- def __init__(self, property_id: str = "", names: list[str] | None = None, verbose: bool = False):
2655
- self.message = (
2656
- "Property should have single preferred label (human readable name)."
2657
- f"Currently property '{property_id}' has multiple preferred labels: {', '.join(names or [])} !"
2658
- f"Only the first name, i.e. '{names[0] if names else ''}' will be considered!"
2659
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2660
- )
2661
- if verbose:
2662
- self.message += f"\nDescription: {self.description}"
2663
- self.message += f"\nExample: {self.example}"
2664
- self.message += f"\nFix: {self.fix}"
2665
-
2666
-
2667
- class OntologyMultiDefinitionProperty(NeatWarning):
2668
- """This warning occurs when a property is given multiple human readable definitions,
2669
- typically if the same property is defined for different classes where each definition
2670
- is different.
2671
-
2672
- Args:
2673
- property_id: property id that raised warning due to multiple definitions
2674
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2675
-
2676
- Notes:
2677
- This would be automatically fixed by concatenating all definitions.
2678
- """
2679
-
2680
- type_: str = "OntologyMultiDefinitionProperty"
2681
- code: int = 404
2682
- description: str = (
2683
- "This warning occurs when a property is given multiple human readable definitions,"
2684
- " typically if the same property is defined for different "
2685
- "classes where each definition is different."
2686
- )
2687
- example: str = ""
2688
- fix: str = "This would be automatically fixed by concatenating all definitions."
2689
-
2690
- def __init__(self, property_id: str, verbose: bool = False):
2691
- self.message = (
2692
- f"Multiple definitions (aka comments) of property '{property_id}' detected."
2693
- " Definitions will be concatenated."
2694
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2695
- )
2696
- if verbose:
2697
- self.message += f"\nDescription: {self.description}"
2698
- self.message += f"\nExample: {self.example}"
2699
- self.message += f"\nFix: {self.fix}"
2700
-
2701
-
2702
- class FieldNotFoundInInstance(NeatWarning):
2703
- """This warning occurs when a property, associated to the pydantic field, is not found in the instance.
2704
- The missing field will be removed, which might lead to failure of the pydantic model validation if
2705
- the field/property is mandatory.
2706
-
2707
- Args:
2708
- id_: instance id that raised warning due to missing field
2709
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2710
-
2711
- Notes:
2712
- If property/field is mandatory make sure that instances contain all mandatory fields.
2713
- Otherwise, no need to fix this warning.
2714
- """
2715
-
2716
- type_: str = "FieldNotFoundInInstance"
2717
- code: int = 405
2718
- description: str = (
2719
- "This warning occurs when a property, associated to the pydantic field, is not found in the instance."
2720
- "The missing field will be removed, which might lead to failure of the pydantic model validation if"
2721
- " the field/property is mandatory."
2722
- )
2723
- example: str = ""
2724
- fix: str = (
2725
- "If property/field is mandatory make sure that instances contain all mandatory fields."
2726
- "Otherwise, no need to fix this warning."
2727
- )
2728
-
2729
- def __init__(self, id_: str | URIRef = "", field_name: str = "", verbose: bool = False):
2730
- self.message = (
2731
- f"Field {field_name} is missing in the instance {id_}."
2732
- " If this field is mandatory, the validation of the pydantic model will fail!"
2733
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2734
- )
2735
- if verbose:
2736
- self.message += f"\nDescription: {self.description}"
2737
- self.message += f"\nExample: {self.example}"
2738
- self.message += f"\nFix: {self.fix}"
2739
-
2740
-
2741
- class FieldContainsMoreThanOneValue(NeatWarning):
2742
- """This warning occurs when a property, associated to the pydantic field, contains
2743
- more than one value (i.e. list of values), while it is defined as single value field.
2744
- As consequence, only the first value will be considered!
2745
-
2746
- Args:
2747
- field_name: field name that raised warning due to multiple values
2748
- no_of_values: number of values that field contains
2749
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2750
-
2751
- Notes:
2752
- If a property takes more than one value, define it as list of values in TransformationRules.
2753
- To do this do not bound its `max_count` to 1, either leave it blank or set it to >1.
2754
- """
2755
-
2756
- type_: str = "FieldContainsMoreThanOneValue"
2757
- code: int = 406
2758
- description: str = (
2759
- "This warning occurs when a property, associated to the pydantic field, contains"
2760
- " more than one value (i.e. list of values), while it is defined as single value field."
2761
- " As consequence, only the first value will be considered!"
2762
- )
2763
- example: str = ""
2764
- fix: str = (
2765
- "If a property takes more than one value, define it as list of values in TransformationRules."
2766
- "To do this do not bound its `max_count` to 1, either leave it blank or set it to >1."
2767
- )
2768
-
2769
- def __init__(self, field_name: str = "", no_of_values: int | None = None, verbose: bool = False):
2770
- self.message = (
2771
- f"Field {field_name} is defined as single value property in TransformationRules,"
2772
- f" but it contains {no_of_values} values!"
2773
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2774
- )
2775
- if verbose:
2776
- self.message += f"\nDescription: {self.description}"
2777
- self.message += f"\nExample: {self.example}"
2778
- self.message += f"\nFix: {self.fix}"
2779
-
2780
-
2781
- class ContainerPropertyTypeUnsupported(NeatWarning):
2782
- """This warning occurs when a property type is not supported by the container.
2783
- Currently only `DatatypeProperty` and `ObjectProperty` are supported, which
2784
- translate to `attribute` and `edge` respectively.
2785
-
2786
- Args:
2787
- property_id: property id that raised warning due to unsupported type
2788
- unsupported_type: unsupported property type
2789
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2790
-
2791
- Notes:
2792
- Contact the NEAT support team if the warning is raised.
2793
- """
2794
-
2795
- type_: str = "ContainerPropertyTypeUnsupported"
2796
- code: int = 407
2797
- description: str = (
2798
- "This warning occurs when a property type is not supported by the container."
2799
- " Currently only `DatatypeProperty` and `ObjectProperty` are supported, which"
2800
- " translate to `attribute` and `edge` respectively."
2801
- )
2802
- example: str = ""
2803
- fix: str = "Contact NEAT support team."
2804
-
2805
- def __init__(self, property_id: str = "", unsupported_type: str = "", verbose: bool = False):
2806
- self.message = (
2807
- f"Property {property_id} has unsupported type {unsupported_type}!"
2808
- "Only DatatypeProperty and ObjectProperty are supported!"
2809
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2810
- )
2811
- if verbose:
2812
- self.message += f"\nDescription: {self.description}"
2813
- self.message += f"\nExample: {self.example}"
2814
- self.message += f"\nFix: {self.fix}"
2815
-
2816
-
2817
- class ViewPropertyTypeUnsupported(NeatWarning):
2818
- """This warning occurs when a TransformationRule property translates to unsupported
2819
- DMS view property. Currently only attributes, edges 1-1 and edges 1-n are supported.
2820
-
2821
- Args:
2822
- property_id: property id that raised warning due to unsupported type
2823
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2824
-
2825
- Notes:
2826
- Contact the NEAT support team if the warning is raised.
2827
- """
2828
-
2829
- type_: str = "ViewPropertyTypeUnsupported"
2830
- code: int = 408
2831
- description: str = (
2832
- "This warning occurs when a TransformationRule property translates to unsupported DMS view property."
2833
- " Currently only attributes, edges 1-1 and edges 1-n are supported."
2834
- )
2835
- example: str = ""
2836
- fix: str = "Contact NEAT support team."
2837
-
2838
- def __init__(self, property_id: str = "", verbose: bool = False):
2839
- self.message = (
2840
- f"Property {property_id} translates to unsupported!"
2841
- " Currently only attributes, edges 1-1 and edges 1-n are supported."
2842
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2843
- )
2844
- if verbose:
2845
- self.message += f"\nDescription: {self.description}"
2846
- self.message += f"\nExample: {self.example}"
2847
- self.message += f"\nFix: {self.fix}"
2848
-
2849
-
2850
- class ContainersAlreadyExist(NeatWarning):
2851
- """This warning occurs when attempting to create containers which already exist in DMS.
2852
-
2853
- Args:
2854
- container_ids: set of container ids that already exist in DMS
2855
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2856
-
2857
- Notes:
2858
- If you need to create containers remove existing once and try again.
2859
- """
2860
-
2861
- type_: str = "ContainersAlreadyExist"
2862
- code: int = 409
2863
- description: str = "This warning occurs when attempting to create containers which already exist in DMS."
2864
- example: str = ""
2865
- fix: str = "Remove existing containers and try again."
2866
-
2867
- def __init__(self, container_ids: set[ContainerId] | None = None, space: str = "", verbose: bool = False):
2868
- self.message = (
2869
- f"Containers {container_ids or set()} already exist in space {space}. "
2870
- "Since update of containers can cause issues, "
2871
- "remove them first prior data model creation!"
2872
- "Aborting containers creation!"
2873
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2874
- )
2875
-
2876
- if verbose:
2877
- self.message += f"\nDescription: {self.description}"
2878
- self.message += f"\nExample: {self.example}"
2879
- self.message += f"\nFix: {self.fix}"
2880
-
2881
-
2882
- class ViewsAlreadyExist(NeatWarning):
2883
- """This warning occurs when attempting to create views which already exist in DMS.
2884
-
2885
- Args:
2886
- views_ids: set of view ids that already exist in DMS
2887
- version: version of data model/views that already exist in DMS
2888
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2889
-
2890
- Notes:
2891
- If you need to create views remove existing once and try again or update
2892
- data model version.
2893
- """
2894
-
2895
- type_: str = "ViewsAlreadyExist"
2896
- code: int = 410
2897
- description: str = "This warning occurs when attempting to create views which already exist in DMS."
2898
- example: str = ""
2899
- fix: str = "Remove existing views and try again or update version of data model."
2900
-
2901
- def __init__(self, views_ids: set[ViewId] | None = None, version: str = "", space: str = "", verbose: bool = False):
2902
- self.message = (
2903
- f"Views {views_ids or set()} version {version} already exist in space {space}. "
2904
- "Since update of views raise issues, "
2905
- "remove them first prior data model creation or update version of data model!"
2906
- "Aborting views creation!"
2907
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2908
- )
2909
-
2910
- if verbose:
2911
- self.message += f"\nDescription: {self.description}"
2912
- self.message += f"\nExample: {self.example}"
2913
- self.message += f"\nFix: {self.fix}"
2914
-
2915
-
2916
- class DataModelAlreadyExist(NeatWarning):
2917
- """This warning occurs when attempting to create data model which already exist in DMS.
2918
-
2919
- Args:
2920
- data_model_id: data model id that already exist in DMS
2921
- version: version of data model that already exist in DMS
2922
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2923
-
2924
- Notes:
2925
- Remove existing data model and try again or update its version
2926
- """
2927
-
2928
- type_: str = "DataModelAlreadyExist"
2929
- code: int = 411
2930
- description: str = "This warning occurs when attempting to create data model which already exist in DMS."
2931
- example: str = ""
2932
- fix: str = "Remove existing data model and try again or update its version."
2933
-
2934
- def __init__(self, data_model_id: str = "", version: str = "", space: str = "", verbose: bool = False):
2935
- self.message = (
2936
- f"Data model {data_model_id} version {version} already exist in space {space}. "
2937
- "Since update of data model can raise issues, "
2938
- "remove it first or update its version!"
2939
- "Aborting data model creation!"
2940
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2941
- )
2942
-
2943
- if verbose:
2944
- self.message += f"\nDescription: {self.description}"
2945
- self.message += f"\nExample: {self.example}"
2946
- self.message += f"\nFix: {self.fix}"
2947
-
2948
-
2949
- class EdgeConditionUnmet(NeatWarning):
2950
- """This warning occurs when attempting to create an edge but not all conditions are met.
2951
-
2952
- Args:
2953
- edge: data model id that already exist in DMS
2954
- verbose: flag that indicates whether to provide enhanced exception message, by default False
2955
- """
2956
-
2957
- type_: str = "EdgeConditionUnmet"
2958
- code: int = 412
2959
- description: str = "This warning occurs when attempting to create an edge, but the conditions are not met."
2960
- example: str = ""
2961
- fix: str = "Check if the edge is valid and that the lenght of the external_id is < 255"
2962
-
2963
- def __init__(self, edge: str, verbose: bool = False):
2964
- self.message = (
2965
- f"Ignoring edge {edge} as its format is not valid"
2966
- f"\nFor more information visit: {DOCS_BASE_URL}.{self.__class__.__name__}"
2967
- )
2968
-
2969
- if verbose:
2970
- self.message += f"\nDescription: {self.description}"
2971
- self.message += f"\nExample: {self.example}"
2972
- self.message += f"\nFix: {self.fix}"