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

Files changed (66) hide show
  1. cognite/neat/__init__.py +1 -1
  2. cognite/neat/_app/api/routers/crud.py +1 -1
  3. cognite/neat/_client/__init__.py +1 -1
  4. cognite/neat/_client/_api/data_modeling_loaders.py +1 -1
  5. cognite/neat/_client/_api/schema.py +1 -1
  6. cognite/neat/_graph/_tracking/__init__.py +1 -1
  7. cognite/neat/_graph/extractors/__init__.py +8 -8
  8. cognite/neat/_graph/extractors/_mock_graph_generator.py +2 -3
  9. cognite/neat/_graph/loaders/_base.py +1 -1
  10. cognite/neat/_graph/loaders/_rdf2dms.py +165 -47
  11. cognite/neat/_graph/transformers/__init__.py +13 -9
  12. cognite/neat/_graph/transformers/_value_type.py +196 -2
  13. cognite/neat/_issues/__init__.py +6 -6
  14. cognite/neat/_issues/_base.py +4 -4
  15. cognite/neat/_issues/errors/__init__.py +22 -22
  16. cognite/neat/_issues/formatters.py +1 -1
  17. cognite/neat/_issues/warnings/__init__.py +20 -18
  18. cognite/neat/_issues/warnings/_properties.py +7 -0
  19. cognite/neat/_issues/warnings/user_modeling.py +2 -2
  20. cognite/neat/_rules/analysis/__init__.py +1 -1
  21. cognite/neat/_rules/catalog/__init__.py +1 -0
  22. cognite/neat/_rules/catalog/hello_world_pump.xlsx +0 -0
  23. cognite/neat/_rules/exporters/__init__.py +5 -5
  24. cognite/neat/_rules/exporters/_rules2excel.py +5 -4
  25. cognite/neat/_rules/importers/__init__.py +4 -4
  26. cognite/neat/_rules/importers/_base.py +7 -3
  27. cognite/neat/_rules/importers/_rdf/__init__.py +1 -1
  28. cognite/neat/_rules/models/__init__.py +5 -5
  29. cognite/neat/_rules/models/_base_rules.py +1 -1
  30. cognite/neat/_rules/models/dms/__init__.py +11 -11
  31. cognite/neat/_rules/models/dms/_validation.py +18 -10
  32. cognite/neat/_rules/models/entities/__init__.py +26 -26
  33. cognite/neat/_rules/models/entities/_single_value.py +25 -5
  34. cognite/neat/_rules/models/information/__init__.py +5 -5
  35. cognite/neat/_rules/models/mapping/_classic2core.yaml +54 -8
  36. cognite/neat/_rules/transformers/__init__.py +12 -12
  37. cognite/neat/_rules/transformers/_pipelines.py +10 -5
  38. cognite/neat/_session/_base.py +71 -0
  39. cognite/neat/_session/_collector.py +3 -1
  40. cognite/neat/_session/_drop.py +10 -0
  41. cognite/neat/_session/_inspect.py +35 -1
  42. cognite/neat/_session/_mapping.py +5 -0
  43. cognite/neat/_session/_prepare.py +121 -15
  44. cognite/neat/_session/_read.py +180 -20
  45. cognite/neat/_session/_set.py +11 -1
  46. cognite/neat/_session/_show.py +50 -11
  47. cognite/neat/_session/_to.py +58 -10
  48. cognite/neat/_session/engine/__init__.py +1 -1
  49. cognite/neat/_store/__init__.py +3 -2
  50. cognite/neat/_store/{_base.py → _graph_store.py} +33 -0
  51. cognite/neat/_store/_provenance.py +11 -1
  52. cognite/neat/_store/_rules_store.py +20 -0
  53. cognite/neat/_utils/auth.py +1 -1
  54. cognite/neat/_utils/io_.py +11 -0
  55. cognite/neat/_utils/reader/__init__.py +1 -1
  56. cognite/neat/_version.py +2 -2
  57. cognite/neat/_workflows/__init__.py +3 -3
  58. cognite/neat/_workflows/steps/lib/current/graph_extractor.py +1 -1
  59. cognite/neat/_workflows/steps/lib/current/rules_exporter.py +1 -1
  60. cognite/neat/_workflows/steps/lib/current/rules_importer.py +2 -2
  61. cognite/neat/_workflows/steps/lib/io/io_steps.py +3 -3
  62. {cognite_neat-0.102.0.dist-info → cognite_neat-0.103.1.dist-info}/METADATA +1 -1
  63. {cognite_neat-0.102.0.dist-info → cognite_neat-0.103.1.dist-info}/RECORD +66 -63
  64. {cognite_neat-0.102.0.dist-info → cognite_neat-0.103.1.dist-info}/LICENSE +0 -0
  65. {cognite_neat-0.102.0.dist-info → cognite_neat-0.103.1.dist-info}/WHEEL +0 -0
  66. {cognite_neat-0.102.0.dist-info → cognite_neat-0.103.1.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,6 @@
1
1
  import warnings
2
2
  from collections import Counter, defaultdict
3
+ from collections.abc import Mapping
3
4
  from functools import lru_cache
4
5
  from typing import ClassVar
5
6
 
@@ -115,7 +116,9 @@ class DMSValidation:
115
116
  **ref_container_by_id,
116
117
  }
