cognite-neat 0.123.41__py3-none-any.whl → 0.123.42__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.41"
1
+ __version__ = "0.123.42"
2
2
  __engine__ = "^2.0.4"
@@ -274,3 +274,5 @@ DMS_RESERVED_PROPERTIES = frozenset(
274
274
  "endNode",
275
275
  }
276
276
  )
277
+
278
+ NAMED_GRAPH_NAMESPACE = Namespace("http://thisisneat.io/namedgraph/")
@@ -1,15 +1,19 @@
1
+ import re
1
2
  import warnings
2
3
  from typing import Any, Literal, cast
3
4
 
4
5
  from cognite.client.data_classes.data_modeling import DataModelId, DataModelIdentifier
5
6
  from cognite.client.utils.useful_types import SequenceNotStr
7
+ from rdflib import URIRef
6
8
 
7
9
  from cognite.neat.v0.core._client import NeatClient
8
10
  from cognite.neat.v0.core._constants import (
9
11
  CLASSIC_CDF_NAMESPACE,
12
+ NAMED_GRAPH_NAMESPACE,
10
13
  get_default_prefixes_and_namespaces,
11
14
  )
12
15
  from cognite.neat.v0.core._data_model import catalog, importers
16
+ from cognite.neat.v0.core._data_model._constants import SPACE_COMPLIANCE_REGEX
13
17
  from cognite.neat.v0.core._data_model.importers import BaseImporter
14
18
  from cognite.neat.v0.core._data_model.models.entities._single_value import ViewEntity
15
19
  from cognite.neat.v0.core._data_model.transformers import ClassicPrepareCore
@@ -826,13 +830,21 @@ class RDFReadAPI(BaseReadAPI):
826
830
  importer = importers.OWLImporter.from_file(reader.materialize_path(), source_name=f"file {reader!s}")
827
831
  return self._state.data_model_import(importer)
828
832
 
829
- def instances(self, io: Any) -> IssueList:
833
+ def instances(self, io: Any, named_graph: str | None = None) -> IssueList:
830
834
  self._state._raise_exception_if_condition_not_met(
831
835
  "Read RDF Instances",
832
836
  empty_data_model_store_required=True,
833
837
  )
834
838
  reader = NeatReader.create(io)
835
- self._state.instances.store.write(extractors.RdfFileExtractor(reader.materialize_path()))
839
+
840
+ # validate and convert named_graph to URI
841
+ named_graph_uri: URIRef | None = None
842
+ if named_graph:
843
+ if not re.match(SPACE_COMPLIANCE_REGEX, named_graph):
844
+ raise NeatValueError(f"Named graph '{named_graph}' does not comply with naming requirements. ")
845
+ named_graph_uri = NAMED_GRAPH_NAMESPACE[named_graph]
846
+
847
+ self._state.instances.store.write(extractors.RdfFileExtractor(reader.materialize_path()), named_graph_uri)
836
848
  return IssueList()
837
849
 
838
850
  def __call__(
@@ -840,6 +852,7 @@ class RDFReadAPI(BaseReadAPI):
840
852
  io: Any,
841
853
  type: NeatObjectType | None = None,
842
854
  source: RDFFileType | None = None,
855
+ named_graph: str | URIRef | None = None,
843
856
  ) -> IssueList:
844
857
  if type is None:
845
858
  type = object_wizard()
@@ -858,7 +871,7 @@ class RDFReadAPI(BaseReadAPI):
858
871
  raise ValueError(f"Expected ontology, imf types or instances, got {source}")
859
872
 
860
873
  elif type == "instances":
861
- return self.instances(io)
874
+ return self.instances(io, named_graph=named_graph)
862
875
 
863
876
  else:
