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

cognite/neat/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.81.8"
1
+ __version__ = "0.81.10"
@@ -1,5 +1,19 @@
1
- from ._classic_cdf import AddAssetDepth, AssetSequenceConnector, AssetTimeSeriesConnector
1
+ from ._classic_cdf import (
2
+ AddAssetDepth,
3
+ AssetEventConnector,
4
+ AssetFileConnector,
5
+ AssetSequenceConnector,
6
+ AssetTimeSeriesConnector,
7
+ )
2
8
 
3
- __all__ = ["AddAssetDepth", "AssetTimeSeriesConnector", "AssetSequenceConnector"]
9
+ __all__ = [
10
+ "AddAssetDepth",
11
+ "AssetTimeSeriesConnector",
12
+ "AssetSequenceConnector",
13
+ "AssetFileConnector",
14
+ "AssetEventConnector",
15
+ ]
4
16
 
5
- Transformers = AddAssetDepth | AssetTimeSeriesConnector | AssetSequenceConnector
17
+ Transformers = (
18
+ AddAssetDepth | AssetTimeSeriesConnector | AssetSequenceConnector | AssetFileConnector | AssetEventConnector
19
+ )
@@ -133,3 +133,75 @@ class AssetSequenceConnector(BaseTransformer):
133
133
  # sequence can be connected to only one asset in the graph
134
134
  asset_id = cast(list[tuple], asset_id_res)[0][0]
135
135
  graph.add((asset_id, DEFAULT_NAMESPACE.sequence, sequence_id))
136
+
137
+
138
+ class AssetFileConnector(BaseTransformer):
139
+ description: str = "Connects assets to files, thus forming bi-directional connection"
140
+ _use_only_once: bool = True
141
+ _need_changes = frozenset({str(extractors.AssetsExtractor.__name__), str(extractors.FilesExtractor.__name__)})
142
+ _asset_template: str = """SELECT ?asset_id WHERE {{
143
+ <{file_id}> <{asset_prop}> ?asset_id .
144
+ ?asset_id a <{asset_type}>}}"""
145
+
146
+ def __init__(
147
+ self,
148
+ asset_type: URIRef | None = None,
149
+ file_type: URIRef | None = None,
150
+ asset_prop: URIRef | None = None,
151
+ ):
152
+ self.asset_type = asset_type or DEFAULT_NAMESPACE.Asset
153
+ self.file_type = file_type or DEFAULT_NAMESPACE.File
154
+ self.asset_prop = asset_prop or DEFAULT_NAMESPACE.asset
155
+
156
+ def transform(self, graph: Graph) -> None:
157
+ for sequency_id_result in graph.query(f"SELECT DISTINCT ?file_id WHERE {{?file_id a <{self.file_type}>}}"):
158
+ file_id: URIRef = cast(tuple, sequency_id_result)[0]
159
+
160
+ if assets_id_res := list(
161
+ graph.query(
162
+ self._asset_template.format(
163
+ file_id=file_id,
164
+ asset_prop=self.asset_prop,
165
+ asset_type=self.asset_type,
166
+ )
167
+ )
168
+ ):
169
+ # files can be connected to multiple assets in the graph
170
+ for (asset_id,) in cast(list[tuple], assets_id_res):
171
+ graph.add((asset_id, DEFAULT_NAMESPACE.file, file_id))
172
+
173
+
174
+ class AssetEventConnector(BaseTransformer):
175
+ description: str = "Connects assets to events, thus forming bi-directional connection"
176
+ _use_only_once: bool = True
177
+ _need_changes = frozenset({str(extractors.AssetsExtractor.__name__), str(extractors.EventsExtractor.__name__)})
178
+ _asset_template: str = """SELECT ?asset_id WHERE {{
179
+ <{event_id}> <{asset_prop}> ?asset_id .
180
+ ?asset_id a <{asset_type}>}}"""
181
+
182
+ def __init__(
183
+ self,
184
+ asset_type: URIRef | None = None,
185
+ event_type: URIRef | None = None,
186
+ asset_prop: URIRef | None = None,
187
+ ):
188
+ self.asset_type = asset_type or DEFAULT_NAMESPACE.Asset
189
+ self.event_type = event_type or DEFAULT_NAMESPACE.Event
190
+ self.asset_prop = asset_prop or DEFAULT_NAMESPACE.asset
191
+
192
+ def transform(self, graph: Graph) -> None:
193
+ for event_id_result in graph.query(f"SELECT DISTINCT ?event_id WHERE {{?event_id a <{self.event_type}>}}"):
194
+ event_id: URIRef = cast(tuple, event_id_result)[0]
195
+
196
+ if assets_id_res := list(
197
+ graph.query(
198
+ self._asset_template.format(
199
+ event_id=event_id,
200
+ asset_prop=self.asset_prop,
201
+ asset_type=self.asset_type,
202
+ )
203
+ )
204
+ ):
205
+ # files can be connected to multiple assets in the graph
206
+ for (asset_id,) in cast(list[tuple], assets_id_res):
207
+ graph.add((asset_id, DEFAULT_NAMESPACE.event, event_id))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.81.8
3
+ Version: 0.81.10
4
4
  Summary: Knowledge graph transformation