117
118
  all_views_by_id: dict[dm.ViewId, dm.ViewApply | dm.View] = {**dict(dms_schema.views.items()), **ref_view_by_id}
118
- properties_by_ids = self._as_properties_by_ids(dms_schema, ref_view_by_id)
119
+ properties_by_ids = self._as_properties_by_ids(dms_schema.views, ref_view_by_id)
120
+ ref_properties_by_ids = self._as_properties_by_ids(ref_view_by_id, {})
121
+ all_properties_by_ids = {**ref_properties_by_ids, **properties_by_ids}
119
122
  view_properties_by_id = self._as_view_properties_by_id(properties_by_ids)
120
123
  parents_view_ids_by_child_id = self._parent_view_ids_by_child_id(all_views_by_id)
121
124
 
@@ -132,7 +135,9 @@ class DMSValidation:
132
135
  # SDK classes validation
133
136
  issue_list.extend(self._containers_are_proper_size(dms_schema))
134
137
  issue_list.extend(
135
- self._validate_reverse_connections(properties_by_ids, all_containers_by_id, parents_view_ids_by_child_id)
138
+ self._validate_reverse_connections(
139
+ properties_by_ids, all_containers_by_id, parents_view_ids_by_child_id, all_properties_by_ids
140
+ )
136
141
  )
137
142
  issue_list.extend(self._validate_schema(dms_schema, all_views_by_id, all_containers_by_id))
138
143
  issue_list.extend(self._validate_referenced_container_limits(dms_schema.views, view_properties_by_id))
@@ -140,22 +145,22 @@ class DMSValidation:
140
145
 
141
146
  @staticmethod
142
147
  def _as_properties_by_ids(
143
- dms_schema: DMSSchema, ref_view_by_id: dict[dm.ViewId, dm.View]
148
+ view_by_id: Mapping[dm.ViewId, dm.ViewApply] | Mapping[dm.ViewId, dm.View],
149
+ ref_view_by_id: dict[dm.ViewId, dm.View],
144
150
  ) -> dict[tuple[ViewId, str], ViewPropertyApply | ViewProperty]:
145
151
  # Priority DMS schema properties.
146
152
  # No need to do long lookups in ref_views as these already contain all ancestor properties.
147
153
  properties_by_id: dict[tuple[ViewId, str], ViewPropertyApply | ViewProperty] = {}
148
- for view in dms_schema.views.values():
149
- view_id = view.as_id()
154
+ for view_id, view in view_by_id.items():
150
155
  for prop_id, prop in (view.properties or {}).items():
151
156
  properties_by_id[(view_id, prop_id)] = prop
152
157
  if view.implements:
153
158
  to_check = view.implements.copy()
154
159
  while to_check:
155
160
  parent_id = to_check.pop()
156
- if parent_id in dms_schema.views:
157
- # Priority DMS Schema properties
158
- parent_view = dms_schema.views[parent_id]
161
+ if parent_id in view_by_id:
162
+ # Priority of the DMS schema properties
163
+ parent_view = view_by_id[parent_id]
159
164
  for prop_id, prop in (parent_view.properties or {}).items():
160
165
  if (view_id, prop_id) not in properties_by_id:
161
166
  properties_by_id[(view_id, prop_id)] = prop
@@ -189,6 +194,8 @@ class DMSValidation:
189
194
  ) -> dict[ViewId, set[ViewId]]:
190
195
  @lru_cache
191
196
  def get_parents(child_view_id: ViewId) -> set[ViewId]:
197
+ if child_view_id not in all_views_by_id:
198
+ return set()
192
199
  child_view = all_views_by_id[child_view_id]
