cognite-neat 0.123.21__py3-none-any.whl → 0.123.22__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/session/_session/_data_model/_read.py +51 -12
- {cognite_neat-0.123.21.dist-info → cognite_neat-0.123.22.dist-info}/METADATA +1 -1
- {cognite_neat-0.123.21.dist-info → cognite_neat-0.123.22.dist-info}/RECORD +6 -6
- {cognite_neat-0.123.21.dist-info → cognite_neat-0.123.22.dist-info}/WHEEL +0 -0
- {cognite_neat-0.123.21.dist-info → cognite_neat-0.123.22.dist-info}/licenses/LICENSE +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.123.
|
|
1
|
+
__version__ = "0.123.22"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
from typing import Any, Literal
|
|
1
|
+
from typing import Any, Literal, cast
|
|
2
2
|
from zipfile import Path
|
|
3
3
|
|
|
4
|
+
from cognite.client.data_classes.data_modeling import DataModelId, DataModelIdentifier
|
|
5
|
+
|
|
6
|
+
from cognite.neat.core._client._api_client import NeatClient
|
|
4
7
|
from cognite.neat.core._data_model import importers
|
|
5
8
|
from cognite.neat.core._data_model.importers._base import BaseImporter
|
|
6
9
|
from cognite.neat.core._issues._base import IssueList
|
|
@@ -12,7 +15,7 @@ from cognite.neat.plugins.data_model.importers._base import DataModelImporterPlu
|
|
|
12
15
|
from cognite.neat.session._state import SessionState
|
|
13
16
|
from cognite.neat.session.exceptions import NeatSessionError, session_class_wrapper
|
|
14
17
|
|
|
15
|
-
InternalReaderName = Literal["excel", "ontology", "yaml"]
|
|
18
|
+
InternalReaderName = Literal["excel", "cdf", "ontology", "yaml"]
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
@session_class_wrapper
|
|
@@ -20,16 +23,21 @@ class ReadAPI:
|
|
|
20
23
|
def __init__(self, state: SessionState) -> None:
|
|
21
24
|
self._state = state
|
|
22
25
|
|
|
23
|
-
def __call__(self, name: str, io: str | Path, **kwargs: Any) -> IssueList:
|
|
24
|
-
"""Provides access to
|
|
26
|
+
def __call__(self, name: str, io: str | Path | DataModelIdentifier, **kwargs: Any) -> IssueList:
|
|
27
|
+
"""Provides access to internal data model readers and external data model
|
|
28
|
+
reader plugins.
|
|
25
29
|
|
|
26
30
|
Args:
|
|
27
|
-
name (str): The name of format (e.g. Excel)
|
|
28
|
-
io (str | Path | None): The input/output interface for the
|
|
29
|
-
**kwargs (Any): Additional keyword arguments for the
|
|
31
|
+
name (str): The name of format (e.g. Excel) reader is handling.
|
|
32
|
+
io (str | Path | | DataModelIdentifier | None): The input/output interface for the reader.
|
|
33
|
+
**kwargs (Any): Additional keyword arguments for the reader.
|
|
34
|
+
|
|
35
|
+
!!! note "io"
|
|
36
|
+
The `io` parameter can be a file path, sting, or a DataModelIdentifier
|
|
37
|
+
depending on the reader's requirements.
|
|
30
38
|
|
|
31
39
|
!!! note "kwargs"
|
|
32
|
-
Users must consult the documentation of the
|
|
40
|
+
Users must consult the documentation of the reader to understand
|
|
33
41
|
what keyword arguments are supported.
|
|
34
42
|
"""
|
|
35
43
|
|
|
@@ -39,16 +47,19 @@ class ReadAPI:
|
|
|
39
47
|
# The match statement cleanly handles each case.
|
|
40
48
|
match clean_name:
|
|
41
49
|
case "excel":
|
|
42
|
-
return self.excel(io, **kwargs)
|
|
50
|
+
return self.excel(cast(str | Path, io), **kwargs)
|
|
51
|
+
|
|
52
|
+
case "cdf":
|
|
53
|
+
return self.cdf(cast(DataModelIdentifier, io))
|
|
43
54
|
|
|
44
55
|
case "ontology":
|
|
45
|
-
return self.ontology(io)
|
|
56
|
+
return self.ontology(cast(str | Path, io))
|
|
46
57
|
|
|
47
58
|
case "yaml":
|
|
48
|
-
return self.yaml(io, **kwargs)
|
|
59
|
+
return self.yaml(cast(str | Path, io), **kwargs)
|
|
49
60
|
|
|
50
61
|
case _: # The wildcard '_' acts as the default 'else' case.
|
|
51
|
-
return self._plugin(name, io, **kwargs)
|
|
62
|
+
return self._plugin(name, cast(str | Path, io), **kwargs)
|
|
52
63
|
|
|
53
64
|
def _plugin(self, name: str, io: str | Path, **kwargs: Any) -> IssueList:
|
|
54
65
|
"""Provides access to the external plugins for data model importing.
|
|
@@ -82,6 +93,34 @@ class ReadAPI:
|
|
|
82
93
|
|
|
83
94
|
return self._state.data_model_import(plugin().configure(io=path, **kwargs))
|
|
84
95
|
|
|
96
|
+
def cdf(self, io: DataModelIdentifier) -> IssueList:
|
|
97
|
+
"""Reads a Data Model from CDF to the knowledge graph.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
io: Tuple of strings with the id of a CDF Data Model.
|
|
101
|
+
Notation as follows (<name_of_space>, <name_of_data_model>, <data_model_version>)
|
|
102
|
+
|
|
103
|
+
Example:
|
|
104
|
+
```python
|
|
105
|
+
neat.read.cdf.data_model(("example_data_model_space", "EXAMPLE_DATA_MODEL", "v1"))
|
|
106
|
+
```
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
data_model_id = DataModelId.load(io)
|
|
110
|
+
|
|
111
|
+
if not data_model_id.version:
|
|
112
|
+
raise NeatSessionError("Data model version is required to read a data model.")
|
|
113
|
+
|
|
114
|
+
self._state._raise_exception_if_condition_not_met(
|
|
115
|
+
"Read data model from CDF",
|
|
116
|
+
empty_data_model_store_required=True,
|
|
117
|
+
client_required=True,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return self._state.data_model_import(
|
|
121
|
+
importers.DMSImporter.from_data_model_id(cast(NeatClient, self._state.client), data_model_id)
|
|
122
|
+
)
|
|
123
|
+
|
|
85
124
|
def excel(self, io: str | Path, *, enable_manual_edit: bool = False) -> IssueList:
|
|
86
125
|
"""Reads a Neat Excel Data Model to the data model store.
|
|
87
126
|
The data model spreadsheets may contain conceptual or physical data model definitions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 0.123.
|
|
3
|
+
Version: 0.123.22
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
Project-URL: Documentation, https://cognite-neat.readthedocs-hosted.com/
|
|
6
6
|
Project-URL: Homepage, https://cognite-neat.readthedocs-hosted.com/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
cognite/neat/__init__.py,sha256=12StS1dzH9_MElqxGvLWrNsxCJl9Hv8A2a9D0E5OD_U,193
|
|
2
|
-
cognite/neat/_version.py,sha256=
|
|
2
|
+
cognite/neat/_version.py,sha256=F_PTAPIzLmGDm4RPxIsNpijbHtxGJrALannZQ5hHcUY,47
|
|
3
3
|
cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
cognite/neat/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite/neat/core/_config.py,sha256=WT1BS8uADcFvGoUYOOfwFOVq_VBl472TisdoA3wLick,280
|
|
@@ -186,7 +186,7 @@ cognite/neat/session/_wizard.py,sha256=hARNNzD5Zfkk_V147rIjOLVvrFaqzXGXWhZuH1NJG
|
|
|
186
186
|
cognite/neat/session/exceptions.py,sha256=z5jxwfVTXDCCFZKTTYVIaksNKqb9CMa2tyIZgyNL3Us,3475
|
|
187
187
|
cognite/neat/session/_session/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
188
188
|
cognite/neat/session/_session/_data_model/__init__.py,sha256=417QF6wm3r-bLTmhYGXL_5XnEFShCklLCoGg3YBOIqY,62
|
|
189
|
-
cognite/neat/session/_session/_data_model/_read.py,sha256=
|
|
189
|
+
cognite/neat/session/_session/_data_model/_read.py,sha256=B_mVOt_9uKzG5vbrZG2Uf5D0FQGjcCDEdfAhIp2veUI,7902
|
|
190
190
|
cognite/neat/session/_session/_data_model/_routes.py,sha256=wF83vLtmgyGCM2zxnHq0m3-sPQXQamObc58u2kSN7nQ,1666
|
|
191
191
|
cognite/neat/session/_session/_data_model/_show.py,sha256=yX4BTIeBzcCcllfJvGm8g4qy13heFmcJtpXPixI8T2o,5835
|
|
192
192
|
cognite/neat/session/_state/README.md,sha256=o6N7EL98lgyWffw8IoEUf2KG5uSKveD5__TW45YzVjA,902
|
|
@@ -194,7 +194,7 @@ cognite/neat/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvc
|
|
|
194
194
|
cognite/neat/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
|
|
195
195
|
cognite/neat/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
|
|
196
196
|
cognite/neat/session/engine/_load.py,sha256=g52uYakQM03VqHt_RDHtpHso1-mFFifH5M4T2ScuH8A,5198
|
|
197
|
-
cognite_neat-0.123.
|
|
198
|
-
cognite_neat-0.123.
|
|
199
|
-
cognite_neat-0.123.
|
|
200
|
-
cognite_neat-0.123.
|
|
197
|
+
cognite_neat-0.123.22.dist-info/METADATA,sha256=cIvYIW2976HqHJSdiseJuSEG3om5ldv2Z-csEbZQt6Y,9172
|
|
198
|
+
cognite_neat-0.123.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
199
|
+
cognite_neat-0.123.22.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
200
|
+
cognite_neat-0.123.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|