cognite-neat 0.123.34__py3-none-any.whl → 0.123.36__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,2 +1,2 @@
1
- __version__ = "0.123.34"
1
+ __version__ = "0.123.36"
2
2
  __engine__ = "^2.0.4"
@@ -128,6 +128,8 @@ SPLIT_ON_EQUAL_PATTERN = re.compile(r"=(?![^(]*\))")
128
128
  # Very special Edge Entity parsing
129
129
  SPLIT_ON_EDGE_ENTITY_ARGS_PATTERN = re.compile(r"(\btype\b|\bproperties\b|\bdirection\b)\s*=\s*([^,]+)")
130
130
 
131
+ CONSTRAINT_ID_MAX_LENGTH = 43
132
+
131
133
 
132
134
  class _Patterns:
133
135
  @cached_property
@@ -1,3 +1,4 @@
1
+ import hashlib
1
2
  import warnings
2
3
  from collections import defaultdict
3
4
  from collections.abc import Collection, Hashable, Sequence
@@ -25,6 +26,7 @@ from cognite.neat.v0.core._constants import (
25
26
  DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
26
27
  DMS_PRIMITIVE_LIST_DEFAULT_LIMIT,
27
28
  )
29
+ from cognite.neat.v0.core._data_model._constants import CONSTRAINT_ID_MAX_LENGTH
28
30
  from cognite.neat.v0.core._data_model.models.data_types import DataType, Double, Enum, Float, LangString, String
