cognite-neat 0.123.11__py3-none-any.whl → 0.123.13__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 CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.123.11"
1
+ __version__ = "0.123.13"
2
2
  __engine__ = "^2.0.4"
@@ -78,7 +78,7 @@ class UnverifiedConceptualMetadata(UnverifiedComponent[ConceptualMetadata]):
78
78
 
79
79
  @dataclass
80
80
  class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
81
- concept: ConceptEntity | str
81
+ concept: ConceptEntity | str | UnknownEntity
82
82
  property_: str
83
83
  value_type: DataType | ConceptEntity | MultiValueTypeInfo | UnknownEntity | str
84
84
  name: str | None = None
@@ -146,8 +146,8 @@ class UnverifiedConcept(UnverifiedComponent[Concept]):
146
146
  @dataclass
147
147
  class UnverifiedConceptualDataModel(UnverifiedDataModel[ConceptualDataModel]):
148
148
  metadata: UnverifiedConceptualMetadata
149
- properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
150
149
  concepts: list[UnverifiedConcept] = field(default_factory=list)
150
+ properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
151
151
  prefixes: dict[str, Namespace] | None = None
152
152
 
153
153
  @classmethod
@@ -11,7 +11,11 @@ from cognite.neat.core._issues.errors._resources import (
11
11
  ResourceDuplicatedError,
12
12
  ResourceNotDefinedError,
13
13
  )
14
- from cognite.neat.core._issues.warnings._models import UndefinedConceptWarning
14
+ from cognite.neat.core._issues.warnings._models import (
15
+ ConceptOnlyDataModelWarning,
16
+ DanglingPropertyWarning,
17
+ UndefinedConceptWarning,
18
+ )
15
19
  from cognite.neat.core._issues.warnings._resources import (
16
20
  ResourceNotDefinedWarning,
17
21
  ResourceRegexViolationWarning,
@@ -46,10 +50,24 @@ class ConceptualValidation:
46
50
  self._parent_concept_defined()
47
51
  self._referenced_classes_exist()
48
52
  self._referenced_value_types_exist()
53
+ self._concept_only_data_model()
54
+ self._dangling_properties()
49
55
  self._regex_compliance_with_physical_data_model()
50
56
 
51
57
  return self.issue_list
52
58
 
59
+ def _concept_only_data_model(self) -> None:
60
+ """Check if the data model only consists of concepts without any properties."""
61
+ if not self._properties:
62
+ self.issue_list.append(ConceptOnlyDataModelWarning())
63
+
64
+ def _dangling_properties(self) -> None:
65
+ """Check if there are properties that do not reference any concept."""
66
+ dangling_properties = [prop for prop in self._properties if prop.concept == UnknownEntity()]
67
+ if dangling_properties:
68
+ for prop in dangling_properties:
69
+ self.issue_list.append(DanglingPropertyWarning(property_id=prop.property_))
70
+
53
71
  def _duplicated_resources(self) -> None:
54
72
  properties_sheet = self._read_info_by_spreadsheet.get("Properties")
55
73
  concepts_sheet = self._read_info_by_spreadsheet.get("Concepts")
@@ -113,7 +131,7 @@ class ConceptualValidation:
113
131
 
114
132
  def _undefined_classes(self) -> None:
115
133
  defined_concept = {concept.concept for concept in self._concepts}
116
- referred_concepts = {property_.concept for property_ in self._properties}
134
+ referred_concepts = {property_.concept for property_ in self._properties} - {UnknownEntity()}
117
135
 
118
136
  if undefined_concepts := referred_concepts.difference(defined_concept):
119
137
  for concept in undefined_concepts:
@@ -193,7 +211,7 @@ class ConceptualValidation:
193
211
  PATTERNS.physical_property_id_compliance.pattern,
194
212
  )
195
213
  )
