cognite-neat 0.115.0__py3-none-any.whl → 0.115.1__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.

@@ -165,6 +165,9 @@ class NeatSession:
165
165
  neat.convert()
166
166
  ```
167
167
  """
168
+ self._state._raise_exception_if_condition_not_met(
169
+ "Convert to physical", has_dms_rules=False, has_information_rules=True
170
+ )
168
171
  converter = InformationToDMS(reserved_properties=reserved_properties)
169
172
 
170
173
  issues = self._state.rule_transform(converter)
@@ -362,6 +362,11 @@ class ExcelReadAPI(BaseReadAPI):
362
362
  if enable_manual_edit:
363
363
  warnings.filterwarnings("default")
364
364
  AlphaFlags.manual_rules_edit.warn()
365
+ else:
366
+ self._state._raise_exception_if_condition_not_met(
367
+ "Read Excel Rules",
368
+ empty_rules_store_required=True,
369
+ )
365
370
 
366
371
  return self._state.rule_import(importers.ExcelImporter(path), enable_manual_edit)
367
372
 
@@ -381,6 +386,10 @@ class YamlReadAPI(BaseReadAPI):
381
386
  neat.read.yaml("path_to_toolkit_yamls")
382
387
  ```
383
388
  """
389
+ self._state._raise_exception_if_condition_not_met(
390
+ "Read YAML data model",
391
+ empty_rules_store_required=True,
392
+ )
384
393
  reader = NeatReader.create(io)
385
394
  path = reader.materialize_path()
386
395
  importer: BaseImporter
@@ -634,6 +643,10 @@ class RDFReadAPI(BaseReadAPI):
634
643
  return self._state.rule_import(importer)
635
644
 
636
645
  def instances(self, io: Any) -> IssueList:
646
+ self._state._raise_exception_if_condition_not_met(
647
+ "Read RDF Instances",
648
+ empty_rules_store_required=True,
649
+ )
637
650
  reader = NeatReader.create(io)
638
651
  self._state.instances.store.write(extractors.RdfFileExtractor(reader.materialize_path()))
639
652
  return IssueList()
@@ -71,14 +71,23 @@ class SessionState:
71
71
  empty_instances_store_required: bool = False,
72
72
  instances_required: bool = False,
73
73
  client_required: bool = False,
74
+ has_information_rules: bool | None = None,
75
+ has_dms_rules: bool | None = None,
74
76
  ) -> None:
75
77
  """Set conditions for raising an error in the session that are used by various methods in the session."""
76
78
  condition = set()
77
79
  suggestion = set()
78
-
80
+ try_again = True
79
81
  if client_required and not self.client:
80
82
  condition.add(f"{activity} expects a client in NEAT session")
81
83
  suggestion.add("Please provide a client")
84
+ if has_information_rules is True and self.rule_store.try_get_last_information_rules is None:
85
+ condition.add(f"{activity} expects information rules in NEAT session")
86
+ suggestion.add("Read in information rules to neat session")
87
+ if has_dms_rules is False and self.rule_store.try_get_last_dms_rules is not None:
88
+ condition.add(f"{activity} expects no DMS data model in NEAT session")
89
+ suggestion.add("You already have a DMS data model in the session")
90
+ try_again = False
82
91
  if empty_rules_store_required and not self.rule_store.empty:
83
92
  condition.add(f"{activity} expects no data model in NEAT session")
84
93
  suggestion.add("Start new session")
@@ -90,7 +99,10 @@ class SessionState:
90
99
  suggestion.add("Read in instances to neat session")
91
100
 
92
101
  if condition:
93
- raise NeatSessionError(". ".join(condition) + ". " + ". ".join(suggestion) + ". And try again.")
102
+ message = ". ".join(condition) + ". " + ". ".join(suggestion) + "."
103
+ if try_again:
104
+ message += " And try again."
105
+ raise NeatSessionError(message)
94
106
 
95
107
 
96
108
  class InstancesState:
@@ -421,6 +421,20 @@ class NeatRulesStore:
421
421
  self._iteration_by_id[identifier] += 1
422
422
  return identifier + f"/Iteration_{self._iteration_by_id[identifier]}"
423
423
 
424
+ @property
425
+ def try_get_last_dms_rules(self) -> DMSRules | None:
426
+ if not self.provenance:
427
+ return None
428
+ if self.provenance[-1].target_entity.dms is None:
429
+ return None
430
+ return self.provenance[-1].target_entity.dms
431
+
432
+ @property
433
+ def try_get_last_information_rules(self) -> InformationRules | None:
434
+ if not self.provenance:
435
+ return None
436
+ return self.provenance[-1].target_entity.information
437
+
424
438
  @property
425
439
  def last_verified_dms_rules(self) -> DMSRules:
426
440
  if not self.provenance:
cognite/neat/_version.py CHANGED
@@ -1,2 +1,2 @@
1
- __version__ = "0.115.0"
1
+ __version__ = "0.115.1"
2
2
  __engine__ = "^2.0.4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cognite-neat
3
- Version: 0.115.0
3
+ Version: 0.115.1
4
4
  Summary: Knowledge graph transformation
5
5
  License: Apache-2.0
6
6
  Author: Nikola Vasiljevic
@@ -135,7 +135,7 @@ cognite/neat/_rules/transformers/_converters.py,sha256=AoCOn6t6FVvCJVUOM6dr_9p-J
135
135
  cognite/neat/_rules/transformers/_mapping.py,sha256=lIMWNnqZoyOfOGlc2k7FgasZJqudBklcHoH1qW5EeAw,18192
136
136
  cognite/neat/_rules/transformers/_verification.py,sha256=coZjoLqdfS8yrPP62T_xEKrDZc9ETbPWrLuwEVBSLZQ,4370
137
137
  cognite/neat/_session/__init__.py,sha256=fxQ5URVlUnmEGYyB8Baw7IDq-uYacqkigbc4b-Pr9Fw,58
138
- cognite/neat/_session/_base.py,sha256=h-zJdzvDGz8aOFwgyMmzolX5MFp4qf1VrF8XwiI_dAg,12157
138
+ cognite/neat/_session/_base.py,sha256=doFh7HqUXVMXPxoCNsL20TUEo30wYlQzHbjx9sAxm8k,12309
139
139
  cognite/neat/_session/_collector.py,sha256=RcOGY0DjTCCKJt9j_p0gnQXn4omhsIX2G8Aq3ZFHIt4,4218
140
140
  cognite/neat/_session/_create.py,sha256=doDCbDIWMbHCYe3cyk1obQaFdYJjvARg3X4lRUVicCk,7214
141
141
  cognite/neat/_session/_drop.py,sha256=gOkDAnddASpFxYxkPjlTyhkpNfnmDEj94GRI8tnHFR0,4167
@@ -144,10 +144,10 @@ cognite/neat/_session/_fix.py,sha256=wYXIIHKmWTNmOLr9RvDSkBJllKoomP2mCnMdB9x2ojw
144
144
  cognite/neat/_session/_inspect.py,sha256=qoBAfCQnzC40ef91gxJmhonWo1Kr_VEjBb2KhbCOO_s,10084
145
145
  cognite/neat/_session/_mapping.py,sha256=AkQwmqYH-0EgqoXHqCFwJY92hNSGzfojOelhVFlqH4c,2655
146
146
  cognite/neat/_session/_prepare.py,sha256=BZ1NurenrsZDU4tg629wnt1Iuw_zVLRA58FNTQMYS9I,12636
147
- cognite/neat/_session/_read.py,sha256=daLeRbFvW6aUZSktTDfmEMaFtfgTx0mW1AOGs_SpIIA,26732
147
+ cognite/neat/_session/_read.py,sha256=p3M97fJt8xW5Th0b6kIiJqmfOKyskKEji6adZiqMwMw,27206
148
148
  cognite/neat/_session/_set.py,sha256=dCZ5zEmNAw8tiqOGT7-EigSXOIGlfVP2ldA7nmC8LJ8,4451
149
149
  cognite/neat/_session/_show.py,sha256=2lnkud996ouwf6-aKGvU0cU0ttfMeQ3vcb__g_7Yko4,10539
150
- cognite/neat/_session/_state.py,sha256=BzDrkhxD65fXo9eUVnPz64Rzj7y1yG8CzGMcpVie_ps,5571
150
+ cognite/neat/_session/_state.py,sha256=6b0BSXm7m5-OcsF_O0A_7ec9tt8oPqH8zHImyEhVQQA,6313
151
151
  cognite/neat/_session/_subset.py,sha256=vKtBiEnOruqe_749Nd8vzRS5HIZMR-sXSxyEH9Fa6Gk,2673
152
152
  cognite/neat/_session/_to.py,sha256=_SCvLnZZqGDWypDRzOvdEfbGjTqUBVh6yrg6F3uN26M,19097
153
153
  cognite/neat/_session/_wizard.py,sha256=9idlzhZy54h2Iwupe9iXKX3RDb5jJQuBZFEouni50L0,1476
@@ -160,7 +160,7 @@ cognite/neat/_shared.py,sha256=Ov59SWYboRRsncB_5V1ZC_BAoACfNLjo80vqE5Ru6wo,2325
160
160
  cognite/neat/_store/__init__.py,sha256=RrvuZrMdezqun5dOrwHWSk26kampZcvqiHBqSFumkEE,130
161
161
  cognite/neat/_store/_graph_store.py,sha256=mWWax09ZTOUbFOpX8Gxq9yTOyduEebMvVddQ0-FvDwc,17141
162
162
  cognite/neat/_store/_provenance.py,sha256=0HeWyzvfCTxQiG2PygLLqWpdCAooVsFRckpGsnJbwzk,7260
163
- cognite/neat/_store/_rules_store.py,sha256=R-bkiNiwqGQ9udrEmamvuEidQsemFpGBif1zmf4H-QA,17713
163
+ cognite/neat/_store/_rules_store.py,sha256=CEvRKJMB-Yh_nXenPFSLrGgsEOpSyvkb-xzkMyvtHs8,18181
164
164
  cognite/neat/_store/exceptions.py,sha256=fbed_CGDdYU4oELgCL0_c5d85HGrUiYvXmL2D0WIDww,1593
165
165
  cognite/neat/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
166
  cognite/neat/_utils/auth.py,sha256=hpNQjXpM3i7r0RU13ZLen1sa78nvPd4E1Sh3j1TMK4g,14701
@@ -176,10 +176,10 @@ cognite/neat/_utils/text.py,sha256=BFJoEOQBFgpelysL92FdF0OVRVFl0q9tRNoz-oRanNc,7
176
176
  cognite/neat/_utils/time_.py,sha256=O30LUiDH9TdOYz8_a9pFqTtJdg8vEjC3qHCk8xZblG8,345
177
177
  cognite/neat/_utils/upload.py,sha256=xWtM6mFuD2QYQHaZ7zCAuGptbEpPIxcH-raWQu93-Ug,5845
178
178
  cognite/neat/_utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP2DQ,1710
179
- cognite/neat/_version.py,sha256=GLo0KGogAVNDPksL8ypcrOwW7_DTQdOnHqI9DgVtSao,46
179
+ cognite/neat/_version.py,sha256=yljJqofjcIqTDKIH7NZa9-067RSLDPmlCpJR0Bq72iI,46
180
180
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
181
- cognite_neat-0.115.0.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
182
- cognite_neat-0.115.0.dist-info/METADATA,sha256=_AkiioB7cTY4N1ChU0Rx_cXpgmwvPzFqhKYx3jZ15xY,5361
183
- cognite_neat-0.115.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
184
- cognite_neat-0.115.0.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
185
- cognite_neat-0.115.0.dist-info/RECORD,,
181
+ cognite_neat-0.115.1.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
182
+ cognite_neat-0.115.1.dist-info/METADATA,sha256=tyOrOqLVM3GozFkuENSMVRz_FdUzPrTJxVDd1rywIU0,5361
183
+ cognite_neat-0.115.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
184
+ cognite_neat-0.115.1.dist-info/entry_points.txt,sha256=SsQlnl8SNMSSjE3acBI835JYFtsIinLSbVmHmMEXv6E,51
185
+ cognite_neat-0.115.1.dist-info/RECORD,,