cognite-neat 0.97.1__tar.gz → 0.97.3__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.97.1 → cognite_neat-0.97.3}/PKG-INFO +1 -1
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/loaders/_base.py +8 -1
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/loaders/_rdf2dms.py +35 -15
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/queries/_base.py +25 -4
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/__init__.py +4 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/_base.py +48 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/_general.py +3 -1
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/_types.py +24 -16
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/_validation.py +0 -15
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_verification.py +2 -49
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_base.py +48 -26
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_inspect.py +12 -2
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_prepare.py +34 -8
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_set.py +12 -4
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_to.py +34 -7
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/auth.py +4 -3
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/upload.py +20 -0
- cognite_neat-0.97.3/cognite/neat/_version.py +2 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/pyproject.toml +1 -1
- cognite_neat-0.97.1/cognite/neat/_version.py +0 -2
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/LICENSE +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/README.md +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/configuration.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/explorer.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/routers/configuration.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/routers/crud.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/routers/metrics.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/routers/workflows.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/utils/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/utils/logging.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/main.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/monitoring/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/monitoring/metrics.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/index.html +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/package-lock.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/package.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/index.html +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/manifest.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/public/robots.txt +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/App.css +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/App.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/App.test.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/index.css +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/index.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/logo.svg +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/setupTests.js +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_app/ui/neat-app/tsconfig.json +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_constants.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/_shared.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_dms.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_iodd.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/loaders/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/loaders/_rdf2asset.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/queries/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/queries/_construct.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/queries/_shared.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_classic_cdf.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_iodd.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_prune_graph.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_rdfpath.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_graph/transformers/_value_type.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/_external.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/_properties.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/_resources.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/errors/_workflow.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/formatters.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/_external.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/_models.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/_properties.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/_resources.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_issues/warnings/user_modeling.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/_constants.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/_shared.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/analysis/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/analysis/_asset.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/analysis/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/analysis/_dms.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/analysis/_information.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_rules2instance_template.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_imf2rules/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2classes.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2metadata.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2properties.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_rdf/_shared.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/_base_input.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/_base_rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/asset/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/asset/_rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/asset/_rules_input.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/asset/_validation.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/data_types.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/_exporter.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/_rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/_rules_input.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/dms/_schema.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/domain.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_loaders.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_multi_value.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_single_value.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/entities/_wrapped.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/information/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/information/_rules.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/information/_rules_input.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/information/_validation.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/mapping/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/mapping/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/models/mapping/_classic2core.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_converters.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_mapping.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_pipelines.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_read.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_show.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_state.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_session/exceptions.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_store/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_store/_provenance.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/auxiliary.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/data_classes.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/loaders/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/loaders/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/loaders/_data_modeling.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/cdf/loaders/_ingestion.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/rdf_.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/spreadsheet.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/text.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/base.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/cdf_store.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/manager.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/model.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/rules_exporter.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/rules_importer.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/current/rules_validator.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps/step_model.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/steps_registry.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/tasks.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/triggers.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_workflows/utils.py +0 -0
- {cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/py.typed +0 -0
|
@@ -51,7 +51,14 @@ class CDFLoader(BaseLoader[T_Output]):
|
|
|
51
51
|
def load_into_cdf(
|
|
52
52
|
self, client: CogniteClient, dry_run: bool = False, check_client: bool = True
|
|
53
53
|
) -> UploadResultList:
|
|
54
|
-
|
|
54
|
+
upload_result_by_name: dict[str, UploadResult] = {}
|
|
55
|
+
for upload_result in self.load_into_cdf_iterable(client, dry_run, check_client):
|
|
56
|
+
if last_result := upload_result_by_name.get(upload_result.name):
|
|
57
|
+
upload_result_by_name[upload_result.name] = last_result.merge(upload_result)
|
|
58
|
+
else:
|
|
59
|
+
upload_result_by_name[upload_result.name] = upload_result
|
|
60
|
+
|
|
61
|
+
return UploadResultList(upload_result_by_name.values())
|
|
55
62
|
|
|
56
63
|
def load_into_cdf_iterable(
|
|
57
64
|
self, client: CogniteClient, dry_run: bool = False, check_client: bool = True
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import itertools
|
|
1
2
|
import json
|
|
2
3
|
from collections.abc import Iterable, Sequence
|
|
3
4
|
from pathlib import Path
|
|
@@ -295,9 +296,24 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
295
296
|
dry_run: bool,
|
|
296
297
|
read_issues: IssueList,
|
|
297
298
|
) -> Iterable[UploadResult]:
|
|
299
|
+
nodes: list[dm.NodeApply] = []
|
|
300
|
+
edges: list[dm.EdgeApply] = []
|
|
301
|
+
source_by_node_id: dict[dm.NodeId, str] = {}
|
|
302
|
+
source_by_edge_id: dict[dm.EdgeId, str] = {}
|
|
303
|
+
for item in items:
|
|
304
|
+
if isinstance(item, dm.NodeApply):
|
|
305
|
+
nodes.append(item)
|
|
306
|
+
if item.sources:
|
|
307
|
+
source_by_node_id[item.as_id()] = item.sources[0].source.external_id
|
|
308
|
+
else:
|
|
309
|
+
source_by_node_id[item.as_id()] = "node"
|
|
310
|
+
elif isinstance(item, dm.EdgeApply):
|
|
311
|
+
edges.append(item)
|
|
312
|
+
if item.sources:
|
|
313
|
+
source_by_edge_id[item.as_id()] = item.sources[0].source.external_id
|
|
314
|
+
else:
|
|
315
|
+
source_by_edge_id[item.as_id()] = "edge"
|
|
298
316
|
try:
|
|
299
|
-
nodes = [item for item in items if isinstance(item, dm.NodeApply)]
|
|
300
|
-
edges = [item for item in items if isinstance(item, dm.EdgeApply)]
|
|
301
317
|
upserted = client.data_modeling.instances.apply(
|
|
302
318
|
nodes,
|
|
303
319
|
edges,
|
|
@@ -312,19 +328,23 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
312
328
|
result.created.update(item.as_id() for item in e.successful)
|
|
313
329
|
yield result
|
|
314
330
|
else:
|
|
315
|
-
for
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
331
|
+
for instances, ids_by_source in [
|
|
332
|
+
(upserted.nodes, source_by_node_id),
|
|
333
|
+
(upserted.edges, source_by_edge_id),
|
|
334
|
+
]:
|
|
335
|
+
for name, subinstances in itertools.groupby(
|
|
336
|
+
sorted(instances, key=lambda i: ids_by_source[i.as_id()]), # type: ignore[call-overload, index, attr-defined]
|
|
337
|
+
key=lambda i: ids_by_source[i.as_id()], # type: ignore[index]
|
|
338
|
+
):
|
|
339
|
+
result = UploadResult(name=name, issues=read_issues)
|
|
340
|
+
for instance in subinstances: # type: ignore[attr-defined]
|
|
341
|
+
if instance.was_modified and instance.created_time == instance.last_updated_time:
|
|
342
|
+
result.created.add(instance.as_id())
|
|
343
|
+
elif instance.was_modified:
|
|
344
|
+
result.changed.add(instance.as_id())
|
|
345
|
+
else:
|
|
346
|
+
result.unchanged.add(instance.as_id())
|
|
347
|
+
yield result
|
|
328
348
|
|
|
329
349
|
|
|
330
350
|
def _get_field_value_types(cls, info):
|
|
@@ -42,6 +42,27 @@ class Queries:
|
|
|
42
42
|
for res in list(self.graph.query(query_statement))
|
|
43
43
|
]
|
|
44
44
|
|
|
45
|
+
@property
|
|
46
|
+
def types(self) -> dict[URIRef, str]:
|
|
47
|
+
"""Types and their short form in the graph"""
|
|
48
|
+
query = """SELECT DISTINCT ?type
|
|
49
|
+
WHERE {?s a ?type .}"""
|
|
50
|
+
return {type_: remove_namespace_from_uri(cast(URIRef, type_)) for (type_,) in list(self.graph.query(query))} # type: ignore[misc, index, arg-type]
|
|
51
|
+
|
|
52
|
+
def type_uri(self, type_: str) -> list[URIRef]:
|
|
53
|
+
"""Get the URIRef of a type"""
|
|
54
|
+
return [k for k, v in self.types.items() if v == type_]
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def properties(self) -> dict[URIRef, str]:
|
|
58
|
+
query = """SELECT DISTINCT ?property
|
|
59
|
+
WHERE {?s ?property ?o . FILTER(?property != rdf:type)}"""
|
|
60
|
+
return {type_: remove_namespace_from_uri(cast(URIRef, type_)) for (type_,) in list(self.graph.query(query))} # type: ignore[misc, index, arg-type]
|
|
61
|
+
|
|
62
|
+
def property_uri(self, property_: str) -> list[URIRef]:
|
|
63
|
+
"""Get the URIRef of a type"""
|
|
64
|
+
return [k for k, v in self.properties.items() if v == property_]
|
|
65
|
+
|
|
45
66
|
def list_instances_ids_of_class(self, class_uri: URIRef, limit: int = -1) -> list[URIRef]:
|
|
46
67
|
"""Get instances ids for a given class
|
|
47
68
|
|
|
@@ -101,7 +122,7 @@ class Queries:
|
|
|
101
122
|
# We cannot include the RDF.type in case there is a neat:type property
|
|
102
123
|
return [remove_namespace_from_uri(list(triple)) for triple in result if triple[1] != RDF.type] # type: ignore[misc, index, arg-type]
|
|
103
124
|
|
|
104
|
-
def
|
|
125
|
+
def type_with_property(self, type_: URIRef, property_uri: URIRef) -> bool:
|
|
105
126
|
"""Check if a property exists in the graph store
|
|
106
127
|
|
|
107
128
|
Args:
|
|
@@ -110,8 +131,8 @@ class Queries:
|
|
|
110
131
|
Returns:
|
|
111
132
|
True if property exists, False otherwise
|
|
112
133
|
"""
|
|
113
|
-
query = f"SELECT
|
|
114
|
-
return
|
|
134
|
+
query = f"SELECT ?o WHERE {{ ?s a <{type_}> ; <{property_uri}> ?o .}} Limit 1"
|
|
135
|
+
return bool(list(self.graph.query(query)))
|
|
115
136
|
|
|
116
137
|
def has_namespace(self, namespace: Namespace) -> bool:
|
|
117
138
|
"""Check if a namespace exists in the graph store
|
|
@@ -250,7 +271,7 @@ class Queries:
|
|
|
250
271
|
result = self.graph.query(query)
|
|
251
272
|
|
|
252
273
|
# We cannot include the RDF.type in case there is a neat:type property
|
|
253
|
-
return [remove_namespace_from_uri(cast(ResultRow, triple)) for triple in result if triple[1] != RDF.type] # type: ignore[misc, index]
|
|
274
|
+
return [remove_namespace_from_uri(cast(ResultRow, triple)) for triple in result if triple[1] != RDF.type] # type: ignore[misc, index, arg-type]
|
|
254
275
|
else:
|
|
255
276
|
warnings.warn(
|
|
256
277
|
"No rules found for the graph store, returning empty list.",
|
|
@@ -3,12 +3,14 @@ as some helper classes to handle them like NeatIssueList"""
|
|
|
3
3
|
|
|
4
4
|
from ._base import (
|
|
5
5
|
DefaultWarning,
|
|
6
|
+
FutureResult,
|
|
6
7
|
IssueList,
|
|
7
8
|
MultiValueError,
|
|
8
9
|
NeatError,
|
|
9
10
|
NeatIssue,
|
|
10
11
|
NeatIssueList,
|
|
11
12
|
NeatWarning,
|
|
13
|
+
catch_issues,
|
|
12
14
|
catch_warnings,
|
|
13
15
|
)
|
|
14
16
|
|
|
@@ -21,4 +23,6 @@ __all__ = [
|
|
|
21
23
|
"IssueList",
|
|
22
24
|
"MultiValueError",
|
|
23
25
|
"catch_warnings",
|
|
26
|
+
"catch_issues",
|
|
27
|
+
"FutureResult",
|
|
24
28
|
]
|
|
@@ -18,6 +18,7 @@ from cognite.client.data_classes.data_modeling import (
|
|
|
18
18
|
PropertyId,
|
|
19
19
|
ViewId,
|
|
20
20
|
)
|
|
21
|
+
from pydantic import ValidationError
|
|
21
22
|
from pydantic_core import ErrorDetails
|
|
22
23
|
|
|
23
24
|
from cognite.neat._utils.spreadsheet import SpreadsheetRead
|
|
@@ -398,6 +399,10 @@ class NeatIssueList(list, Sequence[T_NeatIssue], ABC):
|
|
|
398
399
|
"""Return all the warnings in this list."""
|
|
399
400
|
return type(self)([issue for issue in self if isinstance(issue, NeatWarning)]) # type: ignore[misc]
|
|
400
401
|
|
|
402
|
+
def has_error_type(self, error_type: type[NeatError]) -> bool:
|
|
403
|
+
"""Return True if this list contains any errors of the given type."""
|
|
404
|
+
return any(isinstance(issue, error_type) for issue in self)
|
|
405
|
+
|
|
401
406
|
def as_errors(self, operation: str = "Operation failed") -> ExceptionGroup:
|
|
402
407
|
"""Return an ExceptionGroup with all the errors in this list."""
|
|
403
408
|
return ExceptionGroup(
|
|
@@ -473,3 +478,46 @@ def catch_warnings(
|
|
|
473
478
|
finally:
|
|
474
479
|
if warning_logger and issues is not None:
|
|
475
480
|
issues.extend([warning_cls.from_warning(warning) for warning in warning_logger]) # type: ignore[misc]
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
class FutureResult:
|
|
484
|
+
def __init__(self) -> None:
|
|
485
|
+
self._result: Literal["success", "failure", "pending"] = "pending"
|
|
486
|
+
|
|
487
|
+
@property
|
|
488
|
+
def result(self) -> Literal["success", "failure", "pending"]:
|
|
489
|
+
return self._result
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
@contextmanager
|
|
493
|
+
def catch_issues(
|
|
494
|
+
issues: IssueList,
|
|
495
|
+
error_cls: type[NeatError] = NeatError,
|
|
496
|
+
warning_cls: type[NeatWarning] = NeatWarning,
|
|
497
|
+
error_args: dict[str, Any] | None = None,
|
|
498
|
+
) -> Iterator[FutureResult]:
|
|
499
|
+
"""This is an internal help function to handle issues and warnings.
|
|
500
|
+
|
|
501
|
+
Args:
|
|
502
|
+
issues: The issues list to append to.
|
|
503
|
+
error_cls: The class used to convert errors to issues.
|
|
504
|
+
warning_cls: The class used to convert warnings to issues.
|
|
505
|
+
|
|
506
|
+
Returns:
|
|
507
|
+
FutureResult: A future result object that can be used to check the result of the context manager.
|
|
508
|
+
"""
|
|
509
|
+
with catch_warnings(issues, warning_cls):
|
|
510
|
+
future_result = FutureResult()
|
|
511
|
+
try:
|
|
512
|
+
yield future_result
|
|
513
|
+
except ValidationError as e:
|
|
514
|
+
issues.extend(error_cls.from_pydantic_errors(e.errors(), **(error_args or {})))
|
|
515
|
+
future_result._result = "failure"
|
|
516
|
+
except MultiValueError as e:
|
|
517
|
+
issues.extend(e.errors)
|
|
518
|
+
future_result._result = "failure"
|
|
519
|
+
except NeatError as e:
|
|
520
|
+
issues.append(e)
|
|
521
|
+
future_result._result = "failure"
|
|
522
|
+
else:
|
|
523
|
+
future_result._result = "success"
|
|
@@ -19,10 +19,12 @@ class NeatTypeError(NeatError, TypeError):
|
|
|
19
19
|
|
|
20
20
|
@dataclass(unsafe_hash=True)
|
|
21
21
|
class RegexViolationError(NeatError, ValueError):
|
|
22
|
-
"""Value, {value} failed regex, {regex}, validation.
|
|
22
|
+
"""Value, {value} in {location} failed regex, {regex}, validation.
|
|
23
|
+
Make sure that the name follows the regex pattern."""
|
|
23
24
|
|
|
24
25
|
value: str
|
|
25
26
|
regex: str
|
|
27
|
+
location: str
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
@dataclass(unsafe_hash=True)
|
|
@@ -76,13 +76,17 @@ NamespaceType = Annotated[
|
|
|
76
76
|
PrefixType = Annotated[
|
|
77
77
|
str,
|
|
78
78
|
StringConstraints(pattern=PREFIX_COMPLIANCE_REGEX),
|
|
79
|
-
_custom_error(
|
|
79
|
+
_custom_error(
|
|
80
|
+
lambda _, value: RegexViolationError(value, PREFIX_COMPLIANCE_REGEX, "prefix entry in metadata"),
|
|
81
|
+
),
|
|
80
82
|
]
|
|
81
83
|
|
|
82
84
|
DataModelExternalIdType = Annotated[
|
|
83
85
|
str,
|
|
84
86
|
StringConstraints(pattern=DATA_MODEL_COMPLIANCE_REGEX),
|
|
85
|
-
_custom_error(
|
|
87
|
+
_custom_error(
|
|
88
|
+
lambda _, value: RegexViolationError(value, DATA_MODEL_COMPLIANCE_REGEX, "external ID entry in metadata")
|
|
89
|
+
),
|
|
86
90
|
]
|
|
87
91
|
|
|
88
92
|
|
|
@@ -90,15 +94,15 @@ VersionType = Annotated[
|
|
|
90
94
|
str,
|
|
91
95
|
BeforeValidator(str),
|
|
92
96
|
StringConstraints(pattern=VERSION_COMPLIANCE_REGEX),
|
|
93
|
-
_custom_error(lambda _, value: RegexViolationError(value, VERSION_COMPLIANCE_REGEX)),
|
|
97
|
+
_custom_error(lambda _, value: RegexViolationError(value, VERSION_COMPLIANCE_REGEX, "version entry in metadata")),
|
|
94
98
|
]
|
|
95
99
|
|
|
96
100
|
|
|
97
|
-
def _external_id_validation_factory(entity_type: EntityTypes):
|
|
101
|
+
def _external_id_validation_factory(entity_type: EntityTypes, location: str):
|
|
98
102
|
def _external_id_validation(value: str) -> str:
|
|
99
103
|
compiled_regex = PATTERNS.entity_pattern(entity_type)
|
|
100
104
|
if not compiled_regex.match(value):
|
|
101
|
-
raise RegexViolationError(value, compiled_regex.pattern)
|
|
105
|
+
raise RegexViolationError(value, compiled_regex.pattern, location)
|
|
102
106
|
if PATTERNS.more_than_one_alphanumeric.search(value):
|
|
103
107
|
warnings.warn(
|
|
104
108
|
RegexViolationWarning(
|
|
@@ -116,36 +120,40 @@ def _external_id_validation_factory(entity_type: EntityTypes):
|
|
|
116
120
|
|
|
117
121
|
SpaceType = Annotated[
|
|
118
122
|
str,
|
|
119
|
-
AfterValidator(_external_id_validation_factory(EntityTypes.space)),
|
|
123
|
+
AfterValidator(_external_id_validation_factory(EntityTypes.space, "space entry in metadata")),
|
|
120
124
|
]
|
|
121
125
|
|
|
122
126
|
InformationPropertyType = Annotated[
|
|
123
127
|
str,
|
|
124
|
-
AfterValidator(_external_id_validation_factory(EntityTypes.information_property)),
|
|
128
|
+
AfterValidator(_external_id_validation_factory(EntityTypes.information_property, "Property column in properties")),
|
|
125
129
|
]
|
|
126
130
|
DmsPropertyType = Annotated[
|
|
127
131
|
str,
|
|
128
|
-
AfterValidator(_external_id_validation_factory(EntityTypes.dms_property)),
|
|
132
|
+
AfterValidator(_external_id_validation_factory(EntityTypes.dms_property, "Property column in properties")),
|
|
129
133
|
]
|
|
130
134
|
|
|
131
135
|
|
|
132
|
-
def _entity_validation(value: Entities) -> Entities:
|
|
136
|
+
def _entity_validation(value: Entities, location: str) -> Entities:
|
|
133
137
|
suffix_regex = PATTERNS.entity_pattern(value.type_)
|
|
134
138
|
if not suffix_regex.match(value.suffix):
|
|
135
|
-
raise RegexViolationError(str(value), suffix_regex.pattern)
|
|
139
|
+
raise RegexViolationError(str(value), suffix_regex.pattern, location)
|
|
136
140
|
return value
|
|
137
141
|
|
|
138
142
|
|
|
139
|
-
ClassEntityType = Annotated[ClassEntity, AfterValidator(_entity_validation)]
|
|
140
|
-
ViewEntityType = Annotated[ViewEntity, AfterValidator(_entity_validation)]
|
|
141
|
-
ContainerEntityType = Annotated[
|
|
143
|
+
ClassEntityType = Annotated[ClassEntity, AfterValidator(lambda v: _entity_validation(v, "the Class column"))]
|
|
144
|
+
ViewEntityType = Annotated[ViewEntity, AfterValidator(lambda v: _entity_validation(v, "the View column"))]
|
|
145
|
+
ContainerEntityType = Annotated[
|
|
146
|
+
ContainerEntity, AfterValidator(lambda v: _entity_validation(v, "the Container column"))
|
|
147
|
+
]
|
|
142
148
|
|
|
143
149
|
|
|
144
|
-
def _multi_value_type_validation(value: MultiValueTypeInfo) -> MultiValueTypeInfo:
|
|
150
|
+
def _multi_value_type_validation(value: MultiValueTypeInfo, location: str) -> MultiValueTypeInfo:
|
|
145
151
|
for type_ in value.types:
|
|
146
152
|
if isinstance(type_, ClassEntity):
|
|
147
|
-
_entity_validation(type_)
|
|
153
|
+
_entity_validation(type_, location)
|
|
148
154
|
return value
|
|
149
155
|
|
|
150
156
|
|
|
151
|
-
MultiValueTypeType = Annotated[
|
|
157
|
+
MultiValueTypeType = Annotated[
|
|
158
|
+
MultiValueTypeInfo, AfterValidator(lambda v: _multi_value_type_validation(v, "the Value Type column"))
|
|
159
|
+
]
|
|
@@ -157,21 +157,6 @@ class DMSPostValidation:
|
|
|
157
157
|
)
|
|
158
158
|
)
|
|
159
159
|
|
|
160
|
-
# This sets the container definition for all the properties where it is not defined.
|
|
161
|
-
# This allows the user to define the container only once.
|
|
162
|
-
value_type = next(iter(value_types))
|
|
163
|
-
list_definition = next(iter(list_definitions)) if list_definitions else None
|
|
164
|
-
nullable_definition = next(iter(nullable_definitions)) if nullable_definitions else None
|
|
165
|
-
default_definition = next(iter(default_definitions)) if default_definitions else None
|
|
166
|
-
index_definition = next(iter(index_definitions)).split(",") if index_definitions else None
|
|
167
|
-
constraint_definition = next(iter(constraint_definitions)).split(",") if constraint_definitions else None
|
|
168
|
-
for _, prop in properties:
|
|
169
|
-
prop.value_type = value_type
|
|
170
|
-
prop.is_list = prop.is_list or list_definition
|
|
171
|
-
prop.nullable = prop.nullable or nullable_definition
|
|
172
|
-
prop.default = prop.default or default_definition
|
|
173
|
-
prop.index = prop.index or index_definition
|
|
174
|
-
prop.constraint = prop.constraint or constraint_definition
|
|
175
160
|
self.issue_list.extend(errors)
|
|
176
161
|
|
|
177
162
|
def _referenced_views_and_containers_are_existing_and_proper_size(self) -> None:
|
{cognite_neat-0.97.1 → cognite_neat-0.97.3}/cognite/neat/_rules/transformers/_verification.py
RENAMED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
from abc import ABC
|
|
2
|
-
from collections.abc import Iterator
|
|
3
|
-
from contextlib import contextmanager
|
|
4
2
|
from typing import Any, Literal
|
|
5
3
|
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
from cognite.neat._issues import IssueList, MultiValueError, NeatError, NeatWarning, catch_warnings
|
|
4
|
+
from cognite.neat._issues import IssueList, NeatError, NeatWarning, catch_issues
|
|
9
5
|
from cognite.neat._issues.errors import NeatTypeError
|
|
10
6
|
from cognite.neat._rules._shared import (
|
|
11
7
|
InputRules,
|
|
@@ -45,7 +41,7 @@ class VerificationTransformer(RulesTransformer[T_InputRules, T_VerifiedRules], A
|
|
|
45
41
|
if isinstance(rules, ReadRules):
|
|
46
42
|
error_args = rules.read_context
|
|
47
43
|
verified_rules: T_VerifiedRules | None = None
|
|
48
|
-
with
|
|
44
|
+
with catch_issues(issues, NeatError, NeatWarning, error_args) as future:
|
|
49
45
|
rules_cls = self._get_rules_cls(in_)
|
|
50
46
|
verified_rules = rules_cls.model_validate(in_.dump()) # type: ignore[assignment]
|
|
51
47
|
|
|
@@ -92,46 +88,3 @@ class VerifyAnyRules(VerificationTransformer[InputRules, VerifiedRules]):
|
|
|
92
88
|
return DomainRules
|
|
93
89
|
else:
|
|
94
90
|
raise NeatTypeError(f"Unsupported rules type: {type(in_)}")
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class _FutureResult:
|
|
98
|
-
def __init__(self) -> None:
|
|
99
|
-
self._result: Literal["success", "failure", "pending"] = "pending"
|
|
100
|
-
|
|
101
|
-
@property
|
|
102
|
-
def result(self) -> Literal["success", "failure", "pending"]:
|
|
103
|
-
return self._result
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
@contextmanager
|
|
107
|
-
def _catch_issues(
|
|
108
|
-
issues: IssueList,
|
|
109
|
-
error_cls: type[NeatError] = NeatError,
|
|
110
|
-
warning_cls: type[NeatWarning] = NeatWarning,
|
|
111
|
-
error_args: dict[str, Any] | None = None,
|
|
112
|
-
) -> Iterator[_FutureResult]:
|
|
113
|
-
"""This is an internal help function to handle issues and warnings.
|
|
114
|
-
|
|
115
|
-
Args:
|
|
116
|
-
issues: The issues list to append to.
|
|
117
|
-
error_cls: The class used to convert errors to issues.
|
|
118
|
-
warning_cls: The class used to convert warnings to issues.
|
|
119
|
-
|
|
120
|
-
Returns:
|
|
121
|
-
FutureResult: A future result object that can be used to check the result of the context manager.
|
|
122
|
-
"""
|
|
123
|
-
with catch_warnings(issues, warning_cls):
|
|
124
|
-
future_result = _FutureResult()
|
|
125
|
-
try:
|
|
126
|
-
yield future_result
|
|
127
|
-
except ValidationError as e:
|
|
128
|
-
issues.extend(error_cls.from_pydantic_errors(e.errors(), **(error_args or {})))
|
|
129
|
-
future_result._result = "failure"
|
|
130
|
-
except MultiValueError as e:
|
|
131
|
-
issues.extend(e.errors)
|
|
132
|
-
future_result._result = "failure"
|
|
133
|
-
except NeatError as e:
|
|
134
|
-
issues.append(e)
|
|
135
|
-
future_result._result = "failure"
|
|
136
|
-
else:
|
|
137
|
-
future_result._result = "success"
|
|
@@ -5,9 +5,10 @@ from cognite.client import CogniteClient
|
|
|
5
5
|
from cognite.client import data_modeling as dm
|
|
6
6
|
|
|
7
7
|
from cognite.neat import _version
|
|
8
|
-
from cognite.neat._issues import IssueList
|
|
8
|
+
from cognite.neat._issues import IssueList, catch_issues
|
|
9
|
+
from cognite.neat._issues.errors import RegexViolationError
|
|
9
10
|
from cognite.neat._rules import importers
|
|
10
|
-
from cognite.neat._rules._shared import ReadRules
|
|
11
|
+
from cognite.neat._rules._shared import ReadRules, VerifiedRules
|
|
11
12
|
from cognite.neat._rules.importers._rdf._base import DEFAULT_NON_EXISTING_NODE_TYPE
|
|
12
13
|
from cognite.neat._rules.models import DMSRules
|
|
13
14
|
from cognite.neat._rules.models.data_types import AnyURI
|
|
@@ -15,10 +16,12 @@ from cognite.neat._rules.models.entities._single_value import UnknownEntity
|
|
|
15
16
|
from cognite.neat._rules.models.information._rules import InformationRules
|
|
16
17
|
from cognite.neat._rules.models.information._rules_input import InformationInputRules
|
|
17
18
|
from cognite.neat._rules.transformers import ConvertToRules, VerifyAnyRules
|
|
19
|
+
from cognite.neat._rules.transformers._converters import ConversionTransformer
|
|
18
20
|
from cognite.neat._store._provenance import (
|
|
19
21
|
INSTANCES_ENTITY,
|
|
20
22
|
Change,
|
|
21
23
|
)
|
|
24
|
+
from cognite.neat._utils.auth import _CLIENT_NAME
|
|
22
25
|
|
|
23
26
|
from ._inspect import InspectAPI
|
|
24
27
|
from ._prepare import PrepareAPI
|
|
@@ -49,6 +52,8 @@ class NeatSession:
|
|
|
49
52
|
self.show = ShowAPI(self._state)
|
|
50
53
|
self.set = SetAPI(self._state, verbose)
|
|
51
54
|
self.inspect = InspectAPI(self._state)
|
|
55
|
+
if self._client is not None and self._client._config is not None:
|
|
56
|
+
self._client._config.client_name = _CLIENT_NAME
|
|
52
57
|
if load_engine != "skip" and (engine_version := load_neat_engine(client, load_engine)):
|
|
53
58
|
print(f"Neat Engine {engine_version} loaded.")
|
|
54
59
|
|
|
@@ -85,35 +90,52 @@ class NeatSession:
|
|
|
85
90
|
print("You can inspect the issues with the .inspect.issues(...) method.")
|
|
86
91
|
return output.issues
|
|
87
92
|
|
|
88
|
-
def convert(self, target: Literal["dms", "information"]) ->
|
|
93
|
+
def convert(self, target: Literal["dms", "information"]) -> IssueList:
|
|
89
94
|
start = datetime.now(timezone.utc)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
issues = IssueList()
|
|
96
|
+
converter: ConversionTransformer | None = None
|
|
97
|
+
converted_rules: VerifiedRules | None = None
|
|
98
|
+
with catch_issues(issues):
|
|
99
|
+
if target == "dms":
|
|
100
|
+
source_id, info_rules = self._state.data_model.last_verified_information_rules
|
|
101
|
+
converter = ConvertToRules(DMSRules)
|
|
102
|
+
converted_rules = converter.transform(info_rules).rules
|
|
103
|
+
elif target == "information":
|
|
104
|
+
source_id, dms_rules = self._state.data_model.last_verified_dms_rules
|
|
105
|
+
converter = ConvertToRules(InformationRules)
|
|
106
|
+
converted_rules = converter.transform(dms_rules).rules
|
|
107
|
+
else:
|
|
108
|
+
# Session errors are not caught by the catch_issues context manager
|
|
109
|
+
raise NeatSessionError(f"Target {target} not supported.")
|
|
110
|
+
|
|
100
111
|
end = datetime.now(timezone.utc)
|
|
112
|
+
if issues:
|
|
113
|
+
self._state.data_model.issue_lists.append(issues)
|
|
101
114
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
if converted_rules is not None and converter is not None:
|
|
116
|
+
# Provenance
|
|
117
|
+
change = Change.from_rules_activity(
|
|
118
|
+
converted_rules,
|
|
119
|
+
converter.agent,
|
|
120
|
+
start,
|
|
121
|
+
end,
|
|
122
|
+
f"Converted data model {source_id} to {converted_rules.id_}",
|
|
123
|
+
self._state.data_model.provenance.source_entity(source_id)
|
|
124
|
+
or self._state.data_model.provenance.target_entity(source_id),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
self._state.data_model.write(converted_rules, change)
|
|
112
128
|
|
|
113
|
-
|
|
129
|
+
if self._verbose and not issues.has_errors:
|
|
130
|
+
print(f"Rules converted to {target}")
|
|
131
|
+
else:
|
|
132
|
+
print("Conversion failed.")
|
|
133
|
+
if issues:
|
|
134
|
+
print("You can inspect the issues with the .inspect.issues(...) method.")
|
|
135
|
+
if issues.has_error_type(RegexViolationError):
|
|
136
|
+
print("You can use .prepare. to try to fix the issues")
|
|
114
137
|
|
|
115
|
-
|
|
116
|
-
print(f"Rules converted to {target}")
|
|
138
|
+
return issues
|
|
117
139
|
|
|
118
140
|
def infer(
|
|
119
141
|
self,
|
|
@@ -173,8 +173,18 @@ class InspectUploadOutcome:
|
|
|
173
173
|
continue
|
|
174
174
|
lines.append(f"#### {key}")
|
|
175
175
|
if isinstance(value, list):
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
total = len(value)
|
|
177
|
+
for i, v in enumerate(value):
|
|
178
|
+
if key in ["created", "updated", "changed"]:
|
|
179
|
+
if i < 50:
|
|
180
|
+
lines.append(f" * {v}")
|
|
181
|
+
elif i == 50 and total > 50:
|
|
182
|
+
lines.append(f" * ... {total-50} more")
|
|
183
|
+
elif i == 50 and total == 50:
|
|
184
|
+
lines.append(f" * {v}")
|
|
185
|
+
else:
|
|
186
|
+
lines.append(f" * {v}")
|
|
187
|
+
|
|
178
188
|
else:
|
|
179
189
|
lines.append(f" * {value}")
|
|
180
190
|
|
|
@@ -12,7 +12,7 @@ from cognite.neat._rules.transformers import ReduceCogniteModel, ToCompliantEnti
|
|
|
12
12
|
from cognite.neat._store._provenance import Change
|
|
13
13
|
|
|
14
14
|
from ._state import SessionState
|
|
15
|
-
from .exceptions import intercept_session_exceptions
|
|
15
|
+
from .exceptions import NeatSessionError, intercept_session_exceptions
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
@intercept_session_exceptions
|
|
@@ -32,18 +32,18 @@ class InstancePrepareAPI:
|
|
|
32
32
|
|
|
33
33
|
def make_connection_on_exact_match(
|
|
34
34
|
self,
|
|
35
|
-
source: tuple[
|
|
36
|
-
target: tuple[
|
|
37
|
-
connection:
|
|
35
|
+
source: tuple[str, str],
|
|
36
|
+
target: tuple[str, str],
|
|
37
|
+
connection: str | None = None,
|
|
38
38
|
limit: int | None = 100,
|
|
39
39
|
) -> None:
|
|
40
40
|
"""Make connection on exact match.
|
|
41
41
|
|
|
42
42
|
Args:
|
|
43
|
-
source: The source of the connection. A tuple of (
|
|
43
|
+
source: The source of the connection. A tuple of (type, property) where
|
|
44
44
|
where property is the property that should be matched on the source
|
|
45
45
|
to make the connection with the target.
|
|
46
|
-
target: The target of the connection. A tuple of (
|
|
46
|
+
target: The target of the connection. A tuple of (type, property) where
|
|
47
47
|
where property is the property that should be matched on the target
|
|
48
48
|
to make the connection with the source.
|
|
49
49
|
|
|
@@ -51,11 +51,19 @@ class InstancePrepareAPI:
|
|
|
51
51
|
will be made by lowercasing the target type.
|
|
52
52
|
limit: The maximum number of connections to make. If None, all connections
|
|
53
53
|
|
|
54
|
+
!!! note "Make Connection on Exact Match"
|
|
55
|
+
This method will make a connection between the source and target based on the exact match:
|
|
56
|
+
(SourceType)-[sourceProperty]->(sourceValue) == (TargetType)-[targetProperty]->(targetValue)
|
|
57
|
+
|
|
58
|
+
The connection will be made by creating a new property on the source type that will contain the
|
|
59
|
+
target value, as follows:
|
|
60
|
+
(SourceType)-[connection]->(TargetType)
|
|
61
|
+
|
|
54
62
|
|
|
55
63
|
"""
|
|
56
64
|
|
|
57
|
-
subject_type, subject_predicate = source
|
|
58
|
-
object_type, object_predicate = target
|
|
65
|
+
subject_type, subject_predicate = self._get_type_and_property_uris(*source)
|
|
66
|
+
object_type, object_predicate = self._get_type_and_property_uris(*target)
|
|
59
67
|
|
|
60
68
|
transformer = MakeConnectionOnExactMatch(
|
|
61
69
|
subject_type,
|
|
@@ -68,6 +76,24 @@ class InstancePrepareAPI:
|
|
|
68
76
|
|
|
69
77
|
self._state.instances.store.transform(transformer)
|
|
70
78
|
|
|
79
|
+
def _get_type_and_property_uris(self, type_: str, property_: str) -> tuple[URIRef, URIRef]:
|
|
80
|
+
type_uri = self._state.instances.store.queries.type_uri(type_)
|
|
81
|
+
property_uri = self._state.instances.store.queries.property_uri(property_)
|
|
82
|
+
|
|
83
|
+
if not type_uri:
|
|
84
|
+
raise NeatSessionError(f"Type {type_} does not exist in the graph.")
|
|
85
|
+
elif len(type_uri) > 1:
|
|
86
|
+
raise NeatSessionError(f"{type_} has multiple ids found in the graph: {','.join(type_uri)}.")
|
|
87
|
+
|
|
88
|
+
if not property_uri:
|
|
89
|
+
raise NeatSessionError(f"Property {property_} does not exist in the graph.")
|
|
90
|
+
elif len(type_uri) > 1:
|
|
91
|
+
raise NeatSessionError(f"{property_} has multiple ids found in the graph: {','.join(property_uri)}.")
|
|
92
|
+
|
|
93
|
+
if not self._state.instances.store.queries.type_with_property(type_uri[0], property_uri[0]):
|
|
94
|
+
raise NeatSessionError(f"Property {property_} is not defined for type {type_}. Cannot make connection")
|
|
95
|
+
return type_uri[0], property_uri[0]
|
|
96
|
+
|
|
71
97
|
|
|
72
98
|
@intercept_session_exceptions
|
|
73
99
|
class DataModelPrepareAPI:
|