cognite-neat 0.99.0__tar.gz → 0.99.1__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.99.0 → cognite_neat-0.99.1}/PKG-INFO +1 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/_api/data_modeling_loaders.py +77 -4
- cognite_neat-0.99.1/cognite/neat/_client/_api/schema.py +111 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/data_classes/schema.py +2 -348
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_constants.py +27 -4
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +5 -5
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/loaders/_rdf2dms.py +2 -2
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_classic_cdf.py +24 -13
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/_base.py +26 -17
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/__init__.py +4 -2
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/_external.py +7 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/_properties.py +2 -7
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/_resources.py +1 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/__init__.py +4 -2
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/_external.py +9 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/_resources.py +26 -2
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/user_modeling.py +4 -4
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/_constants.py +2 -6
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_rules2dms.py +4 -6
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/__init__.py +1 -3
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_base.py +1 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dms2rules.py +3 -25
- cognite_neat-0.99.1/cognite/neat/_rules/importers/_rdf/__init__.py +5 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_rdf/_base.py +34 -11
- cognite_neat-0.99.1/cognite/neat/_rules/importers/_rdf/_imf2rules.py +91 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +18 -2
- cognite_neat-0.99.1/cognite/neat/_rules/importers/_rdf/_owl2rules.py +80 -0
- cognite_neat-0.99.1/cognite/neat/_rules/importers/_rdf/_shared.py +168 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/dms/__init__.py +2 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/dms/_exporter.py +32 -30
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/dms/_rules.py +3 -45
- cognite_neat-0.99.1/cognite/neat/_rules/models/dms/_validation.py +553 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/information/__init__.py +2 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/information/_rules.py +0 -59
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/information/_validation.py +9 -9
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/mapping/_classic2core.py +1 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/mapping/_classic2core.yaml +8 -4
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/_pipelines.py +1 -1
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/_verification.py +29 -4
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_base.py +16 -41
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_prepare.py +6 -5
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_to.py +5 -2
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/exceptions.py +4 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/rdf_.py +6 -4
- cognite_neat-0.99.1/cognite/neat/_version.py +2 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/rules_exporter.py +0 -88
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/rules_importer.py +2 -16
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/rules_validator.py +3 -5
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/pyproject.toml +1 -1
- cognite_neat-0.99.0/cognite/neat/_client/_api/schema.py +0 -50
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_imf2rules/__init__.py +0 -3
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2classes.py +0 -86
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2metadata.py +0 -29
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2properties.py +0 -130
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2rules.py +0 -154
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_owl2rules/__init__.py +0 -3
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2classes.py +0 -58
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2metadata.py +0 -65
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2properties.py +0 -59
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2rules.py +0 -39
- cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf/_shared.py +0 -471
- cognite_neat-0.99.0/cognite/neat/_rules/models/dms/_validation.py +0 -286
- cognite_neat-0.99.0/cognite/neat/_version.py +0 -2
- cognite_neat-0.99.0/cognite/neat/_workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/LICENSE +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/README.md +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/configuration.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/explorer.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/routers/configuration.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/routers/crud.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/routers/metrics.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/routers/workflows.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/utils/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/utils/logging.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/main.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/monitoring/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/monitoring/metrics.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/index.html +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/package-lock.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/package.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/index.html +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/manifest.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/public/robots.txt +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/App.css +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/App.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/App.test.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/index.css +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/index.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/logo.svg +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/setupTests.js +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_app/ui/neat-app/tsconfig.json +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/_api/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/_api_client.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/data_classes/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/data_classes/data_modeling.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/_shared.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_dms.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_iodd.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/loaders/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/loaders/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/queries/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/queries/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/queries/_construct.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/queries/_shared.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_iodd.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_prune_graph.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_rdfpath.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_graph/transformers/_value_type.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/_general.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/errors/_workflow.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/formatters.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/_models.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_issues/warnings/_properties.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/_shared.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/analysis/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/analysis/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/analysis/_dms.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/analysis/_information.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_rules2instance_template.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/_base_input.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/_base_rules.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/_types.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/data_types.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/dms/_rules_input.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_loaders.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_multi_value.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_single_value.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/entities/_wrapped.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/information/_rules_input.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/models/mapping/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/_converters.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_rules/transformers/_mapping.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_collector.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_drop.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_inspect.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_mapping.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_read.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_set.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_show.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_state.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_store/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_store/_provenance.py +0 -0
- {cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf → cognite_neat-0.99.1/cognite/neat/_utils}/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/auth.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/auxiliary.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/spreadsheet.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/text.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/upload.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/base.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/cdf_store.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/manager.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/model.py +0 -0
- {cognite_neat-0.99.0/cognite/neat/_utils → cognite_neat-0.99.1/cognite/neat/_workflows/steps}/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.99.0/cognite/neat/_workflows/steps → cognite_neat-0.99.1/cognite/neat/_workflows/steps/lib}/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps/step_model.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/steps_registry.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/tasks.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/triggers.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_workflows/utils.py +0 -0
- {cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/py.typed +0 -0
{cognite_neat-0.99.0 → cognite_neat-0.99.1}/cognite/neat/_client/_api/data_modeling_loaders.py
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import warnings
|
|
1
2
|
from abc import ABC, abstractmethod
|
|
2
3
|
from collections.abc import Sequence
|
|
3
4
|
from graphlib import TopologicalSorter
|
|
@@ -47,6 +48,7 @@ from cognite.client.data_classes.data_modeling.views import (
|
|
|
47
48
|
from cognite.client.exceptions import CogniteAPIError
|
|
48
49
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
49
50
|
|
|
51
|
+
from cognite.neat._issues.warnings import CDFMaxIterationsWarning
|
|
50
52
|
from cognite.neat._shared import T_ID
|
|
51
53
|
|
|
52
54
|
if TYPE_CHECKING:
|
|
@@ -99,7 +101,8 @@ class ResourceLoader(
|
|
|
99
101
|
if missing_ids:
|
|
100
102
|
retrieved = self._retrieve(missing_ids)
|
|
101
103
|
self._items_by_id.update({self.get_id(item): item for item in retrieved})
|
|
102
|
-
|
|
104
|
+
# We need to check the cache again, in case we didn't retrieve all the items.
|
|
105
|
+
return self._create_list([self._items_by_id[id] for id in ids if id in self._items_by_id])
|
|
103
106
|
|
|
104
107
|
def update(self, items: Sequence[T_WriteClass]) -> T_WritableCogniteResourceList:
|
|
105
108
|
if not self.cache:
|
|
@@ -273,12 +276,12 @@ class ViewLoader(DataModelingLoader[ViewId, ViewApply, View, ViewApplyList, View
|
|
|
273
276
|
return self._client.data_modeling.views.apply(items)
|
|
274
277
|
|
|
275
278
|
def retrieve(
|
|
276
|
-
self, ids: SequenceNotStr[ViewId],
|
|
279
|
+
self, ids: SequenceNotStr[ViewId], include_connected: bool = False, include_ancestor: bool = False
|
|
277
280
|
) -> ViewList:
|
|
278
|
-
if not
|
|
281
|
+
if not include_connected and not include_ancestor:
|
|
279
282
|
return super().retrieve(ids)
|
|
280
283
|
# Retrieve recursively updates the cache.
|
|
281
|
-
return self._retrieve_recursive(ids,
|
|
284
|
+
return self._retrieve_recursive(ids, include_connected, include_ancestor)
|
|
282
285
|
|
|
283
286
|
def _retrieve(self, ids: SequenceNotStr[ViewId]) -> ViewList:
|
|
284
287
|
return self._client.data_modeling.views.retrieve(cast(Sequence, ids))
|
|
@@ -429,6 +432,12 @@ class ContainerLoader(DataModelingLoader[ContainerId, ContainerApply, Container,
|
|
|
429
432
|
def _create(self, items: Sequence[ContainerApply]) -> ContainerList:
|
|
430
433
|
return self._client.data_modeling.containers.apply(items)
|
|
431
434
|
|
|
435
|
+
def retrieve(self, ids: SequenceNotStr[ContainerId], include_connected: bool = False) -> ContainerList:
|
|
436
|
+
if not include_connected:
|
|
437
|
+
return super().retrieve(ids)
|
|
438
|
+
# Retrieve recursively updates the cache.
|
|
439
|
+
return self._retrieve_recursive(ids)
|
|
440
|
+
|
|
432
441
|
def _retrieve(self, ids: SequenceNotStr[ContainerId]) -> ContainerList:
|
|
433
442
|
return self._client.data_modeling.containers.retrieve(cast(Sequence, ids))
|
|
434
443
|
|
|
@@ -441,6 +450,68 @@ class ContainerLoader(DataModelingLoader[ContainerId, ContainerApply, Container,
|
|
|
441
450
|
def _create_list(self, items: Sequence[Container]) -> ContainerList:
|
|
442
451
|
return ContainerList(items)
|
|
443
452
|
|
|
453
|
+
def _retrieve_recursive(self, container_ids: SequenceNotStr[ContainerId]) -> ContainerList:
|
|
454
|
+
"""Containers can reference each other through the 'requires' constraint.
|
|
455
|
+
|
|
456
|
+
This method retrieves all containers that are referenced by other containers through the 'requires' constraint,
|
|
457
|
+
including their parents.
|
|
458
|
+
"""
|
|
459
|
+
max_iterations = 10 # Limiting the number of iterations to avoid infinite loops
|
|
460
|
+
found = ContainerList([])
|
|
461
|
+
found_ids: set[ContainerId] = set()
|
|
462
|
+
last_batch = list(container_ids)
|
|
463
|
+
for _ in range(max_iterations):
|
|
464
|
+
if not last_batch:
|
|
465
|
+
break
|
|
466
|
+
to_retrieve_from_cdf: set[ContainerId] = set()
|
|
467
|
+
batch_ids: list[ContainerId] = []
|
|
468
|
+
for container_id in last_batch:
|
|
469
|
+
if container_id in found_ids:
|
|
470
|
+
continue
|
|
471
|
+
elif container_id in self._items_by_id:
|
|
472
|
+
container = self._items_by_id[container_id]
|
|
473
|
+
found.append(container)
|
|
474
|
+
batch_ids.extend(self.get_connected_containers(container, found_ids))
|
|
475
|
+
else:
|
|
476
|
+
to_retrieve_from_cdf.add(container_id)
|
|
477
|
+
|
|
478
|
+
if to_retrieve_from_cdf:
|
|
479
|
+
retrieved_batch = self._client.data_modeling.containers.retrieve(list(to_retrieve_from_cdf))
|
|
480
|
+
self._items_by_id.update({view.as_id(): view for view in retrieved_batch})
|
|
481
|
+
found.extend(retrieved_batch)
|
|
482
|
+
found_ids.update({view.as_id() for view in retrieved_batch})
|
|
483
|
+
for container in retrieved_batch:
|
|
484
|
+
batch_ids.extend(self.get_connected_containers(container, found_ids))
|
|
485
|
+
|
|
486
|
+
last_batch = batch_ids
|
|
487
|
+
else:
|
|
488
|
+
warnings.warn(
|
|
489
|
+
CDFMaxIterationsWarning(
|
|
490
|
+
"The maximum number of iterations was reached while resolving referenced containers."
|
|
491
|
+
"There might be referenced containers that are not included in the list of containers.",
|
|
492
|
+
max_iterations=max_iterations,
|
|
493
|
+
),
|
|
494
|
+
stacklevel=2,
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
if self.cache is False:
|
|
498
|
+
# We must update the cache to retrieve recursively.
|
|
499
|
+
# If the cache is disabled, bust the cache to avoid storing the retrieved views.
|
|
500
|
+
self.bust_cache()
|
|
501
|
+
return found
|
|
502
|
+
|
|
503
|
+
@staticmethod
|
|
504
|
+
def get_connected_containers(
|
|
505
|
+
container: Container | ContainerApply, skip: set[ContainerId] | None = None
|
|
506
|
+
) -> set[ContainerId]:
|
|
507
|
+
connected_containers = set()
|
|
508
|
+
for constraint in container.constraints.values():
|
|
509
|
+
if isinstance(constraint, RequiresConstraint):
|
|
510
|
+
connected_containers.add(constraint.require)
|
|
511
|
+
if skip:
|
|
512
|
+
return {container_id for container_id in connected_containers if container_id not in skip}
|
|
513
|
+
return connected_containers
|
|
514
|
+
|
|
444
515
|
def are_equal(self, local: ContainerApply, remote: Container) -> bool:
|
|
445
516
|
local_dumped = local.dump(camel_case=True)
|
|
446
517
|
if "usedFor" not in local_dumped:
|
|
@@ -509,4 +580,6 @@ class DataModelLoaderAPI:
|
|
|
509
580
|
raise ValueError(f"Cannot determine resource name from {items}")
|
|
510
581
|
if resource_name[-1] != "s":
|
|
511
582
|
resource_name += "s"
|
|
583
|
+
if resource_name == "datamodels":
|
|
584
|
+
resource_name = "data_models"
|
|
512
585
|
return getattr(self, resource_name)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from typing import TYPE_CHECKING
|
|
3
|
+
|
|
4
|
+
from cognite.client import data_modeling as dm
|
|
5
|
+
|
|
6
|
+
from cognite.neat._client.data_classes.data_modeling import ContainerApplyDict, SpaceApplyDict, ViewApplyDict
|
|
7
|
+
from cognite.neat._client.data_classes.schema import DMSSchema
|
|
8
|
+
from cognite.neat._issues.errors import NeatValueError
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from cognite.neat._client._api_client import NeatClient
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class SchemaAPI:
|
|
15
|
+
def __init__(self, client: "NeatClient") -> None:
|
|
16
|
+
self._client = client
|
|
17
|
+
|
|
18
|
+
def retrieve(
|
|
19
|
+
self,
|
|
20
|
+
view_ids: Sequence[dm.ViewId],
|
|
21
|
+
container_ids: Sequence[dm.ContainerId],
|
|
22
|
+
include_ancestors: bool = True,
|
|
23
|
+
include_connections=True,
|
|
24
|
+
data_model_id: dm.DataModelId | None = None,
|
|
25
|
+
) -> DMSSchema:
|
|
26
|
+
data_model_id = data_model_id or dm.DataModelId("NEAT_LOOKUP", "NEAT_LOOKUP", "NEAT_LOOKUP")
|
|
27
|
+
if data_model_id.version is None:
|
|
28
|
+
raise NeatValueError("Data model version must be specified")
|
|
29
|
+
read_views = self._client.loaders.views.retrieve(
|
|
30
|
+
view_ids, # type: ignore[arg-type]
|
|
31
|
+
include_connected=include_connections,
|
|
32
|
+
include_ancestor=include_ancestors,
|
|
33
|
+
)
|
|
34
|
+
views = ViewApplyDict([self._client.loaders.views.as_write(view) for view in read_views])
|
|
35
|
+
|
|
36
|
+
container_set = set(container_ids) | {
|
|
37
|
+
container for view in read_views for container in view.referenced_containers()
|
|
38
|
+
}
|
|
39
|
+
containers = self._client.loaders.containers.retrieve(list(container_set))
|
|
40
|
+
|
|
41
|
+
return DMSSchema(
|
|
42
|
+
data_model=dm.DataModelApply(
|
|
43
|
+
space=data_model_id.space,
|
|
44
|
+
external_id=data_model_id.external_id,
|
|
45
|
+
version=data_model_id.version,
|
|
46
|
+
views=list(views.keys()),
|
|
47
|
+
),
|
|
48
|
+
views=views,
|
|
49
|
+
containers=ContainerApplyDict(containers.as_write()),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
def retrieve_data_model_id(self, data_model_id: dm.DataModelIdentifier) -> DMSSchema:
|
|
53
|
+
data_models = self._client.data_modeling.data_models.retrieve(data_model_id, inline_views=True)
|
|
54
|
+
if len(data_models) == 0:
|
|
55
|
+
raise NeatValueError(f"Data model {data_model_id} not found")
|
|
56
|
+
data_model = data_models.latest_version()
|
|
57
|
+
return self.retrieve_data_model(data_model)
|
|
58
|
+
|
|
59
|
+
def retrieve_data_model(
|
|
60
|
+
self,
|
|
61
|
+
data_model: dm.DataModel[dm.View],
|
|
62
|
+
) -> DMSSchema:
|
|
63
|
+
"""Create a schema from a data model.
|
|
64
|
+
|
|
65
|
+
If a reference model is provided, the schema will include a reference schema. To determine which views,
|
|
66
|
+
and containers to put in the reference schema, the following rule is applied:
|
|
67
|
+
|
|
68
|
+
If a view or container space is different from the data model space,
|
|
69
|
+
it will be included in the reference schema.*
|
|
70
|
+
|
|
71
|
+
*One exception to this rule is if a view is directly referenced by the data model. In this case, the view will
|
|
72
|
+
be included in the data model schema, even if the space is different.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
data_model: The data model to create the schema from.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
DMSSchema: The schema created from the data model.
|
|
79
|
+
"""
|
|
80
|
+
data_model_views = dm.ViewList(data_model.views)
|
|
81
|
+
data_model_write = data_model.as_write()
|
|
82
|
+
data_model_write.views = list(data_model_views.as_ids())
|
|
83
|
+
|
|
84
|
+
container_ids = data_model_views.referenced_containers()
|
|
85
|
+
containers = self._client.loaders.containers.retrieve(list(container_ids), include_connected=True)
|
|
86
|
+
|
|
87
|
+
space_ids = [data_model.space]
|
|
88
|
+
space_read = self._client.loaders.spaces.retrieve(space_ids)
|
|
89
|
+
if len(space_read) != len(space_ids):
|
|
90
|
+
raise NeatValueError(f"Space(s) {space_read} not found")
|
|
91
|
+
space_write = space_read.as_write()
|
|
92
|
+
|
|
93
|
+
existing_view_ids = set(data_model_views.as_ids())
|
|
94
|
+
views_with_referenced = self._client.loaders.views.retrieve(
|
|
95
|
+
list(existing_view_ids), include_connected=True, include_ancestor=True
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Converting views from read to write format requires to account for parents (implements)
|
|
99
|
+
# as the read format contains all properties from all parents, while the write formate should not contain
|
|
100
|
+
# properties from any parents.
|
|
101
|
+
# The ViewLoader as_write method looks up parents and remove properties from them.
|
|
102
|
+
view_write = ViewApplyDict([self._client.loaders.views.as_write(view) for view in views_with_referenced])
|
|
103
|
+
|
|
104
|
+
container_write = ContainerApplyDict(containers.as_write())
|
|
105
|
+
user_space = data_model.space
|
|
106
|
+
return DMSSchema(
|
|
107
|
+
spaces=SpaceApplyDict([s for s in space_write if s.space == user_space]),
|
|
108
|
+
data_model=data_model_write,
|
|
109
|
+
views=view_write,
|
|
110
|
+
containers=container_write,
|
|
111
|
+
)
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
import warnings
|
|
3
3
|
import zipfile
|
|
4
|
-
from collections import ChainMap
|
|
4
|
+
from collections import ChainMap
|
|
5
5
|
from collections.abc import Iterable, MutableMapping
|
|
6
6
|
from dataclasses import Field, dataclass, field, fields
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import
|
|
8
|
+
from typing import Any, ClassVar, Literal, cast
|
|
9
9
|
|
|
10
10
|
import yaml
|
|
11
|
-
from cognite.client import CogniteClient
|
|
12
11
|
from cognite.client import data_modeling as dm
|
|
13
12
|
from cognite.client.data_classes import DatabaseWrite, TransformationWrite
|
|
14
13
|
from cognite.client.data_classes.data_modeling.views import (
|
|
15
|
-
ReverseDirectRelation,
|
|
16
14
|
ReverseDirectRelationApply,
|
|
17
15
|
SingleEdgeConnection,
|
|
18
16
|
SingleEdgeConnectionApply,
|
|
@@ -29,22 +27,13 @@ from cognite.neat._client.data_classes.data_modeling import (
|
|
|
29
27
|
SpaceApplyDict,
|
|
30
28
|
ViewApplyDict,
|
|
31
29
|
)
|
|
32
|
-
from cognite.neat._issues import NeatError
|
|
33
30
|
from cognite.neat._issues.errors import (
|
|
34
31
|
NeatYamlError,
|
|
35
|
-
PropertyMappingDuplicatedError,
|
|
36
|
-
PropertyNotFoundError,
|
|
37
|
-
ResourceDuplicatedError,
|
|
38
|
-
ResourceNotFoundError,
|
|
39
32
|
)
|
|
40
33
|
from cognite.neat._issues.warnings import (
|
|
41
34
|
FileTypeUnexpectedWarning,
|
|
42
|
-
ResourceNotFoundWarning,
|
|
43
|
-
ResourceRetrievalWarning,
|
|
44
35
|
ResourcesDuplicatedWarning,
|
|
45
36
|
)
|
|
46
|
-
from cognite.neat._issues.warnings.user_modeling import DirectRelationMissingSourceWarning
|
|
47
|
-
from cognite.neat._utils.rdf_ import get_inheritance_path
|
|
48
37
|
from cognite.neat._utils.text import to_camel
|
|
49
38
|
|
|
50
39
|
if sys.version_info >= (3, 11):
|
|
@@ -52,9 +41,6 @@ if sys.version_info >= (3, 11):
|
|
|
52
41
|
else:
|
|
53
42
|
from typing_extensions import Self
|
|
54
43
|
|
|
55
|
-
if TYPE_CHECKING:
|
|
56
|
-
from cognite.neat._client import NeatClient
|
|
57
|
-
|
|
58
44
|
|
|
59
45
|
@dataclass
|
|
60
46
|
class DMSSchema:
|
|
@@ -63,11 +49,6 @@ class DMSSchema:
|
|
|
63
49
|
views: ViewApplyDict = field(default_factory=ViewApplyDict)
|
|
64
50
|
containers: ContainerApplyDict = field(default_factory=ContainerApplyDict)
|
|
65
51
|
node_types: NodeApplyDict = field(default_factory=NodeApplyDict)
|
|
66
|
-
# The last schema is the previous version of the data model. In the case, extension=addition, this
|
|
67
|
-
# should not be modified.
|
|
68
|
-
last: "DMSSchema | None" = None
|
|
69
|
-
# Reference is typically the Enterprise model, while this is the solution model.
|
|
70
|
-
reference: "DMSSchema | None" = None
|
|
71
52
|
|
|
72
53
|
_FIELD_NAME_BY_RESOURCE_TYPE: ClassVar[dict[str, str]] = {
|
|
73
54
|
"container": "containers",
|
|
@@ -77,177 +58,6 @@ class DMSSchema:
|
|
|
77
58
|
"node": "node_types",
|
|
78
59
|
}
|
|
79
60
|
|
|
80
|
-
def _get_mapped_container_from_view(self, view_id: dm.ViewId) -> set[dm.ContainerId]:
|
|
81
|
-
# index all views, including ones from reference
|
|
82
|
-
view_by_id = self.views.copy()
|
|
83
|
-
if self.reference:
|
|
84
|
-
view_by_id.update(self.reference.views)
|
|
85
|
-
|
|
86
|
-
if view_id not in view_by_id:
|
|
87
|
-
raise ValueError(f"View {view_id} not found")
|
|
88
|
-
|
|
89
|
-
indexed_implemented_views = {id_: view.implements for id_, view in view_by_id.items()}
|
|
90
|
-
view_inheritance = get_inheritance_path(view_id, indexed_implemented_views)
|
|
91
|
-
|
|
92
|
-
directly_referenced_containers = view_by_id[view_id].referenced_containers()
|
|
93
|
-
inherited_referenced_containers = set()
|
|
94
|
-
|
|
95
|
-
for parent_id in view_inheritance:
|
|
96
|
-
if implemented_view := view_by_id.get(parent_id):
|
|
97
|
-
inherited_referenced_containers |= implemented_view.referenced_containers()
|
|
98
|
-
else:
|
|
99
|
-
raise ResourceNotFoundError(parent_id, "view", view_id, "view")
|
|
100
|
-
|
|
101
|
-
return directly_referenced_containers | inherited_referenced_containers
|
|
102
|
-
|
|
103
|
-
@classmethod
|
|
104
|
-
def from_model_id(cls, client: "NeatClient", data_model_id: dm.DataModelIdentifier) -> "DMSSchema":
|
|
105
|
-
data_models = client.data_modeling.data_models.retrieve(data_model_id, inline_views=True)
|
|
106
|
-
if len(data_models) == 0:
|
|
107
|
-
raise ValueError(f"Data model {data_model_id} not found")
|
|
108
|
-
data_model = data_models.latest_version()
|
|
109
|
-
return cls.from_data_model(client, data_model)
|
|
110
|
-
|
|
111
|
-
@classmethod
|
|
112
|
-
def from_data_model(
|
|
113
|
-
cls,
|
|
114
|
-
client: "NeatClient",
|
|
115
|
-
data_model: dm.DataModel[dm.View],
|
|
116
|
-
reference_model: dm.DataModel[dm.View] | None = None,
|
|
117
|
-
) -> "DMSSchema":
|
|
118
|
-
"""Create a schema from a data model.
|
|
119
|
-
|
|
120
|
-
If a reference model is provided, the schema will include a reference schema. To determine which views,
|
|
121
|
-
and containers to put in the reference schema, the following rule is applied:
|
|
122
|
-
|
|
123
|
-
If a view or container space is different from the data model space,
|
|
124
|
-
it will be included in the reference schema.*
|
|
125
|
-
|
|
126
|
-
*One exception to this rule is if a view is directly referenced by the data model. In this case, the view will
|
|
127
|
-
be included in the data model schema, even if the space is different.
|
|
128
|
-
|
|
129
|
-
Args:
|
|
130
|
-
client: The Cognite client used for retrieving components referenced by the data model.
|
|
131
|
-
data_model: The data model to create the schema from.
|
|
132
|
-
reference_model: (Optional) The reference model to include in the schema.
|
|
133
|
-
This is typically the Enterprise model.
|
|
134
|
-
|
|
135
|
-
Returns:
|
|
136
|
-
DMSSchema: The schema created from the data model.
|
|
137
|
-
"""
|
|
138
|
-
from cognite.neat._client._api.data_modeling_loaders import ViewLoader
|
|
139
|
-
|
|
140
|
-
views = dm.ViewList(data_model.views)
|
|
141
|
-
|
|
142
|
-
data_model_write = data_model.as_write()
|
|
143
|
-
data_model_write.views = list(views.as_ids())
|
|
144
|
-
|
|
145
|
-
if reference_model:
|
|
146
|
-
views.extend(reference_model.views)
|
|
147
|
-
|
|
148
|
-
container_ids = views.referenced_containers()
|
|
149
|
-
containers = client.data_modeling.containers.retrieve(list(container_ids))
|
|
150
|
-
cls._append_referenced_containers(client, containers)
|
|
151
|
-
|
|
152
|
-
space_ids = [data_model.space, reference_model.space] if reference_model else [data_model.space]
|
|
153
|
-
space_read = client.data_modeling.spaces.retrieve(space_ids)
|
|
154
|
-
if len(space_read) != len(space_ids):
|
|
155
|
-
raise ValueError(f"Space(s) {space_read} not found")
|
|
156
|
-
space_write = space_read.as_write()
|
|
157
|
-
|
|
158
|
-
view_loader = ViewLoader(NeatClient(client))
|
|
159
|
-
|
|
160
|
-
existing_view_ids = set(views.as_ids())
|
|
161
|
-
|
|
162
|
-
# We need to include all views the edges/direct relations are pointing to have a complete schema.
|
|
163
|
-
connection_referenced_view_ids: set[dm.ViewId] = set()
|
|
164
|
-
for view in views:
|
|
165
|
-
connection_referenced_view_ids |= cls._connection_references(view)
|
|
166
|
-
connection_referenced_view_ids = connection_referenced_view_ids - existing_view_ids
|
|
167
|
-
if connection_referenced_view_ids:
|
|
168
|
-
for view_id in connection_referenced_view_ids:
|
|
169
|
-
warnings.warn(
|
|
170
|
-
ResourceNotFoundWarning(view_id, "view", data_model_write.as_id(), "data model"),
|
|
171
|
-
stacklevel=2,
|
|
172
|
-
)
|
|
173
|
-
connection_referenced_views = view_loader.retrieve(list(connection_referenced_view_ids))
|
|
174
|
-
if failed := connection_referenced_view_ids - set(connection_referenced_views.as_ids()):
|
|
175
|
-
warnings.warn(ResourceRetrievalWarning(frozenset(failed), "view"), stacklevel=2)
|
|
176
|
-
views.extend(connection_referenced_views)
|
|
177
|
-
|
|
178
|
-
# We need to include parent views in the schema to make sure that the schema is valid.
|
|
179
|
-
parent_view_ids = {parent for view in views for parent in view.implements or []}
|
|
180
|
-
parents = view_loader.retrieve(
|
|
181
|
-
list(parent_view_ids - existing_view_ids), include_ancestor=True, include_connections=True
|
|
182
|
-
)
|
|
183
|
-
views.extend([parent for parent in parents if parent.as_id() not in existing_view_ids])
|
|
184
|
-
|
|
185
|
-
# Converting views from read to write format requires to account for parents (implements)
|
|
186
|
-
# as the read format contains all properties from all parents, while the write formate should not contain
|
|
187
|
-
# properties from any parents.
|
|
188
|
-
# The ViewLoader as_write method looks up parents and remove properties from them.
|
|
189
|
-
view_write = ViewApplyDict([view_loader.as_write(view) for view in views])
|
|
190
|
-
|
|
191
|
-
container_write = ContainerApplyDict(containers.as_write())
|
|
192
|
-
user_space = data_model.space
|
|
193
|
-
if reference_model:
|
|
194
|
-
user_model_view_ids = set(data_model_write.views)
|
|
195
|
-
ref_model_write = reference_model.as_write()
|
|
196
|
-
ref_model_write.views = [view.as_id() for view in reference_model.views]
|
|
197
|
-
|
|
198
|
-
ref_views = ViewApplyDict(
|
|
199
|
-
[
|
|
200
|
-
view
|
|
201
|
-
for view_id, view in view_write.items()
|
|
202
|
-
if (view.space != user_space) or (view_id not in user_model_view_ids)
|
|
203
|
-
]
|
|
204
|
-
)
|
|
205
|
-
view_write = ViewApplyDict(
|
|
206
|
-
[
|
|
207
|
-
view
|
|
208
|
-
for view_id, view in view_write.items()
|
|
209
|
-
if view.space == user_space or view_id in user_model_view_ids
|
|
210
|
-
]
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
ref_containers = ContainerApplyDict(
|
|
214
|
-
[container for container in container_write.values() if container.space != user_space]
|
|
215
|
-
)
|
|
216
|
-
container_write = ContainerApplyDict(
|
|
217
|
-
[container for container in container_write.values() if container.space == user_space]
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
ref_schema: DMSSchema | None = cls(
|
|
221
|
-
spaces=SpaceApplyDict([s for s in space_write if s.space != user_space]),
|
|
222
|
-
data_model=ref_model_write,
|
|
223
|
-
views=ref_views,
|
|
224
|
-
containers=ref_containers,
|
|
225
|
-
)
|
|
226
|
-
else:
|
|
227
|
-
ref_schema = None
|
|
228
|
-
return cls(
|
|
229
|
-
spaces=SpaceApplyDict([s for s in space_write if s.space == user_space]),
|
|
230
|
-
data_model=data_model_write,
|
|
231
|
-
views=view_write,
|
|
232
|
-
containers=container_write,
|
|
233
|
-
reference=ref_schema,
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
@classmethod
|
|
237
|
-
def _connection_references(cls, view: dm.View) -> set[dm.ViewId]:
|
|
238
|
-
view_ids: set[dm.ViewId] = set()
|
|
239
|
-
for prop in (view.properties or {}).values():
|
|
240
|
-
if isinstance(prop, dm.MappedProperty) and isinstance(prop.type, dm.DirectRelation):
|
|
241
|
-
if prop.source:
|
|
242
|
-
view_ids.add(prop.source)
|
|
243
|
-
elif isinstance(prop, dm.EdgeConnection):
|
|
244
|
-
view_ids.add(prop.source)
|
|
245
|
-
if prop.edge_source:
|
|
246
|
-
view_ids.add(prop.edge_source)
|
|
247
|
-
elif isinstance(prop, ReverseDirectRelation):
|
|
248
|
-
view_ids.add(prop.source)
|
|
249
|
-
return view_ids
|
|
250
|
-
|
|
251
61
|
@classmethod
|
|
252
62
|
def from_directory(cls, directory: str | Path) -> Self:
|
|
253
63
|
"""Load a schema from a directory containing YAML files.
|
|
@@ -538,157 +348,6 @@ class DMSSchema:
|
|
|
538
348
|
else:
|
|
539
349
|
raise ValueError(f"Cannot sort item of type {type(item)}")
|
|
540
350
|
|
|
541
|
-
def validate(self) -> list[NeatError]:
|
|
542
|
-
# TODO: This type of validation should be done in NeatSession where all the
|
|
543
|
-
# schema components which are not part of Rules are imported and the model as
|
|
544
|
-
# the whole is validated.
|
|
545
|
-
|
|
546
|
-
errors: set[NeatError] = set()
|
|
547
|
-
defined_spaces = self.spaces.copy()
|
|
548
|
-
defined_containers = self.containers.copy()
|
|
549
|
-
defined_views = self.views.copy()
|
|
550
|
-
for other_schema in [self.reference, self.last]:
|
|
551
|
-
if other_schema:
|
|
552
|
-
defined_spaces |= other_schema.spaces
|
|
553
|
-
defined_containers |= other_schema.containers
|
|
554
|
-
defined_views |= other_schema.views
|
|
555
|
-
|
|
556
|
-
for container in self.containers.values():
|
|
557
|
-
if container.space not in defined_spaces:
|
|
558
|
-
errors.add(
|
|
559
|
-
ResourceNotFoundError[str, dm.ContainerId](container.space, "space", container.as_id(), "container")
|
|
560
|
-
)
|
|
561
|
-
|
|
562
|
-
for view in self.views.values():
|
|
563
|
-
view_id = view.as_id()
|
|
564
|
-
if view.space not in defined_spaces:
|
|
565
|
-
errors.add(ResourceNotFoundError(view.space, "space", view_id, "view"))
|
|
566
|
-
|
|
567
|
-
for parent in view.implements or []:
|
|
568
|
-
if parent not in defined_views:
|
|
569
|
-
errors.add(PropertyNotFoundError(parent, "view", "implements", view_id, "view"))
|
|
570
|
-
|
|
571
|
-
for prop_name, prop in (view.properties or {}).items():
|
|
572
|
-
if isinstance(prop, dm.MappedPropertyApply):
|
|
573
|
-
ref_container = defined_containers.get(prop.container)
|
|
574
|
-
if ref_container is None:
|
|
575
|
-
errors.add(ResourceNotFoundError(prop.container, "container", view_id, "view"))
|
|
576
|
-
elif prop.container_property_identifier not in ref_container.properties:
|
|
577
|
-
errors.add(
|
|
578
|
-
PropertyNotFoundError(
|
|
579
|
-
prop.container,
|
|
580
|
-
"container",
|
|
581
|
-
prop.container_property_identifier,
|
|
582
|
-
view_id,
|
|
583
|
-
"view",
|
|
584
|
-
)
|
|
585
|
-
)
|
|
586
|
-
else:
|
|
587
|
-
container_property = ref_container.properties[prop.container_property_identifier]
|
|
588
|
-
|
|
589
|
-
if isinstance(container_property.type, dm.DirectRelation) and prop.source is None:
|
|
590
|
-
warnings.warn(
|
|
591
|
-
DirectRelationMissingSourceWarning(view_id, prop_name),
|
|
592
|
-
stacklevel=2,
|
|
593
|
-
)
|
|
594
|
-
|
|
595
|
-
if isinstance(prop, dm.EdgeConnectionApply) and prop.source not in defined_views:
|
|
596
|
-
errors.add(PropertyNotFoundError(prop.source, "view", prop_name, view_id, "view"))
|
|
597
|
-
|
|
598
|
-
if (
|
|
599
|
-
isinstance(prop, dm.EdgeConnectionApply)
|
|
600
|
-
and prop.edge_source is not None
|
|
601
|
-
and prop.edge_source not in defined_views
|
|
602
|
-
):
|
|
603
|
-
errors.add(PropertyNotFoundError(prop.edge_source, "view", prop_name, view_id, "view"))
|
|
604
|
-
|
|
605
|
-
# This allows for multiple view properties to be mapped to the same container property,
|
|
606
|
-
# as long as they have different external_id, otherwise this will lead to raising
|
|
607
|
-
# error ContainerPropertyUsedMultipleTimesError
|
|
608
|
-
property_count = Counter(
|
|
609
|
-
(prop.container, prop.container_property_identifier, view_property_identifier)
|
|
610
|
-
for view_property_identifier, prop in (view.properties or {}).items()
|
|
611
|
-
if isinstance(prop, dm.MappedPropertyApply)
|
|
612
|
-
)
|
|
613
|
-
|
|
614
|
-
for (
|
|
615
|
-
container_id,
|
|
616
|
-
container_property_identifier,
|
|
617
|
-
_,
|
|
618
|
-
), count in property_count.items():
|
|
619
|
-
if count > 1:
|
|
620
|
-
view_properties = [
|
|
621
|
-
prop_name
|
|
622
|
-
for prop_name, prop in (view.properties or {}).items()
|
|
623
|
-
if isinstance(prop, dm.MappedPropertyApply)
|
|
624
|
-
and (prop.container, prop.container_property_identifier)
|
|
625
|
-
== (container_id, container_property_identifier)
|
|
626
|
-
]
|
|
627
|
-
errors.add(
|
|
628
|
-
PropertyMappingDuplicatedError(
|
|
629
|
-
container_id,
|
|
630
|
-
"container",
|
|
631
|
-
container_property_identifier,
|
|
632
|
-
frozenset({dm.PropertyId(view_id, prop_name) for prop_name in view_properties}),
|
|
633
|
-
"view property",
|
|
634
|
-
)
|
|
635
|
-
)
|
|
636
|
-
|
|
637
|
-
if self.data_model:
|
|
638
|
-
model = self.data_model
|
|
639
|
-
if model.space not in defined_spaces:
|
|
640
|
-
errors.add(ResourceNotFoundError(model.space, "space", model.as_id(), "data model"))
|
|
641
|
-
|
|
642
|
-
view_counts: dict[dm.ViewId, int] = defaultdict(int)
|
|
643
|
-
for view_id_or_class in model.views or []:
|
|
644
|
-
view_id = view_id_or_class if isinstance(view_id_or_class, dm.ViewId) else view_id_or_class.as_id()
|
|
645
|
-
if view_id not in defined_views:
|
|
646
|
-
errors.add(ResourceNotFoundError(view_id, "view", model.as_id(), "data model"))
|
|
647
|
-
view_counts[view_id] += 1
|
|
648
|
-
|
|
649
|
-
for view_id, count in view_counts.items():
|
|
650
|
-
if count > 1:
|
|
651
|
-
errors.add(
|
|
652
|
-
ResourceDuplicatedError(
|
|
653
|
-
view_id,
|
|
654
|
-
"view",
|
|
655
|
-
repr(model.as_id()),
|
|
656
|
-
)
|
|
657
|
-
)
|
|
658
|
-
|
|
659
|
-
return list(errors)
|
|
660
|
-
|
|
661
|
-
@classmethod
|
|
662
|
-
def _append_referenced_containers(cls, client: CogniteClient, containers: dm.ContainerList) -> None:
|
|
663
|
-
"""Containers can reference each other through the 'requires' constraint.
|
|
664
|
-
|
|
665
|
-
This method retrieves all containers that are referenced by other containers through the 'requires' constraint,
|
|
666
|
-
including their parents.
|
|
667
|
-
|
|
668
|
-
"""
|
|
669
|
-
for _ in range(10): # Limiting the number of iterations to avoid infinite loops
|
|
670
|
-
referenced_containers = {
|
|
671
|
-
const.require
|
|
672
|
-
for container in containers
|
|
673
|
-
for const in (container.constraints or {}).values()
|
|
674
|
-
if isinstance(const, dm.RequiresConstraint)
|
|
675
|
-
}
|
|
676
|
-
missing_containers = referenced_containers - set(containers.as_ids())
|
|
677
|
-
if not missing_containers:
|
|
678
|
-
break
|
|
679
|
-
found_containers = client.data_modeling.containers.retrieve(list(missing_containers))
|
|
680
|
-
containers.extend(found_containers)
|
|
681
|
-
if len(found_containers) != len(missing_containers):
|
|
682
|
-
break
|
|
683
|
-
else:
|
|
684
|
-
warnings.warn(
|
|
685
|
-
"The maximum number of iterations was reached while resolving referenced containers."
|
|
686
|
-
"There might be referenced containers that are not included in the list of containers.",
|
|
687
|
-
RuntimeWarning,
|
|
688
|
-
stacklevel=2,
|
|
689
|
-
)
|
|
690
|
-
return None
|
|
691
|
-
|
|
692
351
|
def referenced_spaces(self, include_indirect_references: bool = True) -> set[str]:
|
|
693
352
|
"""Get the spaces referenced by the schema.
|
|
694
353
|
|
|
@@ -724,11 +383,6 @@ class DMSSchema:
|
|
|
724
383
|
raise ValueError("Data model is not defined")
|
|
725
384
|
all_containers = self.containers.copy()
|
|
726
385
|
all_views = self.views.copy()
|
|
727
|
-
for other_schema in [self.reference, self.last]:
|
|
728
|
-
if other_schema:
|
|
729
|
-
all_containers |= other_schema.containers
|
|
730
|
-
all_views |= other_schema.views
|
|
731
|
-
|
|
732
386
|
views: list[dm.View] = []
|
|
733
387
|
for view in self.views.values():
|
|
734
388
|
referenced_containers = ContainerApplyDict()
|