193
200
  parents = set(child_view.implements or [])
194
201
  for parent_id in child_view.implements or []:
@@ -406,6 +413,7 @@ class DMSValidation:
406
413
  view_property_by_property_id: dict[tuple[dm.ViewId, str], ViewPropertyApply | ViewProperty],
407
414
  containers_by_id: dict[dm.ContainerId, dm.ContainerApply | dm.Container],
408
415
  parents_by_view: dict[dm.ViewId, set[dm.ViewId]],
416
+ all_view_property_by_property_id: dict[tuple[dm.ViewId, str], ViewPropertyApply | ViewProperty],
409
417
  ) -> IssueList:
410
418
  issue_list = IssueList()
411
419
  # do not check for reverse connections in Cognite models
@@ -416,7 +424,7 @@ class DMSValidation:
416
424
  if not isinstance(prop_, ReverseDirectRelationApply | ReverseDirectRelation):
417
425
  continue
418
426
  target_id = prop_.through.source, prop_.through.property
419
- if target_id not in view_property_by_property_id:
427
+ if target_id not in all_view_property_by_property_id:
420
428
  issue_list.append(
421
429
  ReversedConnectionNotFeasibleError(
422
430
  view_id,
@@ -430,7 +438,7 @@ class DMSValidation:
430
438
  # Todo: How to handle this case? Should not happen if you created the model with Neat
431
439
  continue
432
440
 
433
- target_property = view_property_by_property_id[(target_id[0], target_id[1])]
441
+ target_property = all_view_property_by_property_id[(target_id[0], target_id[1])]
434
442
  # Validate that the target is a direct relation pointing to the view_id
435
443
  is_direct_relation = False
436
444
  if isinstance(target_property, dm.MappedProperty) and isinstance(target_property.type, dm.DirectRelation):
@@ -25,38 +25,38 @@ from ._types import CdfResourceEntityList, ClassEntityList, ContainerEntityList,
25
25
  from ._wrapped import DMSFilter, HasDataFilter, NodeTypeFilter, RawFilter, WrappedEntity
26
26
 
27
27
  __all__ = [
28
- "Entity",
29
- "UnitEntity",
30
- "DMSVersionedEntity",
31
- "RelationshipEntity",
32
- "EdgeEntity",
33
- "ViewEntity",
34
- "ClassEntity",
35
- "ViewEntityList",
36
- "UnknownEntity",
37
- "Unknown",
38
- "Undefined",
39
- "T_Entity",
40
28
  "AssetEntity",
41
29
  "AssetFields",
42
- "ReverseConnectionEntity",
43
- "MultiValueTypeInfo",
44
- "DMSNodeEntity",
45
- "DMSEntity",
30
+ "CdfResourceEntityList",
31
+ "ClassEntity",
32
+ "ClassEntityList",
46
33
  "ContainerEntity",
34
+ "ContainerEntityList",
35
+ "DMSEntity",
36
+ "DMSFilter",
37
+ "DMSNodeEntity",
47
38
  "DMSUnknownEntity",
39
+ "DMSVersionedEntity",
48
40
  "DataModelEntity",
41
+ "EdgeEntity",
42
+ "Entity",
43
+ "HasDataFilter",
44
+ "MultiValueTypeInfo",
45
+ "NodeTypeFilter",
46
+ "RawFilter",
49
47
  "ReferenceEntity",
50
- "ClassEntityList",
51
- "CdfResourceEntityList",
52
- "ContainerEntityList",
48
+ "RelationshipEntity",
49
+ "ReverseConnectionEntity",
50
+ "T_Entity",
53
51
  "URLEntity",
54
- "load_value_type",
55
- "load_dms_value_type",
56
- "load_connection",
52
+ "Undefined",
53
+ "UnitEntity",
54
+ "Unknown",
55
+ "UnknownEntity",
56
+ "ViewEntity",
57
+ "ViewEntityList",
57
58
  "WrappedEntity",
58
- "NodeTypeFilter",
59
- "DMSFilter",
60
- "HasDataFilter",
61
- "RawFilter",
59
+ "load_connection",
60
+ "load_dms_value_type",
61
+ "load_value_type",
62
62
  ]
@@ -201,16 +201,36 @@ class Entity(BaseModel, extra="ignore"):
201
201
  for field_name, field in self.model_fields.items()
202
202
  if (v := getattr(self, field_name)) is not None and field_name not in {"prefix", "suffix"}
203
203
  }
204
+ # We only remove the default values if all the fields are default
205
+ # For example, if we dump `cdf_cdm:CogniteAsset(version=v1)` and the default is `version=v1`,
206
+ # we should not remove it unless the space is `cdf_cdm`
207
+ to_delete: list[str] = []
208
+ is_removing_defaults = True
204
209
  if isinstance(defaults, dict):
205
210
  for key, value in defaults.items():
206
- if key in model_dump and model_dump[key] == value:
207
- del model_dump[key]
208
- # Sorting to ensure deterministic order
209
- args = ",".join(f"{k}={v}" for k, v in sorted(model_dump.items(), key=lambda x: x[0]))
210
- if self.prefix == Undefined or (isinstance(defaults, dict) and self.prefix == defaults.get("prefix")):
211
+ if key not in model_dump:
212
+ continue
213
+ if model_dump[key] == value:
214
+ to_delete.append(key)
215
+ elif isinstance(self, EdgeEntity):
216
+ # Exception is edge entity, then, we remove all the defaults we can.
217
+ continue
218
+ else:
219
+ # Not all fields are default. We should not remove any of them.
220
+ is_removing_defaults = False
221
+ break
222
+ if isinstance(defaults, dict) and self.prefix == defaults.get("prefix") and is_removing_defaults:
223
+ base_id = str(self.suffix)
224
+ elif self.prefix == Undefined:
211
225
  base_id = str(self.suffix)
212
226
  else:
227
+ is_removing_defaults = False
213
228
  base_id = f"{self.prefix}:{self.suffix!s}"
229
+ if is_removing_defaults:
230
+ for key in to_delete:
231
+ del model_dump[key]
232
+ # Sorting to ensure deterministic order
233
+ args = ",".join(f"{k}={v}" for k, v in sorted(model_dump.items(), key=lambda x: x[0]))
214
234
  if args:
215
235
  return f"{base_id}({args})"
216
236
  else:
@@ -8,13 +8,13 @@ from ._rules_input import (
8
8
  from ._validation import InformationValidation
9
9
 
10
10
  __all__ = [
11
- "InformationRules",
12
- "InformationMetadata",
13
11
  "InformationClass",
14
- "InformationProperty",
15
- "InformationInputRules",
16
- "InformationInputMetadata",
17
12
  "InformationInputClass",
13
+ "InformationInputMetadata",
18
14
  "InformationInputProperty",
15
+ "InformationInputRules",
16
+ "InformationMetadata",
17
+ "InformationProperty",
18
+ "InformationRules",
19
19
  "InformationValidation",
20
20
  ]
@@ -2,10 +2,12 @@ enum:
2
2
  - collection: timeseriesType
3
3
  description: Time series with double floating point data points.
4
4
  name: numeric
5
+ neatId: http://purl.org/cognite/neat/neatId_d4e42064_7c60_4bfc_b629_a873345f0ee2
5
6
  value: numeric
6
7
  - collection: timeseriesType
7
8
  description: Time series with string data points.
8
9
  name: string
10
+ neatId: http://purl.org/cognite/neat/neatId_8bb46fae_572d_464a_bc61_1055b0aa6c5d
9
11
  value: string
10
12
  metadata:
11
13
  created: '2024-08-29T13:49:56.696000'
@@ -23,6 +25,7 @@ properties:
23
25
  description: Description of the instance
24
26
  immutable: false
25
27
  is_list: false
28
+ neatId: http://purl.org/cognite/neat/neatId_d887305d_af9d_4843_af6e_4115a7217d90
26
29
  nullable: true
27
30
  value_type: text
28
31
  view: ClassicAsset
@@ -32,6 +35,7 @@ properties:
32
35
  description: Text based labels for generic use, limited to 1000
33
36
  immutable: false
34
37
  is_list: true
38
+ neatId: http://purl.org/cognite/neat/neatId_105a0fee_3942_4a6b_9d25_74d46d09c209
35
39
  nullable: true
36
40
  value_type: text
37
41
  view: ClassicAsset
@@ -42,6 +46,7 @@ properties:
42
46
  immutable: false
43
47
  index: name
44
48
  is_list: false
49
+ neatId: http://purl.org/cognite/neat/neatId_9559ecd6_a585_4fb9_90b7_7301da5f2170
45
50
  nullable: true
46
51
  value_type: text
47
52
  view: ClassicAsset
@@ -53,6 +58,7 @@ properties:
53
58
  immutable: false
54
59
  is_list: false
55
60
  name: Parent
61
+ neatId: http://purl.org/cognite/neat/neatId_fdc3280b_0d11_4e66_b2b5_8f37a398bed9
56
62
  nullable: true
57
63
  value_type: ClassicAsset
58
64
  view: ClassicAsset
@@ -64,8 +70,9 @@ properties:
64
70
  immutable: false
65
71
  index: source
66
72
  is_list: false
73
+ neatId: http://purl.org/cognite/neat/neatId_247e5b5d_4caf_4312_bd5b_341ed3fc3a03
67
74
  nullable: true
68
- value_type: cdf_cdm:CogniteSourceSystem(version=v1)
75
+ value_type: ClassicSourceSystem
69
76
  view: ClassicAsset
70
77
  view_property: source
71
78
  - container: cdf_cdm:CogniteDescribable
@@ -73,6 +80,7 @@ properties:
73
80
  description: Alternative names for the node
74
81
  immutable: false
75
82
  is_list: true
83
+ neatId: http://purl.org/cognite/neat/neatId_7412eae6_e77c_41b7_92ca_737798f5844a
76
84
  nullable: true
77
85
  value_type: text
78
86
  view: ClassicEvent
@@ -84,6 +92,7 @@ properties:
84
92
  immutable: false
85
93
  is_list: true
86
94
  name: Assets
95
+ neatId: http://purl.org/cognite/neat/neatId_439538ba_610d_4300_a8cd_aa51dbbf5c1a
87
96
  nullable: true
88
97
  value_type: ClassicAsset
89
98
  view: ClassicEvent
@@ -93,6 +102,7 @@ properties:
93
102
  description: Description of the instance
94
103
  immutable: false
95
104
  is_list: false
105
+ neatId: http://purl.org/cognite/neat/neatId_8ab69b21_b84e_4374_a2bd_6b7e6321f22d
96
106
  nullable: true
97
107
  value_type: text
98
108
  view: ClassicEvent
@@ -103,6 +113,7 @@ properties:
103
113
  immutable: false
104
114
  index: endTime
105
115
  is_list: false
116
+ neatId: http://purl.org/cognite/neat/neatId_fce69deb_af37_4c49_b1cf_caf569563ba7
106
117
  nullable: true
107
118
  value_type: timestamp
108
119
  view: ClassicEvent
@@ -112,6 +123,7 @@ properties:
112
123
  description: Text based labels for generic use, limited to 1000
113
124
  immutable: false
114
125
  is_list: true
126
+ neatId: http://purl.org/cognite/neat/neatId_0ed58b00_11ab_4774_9c66_d2eabc5f8f42
115
127
  nullable: true
116
128
  value_type: text
117
129
  view: ClassicEvent
@@ -123,8 +135,9 @@ properties:
123
135
  immutable: false
124
136
  index: source
125
137
  is_list: false
138
+ neatId: http://purl.org/cognite/neat/neatId_b0c7d726_6504_4189_896d_1b978d9ef5b2
126
139
  nullable: true
127
- value_type: cdf_cdm:CogniteSourceSystem(version=v1)
140
+ value_type: ClassicSourceSystem
128
141
  view: ClassicEvent
129
142
  view_property: source
130
143
  - container: cdf_cdm:CogniteSchedulable
@@ -133,6 +146,7 @@ properties:
133
146
  immutable: false
134
147
  index: startTime
135
148
  is_list: false
149
+ neatId: http://purl.org/cognite/neat/neatId_2304763f_d0f3_4723_a4c5_2e879069195d
136
150
  nullable: true
137
151
  value_type: timestamp
138
152
  view: ClassicEvent
@@ -144,6 +158,7 @@ properties:
144
158
  immutable: false
145
159
  is_list: true
146
160
  name: Assets
161
+ neatId: http://purl.org/cognite/neat/neatId_77ec0da0_839b_4b52_9f64_35382213dac6
147
162
  nullable: true
148
163
  value_type: ClassicAsset
149
164
  view: ClassicFile
@@ -155,6 +170,7 @@ properties:
155
170
  immutable: false
156
171
  is_list: false
157
172
  name: Directory
173
+ neatId: http://purl.org/cognite/neat/neatId_f06ff883_4f00_4a5d_b9c3_83664b62b573
158
174
  nullable: true
159
175
  value_type: text
160
176
  view: ClassicFile
@@ -164,6 +180,7 @@ properties:
164
180
  description: Text based labels for generic use, limited to 1000
165
181
  immutable: false
166
182
  is_list: true
183
+ neatId: http://purl.org/cognite/neat/neatId_5d721016_c99e_4f73_8e9d_bdd27b4472c3
167
184
  nullable: true
168
185
  value_type: text
169
186
  view: ClassicFile
@@ -174,6 +191,7 @@ properties:
174
191
  immutable: false
175
192
  is_list: false
176
193
  name: MIME type
194
+ neatId: http://purl.org/cognite/neat/neatId_d65bd20a_bcb9_4243_b3e9_06188378c4cc
177
195
  nullable: true
178
196
  value_type: text
179
197
  view: ClassicFile
@@ -184,6 +202,7 @@ properties:
184
202
  immutable: false
185
203
  index: name
186
204
  is_list: false
205
+ neatId: http://purl.org/cognite/neat/neatId_793d1480_2fba_4dde_8325_c11ef7e57de5
187
206
  nullable: true
188
207
  value_type: text
189
208
  view: ClassicFile
@@ -195,8 +214,9 @@ properties:
195
214
  immutable: false
196
215
  index: source
197
216
  is_list: false
217
+ neatId: http://purl.org/cognite/neat/neatId_87aa809b_a7cc_4136_885c_276844ed6b38
198
218
  nullable: true
199
- value_type: cdf_cdm:CogniteSourceSystem(version=v1)
219
+ value_type: ClassicSourceSystem
200
220
  view: ClassicFile
201
221
  view_property: source
202
222
  - container: cdf_cdm:CogniteSourceable
@@ -205,6 +225,7 @@ properties:
205
225
  immutable: false
206
226
  index: sourceCreatedTime
207
227
  is_list: false
228
+ neatId: http://purl.org/cognite/neat/neatId_26b7346d_3d5f_43a5_894e_96707e89227c
208
229
  nullable: true
209
230
  value_type: timestamp
210
231
  view: ClassicFile
@@ -215,10 +236,20 @@ properties:
215
236
  immutable: false
216
237
  index: sourceUpdatedTime
217
238
  is_list: false
239
+ neatId: http://purl.org/cognite/neat/neatId_4b6be7c8_8b26_4f11_9ad5_283123a54c91
218
240
  nullable: true
219
241
  value_type: timestamp
220
242
  view: ClassicFile
221
243
  view_property: sourceModifiedTime
244
+ - container: cdf_cdm:CogniteDescribable
245
+ container_property: name
246
+ immutable: false
247
+ is_list: false
248
+ neatId: http://purl.org/cognite/neat/neatId_7d7c614a_43ea_4fc2_abb0_3f3fdddaa239
249
+ nullable: true
250
+ value_type: text
251
+ view: ClassicSourceSystem
252
+ view_property: name
222
253
  - connection: direct
223
254
  container: cdf_cdm:CogniteTimeSeries
224
255
  container_property: assets
@@ -226,6 +257,7 @@ properties:
226
257
  immutable: false
227
258
  is_list: true
228
259
  name: Assets
260
+ neatId: http://purl.org/cognite/neat/neatId_bc4e12b0_82bd_4859_995d_d219181f9b52
229
261
  nullable: true
230
262
  value_type: ClassicAsset
231
263
  view: ClassicTimeSeries
@@ -235,6 +267,7 @@ properties:
235
267
  description: Description of the instance
236
268
  immutable: false
237
269
  is_list: false
270
+ neatId: http://purl.org/cognite/neat/neatId_73372a76_aa52_47c1_bdae_34bfbd80f572
238
271
  nullable: true
239
272
  value_type: text
240
273
  view: ClassicTimeSeries
@@ -246,6 +279,7 @@ properties:
246
279
  immutable: false
247
280
  is_list: false
248
281
  name: Is step
282
+ neatId: http://purl.org/cognite/neat/neatId_cfa476ae_125b_4e6a_8caf_152f44095037
249
283
  nullable: false
250
284
  value_type: boolean
251
285
  view: ClassicTimeSeries
@@ -256,6 +290,7 @@ properties:
256
290
  immutable: true
257
291
  is_list: false
258
292
  name: Type
293
+ neatId: http://purl.org/cognite/neat/neatId_7943437b_6138_47e6_889a_f414280df48e
259
294
  nullable: false
260
295
  value_type: enum(collection=timeseriesType)
261
296
  view: ClassicTimeSeries
@@ -265,6 +300,7 @@ properties:
265
300
  description: Alternative names for the node
266
301
  immutable: false
267
302
  is_list: true
303
+ neatId: http://purl.org/cognite/neat/neatId_15cfc454_8fc0_443b_8af6_9db5368d6fd4
268
304
  nullable: true
269
305
  value_type: text
270
306
  view: ClassicTimeSeries
@@ -275,6 +311,7 @@ properties:
275
311
  immutable: false
276
312
  index: name
277
313
  is_list: false
314
+ neatId: http://purl.org/cognite/neat/neatId_01370dd7_3371_40a1_b4eb_ddfcbbac63c8
278
315
  nullable: true
279
316
  value_type: text
280
317
  view: ClassicTimeSeries
@@ -284,6 +321,7 @@ properties:
284
321
  description: Text based labels for generic use, limited to 1000
285
322
  immutable: false
286
323
  is_list: true
324
+ neatId: http://purl.org/cognite/neat/neatId_d7e122ee_421a_490f_9bec_b0f9f5ececfd
287
325
  nullable: true
288
326
  value_type: text
289
327
  view: ClassicTimeSeries
@@ -294,6 +332,7 @@ properties:
294
332
  immutable: false
295
333
  is_list: false
296
334
  name: Source unit
335
+ neatId: http://purl.org/cognite/neat/neatId_3bfc11e0_9d27_47ea_841e_de1e4363dbed
297
336
  nullable: true
298
337
  value_type: text
299
338
  view: ClassicTimeSeries
@@ -305,39 +344,46 @@ properties:
305
344
  immutable: false
306
345
  is_list: false
307
346
  name: Unit
347
+ neatId: http://purl.org/cognite/neat/neatId_33b75362_e127_4a5a_9690_2df55501250c
308
348
  nullable: true
309
349
  value_type: cdf_cdm:CogniteUnit(version=v1)
310
350
  view: ClassicTimeSeries
311
351
  view_property: unitExternalId
312
352
  views:
313
- - description: The CogniteSourceSystem core concept is used to standardize the way
314
- source system is stored.
315
- implements: cdf_cdm:CogniteDescribable(version=v1)
316
- in_model: true
317
- view: cdf_cdm:CogniteSourceSystem(version=v1)
318
353
  - description: Represents a single unit of measurement
319
354
  implements: cdf_cdm:CogniteDescribable(version=v1)
320
355
  in_model: true
356
+ neatId: http://purl.org/cognite/neat/neatId_f3397b4c_b6e0_4701_8ea3_7edbf72bf50d
321
357
  view: cdf_cdm:CogniteUnit(version=v1)
322
358
  - description: Assets represent systems that support industrial functions or processes.
323
359
  Assets are often called 'functional location'.
324
360
  implements: cdf_cdm:CogniteAsset(version=v1)
325
361
  in_model: true
326
362
  name: Asset
363
+ neatId: http://purl.org/cognite/neat/neatId_23380192_0c8a_4870_9684_cb91e5e5d67d
327
364
  view: ClassicAsset
328
365
  - description: Represents activities. Activities typically happen over a period and
329
366
  have a start and end time.
330
367
  implements: cdf_cdm:CogniteActivity(version=v1)
331
368
  in_model: true
332
369
  name: Activity
370
+ neatId: http://purl.org/cognite/neat/neatId_3c0bda0e_9af0_4c75_9f1c_d76a6eae2e44
333
371
  view: ClassicEvent
334
372
  - description: Represents files.
335
373
  implements: cdf_cdm:CogniteFile(version=v1)
336
374
  in_model: true
337
375
  name: File
376
+ neatId: http://purl.org/cognite/neat/neatId_4a92bfcc_a259_4ec6_b58b_bdb386ba9ce2
338
377
  view: ClassicFile
378
+ - description: The CogniteSourceSystem core concept is used to standardize the way
379
+ source system is stored.
380
+ implements: cdf_cdm:CogniteSourceSystem(version=v1)
381
+ in_model: true
382
+ neatId: http://purl.org/cognite/neat/neatId_280264e2_a809_4feb_81e3_454adc00fdde
383
+ view: ClassicSourceSystem
339
384
  - description: Represents a series of data points in time order.
340
385
  implements: cdf_cdm:CogniteTimeSeries(version=v1)
341
386
  in_model: true
342
387
  name: Time series
388
+ neatId: http://purl.org/cognite/neat/neatId_0730d4f7_51ce_40de_a8af_b9efff498b06
343
389
  view: ClassicTimeSeries
@@ -14,21 +14,21 @@ from ._pipelines import ImporterPipeline
14
14
  from ._verification import VerifyAnyRules, VerifyDMSRules, VerifyInformationRules
15
15
 
16
16
  __all__ = [
17
- "ImporterPipeline",
18
- "RulesTransformer",
19
- "RulesPipeline",
20
- "InformationToDMS",
17
+ "AsParentPropertyId",
21
18
  "ConvertToRules",
22
- "PrefixEntities",
23
19
  "DMSToInformation",
24
- "VerifyDMSRules",
25
- "VerifyInformationRules",
26
- "VerifyAnyRules",
20
+ "ImporterPipeline",
21
+ "InformationToDMS",
27
22
  "MapOneToOne",
28
- "ToCompliantEntities",
29
- "RuleMapper",
30
- "ToExtension",
23
+ "PrefixEntities",
31
24
  "ReduceCogniteModel",
25
+ "RuleMapper",
26
+ "RulesPipeline",
27
+ "RulesTransformer",
32
28
  "SetIDDMSModel",
33
- "AsParentPropertyId",
29
+ "ToCompliantEntities",
30
+ "ToExtension",
31
+ "VerifyAnyRules",
32
+ "VerifyDMSRules",
33
+ "VerifyInformationRules",
34
34
  ]
@@ -1,28 +1,33 @@
1
1
  from collections.abc import Iterable
2
+ from typing import TYPE_CHECKING
2
3
 
3
4
  from cognite.neat._issues.errors import NeatValueError
4
5
  from cognite.neat._rules._shared import InputRules, MaybeRules, VerifiedRules
5
- from cognite.neat._rules.importers import BaseImporter
6
6
  from cognite.neat._rules.models import VERIFIED_RULES_BY_ROLE, RoleTypes
7
7
 
8
8
  from ._base import RulesPipeline, RulesTransformer
9
9
  from ._converters import ConvertToRules
10
10
  from ._verification import VerifyAnyRules
11
11
 
12
+ if TYPE_CHECKING:
13
+ from cognite.neat._rules.importers import BaseImporter
14
+
12
15
 
13
16
  class ImporterPipeline(RulesPipeline[InputRules, VerifiedRules]):
14
17
  """This is a standard pipeline that verifies, convert and return the rules from the importer."""
15
18
 
16
19
  def __init__(
17
20
  self,
18
- importer: BaseImporter[InputRules],
21
+ importer: "BaseImporter[InputRules]",
19
22
  items: Iterable[RulesTransformer[InputRules, VerifiedRules]] | None = None,
20
23
  ) -> None:
21
24
  super().__init__(items or [])
22
25
  self._importer = importer
23
26
 
24
27
  @classmethod
25
- def _create_pipeline(cls, importer: BaseImporter[InputRules], role: RoleTypes | None = None) -> "ImporterPipeline":
28
+ def _create_pipeline(
29
+ cls, importer: "BaseImporter[InputRules]", role: RoleTypes | None = None
30
+ ) -> "ImporterPipeline":
26
31
  items: list[RulesTransformer] = [VerifyAnyRules(errors="continue", validate=True)]
27
32
  if role is not None:
28
33
  out_cls = VERIFIED_RULES_BY_ROLE[role]
@@ -30,7 +35,7 @@ class ImporterPipeline(RulesPipeline[InputRules, VerifiedRules]):
30
35
  return cls(importer, items)
31
36
 
32
37
  @classmethod
33
- def try_verify(cls, importer: BaseImporter, role: RoleTypes | None = None) -> MaybeRules[VerifiedRules]:
38
+ def try_verify(cls, importer: "BaseImporter", role: RoleTypes | None = None) -> MaybeRules[VerifiedRules]:
34
39
  """This is a standard pipeline that verifies, convert and return the rules from the importer.
35
40
 
36
41
  Args:
@@ -43,7 +48,7 @@ class ImporterPipeline(RulesPipeline[InputRules, VerifiedRules]):
43
48
  return cls._create_pipeline(importer, role).try_execute()
44
49
 
45
50
  @classmethod
46
- def verify(cls, importer: BaseImporter, role: RoleTypes | None = None) -> VerifiedRules:
51
+ def verify(cls, importer: "BaseImporter", role: RoleTypes | None = None) -> VerifiedRules:
47
52
  """Verify the rules."""
48
53
  return cls._create_pipeline(importer, role).execute()
49
54