cognite-neat 0.123.1__py3-none-any.whl → 0.123.2__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/plugins/_issues.py +11 -1
- cognite/neat/plugins/_manager.py +8 -4
- cognite/neat/plugins/data_model/importers/_base.py +3 -2
- cognite/neat/session/_base.py +2 -0
- cognite/neat/session/_experimental.py +1 -0
- cognite/neat/session/_plugin.py +67 -0
- cognite/neat/session/exceptions.py +2 -0
- {cognite_neat-0.123.1.dist-info → cognite_neat-0.123.2.dist-info}/METADATA +1 -1
- {cognite_neat-0.123.1.dist-info → cognite_neat-0.123.2.dist-info}/RECORD +12 -11
- {cognite_neat-0.123.1.dist-info → cognite_neat-0.123.2.dist-info}/WHEEL +0 -0
- {cognite_neat-0.123.1.dist-info → cognite_neat-0.123.2.dist-info}/licenses/LICENSE +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.123.
|
|
1
|
+
__version__ = "0.123.2"
|
|
2
2
|
__engine__ = "^2.0.4"
|
cognite/neat/plugins/_issues.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
|
|
3
|
-
from cognite.neat.core._issues.
|
|
3
|
+
from cognite.neat.core._issues.errors import _NEAT_ERRORS_BY_NAME, NeatError
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
@dataclass(unsafe_hash=True)
|
|
@@ -23,3 +23,13 @@ class PluginDuplicateError(PluginError):
|
|
|
23
23
|
"""Plugin of type '{plugin_type}' registered for under name '{plugin_name}' already exists"""
|
|
24
24
|
|
|
25
25
|
...
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Register the errors in the _NEAT_ERRORS_BY_NAME dictionary
|
|
29
|
+
_NEAT_ERRORS_BY_NAME.update(
|
|
30
|
+
{
|
|
31
|
+
"PluginError": PluginError,
|
|
32
|
+
"PluginLoadingError": PluginLoadingError,
|
|
33
|
+
"PluginDuplicateError": PluginDuplicateError,
|
|
34
|
+
}
|
|
35
|
+
)
|
cognite/neat/plugins/_manager.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Plugin manager for external plugins."""
|
|
2
2
|
|
|
3
3
|
from importlib import metadata
|
|
4
|
-
from typing import Any, ClassVar, TypeAlias
|
|
4
|
+
from typing import Any, ClassVar, TypeAlias, TypeVar, cast
|
|
5
5
|
|
|
6
6
|
from ._issues import PluginDuplicateError, PluginError, PluginLoadingError
|
|
7
7
|
from .data_model.importers import DataModelImporterPlugin
|
|
@@ -14,6 +14,9 @@ plugins_entry_points = {
|
|
|
14
14
|
#: Type alias for all supported plugin types
|
|
15
15
|
NeatPlugin: TypeAlias = DataModelImporterPlugin
|
|
16
16
|
|
|
17
|
+
# Generic type variable for plugin types
|
|
18
|
+
T_NeatPlugin = TypeVar("T_NeatPlugin", bound=NeatPlugin)
|
|
19
|
+
|
|
17
20
|
|
|
18
21
|
class Plugin:
|
|
19
22
|
"""Plugin class for registering plugins registered via entry points (i.e. external plugins).
|
|
@@ -33,7 +36,7 @@ class Plugin:
|
|
|
33
36
|
self.type_ = type_
|
|
34
37
|
self.entry_point = entry_point
|
|
35
38
|
|
|
36
|
-
def load(self) ->
|
|
39
|
+
def load(self) -> type[NeatPlugin]:
|
|
37
40
|
try:
|
|
38
41
|
return self.entry_point.load()
|
|
39
42
|
except Exception as e:
|
|
@@ -50,7 +53,7 @@ class PluginManager:
|
|
|
50
53
|
def __init__(self, plugins: dict[tuple[str, type[NeatPlugin]], Any]) -> None:
|
|
51
54
|
self._plugins = plugins
|
|
52
55
|
|
|
53
|
-
def get(self, name: str, type_: type[
|
|
56
|
+
def get(self, name: str, type_: type[T_NeatPlugin]) -> type[T_NeatPlugin]:
|
|
54
57
|
"""
|
|
55
58
|
Returns desired plugin
|
|
56
59
|
|
|
@@ -59,7 +62,8 @@ class PluginManager:
|
|
|
59
62
|
type_ (type): The type of the plugin.
|
|
60
63
|
"""
|
|
61
64
|
try:
|
|
62
|
-
|
|
65
|
+
plugin_class = self._plugins[(name, type_)]
|
|
66
|
+
return cast(type[T_NeatPlugin], plugin_class)
|
|
63
67
|
except KeyError:
|
|
64
68
|
raise PluginError(plugin_name=name, plugin_type=type_.__name__) from None
|
|
65
69
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from pathlib import Path
|
|
1
2
|
from typing import Any
|
|
2
3
|
|
|
3
4
|
from cognite.neat.core._data_model.importers._base import BaseImporter
|
|
@@ -9,11 +10,11 @@ class DataModelImporterPlugin:
|
|
|
9
10
|
It is expected to implement the `configure` method which returns a configured importer.
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
|
-
def configure(self, io:
|
|
13
|
+
def configure(self, io: str | Path | None, **kwargs: Any) -> BaseImporter:
|
|
13
14
|
"""Return a configure plugin for data model import.
|
|
14
15
|
|
|
15
16
|
Args:
|
|
16
|
-
io (
|
|
17
|
+
io (str | Path | None): The input/output interface for the plugin.
|
|
17
18
|
**kwargs (Any): Additional keyword arguments for configuration.
|
|
18
19
|
|
|
19
20
|
Returns:
|
cognite/neat/session/_base.py
CHANGED
|
@@ -30,6 +30,7 @@ from ._explore import ExploreAPI
|
|
|
30
30
|
from ._fix import FixAPI
|
|
31
31
|
from ._inspect import InspectAPI
|
|
32
32
|
from ._mapping import MappingAPI
|
|
33
|
+
from ._plugin import PluginAPI
|
|
33
34
|
from ._prepare import PrepareAPI
|
|
34
35
|
from ._read import ReadAPI
|
|
35
36
|
from ._set import SetAPI
|
|
@@ -108,6 +109,7 @@ class NeatSession:
|
|
|
108
109
|
self.subset = SubsetAPI(self._state)
|
|
109
110
|
self.template = TemplateAPI(self._state)
|
|
110
111
|
self._explore = ExploreAPI(self._state)
|
|
112
|
+
self.plugins = PluginAPI(self._state)
|
|
111
113
|
self.opt = OptAPI()
|
|
112
114
|
self.opt._display()
|
|
113
115
|
if load_engine != "skip" and (engine_version := load_neat_engine(client, load_engine)):
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from cognite.neat.core._issues._base import IssueList
|
|
6
|
+
from cognite.neat.core._utils.reader._base import NeatReader
|
|
7
|
+
from cognite.neat.plugins import get_plugin_manager
|
|
8
|
+
from cognite.neat.plugins.data_model.importers._base import DataModelImporterPlugin
|
|
9
|
+
from cognite.neat.session._experimental import ExperimentalFlags
|
|
10
|
+
|
|
11
|
+
from ._state import SessionState
|
|
12
|
+
from .exceptions import session_class_wrapper
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@session_class_wrapper
|
|
16
|
+
class PluginAPI:
|
|
17
|
+
"""Read from a data source into NeatSession graph store."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, state: SessionState) -> None:
|
|
20
|
+
self._state = state
|
|
21
|
+
|
|
22
|
+
self.data_model = DataModelPlugins(self._state)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@session_class_wrapper
|
|
26
|
+
class DataModelPlugins:
|
|
27
|
+
"""Read from a data source into NeatSession graph store."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, state: SessionState) -> None:
|
|
30
|
+
self._state = state
|
|
31
|
+
|
|
32
|
+
def read(self, name: str, io: str | Path | None = None, **kwargs: Any) -> IssueList:
|
|
33
|
+
"""Provides access to the external plugins for data model importing.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
name (str): The name of format (e.g. Excel) plugin is handling.
|
|
37
|
+
io (str | Path | None): The input/output interface for the plugin.
|
|
38
|
+
**kwargs (Any): Additional keyword arguments for the plugin.
|
|
39
|
+
|
|
40
|
+
!!! note "kwargs"
|
|
41
|
+
Users must consult the documentation of the plugin to understand
|
|
42
|
+
what keyword arguments are supported.
|
|
43
|
+
"""
|
|
44
|
+
warnings.filterwarnings("default")
|
|
45
|
+
ExperimentalFlags.plugin.warn()
|
|
46
|
+
|
|
47
|
+
# Some plugins may not support the io argument
|
|
48
|
+
if io:
|
|
49
|
+
reader = NeatReader.create(io)
|
|
50
|
+
path = reader.materialize_path()
|
|
51
|
+
else:
|
|
52
|
+
path = None
|
|
53
|
+
|
|
54
|
+
self._state._raise_exception_if_condition_not_met(
|
|
55
|
+
"Data Model Read",
|
|
56
|
+
empty_data_model_store_required=True,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
plugin_manager = get_plugin_manager()
|
|
60
|
+
plugin = plugin_manager.get(name, DataModelImporterPlugin)
|
|
61
|
+
|
|
62
|
+
print(
|
|
63
|
+
f"You are using an external plugin {plugin.__name__}, which is not developed by the NEAT team."
|
|
64
|
+
"\nUse it at your own risk."
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return self._state.data_model_import(plugin().configure(io=path, **kwargs))
|
|
@@ -6,6 +6,7 @@ from typing import Any, TypeVar
|
|
|
6
6
|
from cognite.neat.core._issues.errors import CDFMissingClientError, NeatImportError
|
|
7
7
|
from cognite.neat.core._issues.errors._external import OxigraphStorageLockedError
|
|
8
8
|
from cognite.neat.core._issues.errors._general import NeatValueError, WillExceedLimitError
|
|
9
|
+
from cognite.neat.plugins._issues import PluginError
|
|
9
10
|
from cognite.neat.session._experimental import ExperimentalFeatureWarning
|
|
10
11
|
|
|
11
12
|
from ._collector import _COLLECTOR
|
|
@@ -50,6 +51,7 @@ def _session_method_wrapper(func: Callable, cls_name: str) -> Any:
|
|
|
50
51
|
NeatImportError,
|
|
51
52
|
NeatValueError,
|
|
52
53
|
OxigraphStorageLockedError,
|
|
54
|
+
PluginError,
|
|
53
55
|
WillExceedLimitError,
|
|
54
56
|
) as e:
|
|
55
57
|
print(f"{_ERROR_PREFIX} {escape(e.as_message())}")
|
|
@@ -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=HP2O0I_4JuG1TczHFazc53TQqD0Z8qh9R2SVWsXmlSQ,46
|
|
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
|
|
@@ -161,20 +161,21 @@ cognite/neat/core/_utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP
|
|
|
161
161
|
cognite/neat/core/_utils/reader/__init__.py,sha256=fPkrNB_9hLB7CyHTCFV_xEbIfOMqUQzNly5JN33-QfM,146
|
|
162
162
|
cognite/neat/core/_utils/reader/_base.py,sha256=fRXxUWW8a3UFedeCLxDTDgFntWGlHaEGxmKLcITtiWE,5417
|
|
163
163
|
cognite/neat/plugins/__init__.py,sha256=Q7r1FFbybOt71N9TjHjjk-1HguLRfHieLeiGVSG5HTY,75
|
|
164
|
-
cognite/neat/plugins/_issues.py,sha256=
|
|
165
|
-
cognite/neat/plugins/_manager.py,sha256=
|
|
164
|
+
cognite/neat/plugins/_issues.py,sha256=jukeVjSs1DEzqtFuGRcIDbg7bNxZRxGPqnzumVRF-8c,940
|
|
165
|
+
cognite/neat/plugins/_manager.py,sha256=_eJa5_3UGoLVacSQgbDrE0eWcopjeXxgbfSmvujeSiU,3979
|
|
166
166
|
cognite/neat/plugins/data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
167
167
|
cognite/neat/plugins/data_model/importers/__init__.py,sha256=d4UJNCFR1DXPY7lv5LdCW2hiStEhvXiu2g_bRSIp1y0,89
|
|
168
|
-
cognite/neat/plugins/data_model/importers/_base.py,sha256=
|
|
168
|
+
cognite/neat/plugins/data_model/importers/_base.py,sha256=M9zXp7tEu1SfJZRAJAtLmqpssdFcoi2X-5e25q_n_h8,1034
|
|
169
169
|
cognite/neat/session/__init__.py,sha256=fxQ5URVlUnmEGYyB8Baw7IDq-uYacqkigbc4b-Pr9Fw,58
|
|
170
|
-
cognite/neat/session/_base.py,sha256=
|
|
170
|
+
cognite/neat/session/_base.py,sha256=vg8KgzpQxFnFCR4F0yRNSsRmrgYZQ77rW6eX4w7L9M4,12884
|
|
171
171
|
cognite/neat/session/_collector.py,sha256=-icWXOT9YBjAOVZfpPtBx-D39kpRP2RaQKdPtcr7Xm8,4233
|
|
172
172
|
cognite/neat/session/_drop.py,sha256=ipD8RS_ZebPNpeIkhC7yqSSeo7e57TXMRxrh5_6IRik,4239
|
|
173
|
-
cognite/neat/session/_experimental.py,sha256=
|
|
173
|
+
cognite/neat/session/_experimental.py,sha256=0peZPZ9JpmzQE05wHbng2tWmPPLLTAVfWZEEUhdnI6o,1274
|
|
174
174
|
cognite/neat/session/_explore.py,sha256=PLxpHDqBk5B0Q4a5tJKnF6KzL4heQ77b2qUETbf6iVQ,1599
|
|
175
175
|
cognite/neat/session/_fix.py,sha256=oJRXuRI4f_HgLYHkjbtPAwHK0vSDUYd19hIZeFaE7rQ,919
|
|
176
176
|
cognite/neat/session/_inspect.py,sha256=AESQd2SOidR_pDTFk5B_JdPnKZ5PNNskdAQBepH2Mv0,10175
|
|
177
177
|
cognite/neat/session/_mapping.py,sha256=ItEXhXo_8V3069hktHMxdpBsLNeTck3gZBvhlm12Oxw,2895
|
|
178
|
+
cognite/neat/session/_plugin.py,sha256=diFvZUFRvY037iVy_HxnIGMSfrauOpwYCSvFEPOzchQ,2282
|
|
178
179
|
cognite/neat/session/_prepare.py,sha256=pskEVNgcnVJVRvYKk5xI55V89vKDO_kgjszj5flY8Zs,12778
|
|
179
180
|
cognite/neat/session/_read.py,sha256=sKtSw7Ub--vR6wfEexNzzaEHb0MZCHj3kzCEnF5wjf0,35349
|
|
180
181
|
cognite/neat/session/_set.py,sha256=PU4lKI-LGtKFVyvdtfZkk-zLw9e_rnFHzuV9IyrOrTM,4593
|
|
@@ -184,13 +185,13 @@ cognite/neat/session/_subset.py,sha256=p7n6WmL0gZlUbqpVBgyPncQ6uWn_pi7FDSixDFrm7
|
|
|
184
185
|
cognite/neat/session/_template.py,sha256=NCgrrwLT98DpLYoo3Wybr_OUXrEXpsJZjrJ83KqfyWc,9908
|
|
185
186
|
cognite/neat/session/_to.py,sha256=_R-UB3iEIQoa12kTD7tuSrRDdbySQXQg_mzbn5t-7bg,19399
|
|
186
187
|
cognite/neat/session/_wizard.py,sha256=hARNNzD5Zfkk_V147rIjOLVvrFaqzXGXWhZuH1NJG3M,1486
|
|
187
|
-
cognite/neat/session/exceptions.py,sha256=
|
|
188
|
+
cognite/neat/session/exceptions.py,sha256=z5jxwfVTXDCCFZKTTYVIaksNKqb9CMa2tyIZgyNL3Us,3475
|
|
188
189
|
cognite/neat/session/_state/README.md,sha256=o6N7EL98lgyWffw8IoEUf2KG5uSKveD5__TW45YzVjA,902
|
|
189
190
|
cognite/neat/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvca6n48bu_bI,120
|
|
190
191
|
cognite/neat/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
|
|
191
192
|
cognite/neat/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
|
|
192
193
|
cognite/neat/session/engine/_load.py,sha256=g52uYakQM03VqHt_RDHtpHso1-mFFifH5M4T2ScuH8A,5198
|
|
193
|
-
cognite_neat-0.123.
|
|
194
|
-
cognite_neat-0.123.
|
|
195
|
-
cognite_neat-0.123.
|
|
196
|
-
cognite_neat-0.123.
|
|
194
|
+
cognite_neat-0.123.2.dist-info/METADATA,sha256=S0A0bAMepNWiOxj_BGAZL_nSetJnWlVdrgA8JOps3rI,9171
|
|
195
|
+
cognite_neat-0.123.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
196
|
+
cognite_neat-0.123.2.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
197
|
+
cognite_neat-0.123.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|