cognite-neat 0.81.1__py3-none-any.whl → 0.81.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.

Potentially problematic release.


This version of cognite-neat might be problematic. Click here for more details.

cognite/neat/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.81.1"
1
+ __version__ = "0.81.3"
@@ -22,6 +22,7 @@ from cognite.neat.issues import NeatIssue, NeatIssueList
22
22
  from cognite.neat.rules.models import DMSRules
23
23
  from cognite.neat.rules.models.data_types import _DATA_TYPE_BY_DMS_TYPE
24
24
  from cognite.neat.utils.upload import UploadDiffsID
25
+ from cognite.neat.utils.utils import create_sha256_hash
25
26
 
26
27
  from ._base import CDFLoader
27
28
 
@@ -217,9 +218,10 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
217
218
  tracker.issue(error)
218
219
  yield error
219
220
  for target in values:
221
+ external_id = f"{identifier}.{prop}.{target}"
220
222
  yield dm.EdgeApply(
221
223
  space=self.instance_space,
222
- external_id=f"{identifier}.{prop}.{target}",
224
+ external_id=external_id if len(external_id) < 256 else create_sha256_hash(external_id),
223
225
  type=edge.type,
224
226
  start_node=dm.DirectRelationReference(self.instance_space, identifier),
225
227
  end_node=dm.DirectRelationReference(self.instance_space, target),
@@ -21,7 +21,7 @@ from cognite.neat.legacy.rules.exporters._rules2dms import DMSSchemaComponents
21
21
  from cognite.neat.legacy.rules.exporters._validation import are_entity_names_dms_compliant
22
22
  from cognite.neat.legacy.rules.models.rules import Property, Rules
23
23
  from cognite.neat.legacy.rules.models.value_types import ValueTypeMapping
24
- from cognite.neat.utils.utils import generate_exception_report
24
+ from cognite.neat.utils.utils import create_sha256_hash, generate_exception_report
25
25
 
26
26
  if sys.version_info >= (3, 11):
27
27
  from datetime import UTC
@@ -683,9 +683,10 @@ def to_edge(self, data_model: DMSSchemaComponents, add_class_prefix: bool = Fals
683
683
  stacklevel=2,
684
684
  )
685
685
 
686
+ external_id = f"{self.external_id}.{edge_one_to_many}.{end_node_external_id}"
686
687
  edge = EdgeApply(
687
688
  space=data_model.views[view_id].space,
688
- external_id=f"{self.external_id}-{edge_one_to_many}-{end_node_external_id}",
689
+ external_id=external_id if len(external_id) < 256 else create_sha256_hash(external_id),
689
690
  type=(data_model.views[view_id].space, edge_type_id),
690
691
  start_node=(data_model.views[view_id].space, self.external_id),
691
692
  end_node=(data_model.views[view_id].space, end_node_external_id),
@@ -31,6 +31,7 @@ __all__ = [
31
31
  "ReverseRelationMissingOtherSideWarning",
32
32
  "NodeTypeFilterOnParentViewWarning",
33
33
  "MissingViewInModelWarning",
34
+ "ViewSizeWarning",
34
35
  "ChangingContainerError",
35
36
  "ChangingViewError",
36
37
  ]
@@ -44,6 +45,30 @@ class DMSSchemaError(NeatValidationError, ABC): ...
44
45
  class DMSSchemaWarning(ValidationWarning, ABC): ...
45
46
 
46
47
 
48
+ @dataclass(frozen=True)
49
+ class ViewSizeWarning(DMSSchemaWarning):
50
+ description = (
51
+ "The number of properties in the {view} view is {count} which is more than "
52
+ "the recommended limit of {limit} properties. This can lead to performance issues."
53
+ )
54
+ fix = "Reduce the size of the view"
55
+ error_name: ClassVar[str] = "ViewSizeWarning"
56
+
57
+ view_id: dm.ViewId
58
+ limit: int
59
+ count: int
60
+
61
+ def message(self) -> str:
62
+ return self.description.format(view=repr(self.view_id), count=self.count, limit=self.limit)
63
+
64
+ def dump(self) -> dict[str, Any]:
65
+ output = super().dump()
66
+ output["view_id"] = self.view_id.dump()
67
+ output["limit"] = self.limit
68
+ output["count"] = self.count
69
+ return output
70
+
71
+
47
72
  @dataclass(frozen=True)
48
73
  class IncompleteSchemaError(DMSSchemaError):
49
74
  description = "This error is raised when the schema is claimed to be complete but missing some components"
@@ -0,0 +1 @@
1
+ DMS_CONTAINER_SIZE_LIMIT = 100
@@ -6,6 +6,7 @@ from cognite.client import data_modeling as dm
6
6
  from cognite.neat.rules import issues
7
7
  from cognite.neat.rules.issues import IssueList
8
8
  from cognite.neat.rules.models._base import DataModelType, ExtensionCategory, SchemaCompleteness
9
+ from cognite.neat.rules.models._constants import DMS_CONTAINER_SIZE_LIMIT
9
10
  from cognite.neat.rules.models.data_types import DataType
10
11
  from cognite.neat.rules.models.entities import ContainerEntity
11
12
  from cognite.neat.rules.models.wrapped_entities import RawFilter
@@ -34,7 +35,7 @@ class DMSPostValidation:
34
35
  self._validate_raw_filter()
35
36
  self._consistent_container_properties()
36
37
 
37
- self._referenced_views_and_containers_are_existing()
38
+ self._referenced_views_and_containers_are_existing_and_proper_size()
38
39
  if self.metadata.schema_ is SchemaCompleteness.extended:
39
40
  self._validate_extension()
40
41
  if self.metadata.schema_ is SchemaCompleteness.partial:
@@ -118,14 +119,16 @@ class DMSPostValidation:
118
119
  prop.constraint = prop.constraint or constraint_definition
119
120
  self.issue_list.extend(errors)
120
121
 
121
- def _referenced_views_and_containers_are_existing(self) -> None:
122
+ def _referenced_views_and_containers_are_existing_and_proper_size(self) -> None:
122
123
  defined_views = {view.view.as_id() for view in self.views}
123
124
  if self.metadata.schema_ is SchemaCompleteness.extended and self.rules.last:
124
125
  defined_views |= {view.view.as_id() for view in self.rules.last.views}
125
126
 
126
- errors: list[issues.NeatValidationError] = []
127
+ property_count_by_view: dict[dm.ViewId, int] = defaultdict(int)
128
+ errors: list[issues.ValidationIssue] = []
127
129
  for prop_no, prop in enumerate(self.properties):
128
- if prop.view and (view_id := prop.view.as_id()) not in defined_views:
130
+ view_id = prop.view.as_id()
131
+ if view_id not in defined_views:
129
132
  errors.append(
130
133
  issues.spreadsheet.NonExistingViewError(
131
134
  column="View",
@@ -137,6 +140,17 @@ class DMSPostValidation:
137
140
  url=None,
138
141
  )
139
142
  )
143
+ else:
144
+ property_count_by_view[view_id] += 1
145
+ for view_id, count in property_count_by_view.items():
146
+ if count > DMS_CONTAINER_SIZE_LIMIT:
147
+ errors.append(
148
+ issues.dms.ViewSizeWarning(
149
+ view_id=view_id,
150
+ limit=DMS_CONTAINER_SIZE_LIMIT,
151
+ count=count,
152
+ )
153
+ )
140
154
  if self.metadata.schema_ is SchemaCompleteness.complete:
141
155
  defined_containers = {container.container.as_id() for container in self.containers or []}
142
156
  if self.metadata.data_model_type == DataModelType.solution and self.rules.reference:
@@ -8,6 +8,7 @@ from cognite.neat.rules.models._base import (
8
8
  SchemaCompleteness,
9
9
  SheetList,
10
10
  )
11
+ from cognite.neat.rules.models._constants import DMS_CONTAINER_SIZE_LIMIT
11
12
  from cognite.neat.rules.models.data_types import DataType
12
13
  from cognite.neat.rules.models.domain import DomainRules
13
14
  from cognite.neat.rules.models.entities import (
@@ -41,6 +42,7 @@ class _InformationRulesConverter:
41
42
  self.last_classes = {class_.class_: class_ for class_ in self.rules.last.classes}
42
43
  else:
43
44
  self.last_classes = {}
45
+ self.property_count_by_container: dict[ContainerEntity, int] = defaultdict(int)
44
46
 
45
47
  def as_domain_rules(self) -> DomainRules:
46
48
  raise NotImplementedError("DomainRules not implemented yet")
@@ -81,7 +83,6 @@ class _InformationRulesConverter:
81
83
  last_dms_rules = self.rules.last.as_dms_architect_rules() if self.rules.last else None
82
84
  ref_dms_rules = self.rules.reference.as_dms_architect_rules() if self.rules.reference else None
83
85
 
84
- containers: list[DMSContainer] = []
85
86
  class_by_entity = {cls_.class_: cls_ for cls_ in self.rules.classes}
86
87
  if self.rules.last:
87
88
  for cls_ in self.rules.last.classes:
@@ -93,6 +94,7 @@ class _InformationRulesConverter:
93
94
  if rule_set:
94
95
  existing_containers.update({c.container for c in rule_set.containers or []})
95
96
 
97
+ containers: list[DMSContainer] = []
96
98
  for container_entity, class_entities in referenced_containers.items():
97
99
  if container_entity in existing_containers:
98
100
  continue
@@ -227,9 +229,14 @@ class _InformationRulesConverter:
227
229
  # the existing container in the last schema
228
230
  container_entity = prop.class_.as_container_entity(default_space)
229
231
  container_entity.suffix = self._bump_suffix(container_entity.suffix)
230
- return container_entity, prop.property_
231
232
  else:
232
- return prop.class_.as_container_entity(default_space), prop.property_
233
+ container_entity = prop.class_.as_container_entity(default_space)
234
+
235
+ while self.property_count_by_container[container_entity] >= DMS_CONTAINER_SIZE_LIMIT:
236
+ container_entity.suffix = self._bump_suffix(container_entity.suffix)
237
+
238
+ self.property_count_by_container[container_entity] += 1
239
+ return container_entity, prop.property_
233
240
 
234
241
  def _get_view_implements(self, cls_: InformationClass, metadata: InformationMetadata) -> list[ViewEntity]:
235
242
  if isinstance(cls_.reference, ReferenceEntity) and cls_.reference.prefix != metadata.prefix:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.81.1
3
+ Version: 0.81.3
4
4
  Summary: Knowledge graph transformation
5
5
  Home-page: https://cognite-neat.readthedocs-hosted.com/
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  cognite/neat/__init__.py,sha256=v-rRiDOgZ3sQSMQKq0vgUQZvpeOkoHFXissAx6Ktg84,61
2
- cognite/neat/_version.py,sha256=zEgwrETiUxKyTUiAscaK4aVaaACC4OjGI69_cwGk124,23
2
+ cognite/neat/_version.py,sha256=bK5LLQ5c0-mwXmJLM9_cE_lGPthPpVuCp0sGU3PavkI,23
3
3
  cognite/neat/app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cognite/neat/app/api/asgi/metrics.py,sha256=nxFy7L5cChTI0a-zkCiJ59Aq8yLuIJp5c9Dg0wRXtV0,152
5
5
  cognite/neat/app/api/configuration.py,sha256=2U5M6M252swvQPQyooA1EBzFUZNtcTmuSaywfJDgckM,4232
@@ -70,7 +70,7 @@ cognite/neat/graph/issues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
70
70
  cognite/neat/graph/issues/loader.py,sha256=v8YDsehkUT1QUG61JM9BDV_lqowMUnDmGmbay0aFzN4,3085
71
71
  cognite/neat/graph/loaders/__init__.py,sha256=hHC9sfFfbnGSVFTYeuNTIEu4tdLSJ2mWV07fereLelo,125
72
72
  cognite/neat/graph/loaders/_base.py,sha256=bdYC6CwsHVqnQa1QzOhL68qQhF1OtrsearqH6D-z3E4,4037
73
- cognite/neat/graph/loaders/_rdf2dms.py,sha256=Tn7vy6XwXFXpVDn7uzfzgJMJapbPITerKaF5b5Y4ol4,12857
73
+ cognite/neat/graph/loaders/_rdf2dms.py,sha256=w0y2ECKw7RrQndGyTVIWeFF2WDxs9yvl_eWNqg-tKO8,13018
74
74
  cognite/neat/graph/models.py,sha256=AtLgZh2qyRP6NRetjQCy9qLMuTQB0CH52Zsev-qa2sk,149
75
75
  cognite/neat/graph/stores/__init__.py,sha256=G-VG_YwfRt1kuPao07PDJyZ3w_0-eguzLUM13n-Z_RA,64
76
76
  cognite/neat/graph/stores/_base.py,sha256=6MZAXygT6sHTQ1LWm_TDb2Ws6fgNJ-r4evwcLywpBVk,9481
@@ -135,7 +135,7 @@ cognite/neat/legacy/rules/exporters/_rules2dms.py,sha256=13CptTLvY9ghcrLPhumUOg6
135
135
  cognite/neat/legacy/rules/exporters/_rules2excel.py,sha256=ytHsqw2j26T9yLNZHuUSItV8Jp3AvvpIwX8D5-L9GO8,8312
136
136
  cognite/neat/legacy/rules/exporters/_rules2graphql.py,sha256=oXBU5z-qFyxG7MW83HYlW-hazhDDNAPKAbJJcsZfcU4,6251
137
137
  cognite/neat/legacy/rules/exporters/_rules2ontology.py,sha256=m6adoKOP5EVVEjFX4Qi9yw7UflrDRVgNiBxQ9QVgz6g,18458
138
- cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py,sha256=0Cn9juOgNPnmxLe7eUCUNjfaicLcQPpj_qA8HLFB3lc,28824
138
+ cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py,sha256=YqiyTzAD0vEEhLbIPNTkK0AzKUG0yfBjz47Rg1mSTq8,28949
139
139
  cognite/neat/legacy/rules/exporters/_rules2rules.py,sha256=KlBm1hWkx4Ly5G-_gdcURUwADolMJFnueus02IW51uQ,3881
140
140
  cognite/neat/legacy/rules/exporters/_rules2triples.py,sha256=ItkLy6Rji4g5UqLtxaOeodGUvpQG-LVr_ss70PcCPZs,1085
141
141
  cognite/neat/legacy/rules/exporters/_validation.py,sha256=saDorwUqJ4Fo6yeCMSRH0Hp3AGCr-rdjb-sOGo91xL0,5767
@@ -204,7 +204,7 @@ cognite/neat/rules/importers/_spreadsheet2rules.py,sha256=nKSJyZGoTho0bqQ_5_1XB9
204
204
  cognite/neat/rules/importers/_yaml2rules.py,sha256=F0uksSz1A3po5OlRM2152_w5j8D9oYTLB9NFTkSMlWI,4275
205
205
  cognite/neat/rules/issues/__init__.py,sha256=c12m0HAHHzF6oR8lKbULE3TxOPimTi9s1O9IIrtgh0g,549
206
206
  cognite/neat/rules/issues/base.py,sha256=x2YLCfmqtPlFLoURq3qHaprXCpFaQdf0iWkql-EMyps,2446
207
- cognite/neat/rules/issues/dms.py,sha256=CKztcpNu9E_ygbAmiODOhaYKPX6o9eaXeiod7Ak-kNY,23617
207
+ cognite/neat/rules/issues/dms.py,sha256=eZmbQhdo97SufNLKJu4QWlrhZCxmngiWTwPWIOx7GSA,24400
208
208
  cognite/neat/rules/issues/fileread.py,sha256=ao199mtvhPSW0IA8ZQZ0RzuLIIipYtL0jp6fLqxb4_c,5748
209
209
  cognite/neat/rules/issues/formatters.py,sha256=_ag2bJ9hncOj8pAGJvTTEPs9kTtxbD7vkqvS9Zcnizc,3385
210
210
  cognite/neat/rules/issues/importing.py,sha256=uSk4TXo_CO3bglBZkaiWekXLXXd31UWIZE95clVSLz4,13417
@@ -212,6 +212,7 @@ cognite/neat/rules/issues/spreadsheet.py,sha256=jBEczqon1G0H_mCfdCCffWdRLHO5ER8S
212
212
  cognite/neat/rules/issues/spreadsheet_file.py,sha256=YCp0Pk_TsiqYuOPdWpjUpre-zvi2c5_MvrC_dxw10YY,4964
213
213
  cognite/neat/rules/models/__init__.py,sha256=aqhQUidHYgOk5_iqdi6s72s2g8qyMRFXShYzh-ctNpw,782
214
214
  cognite/neat/rules/models/_base.py,sha256=7GUCflYZ7CDVyRZTYd4CYQJr7tPnMefd-1B9UktaWpY,11194
215
+ cognite/neat/rules/models/_constants.py,sha256=zPREgHT79_4FMg58QlaXc7A8XKRJrjP5SUgh63jDnTk,31
215
216
  cognite/neat/rules/models/_rdfpath.py,sha256=RoHnfWufjnDtwJh7UUzWKoJz8luvX7Gb5SDQORfkQTE,11030
216
217
  cognite/neat/rules/models/_types/__init__.py,sha256=l1tGxzE7ezNHIL72AoEvNHN2IFuitxOLxiHJG__s6t4,305
217
218
  cognite/neat/rules/models/_types/_base.py,sha256=2GhLUE1ukV8X8SGL_JDxpbWGZyAvOnSqAE6JmDh5wbI,929
@@ -224,11 +225,11 @@ cognite/neat/rules/models/dms/_rules.py,sha256=XTIEWG49VjNs_bICGlgMd6uk4hseY1H6U
224
225
  cognite/neat/rules/models/dms/_rules_input.py,sha256=apDDTQll9UAyYL5gS2vDxHsujWrGBilTp7lK2kzJWO8,13467
225
226
  cognite/neat/rules/models/dms/_schema.py,sha256=byMG67i80a4sSQS_0k8YGrDvh7whio4iLbmPEIy_P44,49514
226
227
  cognite/neat/rules/models/dms/_serializer.py,sha256=iqp2zyyf8jEcU-R3PERuN8nu248xIqyxiWj4owAn92g,6406
227
- cognite/neat/rules/models/dms/_validation.py,sha256=nPSyfM1vGZ7d9Uv_2vF2HvMetygtehXW7eNtPD6eW8E,13937
228
+ cognite/neat/rules/models/dms/_validation.py,sha256=5mk9L99FSwC8Ok7weEjnFJ_OZnmqMWUc6XFMTfkqfDw,14549
228
229
  cognite/neat/rules/models/domain.py,sha256=wZ-DeIPFnacbNlxSrRuLzUpnhHdTpzNc22z0sDfisi4,2880
229
230
  cognite/neat/rules/models/entities.py,sha256=lkLsKg8U3Xto30PCB85ScDpv2SPRVq1ukVEQHzH53_g,18868
230
231
  cognite/neat/rules/models/information/__init__.py,sha256=HR6g8xgyU53U7Ck8pPdbT70817Q4NC1r1pCRq5SA8iw,291
231
- cognite/neat/rules/models/information/_converter.py,sha256=JN63_G5bygdL5WCz-q0_ygiU0NHkzUxm5mZ3WD8yUes,11029
232
+ cognite/neat/rules/models/information/_converter.py,sha256=r0a2uyzv8m82xzAkYt_-ZXdMN5u46SA_mn95Oo7ng-s,11424
232
233
  cognite/neat/rules/models/information/_rules.py,sha256=ZVTOn5fEB-AbrXL8A6SN9DwOmF9FhgyS7FzibrkT6ZM,13546
233
234
  cognite/neat/rules/models/information/_rules_input.py,sha256=xmcQQl2vBYSG_IbxOwb6x4CdN3nIg_TY2-3RAeGDYic,10418
234
235
  cognite/neat/rules/models/information/_serializer.py,sha256=yti9I_xJruxrib66YIBInhze___Io-oPTQH6uWDumPE,3503
@@ -293,8 +294,8 @@ cognite/neat/workflows/steps_registry.py,sha256=fkTX14ZA7_gkUYfWIlx7A1XbCidvqR23
293
294
  cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
294
295
  cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
295
296
  cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
296
- cognite_neat-0.81.1.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
297
- cognite_neat-0.81.1.dist-info/METADATA,sha256=HvhapkfdDjeI4wNtoR6rsyloUItiSR1R9D-6VbnoIiQ,9290
298
- cognite_neat-0.81.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
299
- cognite_neat-0.81.1.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
300
- cognite_neat-0.81.1.dist-info/RECORD,,
297
+ cognite_neat-0.81.3.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
298
+ cognite_neat-0.81.3.dist-info/METADATA,sha256=OqByinJuu__bDSdYEfAoesZoqR16aVN-1kTkITzv1Gg,9290
299
+ cognite_neat-0.81.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
300
+ cognite_neat-0.81.3.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
301
+ cognite_neat-0.81.3.dist-info/RECORD,,