cognite-neat 0.88.2__py3-none-any.whl → 0.88.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/graph/__init__.py +0 -3
  3. cognite/neat/graph/loaders/_base.py +3 -3
  4. cognite/neat/graph/loaders/_rdf2asset.py +24 -25
  5. cognite/neat/graph/loaders/_rdf2dms.py +20 -15
  6. cognite/neat/issues/__init__.py +1 -3
  7. cognite/neat/issues/_base.py +259 -70
  8. cognite/neat/issues/errors/__init__.py +72 -0
  9. cognite/neat/issues/errors/_external.py +67 -0
  10. cognite/neat/issues/errors/_general.py +28 -0
  11. cognite/neat/issues/errors/_properties.py +62 -0
  12. cognite/neat/issues/errors/_resources.py +111 -0
  13. cognite/neat/issues/errors/_workflow.py +36 -0
  14. cognite/neat/issues/formatters.py +1 -1
  15. cognite/neat/issues/warnings/__init__.py +66 -0
  16. cognite/neat/issues/warnings/_external.py +40 -0
  17. cognite/neat/issues/warnings/_general.py +29 -0
  18. cognite/neat/issues/warnings/_models.py +92 -0
  19. cognite/neat/issues/warnings/_properties.py +44 -0
  20. cognite/neat/issues/warnings/_resources.py +55 -0
  21. cognite/neat/issues/warnings/user_modeling.py +113 -0
  22. cognite/neat/rules/_shared.py +10 -2
  23. cognite/neat/rules/exporters/_base.py +6 -6
  24. cognite/neat/rules/exporters/_rules2dms.py +18 -11
  25. cognite/neat/rules/exporters/_rules2excel.py +4 -4
  26. cognite/neat/rules/exporters/_rules2ontology.py +74 -51
  27. cognite/neat/rules/exporters/_rules2yaml.py +3 -3
  28. cognite/neat/rules/exporters/_validation.py +11 -96
  29. cognite/neat/rules/importers/_base.py +8 -12
  30. cognite/neat/rules/importers/_dms2rules.py +21 -24
  31. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +22 -17
  32. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +26 -19
  33. cognite/neat/rules/importers/_dtdl2rules/spec.py +7 -0
  34. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +1 -1
  35. cognite/neat/rules/importers/_rdf/_imf2rules/_imf2rules.py +9 -7
  36. cognite/neat/rules/importers/_rdf/_inference2rules.py +8 -8
  37. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +1 -0
  38. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +1 -0
  39. cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +4 -4
  40. cognite/neat/rules/importers/_rdf/_shared.py +3 -3
  41. cognite/neat/rules/importers/_spreadsheet2rules.py +35 -22
  42. cognite/neat/rules/importers/_yaml2rules.py +23 -22
  43. cognite/neat/rules/models/_constants.py +2 -1
  44. cognite/neat/rules/models/_rdfpath.py +4 -4
  45. cognite/neat/rules/models/_types/_field.py +5 -10
  46. cognite/neat/rules/models/asset/_rules.py +1 -3
  47. cognite/neat/rules/models/asset/_validation.py +13 -9
  48. cognite/neat/rules/models/dms/_converter.py +2 -4
  49. cognite/neat/rules/models/dms/_exporter.py +30 -8
  50. cognite/neat/rules/models/dms/_rules.py +23 -7
  51. cognite/neat/rules/models/dms/_schema.py +87 -78
  52. cognite/neat/rules/models/dms/_validation.py +104 -65
  53. cognite/neat/rules/models/information/_converter.py +2 -2
  54. cognite/neat/rules/models/information/_rules.py +7 -8
  55. cognite/neat/rules/models/information/_validation.py +47 -24
  56. cognite/neat/rules/transformers/_base.py +15 -0
  57. cognite/neat/utils/auxiliary.py +2 -35
  58. cognite/neat/utils/text.py +17 -0
  59. cognite/neat/workflows/base.py +4 -4
  60. cognite/neat/workflows/cdf_store.py +3 -3
  61. cognite/neat/workflows/steps/data_contracts.py +1 -1
  62. cognite/neat/workflows/steps/lib/current/graph_extractor.py +3 -3
  63. cognite/neat/workflows/steps/lib/current/graph_loader.py +2 -2
  64. cognite/neat/workflows/steps/lib/current/graph_store.py +1 -1
  65. cognite/neat/workflows/steps/lib/current/rules_exporter.py +10 -10
  66. cognite/neat/workflows/steps/lib/current/rules_importer.py +6 -6
  67. cognite/neat/workflows/steps/lib/current/rules_validator.py +5 -6
  68. cognite/neat/workflows/steps/lib/io/io_steps.py +5 -5
  69. cognite/neat/workflows/steps_registry.py +4 -5
  70. {cognite_neat-0.88.2.dist-info → cognite_neat-0.88.3.dist-info}/METADATA +1 -1
  71. {cognite_neat-0.88.2.dist-info → cognite_neat-0.88.3.dist-info}/RECORD +78 -84
  72. cognite/neat/exceptions.py +0 -145
  73. cognite/neat/graph/exceptions.py +0 -90
  74. cognite/neat/issues/errors/external.py +0 -21
  75. cognite/neat/issues/errors/properties.py +0 -75
  76. cognite/neat/issues/errors/resources.py +0 -123
  77. cognite/neat/issues/neat_warnings/__init__.py +0 -2
  78. cognite/neat/issues/neat_warnings/identifier.py +0 -27
  79. cognite/neat/issues/neat_warnings/models.py +0 -22
  80. cognite/neat/issues/neat_warnings/properties.py +0 -77
  81. cognite/neat/issues/neat_warnings/resources.py +0 -125
  82. cognite/neat/rules/issues/__init__.py +0 -22
  83. cognite/neat/rules/issues/base.py +0 -63
  84. cognite/neat/rules/issues/dms.py +0 -549
  85. cognite/neat/rules/issues/fileread.py +0 -197
  86. cognite/neat/rules/issues/ontology.py +0 -298
  87. cognite/neat/rules/issues/spreadsheet.py +0 -563
  88. cognite/neat/rules/issues/spreadsheet_file.py +0 -151
  89. cognite/neat/rules/issues/tables.py +0 -72
  90. cognite/neat/workflows/_exceptions.py +0 -41
  91. /cognite/neat/{issues/errors/schema.py → rules/transformers/__init__.py} +0 -0
  92. /cognite/neat/{graph/stores → store}/__init__.py +0 -0
  93. /cognite/neat/{graph/stores → store}/_base.py +0 -0
  94. /cognite/neat/{graph/stores → store}/_provenance.py +0 -0
  95. {cognite_neat-0.88.2.dist-info → cognite_neat-0.88.3.dist-info}/LICENSE +0 -0
  96. {cognite_neat-0.88.2.dist-info → cognite_neat-0.88.3.dist-info}/WHEEL +0 -0
  97. {cognite_neat-0.88.2.dist-info → cognite_neat-0.88.3.dist-info}/entry_points.txt +0 -0
