cognite-neat 0.103.1__tar.gz → 0.104.0__tar.gz
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-0.103.1 → cognite_neat-0.104.0}/PKG-INFO +1 -1
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_mock_graph_generator.py +1 -1
- cognite_neat-0.104.0/cognite/neat/_graph/transformers/_base.py +122 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_classic_cdf.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_prune_graph.py +103 -47
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_rdfpath.py +41 -17
- cognite_neat-0.104.0/cognite/neat/_graph/transformers/_value_type.py +225 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/_base.py +35 -8
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/_resources.py +1 -1
- cognite_neat-0.104.0/cognite/neat/_rules/_shared.py +40 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_base.py +28 -2
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_rules2dms.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_rules2excel.py +11 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_rules2instance_template.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_rules2ontology.py +13 -1
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_rules2yaml.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_base.py +9 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dms2rules.py +17 -5
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +5 -2
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/_base.py +10 -8
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/_imf2rules.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +7 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/_owl2rules.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_spreadsheet2rules.py +17 -8
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_yaml2rules.py +21 -7
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/_base_input.py +1 -1
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/_base_rules.py +5 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/dms/_rules.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/dms/_rules_input.py +9 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/information/_rules.py +4 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/information/_rules_input.py +9 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/mapping/_classic2core.py +2 -5
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/transformers/__init__.py +5 -4
- cognite_neat-0.104.0/cognite/neat/_rules/transformers/_base.py +64 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/transformers/_converters.py +149 -62
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/transformers/_mapping.py +17 -12
- cognite_neat-0.104.0/cognite/neat/_rules/transformers/_verification.py +117 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_base.py +32 -121
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_inspect.py +3 -3
- cognite_neat-0.104.0/cognite/neat/_session/_mapping.py +56 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_prepare.py +36 -254
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_read.py +11 -130
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_set.py +6 -30
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_show.py +40 -21
- cognite_neat-0.104.0/cognite/neat/_session/_state.py +90 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_to.py +42 -31
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_shared.py +23 -2
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_store/_provenance.py +3 -82
- cognite_neat-0.104.0/cognite/neat/_store/_rules_store.py +382 -0
- cognite_neat-0.104.0/cognite/neat/_store/exceptions.py +23 -0
- cognite_neat-0.104.0/cognite/neat/_utils/graph_transformations_report.py +36 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/rdf_.py +8 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/spreadsheet.py +5 -4
- cognite_neat-0.104.0/cognite/neat/_version.py +2 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/rules_exporter.py +7 -7
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/rules_importer.py +24 -99
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/pyproject.toml +1 -1
- cognite_neat-0.103.1/cognite/neat/_graph/transformers/_base.py +0 -14
- cognite_neat-0.103.1/cognite/neat/_graph/transformers/_value_type.py +0 -260
- cognite_neat-0.103.1/cognite/neat/_rules/_shared.py +0 -56
- cognite_neat-0.103.1/cognite/neat/_rules/transformers/_base.py +0 -88
- cognite_neat-0.103.1/cognite/neat/_rules/transformers/_pipelines.py +0 -70
- cognite_neat-0.103.1/cognite/neat/_rules/transformers/_verification.py +0 -104
- cognite_neat-0.103.1/cognite/neat/_session/_mapping.py +0 -144
- cognite_neat-0.103.1/cognite/neat/_session/_state.py +0 -148
- cognite_neat-0.103.1/cognite/neat/_store/_rules_store.py +0 -20
- cognite_neat-0.103.1/cognite/neat/_version.py +0 -2
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/LICENSE +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/README.md +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/configuration.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/explorer.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/routers/configuration.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/routers/crud.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/routers/metrics.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/routers/workflows.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/utils/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/utils/logging.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/main.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/monitoring/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/monitoring/metrics.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/index.html +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/package-lock.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/package.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/index.html +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/manifest.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/public/robots.txt +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/App.css +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/App.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/App.test.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/index.css +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/index.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/logo.svg +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/setupTests.js +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_app/ui/neat-app/tsconfig.json +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/_api/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/_api/data_modeling_loaders.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/_api/schema.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/_api_client.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/data_classes/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/data_classes/data_modeling.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_client/data_classes/schema.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_constants.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/_shared.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_dms.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_iodd.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/loaders/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/loaders/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/loaders/_rdf2dms.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/queries/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/queries/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/queries/_construct.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/queries/_shared.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_iodd.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/_external.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/_general.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/_properties.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/_resources.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/errors/_workflow.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/formatters.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/_external.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/_models.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/_properties.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_issues/warnings/user_modeling.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/_constants.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/analysis/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/analysis/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/analysis/_dms.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/analysis/_information.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/catalog/hello_world_pump.xlsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/importers/_rdf/_shared.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/_types.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/data_types.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/dms/_exporter.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/dms/_validation.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_loaders.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_multi_value.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_single_value.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/entities/_wrapped.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/information/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/information/_validation.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/mapping/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_rules/models/mapping/_classic2core.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_collector.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_drop.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_session/exceptions.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_store/_graph_store.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/auth.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/auxiliary.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/io_.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/text.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/upload.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/base.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/cdf_store.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/manager.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/model.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/current/rules_validator.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps/step_model.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/steps_registry.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/tasks.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/triggers.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_workflows/utils.py +0 -0
- {cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/py.typed +0 -0
|
@@ -46,7 +46,7 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
46
46
|
# fixes potential issues with circular dependencies
|
|
47
47
|
from cognite.neat._rules.transformers import DMSToInformation
|
|
48
48
|
|
|
49
|
-
self.rules = DMSToInformation().transform(rules)
|
|
49
|
+
self.rules = DMSToInformation().transform(rules)
|
|
50
50
|
elif isinstance(rules, InformationRules):
|
|
51
51
|
self.rules = rules
|
|
52
52
|
else:
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import dataclasses
|
|
2
|
+
import warnings
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from typing import ClassVar, TypeAlias, cast
|
|
5
|
+
|
|
6
|
+
from rdflib import Graph
|
|
7
|
+
from rdflib.query import ResultRow
|
|
8
|
+
|
|
9
|
+
from cognite.neat._issues.warnings import NeatValueWarning
|
|
10
|
+
from cognite.neat._shared import Triple
|
|
11
|
+
from cognite.neat._utils.collection_ import iterate_progress_bar
|
|
12
|
+
from cognite.neat._utils.graph_transformations_report import GraphTransformationResult
|
|
13
|
+
|
|
14
|
+
To_Add_Triples: TypeAlias = list[Triple]
|
|
15
|
+
To_Remove_Triples: TypeAlias = list[Triple]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclasses.dataclass
|
|
19
|
+
class RowTransformationOutput:
|
|
20
|
+
remove_triples: To_Remove_Triples = dataclasses.field(default_factory=list)
|
|
21
|
+
add_triples: To_Add_Triples = dataclasses.field(default_factory=list)
|
|
22
|
+
instances_removed_count: int = 0
|
|
23
|
+
instances_added_count: int = 0
|
|
24
|
+
instances_modified_count: int = 0
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class BaseTransformer(ABC):
|
|
28
|
+
description: str
|
|
29
|
+
_use_only_once: bool = False
|
|
30
|
+
_need_changes: ClassVar[frozenset[str]] = frozenset()
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def transform(self, graph: Graph) -> None:
|
|
34
|
+
raise NotImplementedError()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class BaseTransformerStandardised(ABC):
|
|
38
|
+
"""Standardised base transformer to use in case a transformer is adding or removing triples from a graph. If you
|
|
39
|
+
are doing more specialised operations, please overwrite the .transform() method.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
description: str
|
|
43
|
+
_use_only_once: bool = False
|
|
44
|
+
_need_changes: ClassVar[frozenset[str]] = frozenset()
|
|
45
|
+
_use_iterate_bar_threshold: int = 500
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def operation(self, query_result_row: ResultRow) -> RowTransformationOutput:
|
|
49
|
+
"""The operations to perform on each row resulting from the ._iterate_query() method.
|
|
50
|
+
The operation should return a list of triples to add and to remove.
|
|
51
|
+
"""
|
|
52
|
+
raise NotImplementedError()
|
|
53
|
+
|
|
54
|
+
@abstractmethod
|
|
55
|
+
def _count_query(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
Overwrite to fetch all affected properties in the graph as a result of the transformation.
|
|
58
|
+
Returns:
|
|
59
|
+
A query string.
|
|
60
|
+
"""
|
|
61
|
+
raise NotImplementedError()
|
|
62
|
+
|
|
63
|
+
@abstractmethod
|
|
64
|
+
def _iterate_query(self) -> str:
|
|
65
|
+
"""
|
|
66
|
+
The query to use for extracting target triples from the graph and performing the transformation.
|
|
67
|
+
Returns:
|
|
68
|
+
A query string.
|
|
69
|
+
"""
|
|
70
|
+
raise NotImplementedError()
|
|
71
|
+
|
|
72
|
+
def _skip_count_query(self) -> str:
|
|
73
|
+
"""
|
|
74
|
+
The query to use for extracting target triples from the graph and performing the transformation.
|
|
75
|
+
Returns:
|
|
76
|
+
A query string.
|
|
77
|
+
"""
|
|
78
|
+
return ""
|
|
79
|
+
|
|
80
|
+
def transform(self, graph: Graph) -> GraphTransformationResult:
|
|
81
|
+
outcome = GraphTransformationResult(self.__class__.__name__)
|
|
82
|
+
outcome.added = outcome.modified = outcome.removed = 0
|
|
83
|
+
|
|
84
|
+
iteration_count_res = list(graph.query(self._count_query()))
|
|
85
|
+
iteration_count = int(iteration_count_res[0][0]) # type: ignore [index, arg-type]
|
|
86
|
+
|
|
87
|
+
outcome.affected_nodes_count = iteration_count
|
|
88
|
+
|
|
89
|
+
if self._skip_count_query():
|
|
90
|
+
skipped_count_res = list(graph.query(self._skip_count_query()))
|
|
91
|
+
skipped_count = int(skipped_count_res[0][0]) # type: ignore [index, arg-type]
|
|
92
|
+
warnings.warn(
|
|
93
|
+
NeatValueWarning(f"Skipping {skipped_count} properties in transformation {self.__class__.__name__}"),
|
|
94
|
+
stacklevel=2,
|
|
95
|
+
)
|
|
96
|
+
outcome.skipped = skipped_count
|
|
97
|
+
|
|
98
|
+
if iteration_count == 0:
|
|
99
|
+
return outcome
|
|
100
|
+
|
|
101
|
+
result_iterable = graph.query(self._iterate_query())
|
|
102
|
+
if iteration_count > self._use_iterate_bar_threshold:
|
|
103
|
+
result_iterable = iterate_progress_bar( # type: ignore[misc, assignment]
|
|
104
|
+
result_iterable,
|
|
105
|
+
total=iteration_count,
|
|
106
|
+
description=self.description,
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
for row in result_iterable:
|
|
110
|
+
row = cast(ResultRow, row)
|
|
111
|
+
row_output = self.operation(row)
|
|
112
|
+
|
|
113
|
+
outcome.added += row_output.instances_added_count
|
|
114
|
+
outcome.removed += row_output.instances_removed_count
|
|
115
|
+
outcome.modified += row_output.instances_modified_count
|
|
116
|
+
|
|
117
|
+
for triple in row_output.add_triples:
|
|
118
|
+
graph.add(triple)
|
|
119
|
+
for triple in row_output.remove_triples:
|
|
120
|
+
graph.remove(triple)
|
|
121
|
+
|
|
122
|
+
return outcome
|
{cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_classic_cdf.py
RENAMED
|
@@ -21,6 +21,7 @@ from cognite.neat._utils.rdf_ import (
|
|
|
21
21
|
from ._base import BaseTransformer
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
# TODO: standardise
|
|
24
25
|
class AddAssetDepth(BaseTransformer):
|
|
25
26
|
description: str = "Adds depth of asset in the asset hierarchy to the graph"
|
|
26
27
|
_use_only_once: bool = True
|
|
@@ -84,6 +85,7 @@ class AddAssetDepth(BaseTransformer):
|
|
|
84
85
|
return None
|
|
85
86
|
|
|
86
87
|
|
|
88
|
+
# TODO: standardise
|
|
87
89
|
class BaseAssetConnector(BaseTransformer, ABC):
|
|
88
90
|
_asset_type: URIRef = DEFAULT_NAMESPACE.Asset
|
|
89
91
|
_item_type: URIRef
|
|
@@ -166,6 +168,7 @@ class AssetEventConnector(BaseAssetConnector):
|
|
|
166
168
|
_connection_type = DEFAULT_NAMESPACE.event
|
|
167
169
|
|
|
168
170
|
|
|
171
|
+
# TODO: standardise
|
|
169
172
|
class AssetRelationshipConnector(BaseTransformer):
|
|
170
173
|
description: str = "Connects assets via relationships"
|
|
171
174
|
_use_only_once: bool = True
|
|
@@ -242,6 +245,7 @@ class AssetRelationshipConnector(BaseTransformer):
|
|
|
242
245
|
graph.remove((relationship_id, self.relationship_target_xid_prop, None))
|
|
243
246
|
|
|
244
247
|
|
|
248
|
+
# TODO: standardise
|
|
245
249
|
class RelationshipAsEdgeTransformer(BaseTransformer):
|
|
246
250
|
"""Converts relationships into edges in the graph.
|
|
247
251
|
|
{cognite_neat-0.103.1 → cognite_neat-0.104.0}/cognite/neat/_graph/transformers/_prune_graph.py
RENAMED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
from typing import cast
|
|
2
2
|
|
|
3
3
|
from rdflib import Graph, Namespace, URIRef
|
|
4
|
+
from rdflib.query import ResultRow
|
|
4
5
|
|
|
5
6
|
from cognite.neat._constants import DEFAULT_NAMESPACE
|
|
6
7
|
from cognite.neat._shared import Triple
|
|
7
8
|
from cognite.neat._utils.rdf_ import as_neat_compliant_uri
|
|
8
9
|
from cognite.neat._utils.text import sentence_or_string_to_camel
|
|
9
10
|
|
|
10
|
-
from ._base import BaseTransformer
|
|
11
|
+
from ._base import BaseTransformer, BaseTransformerStandardised, RowTransformationOutput
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
# TODO: Standardise after figuring out the bug which appears when running test_iodd_transformers.py
|
|
13
15
|
class AttachPropertyFromTargetToSource(BaseTransformer):
|
|
14
16
|
"""
|
|
15
17
|
Transformer that considers a TargetNode and SourceNode relationship, to extract a property that is attached to
|
|
@@ -148,6 +150,7 @@ class AttachPropertyFromTargetToSource(BaseTransformer):
|
|
|
148
150
|
graph.remove((target_node, None, None))
|
|
149
151
|
|
|
150
152
|
|
|
153
|
+
# TODO: Remove or adapt IODD
|
|
151
154
|
class PruneDanglingNodes(BaseTransformer):
|
|
152
155
|
"""
|
|
153
156
|
Knowledge graph pruner and resolver. Will remove rdf triples from graph that does not have connections
|
|
@@ -189,18 +192,12 @@ class PruneDanglingNodes(BaseTransformer):
|
|
|
189
192
|
graph.remove((subject, None, None))
|
|
190
193
|
|
|
191
194
|
|
|
192
|
-
class PruneTypes(
|
|
195
|
+
class PruneTypes(BaseTransformerStandardised):
|
|
193
196
|
"""
|
|
194
197
|
Removes all the instances of specific type
|
|
195
198
|
"""
|
|
196
199
|
|
|
197
200
|
description: str = "Prunes nodes of specific rdf types"
|
|
198
|
-
_query_template = """
|
|
199
|
-
SELECT ?subject
|
|
200
|
-
WHERE {{
|
|
201
|
-
?subject a <{rdf_type}> .
|
|
202
|
-
}}
|
|
203
|
-
"""
|
|
204
201
|
|
|
205
202
|
def __init__(
|
|
206
203
|
self,
|
|
@@ -208,50 +205,109 @@ class PruneTypes(BaseTransformer):
|
|
|
208
205
|
):
|
|
209
206
|
self.node_prune_types = node_prune_types
|
|
210
207
|
|
|
211
|
-
def
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
def _iterate_query(self) -> str:
|
|
209
|
+
filter_string = ""
|
|
210
|
+
for node in self.node_prune_types:
|
|
211
|
+
filter_string += f" <{node}> "
|
|
212
|
+
|
|
213
|
+
query = """
|
|
214
|
+
SELECT ?subject
|
|
215
|
+
WHERE {{
|
|
216
|
+
?subject a ?type .
|
|
217
|
+
VALUES ?type {{ {rdf_types_string} }}
|
|
218
|
+
}}
|
|
219
|
+
"""
|
|
220
|
+
return query.format(rdf_types_string=filter_string)
|
|
221
|
+
|
|
222
|
+
def _count_query(self) -> str:
|
|
223
|
+
filter_string = ""
|
|
224
|
+
for node in self.node_prune_types:
|
|
225
|
+
filter_string += f" <{node}> "
|
|
226
|
+
|
|
227
|
+
query = """
|
|
228
|
+
SELECT ( COUNT( ?subject ) as ?count )
|
|
229
|
+
WHERE {{
|
|
230
|
+
?subject a ?type .
|
|
231
|
+
VALUES ?type {{ {rdf_types_string} }}
|
|
232
|
+
}}
|
|
233
|
+
"""
|
|
234
|
+
return query.format(rdf_types_string=filter_string)
|
|
235
|
+
|
|
236
|
+
def operation(self, query_result_row: ResultRow) -> RowTransformationOutput:
|
|
237
|
+
row_output = RowTransformationOutput()
|
|
238
|
+
|
|
239
|
+
(subject,) = query_result_row
|
|
240
|
+
row_output.remove_triples.append((subject, None, None)) # type: ignore
|
|
241
|
+
row_output.instances_removed_count = 1
|
|
242
|
+
|
|
243
|
+
return row_output
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class PruneDeadEndEdges(BaseTransformerStandardised):
|
|
218
247
|
"""
|
|
219
248
|
Removes all the triples where object is a node that is not found in graph
|
|
220
249
|
"""
|
|
221
250
|
|
|
222
|
-
description: str = "
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
def
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
251
|
+
description: str = "Pruning the graph of triples where object is a node that is not found in graph."
|
|
252
|
+
|
|
253
|
+
def _iterate_query(self) -> str:
|
|
254
|
+
return """
|
|
255
|
+
SELECT ?subject ?predicate ?object
|
|
256
|
+
WHERE {
|
|
257
|
+
?subject ?predicate ?object .
|
|
258
|
+
FILTER (isIRI(?object) && ?predicate != rdf:type)
|
|
259
|
+
FILTER NOT EXISTS {?object ?p ?o .}
|
|
260
|
+
}
|
|
261
|
+
"""
|
|
262
|
+
|
|
263
|
+
def _count_query(self) -> str:
|
|
264
|
+
return """
|
|
265
|
+
SELECT (COUNT(?object) AS ?count)
|
|
266
|
+
WHERE {
|
|
267
|
+
?subject ?predicate ?object .
|
|
268
|
+
FILTER (isIRI(?object) && ?predicate != rdf:type)
|
|
269
|
+
FILTER NOT EXISTS {?object ?p ?o .}
|
|
270
|
+
}
|
|
271
|
+
"""
|
|
272
|
+
|
|
273
|
+
def operation(self, row: ResultRow) -> RowTransformationOutput:
|
|
274
|
+
row_output = RowTransformationOutput()
|
|
275
|
+
row_output.remove_triples.append(cast(Triple, row))
|
|
276
|
+
row_output.instances_modified_count = 1
|
|
277
|
+
|
|
278
|
+
return row_output
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class PruneInstancesOfUnknownType(BaseTransformerStandardised):
|
|
240
282
|
"""
|
|
241
283
|
Removes all the triples where object is a node that is not found in graph
|
|
242
284
|
"""
|
|
243
285
|
|
|
244
|
-
description: str = "Prunes the graph of
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
286
|
+
description: str = "Prunes the graph of triples where the object is a node that is not found in the graph."
|
|
287
|
+
|
|
288
|
+
def _iterate_query(self) -> str:
|
|
289
|
+
return """
|
|
290
|
+
SELECT DISTINCT ?subject
|
|
291
|
+
WHERE {
|
|
292
|
+
?subject ?p ?o .
|
|
293
|
+
FILTER NOT EXISTS {?subject a ?object .}
|
|
294
|
+
|
|
295
|
+
}
|
|
296
|
+
"""
|
|
297
|
+
|
|
298
|
+
def _count_query(self) -> str:
|
|
299
|
+
return """
|
|
300
|
+
SELECT (COUNT(DISTINCT ?subject) as ?count)
|
|
301
|
+
WHERE {
|
|
302
|
+
?subject ?p ?o .
|
|
303
|
+
FILTER NOT EXISTS {?subject a ?object .}
|
|
304
|
+
}
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
def operation(self, query_result_row: ResultRow) -> RowTransformationOutput:
|
|
308
|
+
row_output = RowTransformationOutput()
|
|
309
|
+
(subject,) = query_result_row
|
|
310
|
+
row_output.remove_triples.append(cast(Triple, (subject, None, None)))
|
|
311
|
+
row_output.instances_removed_count = 1
|
|
312
|
+
|
|
313
|
+
return row_output
|
|
@@ -2,15 +2,16 @@ from typing import cast
|
|
|
2
2
|
from urllib.parse import quote
|
|
3
3
|
|
|
4
4
|
from rdflib import Graph, URIRef
|
|
5
|
+
from rdflib.query import ResultRow
|
|
5
6
|
|
|
6
7
|
from cognite.neat._constants import DEFAULT_NAMESPACE
|
|
7
8
|
from cognite.neat._rules.analysis import InformationAnalysis
|
|
8
9
|
from cognite.neat._rules.models._rdfpath import RDFPath, SingleProperty
|
|
9
10
|
from cognite.neat._rules.models.information import InformationRules
|
|
10
11
|
from cognite.neat._shared import Triple
|
|
11
|
-
from cognite.neat._utils.rdf_ import
|
|
12
|
+
from cognite.neat._utils.rdf_ import remove_namespace_from_uri
|
|
12
13
|
|
|
13
|
-
from ._base import BaseTransformer
|
|
14
|
+
from ._base import BaseTransformer, BaseTransformerStandardised, RowTransformationOutput
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class ReduceHopTraversal(BaseTransformer):
|
|
@@ -19,6 +20,7 @@ class ReduceHopTraversal(BaseTransformer):
|
|
|
19
20
|
...
|
|
20
21
|
|
|
21
22
|
|
|
23
|
+
# TODO: Standardise
|
|
22
24
|
class AddSelfReferenceProperty(BaseTransformer):
|
|
23
25
|
description: str = "Adds property that contains id of reference to all references of given class in Rules"
|
|
24
26
|
_use_only_once: bool = True
|
|
@@ -56,17 +58,10 @@ class AddSelfReferenceProperty(BaseTransformer):
|
|
|
56
58
|
property_.transformation = RDFPath(traversal=traversal)
|
|
57
59
|
|
|
58
60
|
|
|
59
|
-
class MakeConnectionOnExactMatch(
|
|
61
|
+
class MakeConnectionOnExactMatch(BaseTransformerStandardised):
|
|
60
62
|
description: str = "Adds property that contains id of reference to all references of given class in Rules"
|
|
61
63
|
_use_only_once: bool = True
|
|
62
64
|
_need_changes = frozenset({})
|
|
63
|
-
_ref_template: str = """SELECT DISTINCT ?subject ?object
|
|
64
|
-
WHERE {{
|
|
65
|
-
?subject a <{subject_type}> .
|
|
66
|
-
?subject <{subject_predicate}> ?value .
|
|
67
|
-
?object <{object_predicate}> ?value .
|
|
68
|
-
?object a <{object_type}> .
|
|
69
|
-
}}"""
|
|
70
65
|
|
|
71
66
|
def __init__(
|
|
72
67
|
self,
|
|
@@ -90,20 +85,49 @@ class MakeConnectionOnExactMatch(BaseTransformer):
|
|
|
90
85
|
|
|
91
86
|
self.limit = limit
|
|
92
87
|
|
|
93
|
-
def
|
|
94
|
-
query =
|
|
88
|
+
def _iterate_query(self) -> str:
|
|
89
|
+
query = """SELECT DISTINCT ?subject ?object
|
|
90
|
+
WHERE {{
|
|
91
|
+
?subject a <{subject_type}> .
|
|
92
|
+
?subject <{subject_predicate}> ?value .
|
|
93
|
+
?object <{object_predicate}> ?value .
|
|
94
|
+
?object a <{object_type}> .
|
|
95
|
+
}}"""
|
|
96
|
+
|
|
97
|
+
if self.limit and isinstance(self.limit, int) and self.limit > 0:
|
|
98
|
+
query += f" LIMIT {self.limit}"
|
|
99
|
+
|
|
100
|
+
return query.format(
|
|
95
101
|
subject_type=self.subject_type,
|
|
96
102
|
subject_predicate=self.subject_predicate,
|
|
97
103
|
object_type=self.object_type,
|
|
98
104
|
object_predicate=self.object_predicate,
|
|
99
105
|
)
|
|
100
106
|
|
|
107
|
+
def _count_query(self) -> str:
|
|
108
|
+
query = """SELECT (COUNT(DISTINCT (?subject ?object)) as ?count)
|
|
109
|
+
WHERE {{
|
|
110
|
+
?subject a <{subject_type}> .
|
|
111
|
+
?subject <{subject_predicate}> ?value .
|
|
112
|
+
?object <{object_predicate}> ?value .
|
|
113
|
+
?object a <{object_type}> .
|
|
114
|
+
}}"""
|
|
115
|
+
|
|
101
116
|
if self.limit and isinstance(self.limit, int) and self.limit > 0:
|
|
102
117
|
query += f" LIMIT {self.limit}"
|
|
103
118
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
return query.format(
|
|
120
|
+
subject_type=self.subject_type,
|
|
121
|
+
subject_predicate=self.subject_predicate,
|
|
122
|
+
object_type=self.object_type,
|
|
123
|
+
object_predicate=self.object_predicate,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def operation(self, query_result_row: ResultRow) -> RowTransformationOutput:
|
|
127
|
+
row_output = RowTransformationOutput()
|
|
128
|
+
|
|
129
|
+
subject, object = query_result_row
|
|
107
130
|
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
row_output.add_triples.append(cast(Triple, (subject, self.connection, object)))
|
|
132
|
+
row_output.instances_modified_count += 1
|
|
133
|
+
return row_output
|