cognite-neat 0.81.6__py3-none-any.whl → 0.81.7__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 +1 -1
- cognite/neat/graph/stores/_base.py +7 -9
- cognite/neat/graph/transformers/__init__.py +3 -3
- cognite/neat/graph/transformers/_classic_cdf.py +45 -7
- {cognite_neat-0.81.6.dist-info → cognite_neat-0.81.7.dist-info}/METADATA +1 -1
- {cognite_neat-0.81.6.dist-info → cognite_neat-0.81.7.dist-info}/RECORD +9 -9
- {cognite_neat-0.81.6.dist-info → cognite_neat-0.81.7.dist-info}/LICENSE +0 -0
- {cognite_neat-0.81.6.dist-info → cognite_neat-0.81.7.dist-info}/WHEEL +0 -0
- {cognite_neat-0.81.6.dist-info → cognite_neat-0.81.7.dist-info}/entry_points.txt +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.81.
|
|
1
|
+
__version__ = "0.81.7"
|
|
@@ -234,15 +234,13 @@ class NeatGraphStore:
|
|
|
234
234
|
else:
|
|
235
235
|
_start = datetime.now(timezone.utc)
|
|
236
236
|
transformer.transform(self.graph)
|
|
237
|
-
self.provenance
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
)
|
|
245
|
-
]
|
|
237
|
+
self.provenance.append(
|
|
238
|
+
Change.record(
|
|
239
|
+
activity=f"{type(transformer).__name__}",
|
|
240
|
+
start=_start,
|
|
241
|
+
end=datetime.now(timezone.utc),
|
|
242
|
+
description=transformer.description,
|
|
243
|
+
)
|
|
246
244
|
)
|
|
247
245
|
|
|
248
246
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from ._classic_cdf import AddAssetDepth
|
|
1
|
+
from ._classic_cdf import AddAssetDepth, AssetTimeSeriesConnector
|
|
2
2
|
|
|
3
|
-
__all__ = ["AddAssetDepth"]
|
|
3
|
+
__all__ = ["AddAssetDepth", "AssetTimeSeriesConnector"]
|
|
4
4
|
|
|
5
|
-
Transformers = AddAssetDepth
|
|
5
|
+
Transformers = AddAssetDepth | AssetTimeSeriesConnector
|
|
@@ -3,7 +3,7 @@ from typing import cast
|
|
|
3
3
|
from rdflib import Graph, Literal, URIRef
|
|
4
4
|
|
|
5
5
|
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
6
|
-
from cognite.neat.graph
|
|
6
|
+
from cognite.neat.graph import extractors
|
|
7
7
|
|
|
8
8
|
from ._base import BaseTransformer
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ from ._base import BaseTransformer
|
|
|
11
11
|
class AddAssetDepth(BaseTransformer):
|
|
12
12
|
description: str = "Adds depth of asset in the asset hierarchy to the graph"
|
|
13
13
|
_use_only_once: bool = True
|
|
14
|
-
_need_changes = frozenset({str(AssetsExtractor.__name__)})
|
|
14
|
+
_need_changes = frozenset({str(extractors.AssetsExtractor.__name__)})
|
|
15
15
|
|
|
16
16
|
_parent_template: str = """SELECT ?child ?parent WHERE {{
|
|
17
17
|
<{asset_id}> <{parent_prop}> ?child .
|
|
@@ -45,15 +45,53 @@ class AddAssetDepth(BaseTransformer):
|
|
|
45
45
|
"""Get asset depth in the asset hierarchy."""
|
|
46
46
|
|
|
47
47
|
# Handles non-root assets
|
|
48
|
-
if
|
|
49
|
-
return len(cast(list[tuple],
|
|
48
|
+
if result := list(graph.query(cls._parent_template.format(asset_id=asset_id, parent_prop=parent_prop))):
|
|
49
|
+
return len(cast(list[tuple], result)) + 2 if cast(list[tuple], result)[0][1] else 2
|
|
50
50
|
|
|
51
51
|
# Handles root assets
|
|
52
52
|
elif (
|
|
53
|
-
(
|
|
54
|
-
and len(cast(list[tuple],
|
|
55
|
-
and cast(list[tuple],
|
|
53
|
+
(result := list(graph.query(cls._root_template.format(asset_id=asset_id, root_prop=root_prop))))
|
|
54
|
+
and len(cast(list[tuple], result)) == 1
|
|
55
|
+
and cast(list[tuple], result)[0][0] == asset_id
|
|
56
56
|
):
|
|
57
57
|
return 1
|
|
58
58
|
else:
|
|
59
59
|
return None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class AssetTimeSeriesConnector(BaseTransformer):
|
|
63
|
+
description: str = "Connects assets to timeseries, thus forming bi-directional connection"
|
|
64
|
+
_use_only_once: bool = True
|
|
65
|
+
_need_changes = frozenset({str(extractors.AssetsExtractor.__name__), str(extractors.TimeSeriesExtractor.__name__)})
|
|
66
|
+
_asset_template: str = """SELECT ?asset_id WHERE {{
|
|
67
|
+
<{timeseries_id}> <{asset_prop}> ?asset_id .
|
|
68
|
+
?asset_id a <{asset_type}>}}"""
|
|
69
|
+
|
|
70
|
+
def __init__(
|
|
71
|
+
self,
|
|
72
|
+
asset_type: URIRef | None = None,
|
|
73
|
+
timeseries_type: URIRef | None = None,
|
|
74
|
+
asset_prop: URIRef | None = None,
|
|
75
|
+
):
|
|
76
|
+
self.asset_type = asset_type or DEFAULT_NAMESPACE.Asset
|
|
77
|
+
self.timeseries_type = timeseries_type or DEFAULT_NAMESPACE.TimeSeries
|
|
78
|
+
self.asset_prop = asset_prop or DEFAULT_NAMESPACE.asset
|
|
79
|
+
|
|
80
|
+
def transform(self, graph: Graph) -> None:
|
|
81
|
+
for ts_id_result in graph.query(
|
|
82
|
+
f"SELECT DISTINCT ?timeseries_id WHERE {{?timeseries_id a <{self.timeseries_type}>}}"
|
|
83
|
+
):
|
|
84
|
+
timeseries_id: URIRef = cast(tuple, ts_id_result)[0]
|
|
85
|
+
|
|
86
|
+
if asset_id_res := list(
|
|
87
|
+
graph.query(
|
|
88
|
+
self._asset_template.format(
|
|
89
|
+
timeseries_id=timeseries_id,
|
|
90
|
+
asset_prop=self.asset_prop,
|
|
91
|
+
asset_type=self.asset_type,
|
|
92
|
+
)
|
|
93
|
+
)
|
|
94
|
+
):
|
|
95
|
+
# timeseries can be connected to only one asset in the graph
|
|
96
|
+
asset_id = cast(list[tuple], asset_id_res)[0][0]
|
|
97
|
+
graph.add((asset_id, DEFAULT_NAMESPACE.timeSeries, timeseries_id))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cognite/neat/__init__.py,sha256=v-rRiDOgZ3sQSMQKq0vgUQZvpeOkoHFXissAx6Ktg84,61
|
|
2
|
-
cognite/neat/_version.py,sha256=
|
|
2
|
+
cognite/neat/_version.py,sha256=PtP0Hej8fz6jEW0rAYtnpncSgq-Zo4KnEW-y7gZEHdA,23
|
|
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
|
|
@@ -73,12 +73,12 @@ cognite/neat/graph/loaders/_base.py,sha256=bdYC6CwsHVqnQa1QzOhL68qQhF1OtrsearqH6
|
|
|
73
73
|
cognite/neat/graph/loaders/_rdf2dms.py,sha256=w0y2ECKw7RrQndGyTVIWeFF2WDxs9yvl_eWNqg-tKO8,13018
|
|
74
74
|
cognite/neat/graph/models.py,sha256=AtLgZh2qyRP6NRetjQCy9qLMuTQB0CH52Zsev-qa2sk,149
|
|
75
75
|
cognite/neat/graph/stores/__init__.py,sha256=G-VG_YwfRt1kuPao07PDJyZ3w_0-eguzLUM13n-Z_RA,64
|
|
76
|
-
cognite/neat/graph/stores/_base.py,sha256
|
|
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=
|
|
79
|
+
cognite/neat/graph/transformers/__init__.py,sha256=P304fcH6U9tV049DMxxHMzUoRnTTER_GdAzcFfrOSc4,180
|
|
80
80
|
cognite/neat/graph/transformers/_base.py,sha256=b37Ek-9njuM5pTR_3XhnxCMrg_ip_2BMwM7ZhKpAAlw,328
|
|
81
|
-
cognite/neat/graph/transformers/_classic_cdf.py,sha256=
|
|
81
|
+
cognite/neat/graph/transformers/_classic_cdf.py,sha256=qeF5untGEM1DL8vg75SIPE0vZn0TN8DL9n3OWNJuJ9A,4029
|
|
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.
|
|
301
|
-
cognite_neat-0.81.
|
|
302
|
-
cognite_neat-0.81.
|
|
303
|
-
cognite_neat-0.81.
|
|
304
|
-
cognite_neat-0.81.
|
|
300
|
+
cognite_neat-0.81.7.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
301
|
+
cognite_neat-0.81.7.dist-info/METADATA,sha256=Y6mWnpldS0Lex_kygQrZX-ODmiPmPqhfVAPWURhElEo,9290
|
|
302
|
+
cognite_neat-0.81.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
303
|
+
cognite_neat-0.81.7.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
|
|
304
|
+
cognite_neat-0.81.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|