@@ -1,123 +0,0 @@
1
- from collections.abc import Hashable
2
- from dataclasses import dataclass
3
- from typing import Any, Generic, TypeVar
4
-
5
- from cognite.neat.issues import NeatError
6
-
7
- T_Identifier = TypeVar("T_Identifier", bound=Hashable)
8
-
9
-
10
- @dataclass(frozen=True)
11
- class ResourceError(NeatError, Generic[T_Identifier]):
12
- """Base class for resource errors"""
13
-
14
- identifier: T_Identifier
15
- resource_type: str
16
-
17
-
18
- @dataclass(frozen=True)
19
- class ResourceNotFoundError(ResourceError[T_Identifier]):
20
- """The {resource_type} with identifier {identifier} is missing: {reason}"""
21
-
22
- fix = "Check the {resource_type} {identifier} and try again."
23
- reason: str
24
-
25
- def message(self) -> str:
26
- return (self.__doc__ or "").format(
27
- resource_type=self.resource_type, identifier=repr(self.identifier), reason=self.reason
28
- )
29
-
30
- def dump(self) -> dict[str, Any]:
31
- output = super().dump()
32
- output["resource_type"] = self.resource_type
33
- output["identifier"] = self.identifier
34
- output["reason"] = self.reason
35
- return output
36
-
37
-
38
- T_ReferenceIdentifier = TypeVar("T_ReferenceIdentifier", bound=Hashable)
39
-
40
-
41
- @dataclass(frozen=True)
42
- class ReferredResourceNotFoundError(ResourceError, Generic[T_Identifier, T_ReferenceIdentifier]):
43
- """The {resource_type} with identifier {identifier} referred by {referred_type} {referred_by} does not exist"""
44
-
45
- fix = "Create the {resource_type}"
46
-
47
- referred_by: T_ReferenceIdentifier
48
- referred_type: str
49
-
50
- def message(self) -> str:
51
- return (self.__doc__ or "").format(
52
- resource_type=self.resource_type,
53
- identifier=repr(self.identifier),
54
- referred_type=self.referred_type,
55
- referred_by=repr(self.referred_by),
56
- )
57
-
58
- def dump(self) -> dict[str, Any]:
59
- output = super().dump()
60
- output["resource_type"] = self.resource_type
61
- output["identifier"] = self.identifier
62
- output["referred_by"] = self.referred_by
63
- output["referred_type"] = self.referred_type
64
- return output
65
-
66
-
67
- @dataclass(frozen=True)
68
- class FailedConvertError(NeatError):
69
- description = "Failed to convert the {identifier} to {target_format}: {reason}"
70
- fix = "Check the error message and correct the rules."
71
- identifier: str
72
- target_format: str
73
- reason: str
74
-
75
- def message(self) -> str:
76
- return self.description.format(identifier=self.identifier, target_format=self.target_format, reason=self.reason)
77
-
78
- def dump(self) -> dict[str, Any]:
79
- output = super().dump()
80
- output["identifier"] = self.identifier
81
- output["targetFormat"] = self.target_format
82
- output["reason"] = self.reason
83
- return output
84
-
85
-
86
- @dataclass(frozen=True)
87
- class InvalidResourceError(NeatError):
88
- """The {resource_type} with identifier {identifier} is invalid and will be skipped. {reason}"""
89
-
90
- fix = "Check the error message and correct the instance."
91
-
92
- resource_type: str
93
- identifier: str
94
- reason: str
95
-
96
- def message(self) -> str:
97
- return (self.__doc__ or "").format(
98
- resource_type=self.resource_type, identifier=self.identifier, reason=self.reason
99
- )
100
-
101
- def dump(self) -> dict[str, Any]:
102
- output = super().dump()
103
- output["type"] = self.resource_type
104
- output["identifier"] = self.identifier
105
- output["reason"] = self.reason
106
- return output
107
-
108
-
109
- @dataclass(frozen=True)
110
- class MissingIdentifierError(NeatError):
111
- """The {resource_type} with name {name} is missing an identifier."""
112
-
113
- resource_type: str
114
- name: str | None = None
115
-
116
- def message(self) -> str:
117
- return (self.__doc__ or "").format(resource_type=self.resource_type, name=self.name or "unknown")
118
-
119
- def dump(self) -> dict[str, Any]:
120
- output = super().dump()
121
- output["type"] = self.resource_type
122
- output["name"] = self.name
123
- return output
@@ -1,2 +0,0 @@
1
- """All warnings raised by the neat package are defined here. Note this module is called 'neat_warnings' instead
2
- of 'warnings' to avoid conflicts with the built-in Python warnings module."""
@@ -1,27 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Any
3
-
4
- from cognite.neat.issues import NeatWarning
5
-
6
-
7
- @dataclass(frozen=True)
8
- class RegexViolationWarning(NeatWarning):
9
- """The value '{value}' of {identifier} does not match the {pattern_name} pattern '{pattern}'"""
10
-
11
- value: str
12
- pattern: str
13
- identifier: str
14
- pattern_name: str
15
-
16
- def message(self) -> str:
17
- return (self.__doc__ or "").format(
18
- value=self.value, pattern=self.pattern, identifier=self.identifier, pattern_name=self.pattern_name
19
- )
20
-
21
- def dump(self) -> dict[str, Any]:
22
- output = super().dump()
23
- output["value"] = self.value
24
- output["pattern"] = self.pattern
25
- output["identifier"] = self.identifier
26
- output["pattern_name"] = self.pattern_name
27
- return output
@@ -1,22 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Any
3
-
4
- from cognite.neat.issues import NeatWarning
5
-
6
-
7
- @dataclass(frozen=True)
8
- class InvalidClassWarning(NeatWarning):
9
- description = "The class {class_name} is invalid and will be skipped. {reason}"
10
- fix = "Check the error message and correct the class."
11
-
12
- class_name: str
13
- reason: str
14
-
15
- def message(self) -> str:
16
- return self.description.format(class_name=self.class_name, reason=self.reason)
17
-
18
- def dump(self) -> dict[str, Any]:
19
- output = super().dump()
20
- output["class_name"] = self.class_name
21
- output["reason"] = self.reason
22
- return output
@@ -1,77 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Any, Generic
3
-
4
- from .resources import ResourceWarning, T_Identifier, T_ReferenceIdentifier
5
-
6
-
7
- @dataclass(frozen=True)
8
- class PropertyTypeNotSupportedWarning(ResourceWarning[T_Identifier]):
9
- """The {resource_type} with identifier {identifier} has a property {property_name}
10
- of unsupported type {property_type}. This will be ignored."""
11
-
12
- property_name: str
13
- property_type: str
14
-
15
- def message(self) -> str:
16
- return (self.__doc__ or "").format(
17
- resource_type=self.resource_type,
18
- identifier=repr(self.identifier),
19
- property_name=self.property_name,
20
- property_type=self.property_type,
21
- )
22
-
23
- def dump(self) -> dict[str, Any]:
24
- output = super().dump()
25
- output["property_name"] = self.property_name
26
- output["property_type"] = self.property_type
27
- return output
28
-
29
-
30
- @dataclass(frozen=True)
31
- class ReferredPropertyNotFoundWarning(ResourceWarning, Generic[T_Identifier, T_ReferenceIdentifier]):
32
- """The {resource_type} with identifier {identifier} does not have a property {property_name} referred
33
- to by {referred_type} {referred_by} does not exist. This will be ignored.
34
- """
35
-
36
- fix = "Ensure the {resource_type} {identifier} has a {property_name} property"
37
-
38
- referred_by: T_ReferenceIdentifier
39
- referred_type: str
40
- property_name: str
41
-
42
- def message(self) -> str:
43
- return (self.__doc__ or "").format(
44
- resource_type=self.resource_type,
45
- identifier=repr(self.identifier),
46
- referred_type=self.referred_type,
47
- referred_by=repr(self.referred_by),
48
- property_name=self.property_name,
49
- )
50
-
51
- def dump(self) -> dict[str, Any]:
52
- output = super().dump()
53
- output["resource_type"] = self.resource_type
54
- output["identifier"] = self.identifier
55
- output["referred_by"] = self.referred_by
56
- output["referred_type"] = self.referred_type
57
- output["property_name"] = self.property_name
58
- return output
59
-
60
-
61
- @dataclass(frozen=True)
62
- class PropertyRedefinedWarning(ResourceWarning[T_Identifier]):
63
- """The {resource_type} with identifier {identifier} has a property {property_name} redefined."""
64
-
65
- property_id: str
66
-
67
- def message(self) -> str:
68
- return (self.__doc__ or "").format(
69
- resource_type=self.resource_type, identifier=repr(self.identifier), property_name=self.property_id
70
- )
71
-
72
- def dump(self) -> dict[str, Any]:
73
- output = super().dump()
74
- output["property_id"] = self.property_id
75
- output["resource_type"] = self.resource_type
76
- output["identifier"] = self.identifier
77
- return output
@@ -1,125 +0,0 @@
1
- from collections.abc import Hashable
2
- from dataclasses import dataclass
3
- from typing import Any, Generic, TypeVar
4
-
5
- from cognite.neat.issues import NeatWarning
6
-
7
- T_Identifier = TypeVar("T_Identifier", bound=Hashable)
8
-
9
- T_ReferenceIdentifier = TypeVar("T_ReferenceIdentifier", bound=Hashable)
10
-
11
-
12
- @dataclass(frozen=True)
13
- class ResourceWarning(NeatWarning, Generic[T_Identifier]):
14
- """Base class for resource warnings"""
15
-
16
- identifier: T_Identifier
17
- resource_type: str
18
-
19
-
20
- @dataclass(frozen=True)
21
- class ResourceNotFoundWarning(ResourceWarning[T_Identifier]):
22
- """The {resource_type} with identifier {identifier} is missing: {reason}. This will be ignored."""
23
-
24
- fix = "Check the {resource_type} {identifier} and try again."
25
- reason: str
26
-
27
- def message(self) -> str:
28
- return (self.__doc__ or "").format(
29
- resource_type=self.resource_type, identifier=repr(self.identifier), reason=self.reason
30
- )
31
-
32
- def dump(self) -> dict[str, Any]:
33
- output = super().dump()
34
- output["resource_type"] = self.resource_type
35
- output["identifier"] = self.identifier
36
- output["reason"] = self.reason
37
- return output
38
-
39
-
40
- @dataclass(frozen=True)
41
- class ReferredResourceNotFoundWarning(ResourceWarning, Generic[T_Identifier, T_ReferenceIdentifier]):
42
- """The {resource_type} with identifier {identifier} referred by {referred_type} {referred_by} does not exist.
43
- This will be ignored."""
44
-
45
- fix = "Create the {resource_type}"
46
-
47
- referred_by: T_ReferenceIdentifier
48
- referred_type: str
49
-
50
- def message(self) -> str:
51
- return (self.__doc__ or "").format(
52
- resource_type=self.resource_type,
53
- identifier=repr(self.identifier),
54
- referred_type=self.referred_type,
55
- referred_by=repr(self.referred_by),
56
- )
57
-
58
- def dump(self) -> dict[str, Any]:
59
- output = super().dump()
60
- output["resource_type"] = self.resource_type
61
- output["identifier"] = self.identifier
62
- output["referred_by"] = self.referred_by
63
- output["referred_type"] = self.referred_type
64
- return output
65
-
66
-
67
- @dataclass(frozen=True)
68
- class MultipleResourcesWarning(NeatWarning, Generic[T_Identifier]):
69
- """Multiple resources of type {resource_type} with identifiers {resources} were found. This will be ignored."""
70
-
71
- fix = "Remove the duplicate resources"
72
-
73
- resources: frozenset[T_Identifier]
74
- resource_type: str
75
-
76
- def message(self) -> str:
77
- return (self.__doc__ or "").format(
78
- resource_type=self.resource_type,
79
- resources=self.resources,
80
- )
81
-
82
- def dump(self) -> dict[str, Any]:
83
- output = super().dump()
84
- output["resource_type"] = self.resource_type
85
- output["resources"] = self.resources
86
- return output
87
-
88
-
89
- @dataclass(frozen=True)
90
- class FailedLoadingResourcesWarning(NeatWarning, Generic[T_Identifier]):
91
- """Failed to load resources of type {resource_type} with identifiers {resources}. Continuing without
92
- these resources."""
93
-
94
- extra = "The error was: {error}"
95
-
96
- fix = "Check the error."
97
-
98
- resources: frozenset[T_Identifier]
99
- resource_type: str
100
- error: str | None = None
101
-
102
- def message(self) -> str:
103
- return (self.__doc__ or "").format(
104
- resource_type=self.resource_type,
105
- resources=self.resources,
106
- ) + (self.extra.format(error=self.error) if self.error else "")
107
-
108
- def dump(self) -> dict[str, Any]:
109
- output = super().dump()
110
- output["resource_type"] = self.resource_type
111
- output["resources"] = self.resources
112
- return output
113
-
114
-
115
- class ResourceTypeNotSupportedWarning(ResourceWarning[T_Identifier]):
116
- """The {resource_type} with identifier {identifier} is not supported. This will be ignored."""
117
-
118
- def message(self) -> str:
119
- return (self.__doc__ or "").format(resource_type=self.resource_type, identifier=repr(self.identifier))
120
-
121
- def dump(self) -> dict[str, Any]:
122
- output = super().dump()
123
- output["resource_type"] = self.resource_type
124
- output["identifier"] = self.identifier
125
- return output
@@ -1,22 +0,0 @@
1
- from cognite.neat.issues import MultiValueError
2
-
3
- from . import dms, fileread, spreadsheet, spreadsheet_file
4
- from .base import (
5
- DefaultPydanticError,
6
- NeatValidationError,
7
- ValidationIssue,
8
- ValidationWarning,
9
- )
10
-
11
- __all__ = [
12
- "DefaultPydanticError",
13
- "MultiValueError",
14
- "NeatValidationError",
15
- "ValidationIssue",
16
- "ValidationIssue",
17
- "ValidationWarning",
18
- "dms",
19
- "fileread",
20
- "spreadsheet",
21
- "spreadsheet_file",
22
- ]
@@ -1,63 +0,0 @@
1
- from abc import ABC
2
- from dataclasses import dataclass
3
- from typing import Any
4
-
5
- from pydantic_core import ErrorDetails
6
-
7
- from cognite.neat.issues import MultiValueError, NeatError, NeatIssue, NeatWarning
8
-
9
- __all__ = [
10
- "ValidationIssue",
11
- "NeatValidationError",
12
- "DefaultPydanticError",
13
- "ValidationWarning",
14
- "MultiValueError",
15
- ]
16
-
17
-
18
- @dataclass(frozen=True)
19
- class ValidationIssue(NeatIssue, ABC): ...
20
-
21
-
22
- @dataclass(frozen=True)
23
- class NeatValidationError(NeatError, ValidationIssue, ABC): ...
24
-
25
-
26
- @dataclass(frozen=True)
27
- class DefaultPydanticError(NeatValidationError):
28
- type: str
29
- loc: tuple[int | str, ...]
30
- msg: str
31
- input: Any
32
- ctx: dict[str, Any] | None
33
-
34
- @classmethod
35
- def from_pydantic_error(cls, error: ErrorDetails) -> "NeatValidationError":
36
- return cls(
37
- type=error["type"],
38
- loc=error["loc"],
39
- msg=error["msg"],
40
- input=error.get("input"),
41
- ctx=error.get("ctx"),
42
- )
43
-
44
- def dump(self) -> dict[str, Any]:
45
- output = super().dump()
46
- output["type"] = self.type
47
- output["loc"] = self.loc
48
- output["msg"] = self.msg
49
- output["input"] = self.input
50
- output["ctx"] = self.ctx
51
- return output
52
-
53
- def message(self) -> str:
54
- if self.loc and len(self.loc) == 1:
55
- return f"{self.loc[0]} sheet: {self.msg}"
56
- elif self.loc and len(self.loc) == 2:
57
- return f"{self.loc[0]} sheet field/column <{self.loc[1]}>: {self.msg}"
58
- else:
59
- return self.msg
60
-
61
-
62
- @dataclass(frozen=True)
63
- class ValidationWarning(NeatWarning, ValidationIssue, ABC): ...