cognite-neat 1.0.15__py3-none-any.whl → 1.0.17__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/deployer/data_classes.py +20 -0
- cognite/neat/_data_model/models/dms/_view_filter.py +4 -1
- cognite/neat/_store/_provenance.py +7 -0
- cognite/neat/_store/_store.py +34 -1
- cognite/neat/_version.py +1 -1
- {cognite_neat-1.0.15.dist-info → cognite_neat-1.0.17.dist-info}/METADATA +1 -1
- {cognite_neat-1.0.15.dist-info → cognite_neat-1.0.17.dist-info}/RECORD +8 -8
- {cognite_neat-1.0.15.dist-info → cognite_neat-1.0.17.dist-info}/WHEEL +1 -1
|
@@ -622,3 +622,23 @@ class DeploymentResult(BaseDeployObject):
|
|
|
622
622
|
|
|
623
623
|
output.update(counts)
|
|
624
624
|
return output
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def humanize_changes(changes: Sequence[FieldChange]) -> str:
|
|
628
|
+
primitive_changes = get_primitive_changes(changes)
|
|
629
|
+
lines = []
|
|
630
|
+
for change in primitive_changes:
|
|
631
|
+
lines.append(f"- Field '{change.field_path}': {change.description}")
|
|
632
|
+
return "\n".join(lines)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def get_primitive_changes(changes: Sequence[FieldChange]) -> list[PrimitiveField]:
|
|
636
|
+
primitive_changes: list[PrimitiveField] = []
|
|
637
|
+
for change in changes:
|
|
638
|
+
if isinstance(change, FieldChanges):
|
|
639
|
+
primitive_changes.extend(get_primitive_changes(change.changes))
|
|
640
|
+
elif isinstance(change, PrimitiveField):
|
|
641
|
+
primitive_changes.append(change)
|
|
642
|
+
else:
|
|
643
|
+
raise NotImplementedError(f"Unknown FieldChange type: {type(change)}")
|
|
644
|
+
return primitive_changes
|
|
@@ -250,6 +250,9 @@ def _move_filter_key(value: Any) -> Any:
|
|
|
250
250
|
return value
|
|
251
251
|
if len(value) != 1:
|
|
252
252
|
raise ValueError("Filter data must have exactly one key.")
|
|
253
|
+
# legacy filter which we want to ignore
|
|
254
|
+
if "invalid" in value:
|
|
255
|
+
return None
|
|
253
256
|
if "filterType" in value:
|
|
254
257
|
# Already in the correct format
|
|
255
258
|
return value
|
|
@@ -280,6 +283,6 @@ def _move_filter_key(value: Any) -> Any:
|
|
|
280
283
|
return value
|
|
281
284
|
|
|
282
285
|
|
|
283
|
-
Filter = Annotated[dict[FilterTypes, FilterData], BeforeValidator(_move_filter_key)]
|
|
286
|
+
Filter = Annotated[dict[FilterTypes, FilterData] | None, BeforeValidator(_move_filter_key)]
|
|
284
287
|
|
|
285
288
|
FilterAdapter: TypeAdapter[Filter] = TypeAdapter(Filter)
|
|
@@ -79,3 +79,10 @@ class Provenance(UserList[Change]):
|
|
|
79
79
|
def provenance_without_failures(self) -> "Provenance":
|
|
80
80
|
"""This method removes all the failed changes from the provenance list."""
|
|
81
81
|
raise NotImplementedError("Not implemented yet")
|
|
82
|
+
|
|
83
|
+
def last_physical_data_model_read(self) -> Change | None:
|
|
84
|
+
"""Get last physical data model read change"""
|
|
85
|
+
for change in reversed(self):
|
|
86
|
+
if change.activity.startswith("to_data_model"):
|
|
87
|
+
return change
|
|
88
|
+
return None
|
cognite/neat/_store/_store.py
CHANGED
|
@@ -11,7 +11,9 @@ from cognite.neat._data_model.deployer.data_classes import DeploymentResult
|
|
|
11
11
|
from cognite.neat._data_model.deployer.deployer import SchemaDeployer
|
|
12
12
|
from cognite.neat._data_model.exporters import DMSExporter, DMSFileExporter
|
|
13
13
|
from cognite.neat._data_model.exporters._api_exporter import DMSAPIExporter
|
|
14
|
+
from cognite.neat._data_model.exporters._table_exporter.exporter import DMSTableExporter
|
|
14
15
|
from cognite.neat._data_model.importers import DMSImporter, DMSTableImporter
|
|
16
|
+
from cognite.neat._data_model.importers._api_importer import DMSAPIImporter
|
|
15
17
|
from cognite.neat._data_model.models.dms import RequestSchema as PhysicalDataModel
|
|
16
18
|
from cognite.neat._data_model.models.dms._limits import SchemaLimits
|
|
17
19
|
from cognite.neat._exceptions import DataModelImportException
|
|
@@ -62,7 +64,9 @@ class NeatStore:
|
|
|
62
64
|
else:
|
|
63
65
|
activity = writer.export
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
data_model = self._gather_data_model(writer)
|
|
68
|
+
|
|
69
|
+
change, _ = self._do_activity(activity, on_success, data_model=data_model, **kwargs)
|
|
66
70
|
|
|
67
71
|
if not change.issues:
|
|
68
72
|
change.target_entity = "ExternalEntity"
|
|
@@ -79,6 +83,35 @@ class NeatStore:
|
|
|
79
83
|
# Update CDF snapshot after successful deployment
|
|
80
84
|
self.cdf_snapshot = SchemaSnapshot.fetch_entire_cdf(self._client)
|
|
81
85
|
|
|
86
|
+
def _gather_data_model(self, writer: DMSExporter) -> PhysicalDataModel:
|
|
87
|
+
"""Gather the current physical data model from the store
|
|
88
|
+
|
|
89
|
+
Args:
|
|
90
|
+
writer (DMSExporter): The exporter that will be used to write the data model.
|
|
91
|
+
"""
|
|
92
|
+
# getting provenance of the last successful physical data model read
|
|
93
|
+
change = self.provenance.last_physical_data_model_read()
|
|
94
|
+
|
|
95
|
+
if not change:
|
|
96
|
+
raise RuntimeError("No successful physical data model read found in provenance.")
|
|
97
|
+
|
|
98
|
+
# We do not want to modify the data model for API representations
|
|
99
|
+
if not (change.agent == DMSAPIImporter.__name__ and isinstance(writer, DMSTableExporter)):
|
|
100
|
+
return self.physical_data_model[-1]
|
|
101
|
+
|
|
102
|
+
# This will handle data model that are partially and require to be converted to
|
|
103
|
+
# tabular representation to include all containers referenced by views.
|
|
104
|
+
copy = self.physical_data_model[-1].model_copy(deep=True)
|
|
105
|
+
container_refs = {container.as_reference() for container in copy.containers}
|
|
106
|
+
|
|
107
|
+
for view in copy.views:
|
|
108
|
+
for container in view.used_containers:
|
|
109
|
+
if container not in container_refs and (cdf_container := self.cdf_snapshot.containers.get(container)):
|
|
110
|
+
copy.containers.append(cdf_container)
|
|
111
|
+
container_refs.add(container)
|
|
112
|
+
|
|
113
|
+
return copy
|
|
114
|
+
|
|
82
115
|
def _can_agent_do_activity(self, agent: Agents) -> None:
|
|
83
116
|
"""Validate if activity can be performed in the current state and considering provenance"""
|
|
84
117
|
if not self.state.can_transition(agent):
|
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "1.0.
|
|
1
|
+
__version__ = "1.0.17"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.17
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
Author: Nikola Vasiljevic, Anders Albert
|
|
6
6
|
Author-email: Nikola Vasiljevic <nikola.vasiljevic@cognite.com>, Anders Albert <anders.albert@cognite.com>
|
|
@@ -22,7 +22,7 @@ cognite/neat/_data_model/deployer/_differ_container.py,sha256=mcy7PhUOfnvAxnZWNo
|
|
|
22
22
|
cognite/neat/_data_model/deployer/_differ_data_model.py,sha256=iA7Xp-7NRvzZJXLLpJaLebkKKpv_VCBKPX6f-RU9wBk,1864
|
|
23
23
|
cognite/neat/_data_model/deployer/_differ_space.py,sha256=J_AaqiseLpwQsOkKc7gmho4U2oSWAGVeEdQNepZiWw0,343
|
|
24
24
|
cognite/neat/_data_model/deployer/_differ_view.py,sha256=g1xHwsoxFUaTOTtQa19nntKF3rxFzc2FxpKKFAUN_NE,11412
|
|
25
|
-
cognite/neat/_data_model/deployer/data_classes.py,sha256=
|
|
25
|
+
cognite/neat/_data_model/deployer/data_classes.py,sha256=cq86u7wuKCcvH-A_cGI_gWzlQCTIG6mrXG2MahdiGco,27299
|
|
26
26
|
cognite/neat/_data_model/deployer/deployer.py,sha256=acMGnAeZnfFf-kzN5UFDiErT48bsTW7qsXhwdt9h-Mw,19096
|
|
27
27
|
cognite/neat/_data_model/exporters/__init__.py,sha256=AskjmB_0Vqib4kN84bWt8-M8nO42QypFf-l-E8oA5W8,482
|
|
28
28
|
cognite/neat/_data_model/exporters/_api_exporter.py,sha256=G9cqezy_SH8VdhW4o862qBHh_QcbzfP6O1Yyjvdpeog,1579
|
|
@@ -60,7 +60,7 @@ cognite/neat/_data_model/models/dms/_references.py,sha256=Mx_nxfvOrvAx7nvebhhbFw
|
|
|
60
60
|
cognite/neat/_data_model/models/dms/_schema.py,sha256=2JFLcm52smzPdtZ69Lf02UbYAD8I_hpRbI7ZAzdxJJs,641
|
|
61
61
|
cognite/neat/_data_model/models/dms/_space.py,sha256=3KvWg0bVuLpgQwhkDbsJ53ZMMmK0cKUgfyDRrSrERko,1904
|
|
62
62
|
cognite/neat/_data_model/models/dms/_types.py,sha256=5-cgC53AG186OZUqkltv7pMjcGNLuH7Etbn8IUcgk1c,447
|
|
63
|
-
cognite/neat/_data_model/models/dms/_view_filter.py,sha256=
|
|
63
|
+
cognite/neat/_data_model/models/dms/_view_filter.py,sha256=uV5cI8CA_L28Ry2KhH_bSwOx1zru31s5J5ak7TGVPj0,10577
|
|
64
64
|
cognite/neat/_data_model/models/dms/_view_property.py,sha256=nJBPmw4KzJOdaQmvRfCE3A4FL-E13OsNUEufI64vLKo,9271
|
|
65
65
|
cognite/neat/_data_model/models/dms/_views.py,sha256=oWSqp9_tBNwKQgj4xKICQKE3f89Ya6Xyjcms-I66zN0,8931
|
|
66
66
|
cognite/neat/_data_model/models/entities/__init__.py,sha256=7dDyES7fYl9LEREal59F038RdEvfGRpUOc6n_MtSgjU,836
|
|
@@ -112,8 +112,8 @@ cognite/neat/_state_machine/__init__.py,sha256=wrtQUHETiLzYM0pFo7JC6pJCiXetHADQb
|
|
|
112
112
|
cognite/neat/_state_machine/_base.py,sha256=-ZpeAhM6l6N6W70dET25tAzOxaaK5aa474eabwZVzjA,1112
|
|
113
113
|
cognite/neat/_state_machine/_states.py,sha256=nmj4SmunpDYcBsNx8A284xnXGS43wuUuWpMMORha2DE,1170
|
|
114
114
|
cognite/neat/_store/__init__.py,sha256=TvM9CcFbtOSrxydPAuJi6Bv_iiGard1Mxfx42ZFoTl0,55
|
|
115
|
-
cognite/neat/_store/_provenance.py,sha256=
|
|
116
|
-
cognite/neat/_store/_store.py,sha256=
|
|
115
|
+
cognite/neat/_store/_provenance.py,sha256=1zzRDWjR9twZu2jVyIG3UdYdIXtQKJ7uF8a0hV7LEuA,3368
|
|
116
|
+
cognite/neat/_store/_store.py,sha256=Jibx6kKAH8V6iUOegDOcSLTplGLxmuXCLfjbdff_wvI,9367
|
|
117
117
|
cognite/neat/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
118
118
|
cognite/neat/_utils/_reader.py,sha256=9dXrODNNqWU0Gx1zXjRTOiiByFuDZlpQkQEzx3HAxYQ,5390
|
|
119
119
|
cognite/neat/_utils/auxiliary.py,sha256=Cx-LP8dfN782R3iUcm--q26zdzQ0k_RFnVbJ0bwVZMI,1345
|
|
@@ -316,9 +316,9 @@ cognite/neat/_v0/session/_template.py,sha256=BNcvrW5y7LWzRM1XFxZkfR1Nc7e8UgjBClH
|
|
|
316
316
|
cognite/neat/_v0/session/_to.py,sha256=AnsRSDDdfFyYwSgi0Z-904X7WdLtPfLlR0x1xsu_jAo,19447
|
|
317
317
|
cognite/neat/_v0/session/_wizard.py,sha256=baPJgXAAF3d1bn4nbIzon1gWfJOeS5T43UXRDJEnD3c,1490
|
|
318
318
|
cognite/neat/_v0/session/exceptions.py,sha256=jv52D-SjxGfgqaHR8vnpzo0SOJETIuwbyffSWAxSDJw,3495
|
|
319
|
-
cognite/neat/_version.py,sha256=
|
|
319
|
+
cognite/neat/_version.py,sha256=o7GgrsHFEMJXof4FVslWa-ZccQkVdswvAIXHizqt_1I,45
|
|
320
320
|
cognite/neat/legacy.py,sha256=eI2ecxOV8ilGHyLZlN54ve_abtoK34oXognkFv3yvF0,219
|
|
321
321
|
cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
322
|
-
cognite_neat-1.0.
|
|
323
|
-
cognite_neat-1.0.
|
|
324
|
-
cognite_neat-1.0.
|
|
322
|
+
cognite_neat-1.0.17.dist-info/WHEEL,sha256=KSLUh82mDPEPk0Bx0ScXlWL64bc8KmzIPNcpQZFV-6E,79
|
|
323
|
+
cognite_neat-1.0.17.dist-info/METADATA,sha256=o2xcMmYzEhkFNrboqpljF7fhET9EL6vJvjnUXdd15YI,6091
|
|
324
|
+
cognite_neat-1.0.17.dist-info/RECORD,,
|