5
5
  Home-page: https://cognite-neat.readthedocs-hosted.com/
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
1
  cognite/neat/__init__.py,sha256=v-rRiDOgZ3sQSMQKq0vgUQZvpeOkoHFXissAx6Ktg84,61
2
- cognite/neat/_version.py,sha256=dsKkCTqM-NH00Rbmf1g724BSxf9sqwLh6RdLnv6CR_c,23
2
+ cognite/neat/_version.py,sha256=kfoIPOj8SqOTkglqTypeVhT7HKM-I90zJCvSL7WOcg8,24
3
3
  cognite/neat/app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cognite/neat/app/api/asgi/metrics.py,sha256=nxFy7L5cChTI0a-zkCiJ59Aq8yLuIJp5c9Dg0wRXtV0,152
5
5
  cognite/neat/app/api/configuration.py,sha256=2U5M6M252swvQPQyooA1EBzFUZNtcTmuSaywfJDgckM,4232
@@ -76,9 +76,9 @@ cognite/neat/graph/stores/__init__.py,sha256=G-VG_YwfRt1kuPao07PDJyZ3w_0-eguzLUM
76
76
  cognite/neat/graph/stores/_base.py,sha256=-MwqfVCBd4j4xWaI7zOvypsGqtbET-2eKQKf36DO0A0,11001
77
77
  cognite/neat/graph/stores/_oxrdflib.py,sha256=A5zeRm5_e8ui_ihGpgstRDg_N7qcLZ3QZBRGrOXSGI0,9569
78
78
  cognite/neat/graph/stores/_provenance.py,sha256=Hr9WBhFj-eoet4czL8XSBGYnu9Yn66YsTgH_G0n3QpY,3293
79
- cognite/neat/graph/transformers/__init__.py,sha256=HD-qecxyF56JBLO5s9RJPO9DbnG2-yarlaR7Qh90dqg,255
79
+ cognite/neat/graph/transformers/__init__.py,sha256=ZlTjOGX1ly4AlYvc4-D-xoTonkP5OUuJF1t8cj-EUac,440
80
80
  cognite/neat/graph/transformers/_base.py,sha256=b37Ek-9njuM5pTR_3XhnxCMrg_ip_2BMwM7ZhKpAAlw,328
81
- cognite/neat/graph/transformers/_classic_cdf.py,sha256=m_aipKafD7bD4DfAMpYFvp6Xv36KwcWAR0CBAzVb7Ds,5694
81
+ cognite/neat/graph/transformers/_classic_cdf.py,sha256=fsKwbm__5YpgeOwbUbbFatK5_VBWdZo5F8k97zX0nxw,8876
82
82
  cognite/neat/issues.py,sha256=pxQfqfBseMDE8JM0iqZnkLXngeyeFfT0TFtu1UuAd4c,4629
83
83
  cognite/neat/legacy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
84
84
  cognite/neat/legacy/graph/__init__.py,sha256=31uTeejWOSd-I8iUG8GOZFhHZcQCsBitJ6X8vu2r1nU,73
@@ -297,8 +297,8 @@ cognite/neat/workflows/steps_registry.py,sha256=fkTX14ZA7_gkUYfWIlx7A1XbCidvqR23
297
297
  cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
298
298
  cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
299
299
  cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
300
- cognite_neat-0.81.8.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
301
- cognite_neat-0.81.8.dist-info/METADATA,sha256=-C0TP5LnLb2hEggFkUGghGc-A-46VkiZHqUrRtkxKJc,9290
302
- cognite_neat-0.81.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
303
- cognite_neat-0.81.8.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
304
- cognite_neat-0.81.8.dist-info/RECORD,,
300
+ cognite_neat-0.81.10.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
301
+ cognite_neat-0.81.10.dist-info/METADATA,sha256=PJxDNxDQFz5LZWpOfU8ud4ihSmj3lNlF4996gUUR8I0,9291
302
+ cognite_neat-0.81.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
303
+ cognite_neat-0.81.10.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
304
+ cognite_neat-0.81.10.dist-info/RECORD,,