864
877
  raise NeatSessionError(f"Expected data model or instances, got {type}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cognite-neat
3
- Version: 0.123.41
3
+ Version: 0.123.42
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,6 +1,6 @@
1
1
  cognite/neat/__init__.py,sha256=Lo4DbjDOwnhCYUoAgPp5RG1fDdF7OlnomalTe7n1ydw,211
2
2
  cognite/neat/_issues.py,sha256=uv0fkkWwTKqNmTmHqyoBB3L6yMCh42EZpEkLGmIJYOY,812
3
- cognite/neat/_version.py,sha256=ufRXfLAZOiccgiTU2G1cLrNuGEalUnTHSuR_tpkSN2w,47
3
+ cognite/neat/_version.py,sha256=KPC_vMI9YJae3HbWzCydHnx-9mFGFnywrlkj0xH-U6U,47
4
4
  cognite/neat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cognite/neat/_data_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  cognite/neat/_data_model/_constants.py,sha256=NGGvWHlQqhkkSBP_AqoofGYjNph3SiZX6QPINlMsy04,107
@@ -45,7 +45,7 @@ cognite/neat/_utils/http_client/_tracker.py,sha256=EBBnd-JZ7nc_jYNFJokCHN2UZ9sx0
45
45
  cognite/neat/v0/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
46
  cognite/neat/v0/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  cognite/neat/v0/core/_config.py,sha256=WT1BS8uADcFvGoUYOOfwFOVq_VBl472TisdoA3wLick,280
48
- cognite/neat/v0/core/_constants.py,sha256=J0avfxWcipJup-pv9MvFIaO8NC0heDaNAsmSPMFEP3U,9063
48
+ cognite/neat/v0/core/_constants.py,sha256=mNNHu-QAD54DEA9A1yHd9Fk19SbqZAE6DoCfYxDRvbM,9134
49
49
  cognite/neat/v0/core/_shared.py,sha256=Ov59SWYboRRsncB_5V1ZC_BAoACfNLjo80vqE5Ru6wo,2325
50
50
  cognite/neat/v0/core/_client/__init__.py,sha256=RQ7MwL8mwGqGHokRzsPqO3XStDzmI4-c12_gz1UPJ74,177
51
51
  cognite/neat/v0/core/_client/_api_client.py,sha256=ZIipNVjd0kVts5Gh-PcV96DhA-RyT0v5EwZHa77hdXg,863
@@ -217,7 +217,7 @@ cognite/neat/v0/session/_inspect.py,sha256=6xC-tLJfP7sbSQpIlpPmCQWklGxK_rEXBE41j
217
217
  cognite/neat/v0/session/_mapping.py,sha256=9lQFnB0wpizo4ySIEDMWh183qpHh8TlVL7uOgAtJUxE,2904
218
218
  cognite/neat/v0/session/_plugin.py,sha256=TqEeUYDiZmOyl33h44J5OlqkH7VzgGi63nJFidpBV4M,2235
219
219
  cognite/neat/v0/session/_prepare.py,sha256=HFdDmBnYRpaCm90s_A0byHLJIZwKrt2ve6i3EyN0V6w,12802
220
- cognite/neat/v0/session/_read.py,sha256=2pdlWa-OHQ4j2gRKNTeBzWBOipDPnznnqyys-yzUq2s,34658
220
+ cognite/neat/v0/session/_read.py,sha256=jMviC69NLxaGqHFBcqHLNA_XPmIl2vOTTAchTOxR5nw,35288
221
221
  cognite/neat/v0/session/_set.py,sha256=qFi3YrYBd09MfHVJ2Ak0PCGigTAhGttfnA2iWSYwUt4,4617
222
222
  cognite/neat/v0/session/_show.py,sha256=O6Vcp5BNWfp2hpWuyqsdFhN0WAl29ot-QrC5iKBGe5Y,10758
223
223
  cognite/neat/v0/session/_state.py,sha256=2t1DBybamq67CuNZo_a1AQfDfYWnKS-MATFFuJf_h4M,7454
@@ -231,7 +231,7 @@ cognite/neat/v0/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4
231
231
  cognite/neat/v0/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
232
232
  cognite/neat/v0/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
233
233
  cognite/neat/v0/session/engine/_load.py,sha256=u0x7vuQCRoNcPt25KJBJRn8sJabonYK4vtSZpiTdP4k,5201
234
- cognite_neat-0.123.41.dist-info/METADATA,sha256=x1il3bStkdRMLwIwGMK5UABcb2tkCyc3Zr63dkY27Vw,9148
235
- cognite_neat-0.123.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
236
- cognite_neat-0.123.41.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
237
- cognite_neat-0.123.41.dist-info/RECORD,,
234
+ cognite_neat-0.123.42.dist-info/METADATA,sha256=R-A1tkY3opZDSbVVDo2flVy7ZlawJvUISZCllr6i_mM,9148
235
+ cognite_neat-0.123.42.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
236
+ cognite_neat-0.123.42.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
237
+ cognite_neat-0.123.42.dist-info/RECORD,,