cognite-neat 0.88.2__py3-none-any.whl → 0.89.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- cognite/neat/_version.py +1 -1
- cognite/neat/constants.py +3 -0
- cognite/neat/graph/__init__.py +0 -3
- cognite/neat/graph/extractors/_mock_graph_generator.py +2 -1
- cognite/neat/graph/loaders/_base.py +3 -3
- cognite/neat/graph/loaders/_rdf2asset.py +24 -25
- cognite/neat/graph/loaders/_rdf2dms.py +20 -15
- cognite/neat/issues/__init__.py +1 -3
- cognite/neat/issues/_base.py +261 -71
- cognite/neat/issues/errors/__init__.py +73 -0
- cognite/neat/issues/errors/_external.py +67 -0
- cognite/neat/issues/errors/_general.py +35 -0
- cognite/neat/issues/errors/_properties.py +62 -0
- cognite/neat/issues/errors/_resources.py +111 -0
- cognite/neat/issues/errors/_workflow.py +36 -0
- cognite/neat/issues/formatters.py +1 -1
- cognite/neat/issues/warnings/__init__.py +66 -0
- cognite/neat/issues/warnings/_external.py +40 -0
- cognite/neat/issues/warnings/_general.py +29 -0
- cognite/neat/issues/warnings/_models.py +92 -0
- cognite/neat/issues/warnings/_properties.py +44 -0
- cognite/neat/issues/warnings/_resources.py +55 -0
- cognite/neat/issues/warnings/user_modeling.py +113 -0
- cognite/neat/rules/_shared.py +53 -2
- cognite/neat/rules/analysis/_base.py +1 -1
- cognite/neat/rules/exporters/_base.py +7 -18
- cognite/neat/rules/exporters/_rules2dms.py +17 -20
- cognite/neat/rules/exporters/_rules2excel.py +9 -16
- cognite/neat/rules/exporters/_rules2ontology.py +77 -64
- cognite/neat/rules/exporters/_rules2yaml.py +6 -9
- cognite/neat/rules/exporters/_validation.py +11 -96
- cognite/neat/rules/importers/_base.py +9 -58
- cognite/neat/rules/importers/_dms2rules.py +188 -135
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +48 -35
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +36 -45
- cognite/neat/rules/importers/_dtdl2rules/spec.py +7 -0
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +8 -4
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +3 -3
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +18 -11
- cognite/neat/rules/importers/_rdf/_imf2rules/_imf2rules.py +12 -19
- cognite/neat/rules/importers/_rdf/_inference2rules.py +14 -37
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +1 -0
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +1 -0
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +9 -20
- cognite/neat/rules/importers/_rdf/_shared.py +4 -4
- cognite/neat/rules/importers/_spreadsheet2rules.py +46 -97
- cognite/neat/rules/importers/_yaml2rules.py +32 -58
- cognite/neat/rules/models/__init__.py +21 -5
- cognite/neat/rules/models/_base_input.py +162 -0
- cognite/neat/rules/models/{_base.py → _base_rules.py} +1 -12
- cognite/neat/rules/models/_rdfpath.py +4 -4
- cognite/neat/rules/models/{_types/_field.py → _types.py} +5 -10
- cognite/neat/rules/models/asset/__init__.py +5 -2
- cognite/neat/rules/models/asset/_rules.py +3 -23
- cognite/neat/rules/models/asset/_rules_input.py +40 -115
- cognite/neat/rules/models/asset/_validation.py +14 -10
- cognite/neat/rules/models/data_types.py +150 -44
- cognite/neat/rules/models/dms/__init__.py +19 -7
- cognite/neat/rules/models/dms/_exporter.py +102 -34
- cognite/neat/rules/models/dms/_rules.py +65 -162
- cognite/neat/rules/models/dms/_rules_input.py +186 -254
- cognite/neat/rules/models/dms/_schema.py +87 -78
- cognite/neat/rules/models/dms/_serializer.py +44 -3
- cognite/neat/rules/models/dms/_validation.py +106 -68
- cognite/neat/rules/models/domain.py +52 -1
- cognite/neat/rules/models/entities/__init__.py +63 -0
- cognite/neat/rules/models/entities/_constants.py +73 -0
- cognite/neat/rules/models/entities/_loaders.py +76 -0
- cognite/neat/rules/models/entities/_multi_value.py +67 -0
- cognite/neat/rules/models/{entities.py → entities/_single_value.py} +74 -232
- cognite/neat/rules/models/entities/_types.py +86 -0
- cognite/neat/rules/models/{wrapped_entities.py → entities/_wrapped.py} +1 -1
- cognite/neat/rules/models/information/__init__.py +10 -2
- cognite/neat/rules/models/information/_rules.py +10 -22
- cognite/neat/rules/models/information/_rules_input.py +57 -204
- cognite/neat/rules/models/information/_validation.py +48 -25
- cognite/neat/rules/transformers/__init__.py +21 -0
- cognite/neat/rules/transformers/_base.py +81 -0
- cognite/neat/rules/{models/information/_converter.py → transformers/_converters.py} +217 -21
- cognite/neat/rules/transformers/_map_onto.py +97 -0
- cognite/neat/rules/transformers/_pipelines.py +61 -0
- cognite/neat/rules/transformers/_verification.py +136 -0
- cognite/neat/{graph/stores → store}/_provenance.py +10 -1
- cognite/neat/utils/auxiliary.py +2 -35
- cognite/neat/utils/cdf/data_classes.py +20 -0
- cognite/neat/utils/regex_patterns.py +6 -0
- cognite/neat/utils/text.py +17 -0
- cognite/neat/workflows/base.py +4 -4
- cognite/neat/workflows/cdf_store.py +3 -3
- cognite/neat/workflows/steps/data_contracts.py +1 -1
- cognite/neat/workflows/steps/lib/current/graph_extractor.py +3 -3
- cognite/neat/workflows/steps/lib/current/graph_loader.py +2 -2
- cognite/neat/workflows/steps/lib/current/graph_store.py +1 -1
- cognite/neat/workflows/steps/lib/current/rules_exporter.py +116 -47
- cognite/neat/workflows/steps/lib/current/rules_importer.py +30 -28
- cognite/neat/workflows/steps/lib/current/rules_validator.py +5 -6
- cognite/neat/workflows/steps/lib/io/io_steps.py +5 -5
- cognite/neat/workflows/steps_registry.py +4 -5
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/RECORD +105 -106
- cognite/neat/exceptions.py +0 -145
- cognite/neat/graph/exceptions.py +0 -90
- cognite/neat/issues/errors/external.py +0 -21
- cognite/neat/issues/errors/properties.py +0 -75
- cognite/neat/issues/errors/resources.py +0 -123
- cognite/neat/issues/errors/schema.py +0 -0
- cognite/neat/issues/neat_warnings/__init__.py +0 -2
- cognite/neat/issues/neat_warnings/identifier.py +0 -27
- cognite/neat/issues/neat_warnings/models.py +0 -22
- cognite/neat/issues/neat_warnings/properties.py +0 -77
- cognite/neat/issues/neat_warnings/resources.py +0 -125
- cognite/neat/rules/issues/__init__.py +0 -22
- cognite/neat/rules/issues/base.py +0 -63
- cognite/neat/rules/issues/dms.py +0 -549
- cognite/neat/rules/issues/fileread.py +0 -197
- cognite/neat/rules/issues/ontology.py +0 -298
- cognite/neat/rules/issues/spreadsheet.py +0 -563
- cognite/neat/rules/issues/spreadsheet_file.py +0 -151
- cognite/neat/rules/issues/tables.py +0 -72
- cognite/neat/rules/models/_constants.py +0 -1
- cognite/neat/rules/models/_types/__init__.py +0 -19
- cognite/neat/rules/models/asset/_converter.py +0 -4
- cognite/neat/rules/models/dms/_converter.py +0 -145
- cognite/neat/workflows/_exceptions.py +0 -41
- /cognite/neat/{graph/stores → store}/__init__.py +0 -0
- /cognite/neat/{graph/stores → store}/_base.py +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.88.2.dist-info → cognite_neat-0.89.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from typing import Any, Generic
|
|
3
|
-
|
|
4
|
-
from .resources import ResourceError, T_Identifier, T_ReferenceIdentifier
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dataclass(frozen=True)
|
|
8
|
-
class PropertyNotFoundError(ResourceError[T_Identifier]):
|
|
9
|
-
"""The {resource_type} with identifier {identifier} does not have a property {property_name}"""
|
|
10
|
-
|
|
11
|
-
property_name: str
|
|
12
|
-
|
|
13
|
-
def message(self) -> str:
|
|
14
|
-
return (self.__doc__ or "").format(
|
|
15
|
-
resource_type=self.resource_type, identifier=repr(self.identifier), property_name=self.property_name
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
def dump(self) -> dict[str, Any]:
|
|
19
|
-
output = super().dump()
|
|
20
|
-
output["property_name"] = self.property_name
|
|
21
|
-
return output
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@dataclass(frozen=True)
|
|
25
|
-
class ReferredPropertyNotFoundError(ResourceError, Generic[T_Identifier, T_ReferenceIdentifier]):
|
|
26
|
-
"""The {resource_type} with identifier {identifier} does not have a property {property_name} referred
|
|
27
|
-
to by {referred_type} {referred_by} does not exist
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
fix = "Ensure the {resource_type} {identifier} has a {property_name} property"
|
|
31
|
-
|
|
32
|
-
referred_by: T_ReferenceIdentifier
|
|
33
|
-
referred_type: str
|
|
34
|
-
property_name: str
|
|
35
|
-
|
|
36
|
-
def message(self) -> str:
|
|
37
|
-
return (self.__doc__ or "").format(
|
|
38
|
-
resource_type=self.resource_type,
|
|
39
|
-
identifier=repr(self.identifier),
|
|
40
|
-
referred_type=self.referred_type,
|
|
41
|
-
referred_by=repr(self.referred_by),
|
|
42
|
-
property_name=self.property_name,
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
def dump(self) -> dict[str, Any]:
|
|
46
|
-
output = super().dump()
|
|
47
|
-
output["resource_type"] = self.resource_type
|
|
48
|
-
output["identifier"] = self.identifier
|
|
49
|
-
output["referred_by"] = self.referred_by
|
|
50
|
-
output["referred_type"] = self.referred_type
|
|
51
|
-
output["property_name"] = self.property_name
|
|
52
|
-
return output
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@dataclass(frozen=True)
|
|
56
|
-
class PropertyTypeNotSupportedError(ResourceError[T_Identifier]):
|
|
57
|
-
"""The {resource_type} with identifier {identifier} has a property {property_name}
|
|
58
|
-
of unsupported type {property_type}"""
|
|
59
|
-
|
|
60
|
-
property_name: str
|
|
61
|
-
property_type: str
|
|
62
|
-
|
|
63
|
-
def message(self) -> str:
|
|
64
|
-
return (self.__doc__ or "").format(
|
|
65
|
-
resource_type=self.resource_type,
|
|
66
|
-
identifier=repr(self.identifier),
|
|
67
|
-
property_name=self.property_name,
|
|
68
|
-
property_type=self.property_type,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
def dump(self) -> dict[str, Any]:
|
|
72
|
-
output = super().dump()
|
|
73
|
-
output["property_name"] = self.property_name
|
|
74
|
-
output["property_type"] = self.property_type
|
|
75
|
-
return output
|
|
@@ -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
|
|
File without changes
|
|
@@ -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): ...
|