cognite-neat 1.0.1__py3-none-any.whl → 1.0.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.
- cognite/neat/_data_model/exporters/_table_exporter/writer.py +4 -1
- cognite/neat/_data_model/validation/dms/_base.py +55 -13
- cognite/neat/_version.py +1 -1
- {cognite_neat-1.0.1.dist-info → cognite_neat-1.0.3.dist-info}/METADATA +1 -1
- {cognite_neat-1.0.1.dist-info → cognite_neat-1.0.3.dist-info}/RECORD +7 -7
- {cognite_neat-1.0.1.dist-info → cognite_neat-1.0.3.dist-info}/WHEEL +0 -0
- {cognite_neat-1.0.1.dist-info → cognite_neat-1.0.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -23,6 +23,7 @@ from cognite.neat._data_model.models.dms import (
|
|
|
23
23
|
DataType,
|
|
24
24
|
DirectNodeRelation,
|
|
25
25
|
EnumProperty,
|
|
26
|
+
FilterAdapter,
|
|
26
27
|
ListablePropertyTypeDefinition,
|
|
27
28
|
NodeReference,
|
|
28
29
|
RequestSchema,
|
|
@@ -298,7 +299,9 @@ class DMSTableWriter:
|
|
|
298
299
|
implements=[self._create_view_entity(parent) for parent in view.implements]
|
|
299
300
|
if view.implements
|
|
300
301
|
else None,
|
|
301
|
-
filter=
|
|
302
|
+
filter=FilterAdapter.dump_json(view.filter, by_alias=True).decode(encoding="utf-8")
|
|
303
|
+
if view.filter
|
|
304
|
+
else None,
|
|
302
305
|
)
|
|
303
306
|
for view in views
|
|
304
307
|
]
|
|
@@ -224,27 +224,41 @@ class DataModelValidator(ABC):
|
|
|
224
224
|
RuntimeError: If a referenced view is not found in either local or CDF resources.
|
|
225
225
|
"""
|
|
226
226
|
|
|
227
|
-
if self.modus_operandi != "additive":
|
|
228
|
-
return self.local_resources.views_by_reference
|
|
229
|
-
|
|
230
227
|
merged_views: dict[ViewReference, ViewRequest] = {}
|
|
228
|
+
|
|
231
229
|
# Merge local views, combining properties if view exists in both
|
|
230
|
+
# if rebuild mode , self.view_references returns only local views ref
|
|
232
231
|
for view_ref in self.views_references:
|
|
233
232
|
cdf_view = self.cdf_resources.views_by_reference.get(view_ref)
|
|
234
233
|
local_view = self.local_resources.views_by_reference.get(view_ref)
|
|
235
234
|
|
|
236
|
-
if not cdf_view and not local_view:
|
|
235
|
+
if self.modus_operandi == "additive" and not cdf_view and not local_view:
|
|
237
236
|
raise RuntimeError(f"View {view_ref!s} not found in either local or CDF resources. This is a bug!")
|
|
237
|
+
elif self.modus_operandi == "rebuild" and not local_view:
|
|
238
|
+
raise RuntimeError(f"View {view_ref!s} not found in local resources. This is a bug!")
|
|
238
239
|
|
|
239
|
-
# this will later update of local properties and implements
|
|
240
240
|
merged_views[view_ref] = cast(ViewRequest, (cdf_view or local_view)).model_copy(deep=True)
|
|
241
241
|
|
|
242
|
+
# in additive mode, we start off with CDF view as base , which we will update with local
|
|
243
|
+
if (
|
|
244
|
+
self.modus_operandi == "additive"
|
|
245
|
+
or cast(ViewRequest, local_view).space != self.local_resources.data_model_reference.space
|
|
246
|
+
):
|
|
247
|
+
merged_views[view_ref] = cast(ViewRequest, (cdf_view or local_view)).model_copy(deep=True)
|
|
248
|
+
|
|
249
|
+
# rebuild mode
|
|
250
|
+
else:
|
|
251
|
+
merged_views[view_ref] = cast(ViewRequest, local_view).model_copy(deep=True)
|
|
252
|
+
|
|
253
|
+
# this will later update of local properties and implements
|
|
242
254
|
if local_view and local_view.properties:
|
|
243
255
|
if not merged_views[view_ref].properties:
|
|
244
256
|
merged_views[view_ref].properties = local_view.properties
|
|
245
257
|
else:
|
|
246
258
|
merged_views[view_ref].properties.update(local_view.properties)
|
|
247
259
|
|
|
260
|
+
# Special handling for properties which originates from implements
|
|
261
|
+
|
|
248
262
|
if local_view and local_view.implements:
|
|
249
263
|
if not merged_views[view_ref].implements:
|
|
250
264
|
merged_views[view_ref].implements = local_view.implements
|
|
@@ -253,6 +267,27 @@ class DataModelValidator(ABC):
|
|
|
253
267
|
if impl not in cast(list[ViewReference], merged_views[view_ref].implements):
|
|
254
268
|
cast(list[ViewReference], merged_views[view_ref].implements).append(impl)
|
|
255
269
|
|
|
270
|
+
# this handles an edge case where view is defined locally, implements another view, which is not
|
|
271
|
+
# present locally, but only in CDF, this could be typically the case when we define a view which
|
|
272
|
+
# implements a Core Data Model view, while not defining any of its own properties (not uncommon)
|
|
273
|
+
# locally in for example Excel sheets
|
|
274
|
+
for implement in local_view.implements:
|
|
275
|
+
if cdf_implement_view := self.cdf_resources.views_by_reference.get(implement):
|
|
276
|
+
# in rebuild mode, we skip CDF views from the same space as rebuild mode is supposed to
|
|
277
|
+
# rebuild everything from local resources only, but we still need to merge in properties
|
|
278
|
+
# from CDF implements from other spaces
|
|
279
|
+
if (
|
|
280
|
+
self.modus_operandi == "rebuild"
|
|
281
|
+
and cdf_implement_view.space == self.local_resources.data_model_reference.space
|
|
282
|
+
):
|
|
283
|
+
continue
|
|
284
|
+
|
|
285
|
+
for prop_name, prop in cdf_implement_view.properties.items():
|
|
286
|
+
if merged_views[view_ref].properties and prop_name not in merged_views[view_ref].properties:
|
|
287
|
+
merged_views[view_ref].properties[prop_name] = prop
|
|
288
|
+
elif not merged_views[view_ref].properties:
|
|
289
|
+
merged_views[view_ref].properties = {prop_name: prop}
|
|
290
|
+
|
|
256
291
|
return merged_views
|
|
257
292
|
|
|
258
293
|
@cached_property
|
|
@@ -274,23 +309,30 @@ class DataModelValidator(ABC):
|
|
|
274
309
|
RuntimeError: If a referenced container is not found in either local or CDF resources.
|
|
275
310
|
"""
|
|
276
311
|
|
|
277
|
-
if self.modus_operandi != "additive":
|
|
278
|
-
return self.local_resources.containers_by_reference
|
|
279
|
-
|
|
280
312
|
merged_containers: dict[ContainerReference, ContainerRequest] = {}
|
|
281
313
|
# Merge local containers, combining properties if container exists in both
|
|
282
314
|
for container_ref in self.container_references:
|
|
283
315
|
cdf_container = self.cdf_resources.containers_by_reference.get(container_ref)
|
|
284
316
|
local_container = self.local_resources.containers_by_reference.get(container_ref)
|
|
285
317
|
|
|
286
|
-
if not cdf_container and not local_container:
|
|
318
|
+
if self.modus_operandi == "additive" and not cdf_container and not local_container:
|
|
287
319
|
raise RuntimeError(
|
|
288
320
|
f"Container {container_ref!s} not found in either local or CDF resources. This is a bug!"
|
|
289
321
|
)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
322
|
+
elif self.modus_operandi == "rebuild" and not local_container:
|
|
323
|
+
raise RuntimeError(f"Container {container_ref!s} not found in local resources. This is a bug!")
|
|
324
|
+
|
|
325
|
+
# in additive mode, we start off with CDF container as base , which we will update with local
|
|
326
|
+
if (
|
|
327
|
+
self.modus_operandi == "additive"
|
|
328
|
+
or cast(ContainerRequest, local_container).space != self.local_resources.data_model_reference.space
|
|
329
|
+
):
|
|
330
|
+
merged_containers[container_ref] = cast(
|
|
331
|
+
ContainerRequest, (cdf_container or local_container)
|
|
332
|
+
).model_copy(deep=True)
|
|
333
|
+
|
|
334
|
+
else: # rebuild mode
|
|
335
|
+
merged_containers[container_ref] = cast(ContainerRequest, local_container).model_copy(deep=True)
|
|
294
336
|
|
|
295
337
|
if local_container and local_container.properties:
|
|
296
338
|
if not merged_containers[container_ref].properties:
|
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.3"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -2,7 +2,7 @@ cognite/neat/__init__.py,sha256=u5EhnGuNS2GKydU6lVFCNrBpHBBKUnCDAE63Cqk__eo,244
|
|
|
2
2
|
cognite/neat/_config.py,sha256=NXObeA-860LV40KlY4orsqjMGACa0jKRz2UE5L9kH6U,8401
|
|
3
3
|
cognite/neat/_exceptions.py,sha256=ox-5hXpee4UJlPE7HpuEHV2C96aLbLKo-BhPDoOAzhA,1650
|
|
4
4
|
cognite/neat/_issues.py,sha256=wH1mnkrpBsHUkQMGUHFLUIQWQlfJ_qMfdF7q0d9wNhY,1871
|
|
5
|
-
cognite/neat/_version.py,sha256=
|
|
5
|
+
cognite/neat/_version.py,sha256=frvUE6medkh8ryei1FSKVbaV9GjqKvs0ByOYDnxdRO0,44
|
|
6
6
|
cognite/neat/legacy.py,sha256=eI2ecxOV8ilGHyLZlN54ve_abtoK34oXognkFv3yvF0,219
|
|
7
7
|
cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
cognite/neat/_client/__init__.py,sha256=75Bh7eGhaN4sOt3ZcRzHl7pXaheu1z27kmTHeaI05vo,114
|
|
@@ -34,7 +34,7 @@ cognite/neat/_data_model/exporters/_base.py,sha256=rG_qAU5i5Hh5hUMep2UmDFFZID4x3
|
|
|
34
34
|
cognite/neat/_data_model/exporters/_table_exporter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
cognite/neat/_data_model/exporters/_table_exporter/exporter.py,sha256=4BPu_Chtjh1EyOaKbThXYohsqllVOkCbSoNekNZuBXc,5159
|
|
36
36
|
cognite/neat/_data_model/exporters/_table_exporter/workbook.py,sha256=1Afk1WqeNe9tiNeSAm0HrF8jTQ1kTbIv1D9hMztKwO8,18482
|
|
37
|
-
cognite/neat/_data_model/exporters/_table_exporter/writer.py,sha256=
|
|
37
|
+
cognite/neat/_data_model/exporters/_table_exporter/writer.py,sha256=WAXPXjbIXrKtAKebXQ3npShbgWs_rUwdyQsCsm_jt3I,19374
|
|
38
38
|
cognite/neat/_data_model/importers/__init__.py,sha256=dHnKnC_AXk42z6wzEHK15dxIOh8xSEkuUf_AFRZls0E,193
|
|
39
39
|
cognite/neat/_data_model/importers/_api_importer.py,sha256=H8Ow3Tt7utuAuBhC6s7yWvhGqunHAtE0r0XRsVAr6IE,7280
|
|
40
40
|
cognite/neat/_data_model/importers/_base.py,sha256=NRB0FcEBj4GaethU68nRffBfTedBBA866A3zfJNfmiQ,433
|
|
@@ -76,7 +76,7 @@ cognite/neat/_data_model/models/entities/_parser.py,sha256=zef_pSDZYMZrJl4IKreFD
|
|
|
76
76
|
cognite/neat/_data_model/validation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
77
77
|
cognite/neat/_data_model/validation/dms/__init__.py,sha256=kKD18-Bg_G-w11Cs7Wv_TKV0C_q62Pm2RKLpOz27ar4,2642
|
|
78
78
|
cognite/neat/_data_model/validation/dms/_ai_readiness.py,sha256=hFrnRzBBf143ejLHRk3BpylzrVpxUX537BouOlv4PFE,15552
|
|
79
|
-
cognite/neat/_data_model/validation/dms/_base.py,sha256=
|
|
79
|
+
cognite/neat/_data_model/validation/dms/_base.py,sha256=207zS_aTQYZc16jLHfJSz5Idma0ZAgIuZZjVFnN0q4A,16271
|
|
80
80
|
cognite/neat/_data_model/validation/dms/_connections.py,sha256=6ea8WZNqYT9SPluwXvg0mgDJpzZMqpPC5xonbdLrT4E,27305
|
|
81
81
|
cognite/neat/_data_model/validation/dms/_consistency.py,sha256=uJ6coAVupD3WfeeXxoCIebM8WSnR78GXBXIBnN59aao,2477
|
|
82
82
|
cognite/neat/_data_model/validation/dms/_containers.py,sha256=UuvzrBBw45F5f9uzCh97lW4t7m7XIIT1I9FnzzYUYv4,7533
|
|
@@ -312,7 +312,7 @@ cognite/neat/_v0/session/_to.py,sha256=AnsRSDDdfFyYwSgi0Z-904X7WdLtPfLlR0x1xsu_j
|
|
|
312
312
|
cognite/neat/_v0/session/_wizard.py,sha256=baPJgXAAF3d1bn4nbIzon1gWfJOeS5T43UXRDJEnD3c,1490
|
|
313
313
|
cognite/neat/_v0/session/exceptions.py,sha256=jv52D-SjxGfgqaHR8vnpzo0SOJETIuwbyffSWAxSDJw,3495
|
|
314
314
|
cognite/neat/_v0/session/_state/README.md,sha256=o6N7EL98lgyWffw8IoEUf2KG5uSKveD5__TW45YzVjA,902
|
|
315
|
-
cognite_neat-1.0.
|
|
316
|
-
cognite_neat-1.0.
|
|
317
|
-
cognite_neat-1.0.
|
|
318
|
-
cognite_neat-1.0.
|
|
315
|
+
cognite_neat-1.0.3.dist-info/METADATA,sha256=8WESd9hWsL4-9kskDTTa4oYXY_Dv9RJJiy2W8ngdBLA,6030
|
|
316
|
+
cognite_neat-1.0.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
317
|
+
cognite_neat-1.0.3.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
318
|
+
cognite_neat-1.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|