196
- if not PATTERNS.view_id_compliance.match(prop_.concept.suffix):
214
+ if prop_.concept != UnknownEntity() and not PATTERNS.view_id_compliance.match(prop_.concept.suffix):
197
215
  self.issue_list.append(
198
216
  ResourceRegexViolationWarning(
199
217
  prop_.concept,
@@ -123,7 +123,7 @@ class ConceptualProperty(SheetRow):
123
123
  knowledge graph. Defaults to None (no transformation)
124
124
  """
125
125
 
126
- concept: ConceptEntityType = Field(
126
+ concept: ConceptEntityType | UnknownEntity = Field(
127
127
  alias="Concept",
128
128
  description="Concept id that the property is defined for, strongly advise `PascalCase` usage.",
129
129
  )
@@ -241,8 +241,10 @@ class ConceptualProperty(SheetRow):
241
241
 
242
242
  class ConceptualDataModel(BaseVerifiedDataModel):
243
243
  metadata: ConceptualMetadata = Field(alias="Metadata", description="Metadata for the conceptual data model")
244
- properties: SheetList[ConceptualProperty] = Field(alias="Properties", description="List of properties")
245
244
  concepts: SheetList[Concept] = Field(alias="Concepts", description="List of concepts")
245
+ properties: SheetList[ConceptualProperty] = Field(
246
+ alias="Properties", default_factory=SheetList, description="List of properties"
247
+ )
246
248
  prefixes: dict[str, Namespace] = Field(
247
249
  alias="Prefixes",
248
250
  default_factory=get_default_prefixes_and_namespaces,
@@ -101,6 +101,24 @@ class UndefinedConceptWarning(UserModelingWarning):
101
101
  concept_id: str
102
102
 
103
103
 
104
+ @dataclass(unsafe_hash=True)
105
+ class ConceptOnlyDataModelWarning(UserModelingWarning):
106
+ """Data model is concept-only (contains concepts but no properties).
107
+ This model will likely cause issues when converting to a physical data model."""
108
+
109
+ fix = "Define properties for concepts or make sure that concepts implement other concepts that have properties."
110
+
111
+
112
+ @dataclass(unsafe_hash=True)
113
+ class DanglingPropertyWarning(UserModelingWarning):
114
+ """Property {property_id} is not defined for any concept.
115
+ This will likely cause issues when converting to a physical data model."""
116
+
117
+ fix = "Define the property for a concept or remove it from the data model."
118
+
119
+ property_id: str
120
+
121
+
104
122
  @dataclass(unsafe_hash=True)
105
123
  class UndefinedViewWarning(UserModelingWarning):
106
124
  """Undefined view {value_type} has been referred as value type for property <{view_property}> of view {view_id}."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite-neat
3
- Version: 0.123.11
3
+ Version: 0.123.13
4
4
  Summary: Knowledge graph transformation
5
5
  Project-URL: Documentation, https://cognite-neat.readthedocs-hosted.com/
6
6
  Project-URL: Homepage, https://cognite-neat.readthedocs-hosted.com/
@@ -1,5 +1,5 @@
1
1
  cognite/neat/__init__.py,sha256=12StS1dzH9_MElqxGvLWrNsxCJl9Hv8A2a9D0E5OD_U,193
2
- cognite/neat/_version.py,sha256=ozgwvgQNREIJNB1572G0X8P8ElNIjgvEBuwPMdpxGsY,47
2
+ cognite/neat/_version.py,sha256=_QVfpGepX4UR60nDrdZHGAkCm6OBHOLQ084t96SzBBo,47
3
3
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cognite/neat/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cognite/neat/core/_config.py,sha256=WT1BS8uADcFvGoUYOOfwFOVq_VBl472TisdoA3wLick,280
@@ -51,9 +51,9 @@ cognite/neat/core/_data_model/models/_base_verified.py,sha256=nzPrlj7ZvYull_Fdh2
51
51
  cognite/neat/core/_data_model/models/_types.py,sha256=70E8fiLdZkVF2sDUGPuDhzXNA5niVECkVDI7YN0NF60,5488
52
52
  cognite/neat/core/_data_model/models/data_types.py,sha256=uQ_u9KxCetLjxo-VtFzOXSxQuuf97Kg-9lfTTGzY6hc,10150
53
53
  cognite/neat/core/_data_model/models/conceptual/__init__.py,sha256=9A6myEV8s0-LqdXejaljqPj8S0pIpUL75rNdRDZzyR8,585
54
- cognite/neat/core/_data_model/models/conceptual/_unverified.py,sha256=apisgtXMb50dOs7rxZ-jcCW4JqxCdAWGtsYtRe3ssfs,6282
55
- cognite/neat/core/_data_model/models/conceptual/_validation.py,sha256=ywWFkxhQvDvB-NCIjWNv7-aOouBCz7HoxtJ0aC_b6BY,13034
56
- cognite/neat/core/_data_model/models/conceptual/_verified.py,sha256=e5Qs7n1np4g6inHQwuLUk2rCwgLf129je54xLnzENpw,13659
54
+ cognite/neat/core/_data_model/models/conceptual/_unverified.py,sha256=VswgnTSjSCRzBX3z5HvintBGaWBPexxIs-7z7S4J57c,6298
55
+ cognite/neat/core/_data_model/models/conceptual/_validation.py,sha256=tPU8IGV5eiiReF40igjs0t7rMdYnaMcshKa01CY-JKI,13868
56
+ cognite/neat/core/_data_model/models/conceptual/_verified.py,sha256=BUB4Ur4kpBoWiwTf57tjxJ2l0tDTSbY7zGrg1g0yVNQ,13716
57
57
  cognite/neat/core/_data_model/models/entities/__init__.py,sha256=UsW-_6fwd-TW0WcnShPKf40h75l1elVn80VurUwRAic,1567
58
58
  cognite/neat/core/_data_model/models/entities/_constants.py,sha256=GXRzVfArwxF3C67VCkzy0JWTZRkRJUYXBQaaecrqcWc,351
59
59
  cognite/neat/core/_data_model/models/entities/_loaders.py,sha256=PkrVtGlZWYLvAVIRABrgVSgkMvJYpBqdrHBfz-H0Ut8,2783
@@ -131,7 +131,7 @@ cognite/neat/core/_issues/errors/_wrapper.py,sha256=clhuSwUuHy-FQXQopFIQRY8c_NZM
131
131
  cognite/neat/core/_issues/warnings/__init__.py,sha256=lzNZrguzwXyifehsCilAXa5UL94DWHIeO-slyC-EYZc,3165
132
132
  cognite/neat/core/_issues/warnings/_external.py,sha256=w-1R7ea6DXTIWqwlwMMjY0YxKDMSJ8gKAbp_nIIM1AI,1324
133
133
  cognite/neat/core/_issues/warnings/_general.py,sha256=_6dAFaMz-LIv7GsBBIBq2d-kmbuxVXKvU4jZeb7tjAo,972
134
- cognite/neat/core/_issues/warnings/_models.py,sha256=0uqJTR8sXiobIqqh05sRc8-QdMuV6h_4ZDm2RfxpEew,4396
134
+ cognite/neat/core/_issues/warnings/_models.py,sha256=dE8Ha96WtZ9m_Bozx64NCMuJY2gWZleicD5tnnOqbe8,5086
135
135
  cognite/neat/core/_issues/warnings/_properties.py,sha256=I3vqc1aL-ce_FRQNgQQy34RW7kQxcjbwhZIIVtGVmg8,3807
136
136
  cognite/neat/core/_issues/warnings/_resources.py,sha256=_iPRq0pRMmRu3LFjqZTaG3OqOzw4f8-Vc9G4Im__FHc,3578
137
137
  cognite/neat/core/_issues/warnings/user_modeling.py,sha256=Qn_S8TLw7MMYQaJcZBScJA48kz_PrTWz0NaepSR70Fk,4144
@@ -186,7 +186,7 @@ cognite/neat/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvc
186
186
  cognite/neat/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
187
187
  cognite/neat/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
188
188
  cognite/neat/session/engine/_load.py,sha256=g52uYakQM03VqHt_RDHtpHso1-mFFifH5M4T2ScuH8A,5198
189
- cognite_neat-0.123.11.dist-info/METADATA,sha256=NH4ItRGVPjcqNg9VXVWVnJb_55REoG53v5xz598Giwg,9172
190
- cognite_neat-0.123.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
191
- cognite_neat-0.123.11.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
192
- cognite_neat-0.123.11.dist-info/RECORD,,
189
+ cognite_neat-0.123.13.dist-info/METADATA,sha256=nvoEO8JM0qcLabmwghL9j-0ncS7LPeNB5NocH23DPsM,9172
190
+ cognite_neat-0.123.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
191
+ cognite_neat-0.123.13.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
192
+ cognite_neat-0.123.13.dist-info/RECORD,,