cognite-neat 0.81.9__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.9"
1
+ __version__ = "0.81.10"
@@ -1,5 +1,19 @@
1
- from ._classic_cdf import AddAssetDepth, AssetFileConnector, 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", "AssetFileConnector"]
9
+ __all__ = [
10
+ "AddAssetDepth",
11
+ "AssetTimeSeriesConnector",
12
+ "AssetSequenceConnector",
13
+ "AssetFileConnector",
14
+ "AssetEventConnector",
15
+ ]
4
16
 
5
- Transformers = AddAssetDepth | AssetTimeSeriesConnector | AssetSequenceConnector | AssetFileConnector
17
+ Transformers = (
18
+ AddAssetDepth | AssetTimeSeriesConnector | AssetSequenceConnector | AssetFileConnector | AssetEventConnector
19
+ )
@@ -169,3 +169,39 @@ class AssetFileConnector(BaseTransformer):
169
169
  # files can be connected to multiple assets in the graph
170
170
  for (asset_id,) in cast(list[tuple], assets_id_res):
171
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.9
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=gPog-eXLc_NQMwidfkhILHYH8iP4pKjOx2sYNlDyS8k,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=rszYDrhnWD8crYZVwSlZ0X4QcJA40p2Xg42ZjXP0Phs,318
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=Gcsla0nOI1-0msGuo_vhwH5DyqeKMMusipD8e9WyJ7c,7280
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.9.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
301
- cognite_neat-0.81.9.dist-info/METADATA,sha256=JpfmmlhKiKJbfOQgnPCLeH45QbGJbgFjGiQCI3p6nfs,9290
302
- cognite_neat-0.81.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
303
- cognite_neat-0.81.9.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
304
- cognite_neat-0.81.9.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,,