29
31
  from cognite.neat.v0.core._data_model.models.entities import (
30
32
  ConceptEntity,
@@ -409,12 +411,19 @@ class _DMSExporter:
409
411
  for container in containers:
410
412
  if container.constraints:
411
413
  container.constraints = {
412
- name: const
414
+ self._truncate_constraint_name(name): const
413
415
  for name, const in container.constraints.items()
414
416
  if not (isinstance(const, dm.RequiresConstraint) and const.require in container_to_drop)
415
417
  }
416
418
  return ContainerApplyDict([container for container in containers if container.as_id() not in container_to_drop])
417
419
 
420
+ @staticmethod
421
+ def _truncate_constraint_name(name: str) -> str:
422
+ if len(name) <= CONSTRAINT_ID_MAX_LENGTH:
423
+ return name
424
+ half_length = int(CONSTRAINT_ID_MAX_LENGTH / 2)
425
+ return f"{name[: half_length - 1]}{hashlib.md5(name.encode()).hexdigest()[:half_length]}"
426
+
418
427
  @staticmethod
419
428
  def _gather_properties(
420
429
  properties: Sequence[PhysicalProperty],
@@ -1,3 +1,4 @@
1
+ from ._data_model import DataModelImporterPlugin, DataModelTransformerPlugin
1
2
  from ._manager import get_plugin_manager
2
3
 
3
- __all__ = ["get_plugin_manager"]
4
+ __all__ = ["DataModelImporterPlugin", "DataModelTransformerPlugin", "get_plugin_manager"]
@@ -0,0 +1,9 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Any
3
+
4
+
5
+ class NeatPlugin(ABC):
6
+ @abstractmethod
7
+ def configure(self, *args: Any, **kwargs: Any) -> Any:
8
+ """A method that all plugins must implement."""
9
+ raise NotImplementedError()
@@ -0,0 +1,48 @@
1
+ from pathlib import Path
2
+ from typing import Any
3
+
4
+ from cognite.neat.v0.core._data_model.importers._base import BaseImporter
5
+ from cognite.neat.v0.core._data_model.transformers._base import VerifiedDataModelTransformer
6
+
7
+ from ._base import NeatPlugin
8
+
9
+
10
+ class DataModelImporterPlugin(NeatPlugin):
11
+ """This class is used an interface for data model import plugins.
12
+ Any plugin that is used for importing data models should inherit from this class.
13
+ It is expected to implement the `configure` method which returns a configured importer.
14
+ """
15
+
16
+ def configure(self, io: str | Path | None, **kwargs: Any) -> BaseImporter:
17
+ """Return a configure plugin for data model import.
18
+ Args:
19
+ io (str | Path | None): The input/output interface for the plugin.
20
+ **kwargs (Any): Additional keyword arguments for configuration.
21
+ Returns:
22
+ BaseImporter: A configured instance of the BaseImporter.
23
+ !!! note "Returns"
24
+ The method must return an instance of `BaseImporter` or its subclasses
25
+ meaning it must implement the `BaseImporter` interface.
26
+ """
27
+
28
+ raise NotImplementedError()
29
+
30
+
31
+ class DataModelTransformerPlugin(NeatPlugin):
32
+ """This class is used as an interface for data model transformer plugins.
33
+ Any plugin that is used for transforming data models should inherit from this class.
34
+ It is expected to implement the `configure` method which returns a configured transformer.
35
+ """
36
+
37
+ def configure(self, **kwargs: Any) -> VerifiedDataModelTransformer:
38
+ """Return a configure plugin for data model import.
39
+ Args:
40
+ **kwargs (Any): Additional keyword arguments for configuration.
41
+ Returns:
42
+ VerifiedDataModelTransformer: A configured instance of the VerifiedDataModelTransformer.
43
+ !!! note "Returns"
44
+ The method must return an instance of `VerifiedDataModelTransformer` or its subclasses
45
+ meaning it must implement the `VerifiedDataModelTransformer` interface.
46
+ """
47
+
48
+ raise NotImplementedError()
@@ -1,21 +1,11 @@
1
1
  """Plugin manager for external plugins."""
2
2
 
3
3
  from importlib import metadata
4
- from typing import Any, ClassVar, TypeAlias, TypeVar, cast
4
+ from typing import Any, ClassVar
5
5
 
6
+ from ._base import NeatPlugin
7
+ from ._data_model import DataModelImporterPlugin, DataModelTransformerPlugin
6
8
  from ._issues import PluginDuplicateError, PluginError, PluginLoadingError
7
- from .data_model.importers import DataModelImporterPlugin
8
-
9
- # Here we configure entry points where external plugins are going to be registered.
10
- plugins_entry_points = {
11
- "cognite.neat.v0.plugins.data_model.importers": DataModelImporterPlugin,
12
- }
13
-
14
- #: Type alias for all supported plugin types
15
- NeatPlugin: TypeAlias = DataModelImporterPlugin
16
-
17
- # Generic type variable for plugin types
18
- T_NeatPlugin = TypeVar("T_NeatPlugin", bound=NeatPlugin)
19
9
 
20
10
 
21
11
  class Plugin:
@@ -48,12 +38,13 @@ class PluginManager:
48
38
 
49
39
  _plugins_entry_points: ClassVar[dict[str, type[NeatPlugin]]] = {
50
40
  "cognite.neat.v0.plugins.data_model.importers": DataModelImporterPlugin,
41
+ "cognite.neat.v0.plugins.data_model.transformers": DataModelTransformerPlugin,
51
42
  }
52
43
 
53
44
  def __init__(self, plugins: dict[tuple[str, type[NeatPlugin]], Any]) -> None:
54
45
  self._plugins = plugins
55
46
 
56
- def get(self, name: str, type_: type[T_NeatPlugin]) -> type[T_NeatPlugin]:
47
+ def get(self, name: str, type_: type[NeatPlugin]) -> type[NeatPlugin]:
57
48
  """
58
49
  Returns desired plugin
59
50
 
@@ -63,7 +54,7 @@ class PluginManager:
63
54
  """
64
55
  try:
65
56
  plugin_class = self._plugins[(name, type_)]
66
- return cast(type[T_NeatPlugin], plugin_class)
57
+ return plugin_class
67
58
  except KeyError:
68
59
  raise PluginError(plugin_name=name, plugin_type=type_.__name__) from None
69
60
 
@@ -4,8 +4,7 @@ from typing import Any
4
4
 
5
5
  from cognite.neat.v0.core._issues._base import IssueList
6
6
  from cognite.neat.v0.core._utils.reader._base import NeatReader
7
- from cognite.neat.v0.plugins import get_plugin_manager
8
- from cognite.neat.v0.plugins.data_model.importers._base import DataModelImporterPlugin
7
+ from cognite.neat.v0.plugins import DataModelImporterPlugin, get_plugin_manager
9
8
  from cognite.neat.v0.session._experimental import ExperimentalFlags
10
9
 
11
10
  from ._state import SessionState
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite-neat
3
- Version: 0.123.34
3
+ Version: 0.123.36
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/
7
7
  Project-URL: GitHub, https://github.com/cognitedata/neat
8
8
  Project-URL: Changelog, https://github.com/cognitedata/neat/releases
9
- Author-email: Nikola Vasiljevic <nikola.vasiljevic@cognite.com>, Anders Albert <anders.albert@cognite.com>, Rogerio Júnior <rogerio.junior@cognite.com>
9
+ Author-email: Nikola Vasiljevic <nikola.vasiljevic@cognite.com>, Anders Albert <anders.albert@cognite.com>
10
10
  License-Expression: Apache-2.0
11
11
  License-File: LICENSE
12
12
  Requires-Python: >=3.10
@@ -96,16 +96,15 @@ The plot below shows the NEAT authorship from the start until present day.
96
96
  #### Current authors
97
97
  - [Nikola Vasiljević](www.linkedin.com/in/thisisnikola)
98
98
  - [Anders Albert](https://www.linkedin.com/in/anders-albert-00790483/)
99
- - [Rogerio Júnior](https://www.linkedin.com/in/rogerio-saboia-j%C3%BAnior-087118a7/)
100
99
 
101
100
  #### Former authors
102
101
  - [Aleksandrs Livincovs](https://www.linkedin.com/in/aleksandrslivincovs/)
103
102
  - [Julia Graham](https://www.linkedin.com/in/julia-graham-959a78a7/)
103
+ - [Rogerio Júnior](https://www.linkedin.com/in/rogerio-saboia-j%C3%BAnior-087118a7/)
104
104
 
105
105
  ### Contributors
106
106
  We are very grateful for the contributions made by:
107
107
 
108
-
109
108
  - [Marie Solvik Lepoutre](https://www.linkedin.com/in/mslepoutre/), who improved RDF triples projections to Cognite Data Fusion
110
109
  - [Bård Henning Tvedt](https://www.linkedin.com/in/bhtvedt/), who implemented IMF importer
111
110
  - [Hassan Gomaa](https://www.linkedin.com/in/dr-hassan-gomaa-232638121/), who extended the DEXPI extractor
@@ -1,5 +1,5 @@
1
1
  cognite/neat/__init__.py,sha256=Lo4DbjDOwnhCYUoAgPp5RG1fDdF7OlnomalTe7n1ydw,211
2
- cognite/neat/_version.py,sha256=ta4oMlJUvDU3nY4lbUMsc0rlosf138ZYBeYdejtGs_0,47
2
+ cognite/neat/_version.py,sha256=jaav_lFeEoGh_VeTDKjQPDYC__mrYSbc7TXSKhz9g7c,47
3
3
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cognite/neat/_data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cognite/neat/_data_model/_constants.py,sha256=NGGvWHlQqhkkSBP_AqoofGYjNph3SiZX6QPINlMsy04,107
@@ -42,7 +42,7 @@ cognite/neat/v0/core/_client/data_classes/neat_sequence.py,sha256=QZWSfWnwk6KlYJ
42
42
  cognite/neat/v0/core/_client/data_classes/schema.py,sha256=YoLm0YQIhbYSFuSgC-GB3jgNy7qZw4WhT3A-jKkIVhk,25079
43
43
  cognite/neat/v0/core/_client/data_classes/statistics.py,sha256=GU-u41cOTig0Y5pYhW5KqzCsuAUIX9tOmdizMEveYuw,4487
44
44
  cognite/neat/v0/core/_data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
- cognite/neat/v0/core/_data_model/_constants.py,sha256=37lvnq3UZu4bPSzjRRThXJGdvaxmA7KJzWL0YysYBs8,6040
45
+ cognite/neat/v0/core/_data_model/_constants.py,sha256=BEzWHWnEmtkYSPJVcGv3rL7JuYIZZNeI4Y5IUhtqTFk,6071
46
46
  cognite/neat/v0/core/_data_model/_shared.py,sha256=ug6B_Vz7seg464xMMn0v3SKN_FNCNG1QeLqW-Bto-yA,2100
47
47
  cognite/neat/v0/core/_data_model/analysis/__init__.py,sha256=v3hSfz7AEEqcmdjL71I09tP8Hl-gPZYOiDYMp_CW4vg,70
48
48
  cognite/neat/v0/core/_data_model/analysis/_base.py,sha256=AfaKN-NlrXT5J-Tf3CuVzZHwbJXuJbdXwFRJ9uGI_Qg,24472
@@ -91,7 +91,7 @@ cognite/neat/v0/core/_data_model/models/mapping/__init__.py,sha256=T68Hf7rhiXa7b
91
91
  cognite/neat/v0/core/_data_model/models/mapping/_classic2core.py,sha256=F0zusTh9pPR4z-RExPw3o4EMBSU2si6FJLuej2a3JzM,1430
92
92
  cognite/neat/v0/core/_data_model/models/mapping/_classic2core.yaml,sha256=ei-nuivNWVW9HmvzDBKIPF6ZdgaMq64XHw_rKm0CMxg,22584
93
93
  cognite/neat/v0/core/_data_model/models/physical/__init__.py,sha256=pH5ZF8jiW0A2w7VCSoHUsXxe894QFvTtgjxXNGVVaxk,990
94
- cognite/neat/v0/core/_data_model/models/physical/_exporter.py,sha256=Q8a8bgbrT4CyCZiYT0R8wauMmgi9uLGCyfYKg_UByTo,30316
94
+ cognite/neat/v0/core/_data_model/models/physical/_exporter.py,sha256=Dfll4NU5roUCCvjZ5_q25SYjZntCl5LucuH5Fr4JjQY,30744
95
95
  cognite/neat/v0/core/_data_model/models/physical/_unverified.py,sha256=7la586tAfj7a1_Ql8-Z_amf5mFeBXjAJ57bVdNggIrE,20140
96
96
  cognite/neat/v0/core/_data_model/models/physical/_validation.py,sha256=I954pfdIA2OWAwQP7foyNa6FBJUVB3U-aqf6Likoqp0,41188
97
97
  cognite/neat/v0/core/_data_model/models/physical/_verified.py,sha256=WU0HV8coZfRw-XIEVJZl9PxUaY0Y6q75fBoUF2MgwU4,26813
@@ -182,12 +182,11 @@ cognite/neat/v0/core/_utils/upload.py,sha256=nRhq8G63avFZW-o9HCsepXCk1qFmFfm0EpE
182
182
  cognite/neat/v0/core/_utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP2DQ,1710
183
183
  cognite/neat/v0/core/_utils/reader/__init__.py,sha256=fPkrNB_9hLB7CyHTCFV_xEbIfOMqUQzNly5JN33-QfM,146
184
184
  cognite/neat/v0/core/_utils/reader/_base.py,sha256=baZVNEFv7F2xheQOy34K0sBjsHQTUT6se3kZDrBsVXA,5420
185
- cognite/neat/v0/plugins/__init__.py,sha256=Q7r1FFbybOt71N9TjHjjk-1HguLRfHieLeiGVSG5HTY,75
185
+ cognite/neat/v0/plugins/__init__.py,sha256=acsDoiw0ztT2T-RyUIPtr8rfWpQBj4M6LmSEuAJcQjQ,209
186
+ cognite/neat/v0/plugins/_base.py,sha256=zYy9b7LeDrijRHWzj_ASv4WlsSjo12Msu3DIyBW2zT8,255
187
+ cognite/neat/v0/plugins/_data_model.py,sha256=MSfb9Gtz-whsY3-usMaPYBxpc9-C5qN3gWdN5ca6wDI,2088
186
188
  cognite/neat/v0/plugins/_issues.py,sha256=9lbLlxgPSVHjirOhEHyNQ0Pf3NH82Psj_DuTCcJDQQQ,943
187
- cognite/neat/v0/plugins/_manager.py,sha256=KQkQJGcXa5oXGQVqYGJFBNIJuSLxVrcaxBeH0Fs0GRs,3985
188
- cognite/neat/v0/plugins/data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
189
- cognite/neat/v0/plugins/data_model/importers/__init__.py,sha256=d4UJNCFR1DXPY7lv5LdCW2hiStEhvXiu2g_bRSIp1y0,89
190
- cognite/neat/v0/plugins/data_model/importers/_base.py,sha256=fgqf9-HPpiSf9GCyHfcERiOhjNQVk_uAQDz3E-7ezTM,1037
189
+ cognite/neat/v0/plugins/_manager.py,sha256=Pmaw5yjobMJ64OYaODX3FTaH1Q7hW9rzbz0A8wyIZcI,3683
191
190
  cognite/neat/v0/session/__init__.py,sha256=fxQ5URVlUnmEGYyB8Baw7IDq-uYacqkigbc4b-Pr9Fw,58
192
191
  cognite/neat/v0/session/_base.py,sha256=cLVrNEIizWKdPb2LRtXYxQRQczAnyHXJ46Ak1P4X03k,12967
193
192
  cognite/neat/v0/session/_collector.py,sha256=YCPeapbxBK-vAFMq7ekLy0Pn796M9AM7B8hxFtgsOUU,4236
@@ -197,7 +196,7 @@ cognite/neat/v0/session/_explore.py,sha256=YQF8ubCm-dkpO5WuVfYGTkQjhF_XKHFcG6Ko5
197
196
  cognite/neat/v0/session/_fix.py,sha256=PrXfrSR2DMkKD_k3MajaaziKJaYdIp9wr5aHvra66V4,925
198
197
  cognite/neat/v0/session/_inspect.py,sha256=6xC-tLJfP7sbSQpIlpPmCQWklGxK_rEXBE41jtuUQ-s,10184
199
198
  cognite/neat/v0/session/_mapping.py,sha256=9lQFnB0wpizo4ySIEDMWh183qpHh8TlVL7uOgAtJUxE,2904
200
- cognite/neat/v0/session/_plugin.py,sha256=1FTkwCkfUpNUQHzb_EM_2LHKnbxjOgU8exBxhmzNb24,2297
199
+ cognite/neat/v0/session/_plugin.py,sha256=TqEeUYDiZmOyl33h44J5OlqkH7VzgGi63nJFidpBV4M,2235
201
200
  cognite/neat/v0/session/_prepare.py,sha256=HFdDmBnYRpaCm90s_A0byHLJIZwKrt2ve6i3EyN0V6w,12802
202
201
  cognite/neat/v0/session/_read.py,sha256=2pdlWa-OHQ4j2gRKNTeBzWBOipDPnznnqyys-yzUq2s,34658
203
202
  cognite/neat/v0/session/_set.py,sha256=qFi3YrYBd09MfHVJ2Ak0PCGigTAhGttfnA2iWSYwUt4,4617
@@ -213,7 +212,7 @@ cognite/neat/v0/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4
213
212
  cognite/neat/v0/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
214
213
  cognite/neat/v0/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
215
214
  cognite/neat/v0/session/engine/_load.py,sha256=u0x7vuQCRoNcPt25KJBJRn8sJabonYK4vtSZpiTdP4k,5201
216
- cognite_neat-0.123.34.dist-info/METADATA,sha256=LQ5wGh18pUFa70uOa5fM2u8ptNENBCOvLeAaJ2cJTSM,9195
217
- cognite_neat-0.123.34.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
218
- cognite_neat-0.123.34.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
219
- cognite_neat-0.123.34.dist-info/RECORD,,
215
+ cognite_neat-0.123.36.dist-info/METADATA,sha256=6blXCoQDpvS6J53dTnL1gs756MQJTNF5h3O3EyDdDvY,9148
216
+ cognite_neat-0.123.36.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
217
+ cognite_neat-0.123.36.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
218
+ cognite_neat-0.123.36.dist-info/RECORD,,
File without changes
@@ -1,5 +0,0 @@
1
- from ._base import DataModelImporterPlugin
2
-
3
- __all__ = [
4
- "DataModelImporterPlugin",
5
- ]
@@ -1,28 +0,0 @@
1
- from pathlib import Path
2
- from typing import Any
3
-
4
- from cognite.neat.v0.core._data_model.importers._base import BaseImporter
5
-
6
-
7
- class DataModelImporterPlugin:
8
- """This class is used an interface for data model import plugins.
9
- Any plugin that is used for importing data models should inherit from this class.
10
- It is expected to implement the `configure` method which returns a configured importer.
11
- """
12
-
13
- def configure(self, io: str | Path | None, **kwargs: Any) -> BaseImporter:
14
- """Return a configure plugin for data model import.
15
-
16
- Args:
17
- io (str | Path | None): The input/output interface for the plugin.
18
- **kwargs (Any): Additional keyword arguments for configuration.
19
-
20
- Returns:
21
- BaseImporter: A configured instance of the BaseImporter.
22
-
23
- !!! note "Returns"
24
- The method must return an instance of `BaseImporter` or its subclasses
25
- meaning it must implement the `BaseImporter` interface.
26
- """
27
-
28
- raise NotImplementedError()