cognite-neat 0.123.2__py3-none-any.whl → 0.123.3__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/core/_data_model/importers/__init__.py +1 -3
- cognite/neat/core/_data_model/importers/_rdf/__init__.py +1 -2
- cognite/neat/session/_read.py +0 -23
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.123.3.dist-info}/METADATA +1 -1
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.123.3.dist-info}/RECORD +8 -9
- cognite/neat/core/_data_model/importers/_rdf/_imf2data_model.py +0 -98
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.123.3.dist-info}/WHEEL +0 -0
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.123.3.dist-info}/licenses/LICENSE +0 -0
cognite/neat/_version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = "0.123.
|
|
1
|
+
__version__ = "0.123.3"
|
|
2
2
|
__engine__ = "^2.0.4"
|
|
@@ -2,7 +2,7 @@ from ._base import BaseImporter
|
|
|
2
2
|
from ._dict2data_model import DictImporter
|
|
3
3
|
from ._dms2data_model import DMSImporter
|
|
4
4
|
from ._dtdl2data_model import DTDLImporter
|
|
5
|
-
from ._rdf import
|
|
5
|
+
from ._rdf import InferenceImporter, OWLImporter, SubclassInferenceImporter
|
|
6
6
|
from ._spreadsheet2data_model import ExcelImporter
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
@@ -11,7 +11,6 @@ __all__ = [
|
|
|
11
11
|
"DTDLImporter",
|
|
12
12
|
"DictImporter",
|
|
13
13
|
"ExcelImporter",
|
|
14
|
-
"IMFImporter",
|
|
15
14
|
"InferenceImporter",
|
|
16
15
|
"OWLImporter",
|
|
17
16
|
"SubclassInferenceImporter",
|
|
@@ -19,7 +18,6 @@ __all__ = [
|
|
|
19
18
|
|
|
20
19
|
DataModelImporters = (
|
|
21
20
|
OWLImporter
|
|
22
|
-
| IMFImporter
|
|
23
21
|
| DMSImporter
|
|
24
22
|
| ExcelImporter
|
|
25
23
|
| DTDLImporter
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
from ._imf2data_model import IMFImporter
|
|
2
1
|
from ._inference2rdata_model import InferenceImporter, SubclassInferenceImporter
|
|
3
2
|
from ._owl2data_model import OWLImporter
|
|
4
3
|
|
|
5
|
-
__all__ = ["
|
|
4
|
+
__all__ = ["InferenceImporter", "OWLImporter", "SubclassInferenceImporter"]
|
cognite/neat/session/_read.py
CHANGED
|
@@ -826,29 +826,6 @@ class RDFReadAPI(BaseReadAPI):
|
|
|
826
826
|
importer = importers.OWLImporter.from_file(reader.materialize_path(), source_name=f"file {reader!s}")
|
|
827
827
|
return self._state.data_model_import(importer)
|
|
828
828
|
|
|
829
|
-
def imf(self, io: Any) -> IssueList:
|
|
830
|
-
"""Reads IMF Types provided as SHACL shapes into NeatSession.
|
|
831
|
-
|
|
832
|
-
Args:
|
|
833
|
-
io: file path or url to the IMF file
|
|
834
|
-
|
|
835
|
-
Example:
|
|
836
|
-
```python
|
|
837
|
-
neat.read.rdf.imf("url_or_path_to_imf_source")
|
|
838
|
-
```
|
|
839
|
-
"""
|
|
840
|
-
warnings.filterwarnings("default")
|
|
841
|
-
ExperimentalFlags.imf_read.warn()
|
|
842
|
-
|
|
843
|
-
self._state._raise_exception_if_condition_not_met(
|
|
844
|
-
"Read IMF file",
|
|
845
|
-
empty_data_model_store_required=True,
|
|
846
|
-
)
|
|
847
|
-
|
|
848
|
-
reader = NeatReader.create(io)
|
|
849
|
-
importer = importers.IMFImporter.from_file(reader.materialize_path(), source_name=f"file {reader!s}")
|
|
850
|
-
return self._state.data_model_import(importer)
|
|
851
|
-
|
|
852
829
|
def instances(self, io: Any) -> IssueList:
|
|
853
830
|
self._state._raise_exception_if_condition_not_met(
|
|
854
831
|
"Read RDF Instances",
|
|
@@ -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=1LL2p_8I7bAAlssuMiKzpRCctloMXRPY6TNNhG3TaFQ,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
|
|
@@ -34,7 +34,7 @@ cognite/neat/core/_data_model/exporters/_data_model2excel.py,sha256=mRVJzUCEWfm2
|
|
|
34
34
|
cognite/neat/core/_data_model/exporters/_data_model2instance_template.py,sha256=9k8A70b1paeOHjvJRtbl6Xror1GD8AIMdo3cCx5aejE,6103
|
|
35
35
|
cognite/neat/core/_data_model/exporters/_data_model2ontology.py,sha256=YrLTwPAvOOyLFHFJaNs4I82HCp1llJnkF1BRdoIQMck,23409
|
|
36
36
|
cognite/neat/core/_data_model/exporters/_data_model2yaml.py,sha256=1dlb-v4sV8BArnX_6J4wpjQT7r-FinFAvoPDoMNkHYw,3284
|
|
37
|
-
cognite/neat/core/_data_model/importers/__init__.py,sha256=
|
|
37
|
+
cognite/neat/core/_data_model/importers/__init__.py,sha256=4XxrVG5rb_3IjcRSzfC76dOX8b2tB6ar2ybQGrVQ5fg,1286
|
|
38
38
|
cognite/neat/core/_data_model/importers/_base.py,sha256=pKe2OK86Wdj6CTj5bUgjY33ejZhRfD2eJbjcCapHD58,2013
|
|
39
39
|
cognite/neat/core/_data_model/importers/_base_file_reader.py,sha256=m7CwMujEybYMfHWbTQOb7wBvLl2X1TmROkPelJMSaDA,1621
|
|
40
40
|
cognite/neat/core/_data_model/importers/_dict2data_model.py,sha256=-1zmo8JkxJ9qiWuC7sUH7oSlpnPPKTMxZtm4WrRPO5A,4709
|
|
@@ -45,9 +45,8 @@ cognite/neat/core/_data_model/importers/_dtdl2data_model/_unit_lookup.py,sha256=
|
|
|
45
45
|
cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_converter.py,sha256=mjouy5XQCJoybUkCnEoZFrFtWBQrBQRPIM4DwfMDUkw,11879
|
|
46
46
|
cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_importer.py,sha256=t5EkawmYPuQ-dJ1J-IhqhdX_CkaCwQLQDAcpmx7QdS0,6288
|
|
47
47
|
cognite/neat/core/_data_model/importers/_dtdl2data_model/spec.py,sha256=HnKUZbp42pl4DSexo0N6t_20tsvlsxyHHnNak5SVgzg,12182
|
|
48
|
-
cognite/neat/core/_data_model/importers/_rdf/__init__.py,sha256=
|
|
48
|
+
cognite/neat/core/_data_model/importers/_rdf/__init__.py,sha256=1yOjV2PKCxwH7uCTXVZhSdxtn5etmFX40cksvwtKcZ8,199
|
|
49
49
|
cognite/neat/core/_data_model/importers/_rdf/_base.py,sha256=FKceKumKmhEGpMZvo1BwEewnUvfAsTF3Ax9fo1nxsGE,6020
|
|
50
|
-
cognite/neat/core/_data_model/importers/_rdf/_imf2data_model.py,sha256=f5kAkv7-d5DtqzaACkyA-vLXrQ2xArwEd9zg7yX-MfA,3777
|
|
51
50
|
cognite/neat/core/_data_model/importers/_rdf/_inference2rdata_model.py,sha256=PCgM9-qGSLlupN7tYCFLHjivgICtMiahNry1ub8JCYk,28934
|
|
52
51
|
cognite/neat/core/_data_model/importers/_rdf/_owl2data_model.py,sha256=WmncZNpELeZnt6mdw6X8yWnr7XsFXZGfoVe5wTd0HH4,3438
|
|
53
52
|
cognite/neat/core/_data_model/importers/_rdf/_shared.py,sha256=yB4BkupiPhizWSHNKdaspj3xE_6pKDiNG-_IHtTN1gI,5961
|
|
@@ -177,7 +176,7 @@ cognite/neat/session/_inspect.py,sha256=AESQd2SOidR_pDTFk5B_JdPnKZ5PNNskdAQBepH2
|
|
|
177
176
|
cognite/neat/session/_mapping.py,sha256=ItEXhXo_8V3069hktHMxdpBsLNeTck3gZBvhlm12Oxw,2895
|
|
178
177
|
cognite/neat/session/_plugin.py,sha256=diFvZUFRvY037iVy_HxnIGMSfrauOpwYCSvFEPOzchQ,2282
|
|
179
178
|
cognite/neat/session/_prepare.py,sha256=pskEVNgcnVJVRvYKk5xI55V89vKDO_kgjszj5flY8Zs,12778
|
|
180
|
-
cognite/neat/session/_read.py,sha256=
|
|
179
|
+
cognite/neat/session/_read.py,sha256=rd1MeXPt_fS50WYrpM6UqDTKOQkDrOIn8TPS0WOVoSw,34607
|
|
181
180
|
cognite/neat/session/_set.py,sha256=PU4lKI-LGtKFVyvdtfZkk-zLw9e_rnFHzuV9IyrOrTM,4593
|
|
182
181
|
cognite/neat/session/_show.py,sha256=YLt6K4ukG1s_I_FhuVrIVPtw_btvvOL50Rwrx-vo7VQ,10743
|
|
183
182
|
cognite/neat/session/_state.py,sha256=DLEm9wn3GtOuTGhy5-M1IK2v9qvLnTYEruWPidzAP_Q,6580
|
|
@@ -191,7 +190,7 @@ cognite/neat/session/engine/__init__.py,sha256=D3MxUorEs6-NtgoICqtZ8PISQrjrr4dvc
|
|
|
191
190
|
cognite/neat/session/engine/_import.py,sha256=1QxA2_EK613lXYAHKQbZyw2yjo5P9XuiX4Z6_6-WMNQ,169
|
|
192
191
|
cognite/neat/session/engine/_interface.py,sha256=3W-cYr493c_mW3P5O6MKN1xEQg3cA7NHR_ev3zdF9Vk,533
|
|
193
192
|
cognite/neat/session/engine/_load.py,sha256=g52uYakQM03VqHt_RDHtpHso1-mFFifH5M4T2ScuH8A,5198
|
|
194
|
-
cognite_neat-0.123.
|
|
195
|
-
cognite_neat-0.123.
|
|
196
|
-
cognite_neat-0.123.
|
|
197
|
-
cognite_neat-0.123.
|
|
193
|
+
cognite_neat-0.123.3.dist-info/METADATA,sha256=RxK8IrMcBxC0d31JMKtLG0vuPD62WQhOuHM5j11Nov4,9171
|
|
194
|
+
cognite_neat-0.123.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
195
|
+
cognite_neat-0.123.3.dist-info/licenses/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
196
|
+
cognite_neat-0.123.3.dist-info/RECORD,,
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"""This module performs importing of various formats to one of serializations for which
|
|
2
|
-
there are loaders to data model pydantic class."""
|
|
3
|
-
|
|
4
|
-
from cognite.neat.core._data_model.importers._rdf._base import BaseRDFImporter
|
|
5
|
-
from cognite.neat.core._data_model.importers._rdf._shared import (
|
|
6
|
-
parse_concepts,
|
|
7
|
-
parse_properties,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
CLASSES_QUERY = """
|
|
11
|
-
SELECT ?concept ?name ?description ?implements
|
|
12
|
-
WHERE {{
|
|
13
|
-
VALUES ?type {{ imf:BlockType imf:TerminalType imf:AttributeType }}
|
|
14
|
-
?concept a ?type .
|
|
15
|
-
|
|
16
|
-
OPTIONAL {{?concept rdfs:subClassOf ?parent }}.
|
|
17
|
-
OPTIONAL {{?concept rdfs:label|skos:prefLabel ?name }}.
|
|
18
|
-
OPTIONAL {{?concept rdfs:comment|skos:definition ?description}}.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Add imf:Attribute as parent class when no parent is found
|
|
22
|
-
BIND(IF(!bound(?parent) && ?type = imf:AttributeType, imf:Attribute, ?parent) AS ?implements)
|
|
23
|
-
|
|
24
|
-
# FILTERS
|
|
25
|
-
FILTER (!isBlank(?concept))
|
|
26
|
-
FILTER (!bound(?implements) || !isBlank(?implements))
|
|
27
|
-
|
|
28
|
-
FILTER (!bound(?name) || LANG(?name) = "" || LANGMATCHES(LANG(?name), "{language}"))
|
|
29
|
-
FILTER (!bound(?description) || LANG(?description) = "" || LANGMATCHES(LANG(?description), "{language}"))
|
|
30
|
-
}}
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
PROPERTIES_QUERY = """
|
|
34
|
-
SELECT ?concept ?property_ ?name ?description ?value_type ?min_count ?max_count ?default
|
|
35
|
-
WHERE
|
|
36
|
-
{{
|
|
37
|
-
# CASE 1: Handling Blocks and Terminals
|
|
38
|
-
{{
|
|
39
|
-
VALUES ?type {{ imf:BlockType imf:TerminalType }}
|
|
40
|
-
?concept a ?type ;
|
|
41
|
-
sh:property ?propertyShape .
|
|
42
|
-
?propertyShape sh:path ?property_ .
|
|
43
|
-
|
|
44
|
-
OPTIONAL {{ ?property_ skos:prefLabel ?name . }}
|
|
45
|
-
OPTIONAL {{ ?property_ skos:definition ?description . }}
|
|
46
|
-
OPTIONAL {{ ?property_ rdfs:range ?range . }}
|
|
47
|
-
|
|
48
|
-
OPTIONAL {{ ?propertyShape sh:minCount ?min_count . }}
|
|
49
|
-
OPTIONAL {{ ?propertyShape sh:maxCount ?max_count . }}
|
|
50
|
-
OPTIONAL {{ ?propertyShape sh:hasValue ?default . }}
|
|
51
|
-
OPTIONAL {{ ?propertyShape sh:class | sh:qualifiedValueShape/sh:class ?valueShape . }}
|
|
52
|
-
}}
|
|
53
|
-
|
|
54
|
-
UNION
|
|
55
|
-
|
|
56
|
-
# CASE 2: Handling Attributes
|
|
57
|
-
{{
|
|
58
|
-
?concept a imf:AttributeType .
|
|
59
|
-
BIND(xsd:anyURI AS ?valueShape)
|
|
60
|
-
BIND(imf:predicate AS ?property_)
|
|
61
|
-
?concept ?property_ ?defaultURI .
|
|
62
|
-
BIND(STR(?defaultURI) AS ?default)
|
|
63
|
-
|
|
64
|
-
}}
|
|
65
|
-
|
|
66
|
-
# Set the value type for the property based on sh:class, sh:qualifiedValueType or rdfs:range
|
|
67
|
-
BIND(IF(BOUND(?valueShape), ?valueShape, IF(BOUND(?range) , ?range , ?valueShape)) AS ?value_type)
|
|
68
|
-
|
|
69
|
-
FILTER (!isBlank(?property_))
|
|
70
|
-
FILTER (!bound(?concept) || !isBlank(?concept))
|
|
71
|
-
FILTER (!bound(?name) || LANG(?name) = "" || LANGMATCHES(LANG(?name), "{language}"))
|
|
72
|
-
FILTER (!bound(?description) || LANG(?description) = "" || LANGMATCHES(LANG(?description), "{language}"))
|
|
73
|
-
}}
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class IMFImporter(BaseRDFImporter):
|
|
78
|
-
"""Convert IMF Types provided as SHACL shapes to unverified data model."""
|
|
79
|
-
|
|
80
|
-
@property
|
|
81
|
-
def description(self) -> str:
|
|
82
|
-
return f"IMF Types {self.source_name} read as unverified data model"
|
|
83
|
-
|
|
84
|
-
def _to_data_model_components(
|
|
85
|
-
self,
|
|
86
|
-
) -> dict:
|
|
87
|
-
classes, issue_list = parse_concepts(self.graph, CLASSES_QUERY, self.language, self.issue_list)
|
|
88
|
-
self.issue_list = issue_list
|
|
89
|
-
properties, issue_list = parse_properties(self.graph, PROPERTIES_QUERY, self.language, self.issue_list)
|
|
90
|
-
self.issue_list = issue_list
|
|
91
|
-
|
|
92
|
-
components = {
|
|
93
|
-
"Metadata": self._metadata,
|
|
94
|
-
"Concepts": list(classes.values()) if classes else [],
|
|
95
|
-
"Properties": list(properties.values()) if properties else [],
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return components
|
|
File without changes
|
|
File without changes
|