cognite-neat 0.127.25__py3-none-any.whl → 0.127.26__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.
@@ -1,10 +1,11 @@
1
+ import itertools
1
2
  from collections import UserList
2
3
  from dataclasses import dataclass, field
3
4
  from datetime import datetime
4
5
  from typing import Any
5
6
 
6
7
  from cognite.neat._data_model.deployer.data_classes import DeploymentResult
7
- from cognite.neat._issues import IssueList
8
+ from cognite.neat._issues import ConsistencyError, IssueList, ModelSyntaxError
8
9
  from cognite.neat._state_machine import State
9
10
 
10
11
 
@@ -35,6 +36,15 @@ class Change:
35
36
  """Check if change was successful"""
36
37
  return not self.errors
37
38
 
39
+ @property
40
+ def error_count(self) -> int:
41
+ """Get number of errors"""
42
+ return sum(
43
+ 1
44
+ for issue in itertools.chain(self.issues or [], self.errors or [])
45
+ if isinstance(issue, ModelSyntaxError | ConsistencyError)
46
+ )
47
+
38
48
  def as_mixpanel_event(self) -> dict[str, Any]:
39
49
  """Convert change to mixpanel event format"""
40
50
  return {
@@ -62,6 +62,7 @@ class NeatStore:
62
62
  def _can_agent_do_activity(self, agent: Agents) -> None:
63
63
  """Validate if activity can be performed in the current state and considering provenance"""
64
64
  if not self.state.can_transition(agent):
65
+ # specific error messages for common mistakes
65
66
  if isinstance(agent, DMSImporter) and isinstance(self.state, PhysicalState):
66
67
  raise RuntimeError(
67
68
  "⚠️ Cannot read data model, there is already a data model in the session!"
@@ -75,6 +76,17 @@ class NeatStore:
75
76
  )
76
77
  raise RuntimeError(f"Cannot run {type(agent).__name__} in state {self.state}")
77
78
 
79
+ if (
80
+ isinstance(agent, DMSExporter)
81
+ and self.provenance.last_change
82
+ and (error_count := self.provenance.last_change.error_count) > 0
83
+ ):
84
+ raise RuntimeError(
85
+ f"⚠️ Cannot write data model, the model has {error_count} errors!"
86
+ f"{NEWLINE}Resolve issues before exporting the data model."
87
+ f"{NEWLINE}You can inspect issues using neat.issues"
88
+ )
89
+
78
90
  # need implementation of checking if required predecessor activities have been done
79
91
  # this will be done by running self.provenance.can_agent_do_activity(agent)
80
92
 
cognite/neat/_version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.127.25"
1
+ __version__ = "0.127.26"
2
2
  __engine__ = "^2.0.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite-neat
3
- Version: 0.127.25
3
+ Version: 0.127.26
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,7 +1,7 @@
1
1
  cognite/neat/__init__.py,sha256=Lo4DbjDOwnhCYUoAgPp5RG1fDdF7OlnomalTe7n1ydw,211
2
2
  cognite/neat/_exceptions.py,sha256=ox-5hXpee4UJlPE7HpuEHV2C96aLbLKo-BhPDoOAzhA,1650
3
3
  cognite/neat/_issues.py,sha256=wH1mnkrpBsHUkQMGUHFLUIQWQlfJ_qMfdF7q0d9wNhY,1871
4
- cognite/neat/_version.py,sha256=Hsl6r_Z4Ik-HLkbCToNXmmjME2_bdiVlGTB06JNU8HM,47
4
+ cognite/neat/_version.py,sha256=zp1q6MhRkZE6P6k0LZ7xa5KjU1ZbL4JI5oVv8qlg_5Q,47
5
5
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  cognite/neat/v1.py,sha256=owqW5Mml2DSZx1AvPvwNRTBngfhBNrQ6EH-7CKL7Jp0,61
7
7
  cognite/neat/_client/__init__.py,sha256=75Bh7eGhaN4sOt3ZcRzHl7pXaheu1z27kmTHeaI05vo,114
@@ -108,8 +108,8 @@ cognite/neat/_state_machine/__init__.py,sha256=wrtQUHETiLzYM0pFo7JC6pJCiXetHADQb
108
108
  cognite/neat/_state_machine/_base.py,sha256=-ZpeAhM6l6N6W70dET25tAzOxaaK5aa474eabwZVzjA,1112
109
109
  cognite/neat/_state_machine/_states.py,sha256=nmj4SmunpDYcBsNx8A284xnXGS43wuUuWpMMORha2DE,1170
110
110
  cognite/neat/_store/__init__.py,sha256=TvM9CcFbtOSrxydPAuJi6Bv_iiGard1Mxfx42ZFoTl0,55
111
- cognite/neat/_store/_provenance.py,sha256=WGRRLVmYrYEOjeouZj7GvoAlMzCN6vchzpSEKsKNYe0,2772
112
- cognite/neat/_store/_store.py,sha256=RiMJccn44gWxpM1SqPbnt3nzgMgYBeUaapfk4fY9Ikg,6250
111
+ cognite/neat/_store/_provenance.py,sha256=tWQGa2QNPyW7FfHQBRto9eHXCxeOTzlz7DvYjAwHfuY,3102
112
+ cognite/neat/_store/_store.py,sha256=Ql1nZvq2UtNoI-L1OmIUFQGXQ4i5-Zche28-YHnBkyg,6775
113
113
  cognite/neat/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
114
  cognite/neat/_utils/_reader.py,sha256=9dXrODNNqWU0Gx1zXjRTOiiByFuDZlpQkQEzx3HAxYQ,5390
115
115
  cognite/neat/_utils/auxiliary.py,sha256=Cx-LP8dfN782R3iUcm--q26zdzQ0k_RFnVbJ0bwVZMI,1345
@@ -312,7 +312,7 @@ cognite/neat/v0/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4
312
312
  cognite/neat/v0/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
313
313
  cognite/neat/v0/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
314
314
  cognite/neat/v0/session/engine/_load.py,sha256=u0x7vuQCRoNcPt25KJBJRn8sJabonYK4vtSZpiTdP4k,5201
315
- cognite_neat-0.127.25.dist-info/METADATA,sha256=t6VBbJO1-wAlt1FwCCk-rq9Pcdood0JN3AIw8SwdyTI,9150
316
- cognite_neat-0.127.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
317
- cognite_neat-0.127.25.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
318
- cognite_neat-0.127.25.dist-info/RECORD,,
315
+ cognite_neat-0.127.26.dist-info/METADATA,sha256=W1EY7XRW7rN7oqdEfS1UMJW1drv2KQyTFuDIH8V1Yh4,9150
316
+ cognite_neat-0.127.26.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
317
+ cognite_neat-0.127.26.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
318
+ cognite_neat-0.127.26.dist-info/RECORD,,