cognite-neat 0.92.2__py3-none-any.whl → 0.93.0__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/__init__.py +3 -2
- cognite/neat/{app → _app}/api/configuration.py +9 -7
- cognite/neat/_app/api/context_manager/__init__.py +3 -0
- cognite/neat/{app → _app}/api/context_manager/manager.py +1 -1
- cognite/neat/{app → _app}/api/explorer.py +5 -5
- cognite/neat/{app → _app}/api/routers/configuration.py +2 -2
- cognite/neat/{app → _app}/api/routers/crud.py +4 -4
- cognite/neat/{app → _app}/api/routers/workflows.py +7 -7
- cognite/neat/{app → _app}/main.py +1 -1
- cognite/neat/_app/ui/neat-app/package-lock.json +18306 -0
- cognite/neat/_app/ui/neat-app/package.json +62 -0
- cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +116 -0
- cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +112 -0
- cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +34 -0
- cognite/neat/_app/ui/neat-app/public/index.html +43 -0
- cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- cognite/neat/_app/ui/neat-app/public/manifest.json +25 -0
- cognite/neat/_app/ui/neat-app/public/robots.txt +3 -0
- cognite/neat/_app/ui/neat-app/src/App.css +38 -0
- cognite/neat/_app/ui/neat-app/src/App.js +17 -0
- cognite/neat/_app/ui/neat-app/src/App.test.js +8 -0
- cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +70 -0
- cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +43 -0
- cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +124 -0
- cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +63 -0
- cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +511 -0
- cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +36 -0
- cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +56 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +60 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +112 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +67 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +79 -0
- cognite/neat/_app/ui/neat-app/src/index.css +13 -0
- cognite/neat/_app/ui/neat-app/src/index.js +13 -0
- cognite/neat/_app/ui/neat-app/src/logo.svg +1 -0
- cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +13 -0
- cognite/neat/_app/ui/neat-app/src/setupTests.js +5 -0
- cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +388 -0
- cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +61 -0
- cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +184 -0
- cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +180 -0
- cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +570 -0
- cognite/neat/_app/ui/neat-app/tsconfig.json +27 -0
- cognite/neat/{config.py → _config.py} +3 -3
- cognite/neat/{constants.py → _constants.py} +13 -5
- cognite/neat/_graph/_shared.py +34 -0
- cognite/neat/{graph → _graph}/_tracking/base.py +1 -1
- cognite/neat/{graph → _graph}/_tracking/log.py +1 -1
- cognite/neat/{graph → _graph}/extractors/__init__.py +5 -0
- cognite/neat/{graph → _graph}/extractors/_base.py +2 -2
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_assets.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_base.py +4 -4
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_classic.py +5 -5
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_data_sets.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_events.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_files.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_labels.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_relationships.py +2 -2
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_sequences.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_timeseries.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_dexpi.py +5 -5
- cognite/neat/{graph → _graph}/extractors/_dms.py +3 -3
- cognite/neat/_graph/extractors/_iodd.py +402 -0
- cognite/neat/{graph → _graph}/extractors/_mock_graph_generator.py +9 -8
- cognite/neat/_graph/extractors/_rdf_file.py +49 -0
- cognite/neat/{graph → _graph}/loaders/_base.py +5 -5
- cognite/neat/{graph → _graph}/loaders/_rdf2asset.py +11 -10
- cognite/neat/{graph → _graph}/loaders/_rdf2dms.py +10 -10
- cognite/neat/{graph → _graph}/queries/_base.py +91 -19
- cognite/neat/{graph → _graph}/queries/_construct.py +5 -5
- cognite/neat/{graph → _graph}/queries/_shared.py +3 -3
- cognite/neat/{graph → _graph}/transformers/__init__.py +6 -0
- cognite/neat/{graph → _graph}/transformers/_classic_cdf.py +135 -3
- cognite/neat/_graph/transformers/_iodd.py +25 -0
- cognite/neat/_graph/transformers/_prune_graph.py +126 -0
- cognite/neat/{graph → _graph}/transformers/_rdfpath.py +3 -3
- cognite/neat/_graph/transformers/_value_type.py +66 -0
- cognite/neat/{issues → _issues}/_base.py +32 -17
- cognite/neat/{issues → _issues}/errors/__init__.py +1 -1
- cognite/neat/{issues → _issues}/errors/_external.py +8 -8
- cognite/neat/{issues → _issues}/errors/_general.py +5 -5
- cognite/neat/{issues → _issues}/errors/_properties.py +7 -7
- cognite/neat/{issues → _issues}/errors/_resources.py +11 -11
- cognite/neat/{issues → _issues}/errors/_workflow.py +5 -5
- cognite/neat/{issues → _issues}/warnings/__init__.py +1 -1
- cognite/neat/{issues → _issues}/warnings/_external.py +5 -5
- cognite/neat/{issues → _issues}/warnings/_general.py +4 -4
- cognite/neat/{issues → _issues}/warnings/_models.py +10 -10
- cognite/neat/{issues → _issues}/warnings/_properties.py +6 -6
- cognite/neat/{issues → _issues}/warnings/_resources.py +5 -5
- cognite/neat/{issues → _issues}/warnings/user_modeling.py +9 -9
- cognite/neat/_rules/_constants.py +190 -0
- cognite/neat/{rules → _rules}/_shared.py +5 -5
- cognite/neat/_rules/analysis/__init__.py +5 -0
- cognite/neat/{rules → _rules}/analysis/_asset.py +5 -5
- cognite/neat/{rules → _rules}/analysis/_base.py +5 -5
- cognite/neat/_rules/analysis/_dms.py +43 -0
- cognite/neat/{rules → _rules}/analysis/_information.py +12 -6
- cognite/neat/_rules/catalog/__init__.py +6 -0
- cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- cognite/neat/{rules → _rules}/exporters/__init__.py +2 -0
- cognite/neat/{rules → _rules}/exporters/_base.py +3 -3
- cognite/neat/{rules → _rules}/exporters/_rules2dms.py +5 -5
- cognite/neat/{rules → _rules}/exporters/_rules2excel.py +26 -7
- cognite/neat/_rules/exporters/_rules2instance_template.py +152 -0
- cognite/neat/{rules → _rules}/exporters/_rules2ontology.py +10 -9
- cognite/neat/{rules → _rules}/exporters/_rules2yaml.py +1 -3
- cognite/neat/{rules → _rules}/exporters/_validation.py +2 -2
- cognite/neat/{rules → _rules}/importers/_base.py +3 -3
- cognite/neat/{rules → _rules}/importers/_dms2rules.py +9 -9
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/dtdl_converter.py +7 -7
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/dtdl_importer.py +9 -9
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/spec.py +1 -1
- cognite/neat/_rules/importers/_rdf/_base.py +144 -0
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2classes.py +1 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2metadata.py +4 -4
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2properties.py +2 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2rules.py +8 -39
- cognite/neat/{rules → _rules}/importers/_rdf/_inference2rules.py +33 -106
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2classes.py +1 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2metadata.py +5 -5
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2properties.py +1 -1
- cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2rules.py +39 -0
- cognite/neat/{rules → _rules}/importers/_rdf/_shared.py +4 -4
- cognite/neat/{rules → _rules}/importers/_spreadsheet2rules.py +40 -6
- cognite/neat/{rules → _rules}/importers/_yaml2rules.py +5 -5
- cognite/neat/{rules → _rules}/models/__init__.py +5 -5
- cognite/neat/{rules → _rules}/models/_base_input.py +30 -11
- cognite/neat/{rules → _rules}/models/_base_rules.py +22 -8
- cognite/neat/{rules → _rules}/models/_rdfpath.py +1 -1
- cognite/neat/_rules/models/_types.py +151 -0
- cognite/neat/{rules → _rules}/models/asset/_rules.py +4 -4
- cognite/neat/{rules → _rules}/models/asset/_rules_input.py +4 -4
- cognite/neat/{rules → _rules}/models/asset/_validation.py +7 -7
- cognite/neat/{rules → _rules}/models/data_types.py +15 -12
- cognite/neat/{rules → _rules}/models/dms/_exporter.py +60 -12
- cognite/neat/{rules → _rules}/models/dms/_rules.py +29 -26
- cognite/neat/{rules → _rules}/models/dms/_rules_input.py +4 -4
- cognite/neat/{rules → _rules}/models/dms/_schema.py +15 -14
- cognite/neat/{rules → _rules}/models/dms/_validation.py +8 -8
- cognite/neat/{rules → _rules}/models/domain.py +6 -6
- cognite/neat/{rules → _rules}/models/entities/__init__.py +1 -2
- cognite/neat/_rules/models/entities/_constants.py +15 -0
- cognite/neat/{rules → _rules}/models/entities/_loaders.py +2 -2
- cognite/neat/{rules → _rules}/models/entities/_multi_value.py +15 -2
- cognite/neat/{rules → _rules}/models/entities/_single_value.py +16 -4
- cognite/neat/{rules → _rules}/models/information/_rules.py +37 -25
- cognite/neat/{rules → _rules}/models/information/_rules_input.py +3 -3
- cognite/neat/{rules → _rules}/models/information/_validation.py +6 -5
- cognite/neat/_rules/models/mapping/__init__.py +4 -0
- cognite/neat/_rules/models/mapping/_base.py +131 -0
- cognite/neat/_rules/models/mapping/_classic2core.py +150 -0
- cognite/neat/{rules → _rules}/transformers/__init__.py +15 -2
- cognite/neat/{rules → _rules}/transformers/_base.py +3 -3
- cognite/neat/{rules → _rules}/transformers/_converters.py +289 -20
- cognite/neat/{rules/transformers/_map_onto.py → _rules/transformers/_mapping.py} +46 -4
- cognite/neat/{rules → _rules}/transformers/_pipelines.py +4 -4
- cognite/neat/{rules → _rules}/transformers/_verification.py +10 -4
- cognite/neat/_session/__init__.py +3 -0
- cognite/neat/_session/_base.py +86 -0
- cognite/neat/_session/_prepare.py +61 -0
- cognite/neat/_session/_read.py +118 -0
- cognite/neat/_session/_show.py +96 -0
- cognite/neat/_session/_state.py +69 -0
- cognite/neat/_session/_to.py +70 -0
- cognite/neat/_session/_wizard.py +39 -0
- cognite/neat/_session/exceptions.py +42 -0
- cognite/neat/{store → _store}/_base.py +63 -32
- cognite/neat/{store → _store}/_provenance.py +11 -1
- cognite/neat/{utils → _utils}/auth.py +14 -3
- cognite/neat/{utils → _utils}/auxiliary.py +1 -1
- cognite/neat/{utils → _utils}/cdf/loaders/_data_modeling.py +8 -2
- cognite/neat/{utils → _utils}/cdf/loaders/_ingestion.py +1 -1
- cognite/neat/{utils → _utils}/upload.py +1 -1
- cognite/neat/_version.py +1 -1
- cognite/neat/_workflows/__init__.py +17 -0
- cognite/neat/{workflows → _workflows}/base.py +10 -10
- cognite/neat/{workflows → _workflows}/cdf_store.py +3 -3
- cognite/neat/{workflows → _workflows}/examples/Export_DMS/workflow.yaml +89 -89
- cognite/neat/{workflows → _workflows}/manager.py +6 -6
- cognite/neat/{workflows → _workflows}/steps/data_contracts.py +3 -3
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_extractor.py +8 -31
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_loader.py +4 -4
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_store.py +4 -4
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_exporter.py +8 -8
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_importer.py +13 -13
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_validator.py +8 -8
- cognite/neat/{workflows → _workflows}/steps/lib/io/io_steps.py +3 -3
- cognite/neat/{workflows → _workflows}/steps/step_model.py +3 -3
- cognite/neat/{workflows → _workflows}/steps_registry.py +9 -9
- cognite/neat/{workflows → _workflows}/tasks.py +1 -1
- cognite/neat/{workflows → _workflows}/triggers.py +2 -2
- {cognite_neat-0.92.2.dist-info → cognite_neat-0.93.0.dist-info}/METADATA +6 -2
- cognite_neat-0.93.0.dist-info/RECORD +276 -0
- {cognite_neat-0.92.2.dist-info → cognite_neat-0.93.0.dist-info}/WHEEL +1 -1
- cognite_neat-0.93.0.dist-info/entry_points.txt +3 -0
- cognite/neat/app/api/context_manager/__init__.py +0 -3
- cognite/neat/graph/_shared.py +0 -5
- cognite/neat/graph/extractors/_iodd.py +0 -160
- cognite/neat/graph/extractors/_rdf_file.py +0 -26
- cognite/neat/rules/analysis/__init__.py +0 -6
- cognite/neat/rules/examples/__init__.py +0 -10
- cognite/neat/rules/examples/info-rules-imf.xlsx +0 -0
- cognite/neat/rules/examples/wind-energy.owl +0 -1511
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +0 -65
- cognite/neat/rules/models/_types.py +0 -96
- cognite/neat/rules/models/entities/_constants.py +0 -73
- cognite/neat/utils/regex_patterns.py +0 -58
- cognite/neat/workflows/__init__.py +0 -12
- cognite_neat-0.92.2.dist-info/RECORD +0 -224
- cognite_neat-0.92.2.dist-info/entry_points.txt +0 -3
- /cognite/neat/{app → _app}/api/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/asgi/metrics.py +0 -0
- /cognite/neat/{app → _app}/api/data_classes/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/data_classes/rest.py +0 -0
- /cognite/neat/{app → _app}/api/routers/metrics.py +0 -0
- /cognite/neat/{app → _app}/api/utils/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/utils/data_mapping.py +0 -0
- /cognite/neat/{app → _app}/api/utils/logging.py +0 -0
- /cognite/neat/{app → _app}/api/utils/query_templates.py +0 -0
- /cognite/neat/{app → _app}/monitoring/__init__.py +0 -0
- /cognite/neat/{app → _app}/monitoring/metrics.py +0 -0
- /cognite/neat/{app → _app}/ui/index.html +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/.gitignore +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/README.md +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/asset-manifest.json +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/favicon.ico +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/architect-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/developer-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/sme-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/index.html +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/logo192.png +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/manifest.json +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/robots.txt +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- /cognite/neat/{graph → _graph}/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/_tracking/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/{graph → _graph}/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/{graph → _graph}/examples/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- /cognite/neat/{graph → _graph}/extractors/_classic_cdf/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/loaders/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/models.py +0 -0
- /cognite/neat/{graph → _graph}/queries/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/transformers/_base.py +0 -0
- /cognite/neat/{issues → _issues}/__init__.py +0 -0
- /cognite/neat/{issues → _issues}/formatters.py +0 -0
- /cognite/neat/{rules → _rules}/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_dtdl2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_dtdl2rules/_unit_lookup.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/asset/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/dms/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/entities/_types.py +0 -0
- /cognite/neat/{rules → _rules}/models/entities/_wrapped.py +0 -0
- /cognite/neat/{rules → _rules}/models/information/__init__.py +0 -0
- /cognite/neat/{store → _store}/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/data_classes.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/loaders/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/loaders/_base.py +0 -0
- /cognite/neat/{utils → _utils}/collection_.py +0 -0
- /cognite/neat/{utils → _utils}/rdf_.py +0 -0
- /cognite/neat/{utils → _utils}/spreadsheet.py +0 -0
- /cognite/neat/{utils → _utils}/text.py +0 -0
- /cognite/neat/{utils → _utils}/time_.py +0 -0
- /cognite/neat/{utils → _utils}/xml_.py +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Import_DMS/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Validate_Rules/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Validate_Solution_Model/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/model.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/current/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/io/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/utils.py +0 -0
- {cognite_neat-0.92.2.dist-info → cognite_neat-0.93.0.dist-info}/LICENSE +0 -0
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import xml.etree.ElementTree as ET
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import ClassVar
|
|
4
|
-
from xml.etree.ElementTree import Element
|
|
5
|
-
|
|
6
|
-
from rdflib import RDF, Literal, Namespace, URIRef
|
|
7
|
-
|
|
8
|
-
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
9
|
-
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
10
|
-
from cognite.neat.graph.models import Triple
|
|
11
|
-
from cognite.neat.utils.rdf_ import as_neat_compliant_uri
|
|
12
|
-
from cognite.neat.utils.text import to_camel
|
|
13
|
-
from cognite.neat.utils.xml_ import get_children
|
|
14
|
-
|
|
15
|
-
IODD = Namespace("http://www.io-link.com/IODD/2010/10/")
|
|
16
|
-
XSI = Namespace("http://www.w3.org/2001/XMLSchema-instance/")
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class IODDExtractor(BaseExtractor):
|
|
20
|
-
"""
|
|
21
|
-
IODD-XML extractor of RDF triples
|
|
22
|
-
|
|
23
|
-
Each IODD sheet describes an IODD device. This extractor extracts rdf triples that describes the device, and the
|
|
24
|
-
sensors connected to the device.
|
|
25
|
-
This data is described under the elements "DeviceIdentity" and "ProcessDataCollection".
|
|
26
|
-
In addition, triples extacted from "DeviceIdentity" and
|
|
27
|
-
"ProcessDataCollection" may reference "Text" elements which are found under "ExternalTextCollection". Edges to
|
|
28
|
-
these Text element nodes are also extracted.
|
|
29
|
-
|
|
30
|
-
Args:
|
|
31
|
-
root: XML root element of IODD XML file.
|
|
32
|
-
namespace: Optional custom namespace to use for extracted triples that define data
|
|
33
|
-
model instances. Defaults to DEFAULT_NAMESPACE.
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
device_elements_with_text_nodes: ClassVar[list[str]] = ["VendorText", "VendorUrl", "DeviceName", "DeviceFamily"]
|
|
37
|
-
|
|
38
|
-
def __init__(self, root: Element, namespace: Namespace | None = None):
|
|
39
|
-
self.root = root
|
|
40
|
-
self.namespace = namespace or DEFAULT_NAMESPACE
|
|
41
|
-
|
|
42
|
-
@classmethod
|
|
43
|
-
def from_file(cls, filepath: str | Path, namespace: Namespace | None = None):
|
|
44
|
-
return cls(ET.parse(filepath).getroot(), namespace)
|
|
45
|
-
|
|
46
|
-
@classmethod
|
|
47
|
-
def _from_root2triples(cls, root: Element, namespace: Namespace) -> list[Triple]:
|
|
48
|
-
"""Loops through the relevant elements of the IODD XML sheet to create rdf triples that describes the IODD
|
|
49
|
-
device by starting at the root element.
|
|
50
|
-
"""
|
|
51
|
-
triples: list[Triple] = []
|
|
52
|
-
|
|
53
|
-
# Extract DeviceIdentity triples
|
|
54
|
-
if di_root := get_children(
|
|
55
|
-
root, "DeviceIdentity", ignore_namespace=True, include_nested_children=True, no_children=1
|
|
56
|
-
):
|
|
57
|
-
triples.extend(cls._iodd_device_identity2triples(di_root[0], namespace))
|
|
58
|
-
|
|
59
|
-
# Extract ProcessDataCollection triples -
|
|
60
|
-
# this element holds the information about the sensors with data coming from MQTT
|
|
61
|
-
if pc_root := get_children(
|
|
62
|
-
root, "ProcessDataCollection", ignore_namespace=True, include_nested_children=True, no_children=1
|
|
63
|
-
):
|
|
64
|
-
triples.extend(cls._process_data_collection2triples(pc_root[0], namespace))
|
|
65
|
-
|
|
66
|
-
if et_root := get_children(
|
|
67
|
-
root, "ExternalTextCollection", ignore_namespace=True, include_nested_children=True, no_children=1
|
|
68
|
-
):
|
|
69
|
-
triples.extend(cls._text_elements2triples(et_root[0], namespace))
|
|
70
|
-
|
|
71
|
-
return triples
|
|
72
|
-
|
|
73
|
-
@classmethod
|
|
74
|
-
def _device_2text_elements_edges(cls, di_root: Element, id: URIRef, namespace: Namespace) -> list[Triple]:
|
|
75
|
-
"""
|
|
76
|
-
Create edges from the device node to text nodes.
|
|
77
|
-
"""
|
|
78
|
-
triples: list[Triple] = []
|
|
79
|
-
|
|
80
|
-
for element_tag in cls.device_elements_with_text_nodes:
|
|
81
|
-
if child := get_children(
|
|
82
|
-
di_root, child_tag=element_tag, ignore_namespace=True, include_nested_children=True, no_children=1
|
|
83
|
-
):
|
|
84
|
-
if text_id := child[0].attrib.get("textId"):
|
|
85
|
-
# Create connection from device to textId node
|
|
86
|
-
element_tag = to_camel(element_tag)
|
|
87
|
-
triples.append((id, IODD[element_tag], namespace[text_id]))
|
|
88
|
-
|
|
89
|
-
return triples
|
|
90
|
-
|
|
91
|
-
@classmethod
|
|
92
|
-
def _text_elements2triples(cls, et_root: Element, namespace: Namespace) -> list[Triple]:
|
|
93
|
-
"""
|
|
94
|
-
This method extracts all text item triples under the ExternalTextCollection element. This will create a node
|
|
95
|
-
for each text item, and add the text value as a property to the node.
|
|
96
|
-
"""
|
|
97
|
-
triples: list[Triple] = []
|
|
98
|
-
|
|
99
|
-
if text_elements := get_children(
|
|
100
|
-
et_root, child_tag="Text", ignore_namespace=True, include_nested_children=True
|
|
101
|
-
):
|
|
102
|
-
for element in text_elements:
|
|
103
|
-
if id := element.attrib.get("id"):
|
|
104
|
-
text_id = namespace[id]
|
|
105
|
-
|
|
106
|
-
# Create Text node
|
|
107
|
-
triples.append((text_id, RDF.type, as_neat_compliant_uri(IODD["Text"])))
|
|
108
|
-
|
|
109
|
-
# Resolve text value related to the text item
|
|
110
|
-
if value := element.attrib.get("value"):
|
|
111
|
-
triples.append((text_id, IODD.value, Literal(value)))
|
|
112
|
-
|
|
113
|
-
return triples
|
|
114
|
-
|
|
115
|
-
# TODO
|
|
116
|
-
@classmethod
|
|
117
|
-
def _process_data_collection2triples(cls, pc_root: Element, namespace: Namespace) -> list[Triple]:
|
|
118
|
-
"""
|
|
119
|
-
ProcessDataCollection contains both ProcessDataIn and ProcessDataOut. Here, we are interested in the elements
|
|
120
|
-
that corresponds to actual sensor values that we will rececive from the MQTT connection.
|
|
121
|
-
|
|
122
|
-
Most likely this is ProcessDataOut elements (to be verified).
|
|
123
|
-
"""
|
|
124
|
-
triples: list[Triple] = []
|
|
125
|
-
|
|
126
|
-
return triples
|
|
127
|
-
|
|
128
|
-
@classmethod
|
|
129
|
-
def _iodd_device_identity2triples(cls, di_root: Element, namespace: Namespace) -> list[Triple]:
|
|
130
|
-
"""
|
|
131
|
-
Properties and metadata related to the IO Device are described under the 'DeviceIdentity' element in the XML.
|
|
132
|
-
This method extracts the triples that describe the device's identity which is found under the
|
|
133
|
-
DeviceIdentity element and its child elements.
|
|
134
|
-
|
|
135
|
-
"""
|
|
136
|
-
triples: list[Triple] = []
|
|
137
|
-
|
|
138
|
-
if device_id := di_root.attrib.get("deviceId"):
|
|
139
|
-
id_ = namespace[device_id]
|
|
140
|
-
|
|
141
|
-
for attribute_name, attribute_value in di_root.attrib.items():
|
|
142
|
-
if attribute_name == "deviceId":
|
|
143
|
-
# Create rdf type triple for IODD
|
|
144
|
-
triples.append(
|
|
145
|
-
(
|
|
146
|
-
id_,
|
|
147
|
-
RDF.type,
|
|
148
|
-
as_neat_compliant_uri(IODD["IoddDevice"]),
|
|
149
|
-
)
|
|
150
|
-
)
|
|
151
|
-
else:
|
|
152
|
-
# Collect attributes at root element
|
|
153
|
-
triples.append((id_, IODD[attribute_name], Literal(attribute_value)))
|
|
154
|
-
|
|
155
|
-
triples.extend(cls._device_2text_elements_edges(di_root, id_, namespace))
|
|
156
|
-
return triples
|
|
157
|
-
|
|
158
|
-
def extract(self) -> list[Triple]:
|
|
159
|
-
# Extract triples from IODD device XML
|
|
160
|
-
return self._from_root2triples(self.root, self.namespace)
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from rdflib import URIRef
|
|
4
|
-
|
|
5
|
-
from cognite.neat.graph._shared import MIMETypes
|
|
6
|
-
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class RdfFileExtractor(BaseExtractor):
|
|
10
|
-
"""Extract data from RDF files into Neat.
|
|
11
|
-
|
|
12
|
-
Args:
|
|
13
|
-
filepath (Path): The path to the RDF file.
|
|
14
|
-
mime_type (MIMETypes, optional): The MIME type of the RDF file. Defaults to "application/rdf+xml".
|
|
15
|
-
base_uri (URIRef, optional): The base URI to use. Defaults to None.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
def __init__(
|
|
19
|
-
self,
|
|
20
|
-
filepath: Path,
|
|
21
|
-
mime_type: MIMETypes = "application/rdf+xml",
|
|
22
|
-
base_uri: URIRef | None = None,
|
|
23
|
-
):
|
|
24
|
-
self.filepath = filepath
|
|
25
|
-
self.mime_type = mime_type
|
|
26
|
-
self.base_uri = base_uri
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
# we should make this a proper package that loads examples
|
|
4
|
-
# similar how they handle it in xarray:
|
|
5
|
-
# https://github.com/pydata/xarray/blob/main/xarray/tutorial.py
|
|
6
|
-
# Currently there are simple paths to the examples which are then easily loaded in the notebooks
|
|
7
|
-
|
|
8
|
-
_EXAMPLES = Path(__file__).parent
|
|
9
|
-
wind_energy_ontology = _EXAMPLES / "wind-energy.owl"
|
|
10
|
-
imf_info_rules = _EXAMPLES / "info-rules-imf.xlsx"
|
|
Binary file
|