cognite-neat 0.97.3__tar.gz → 0.99.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/PKG-INFO +4 -3
- cognite_neat-0.99.0/cognite/neat/_client/__init__.py +4 -0
- cognite_neat-0.99.0/cognite/neat/_client/_api/data_modeling_loaders.py +512 -0
- cognite_neat-0.99.0/cognite/neat/_client/_api/schema.py +50 -0
- cognite_neat-0.99.0/cognite/neat/_client/_api_client.py +17 -0
- cognite_neat-0.97.3/cognite/neat/_utils/cdf/data_classes.py → cognite_neat-0.99.0/cognite/neat/_client/data_classes/data_modeling.py +8 -135
- cognite_neat-0.97.3/cognite/neat/_rules/models/dms/_schema.py → cognite_neat-0.99.0/cognite/neat/_client/data_classes/schema.py +32 -281
- cognite_neat-0.99.0/cognite/neat/_graph/_shared.py +33 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +37 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_base.py +274 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +23 -12
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +35 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_events.py +33 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_files.py +38 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +54 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +76 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +37 -0
- cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +41 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_rdf_file.py +6 -7
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/loaders/__init__.py +1 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/queries/_base.py +17 -1
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_classic_cdf.py +50 -134
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_prune_graph.py +1 -1
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_rdfpath.py +1 -1
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/__init__.py +6 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/_external.py +8 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/_models.py +9 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/_properties.py +16 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/_constants.py +7 -6
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/_shared.py +3 -8
- cognite_neat-0.99.0/cognite/neat/_rules/analysis/__init__.py +4 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/analysis/_base.py +10 -27
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/analysis/_dms.py +4 -10
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/analysis/_information.py +2 -10
- cognite_neat-0.99.0/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_base.py +3 -4
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_rules2dms.py +29 -40
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_rules2excel.py +15 -72
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_rules2ontology.py +4 -4
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_base.py +3 -4
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dms2rules.py +21 -45
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +1 -7
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +7 -10
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_base.py +17 -29
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2classes.py +2 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2metadata.py +5 -10
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2properties.py +1 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +55 -51
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2classes.py +2 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2metadata.py +5 -8
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2properties.py +1 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_shared.py +25 -140
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_spreadsheet2rules.py +10 -41
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/__init__.py +3 -17
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/_base_rules.py +118 -62
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/dms/__init__.py +2 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/dms/_exporter.py +20 -178
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/dms/_rules.py +65 -128
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/dms/_rules_input.py +72 -56
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/dms/_validation.py +16 -109
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_single_value.py +32 -4
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/information/_rules.py +19 -122
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/information/_rules_input.py +32 -41
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/information/_validation.py +34 -102
- cognite_neat-0.99.0/cognite/neat/_rules/models/mapping/__init__.py +3 -0
- cognite_neat-0.99.0/cognite/neat/_rules/models/mapping/_classic2core.py +40 -0
- cognite_neat-0.99.0/cognite/neat/_rules/models/mapping/_classic2core.yaml +339 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/transformers/__init__.py +3 -6
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/transformers/_converters.py +128 -206
- cognite_neat-0.99.0/cognite/neat/_rules/transformers/_mapping.py +210 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/transformers/_verification.py +5 -16
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_base.py +83 -21
- cognite_neat-0.99.0/cognite/neat/_session/_collector.py +126 -0
- cognite_neat-0.99.0/cognite/neat/_session/_drop.py +35 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_inspect.py +22 -10
- cognite_neat-0.99.0/cognite/neat/_session/_mapping.py +39 -0
- cognite_neat-0.99.0/cognite/neat/_session/_prepare.py +464 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_read.py +109 -19
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_set.py +2 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_show.py +11 -11
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_to.py +27 -14
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/exceptions.py +20 -3
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_store/_base.py +27 -24
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_store/_provenance.py +2 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/auxiliary.py +19 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/rdf_.py +28 -1
- cognite_neat-0.99.0/cognite/neat/_version.py +2 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/data_contracts.py +2 -10
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/rules_exporter.py +14 -49
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/rules_importer.py +4 -1
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/rules_validator.py +5 -9
- cognite_neat-0.99.0/cognite/neat/py.typed +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/pyproject.toml +4 -4
- cognite_neat-0.97.3/cognite/neat/_graph/_shared.py +0 -34
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -177
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_base.py +0 -127
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -110
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -182
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -202
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -122
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +0 -227
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +0 -162
- cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -199
- cognite_neat-0.97.3/cognite/neat/_graph/loaders/_rdf2asset.py +0 -416
- cognite_neat-0.97.3/cognite/neat/_rules/analysis/__init__.py +0 -5
- cognite_neat-0.97.3/cognite/neat/_rules/analysis/_asset.py +0 -173
- cognite_neat-0.97.3/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- cognite_neat-0.97.3/cognite/neat/_rules/models/asset/__init__.py +0 -13
- cognite_neat-0.97.3/cognite/neat/_rules/models/asset/_rules.py +0 -109
- cognite_neat-0.97.3/cognite/neat/_rules/models/asset/_rules_input.py +0 -101
- cognite_neat-0.97.3/cognite/neat/_rules/models/asset/_validation.py +0 -45
- cognite_neat-0.97.3/cognite/neat/_rules/models/domain.py +0 -136
- cognite_neat-0.97.3/cognite/neat/_rules/models/mapping/__init__.py +0 -4
- cognite_neat-0.97.3/cognite/neat/_rules/models/mapping/_base.py +0 -131
- cognite_neat-0.97.3/cognite/neat/_rules/models/mapping/_classic2core.py +0 -150
- cognite_neat-0.97.3/cognite/neat/_rules/transformers/_mapping.py +0 -139
- cognite_neat-0.97.3/cognite/neat/_session/_prepare.py +0 -269
- cognite_neat-0.97.3/cognite/neat/_utils/cdf/loaders/__init__.py +0 -25
- cognite_neat-0.97.3/cognite/neat/_utils/cdf/loaders/_base.py +0 -54
- cognite_neat-0.97.3/cognite/neat/_utils/cdf/loaders/_data_modeling.py +0 -339
- cognite_neat-0.97.3/cognite/neat/_utils/cdf/loaders/_ingestion.py +0 -167
- cognite_neat-0.97.3/cognite/neat/_version.py +0 -2
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/LICENSE +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/README.md +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/configuration.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/explorer.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/routers/configuration.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/routers/crud.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/routers/metrics.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/routers/workflows.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/utils/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/utils/logging.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/main.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/monitoring/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/monitoring/metrics.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/index.html +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/package-lock.json +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/package.json +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/index.html +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/manifest.json +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/public/robots.txt +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/App.css +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/App.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/App.test.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/index.css +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/index.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/logo.svg +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/setupTests.js +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_app/ui/neat-app/tsconfig.json +0 -0
- {cognite_neat-0.97.3/cognite/neat/_graph → cognite_neat-0.99.0/cognite/neat/_client/_api}/__init__.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_graph/extractors/_classic_cdf → cognite_neat-0.99.0/cognite/neat/_client/data_classes}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_constants.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_rules → cognite_neat-0.99.0/cognite/neat/_graph}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_rules/importers/_rdf → cognite_neat-0.99.0/cognite/neat/_graph/extractors/_classic_cdf}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_dms.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_iodd.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/loaders/_base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/loaders/_rdf2dms.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/queries/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/queries/_construct.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/queries/_shared.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_iodd.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_graph/transformers/_value_type.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/_base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/_external.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/_general.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/_properties.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/_resources.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/errors/_workflow.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/formatters.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/_resources.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_issues/warnings/user_modeling.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_utils → cognite_neat-0.99.0/cognite/neat/_rules}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_rules2instance_template.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_utils/cdf → cognite_neat-0.99.0/cognite/neat/_rules/importers/_rdf}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_imf2rules/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_imf2rules/_imf2rules.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/_base_input.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/_types.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/data_types.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_loaders.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_multi_value.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/entities/_wrapped.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/models/information/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/transformers/_base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_rules/transformers/_pipelines.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_state.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_workflows/steps → cognite_neat-0.99.0/cognite/neat/_utils}/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/auth.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/spreadsheet.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/text.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/upload.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/base.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/cdf_store.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/manager.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/model.py +0 -0
- {cognite_neat-0.97.3/cognite/neat/_workflows/steps/lib → cognite_neat-0.99.0/cognite/neat/_workflows/steps}/__init__.py +0 -0
- /cognite_neat-0.97.3/cognite/neat/py.typed → /cognite_neat-0.99.0/cognite/neat/_workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps/step_model.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/steps_registry.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/tasks.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/triggers.py +0 -0
- {cognite_neat-0.97.3 → cognite_neat-0.99.0}/cognite/neat/_workflows/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.99.0
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
Home-page: https://cognite-neat.readthedocs-hosted.com/
|
|
6
6
|
License: Apache-2.0
|
|
@@ -29,6 +29,7 @@ Requires-Dist: google-auth-oauthlib ; extra == "google"
|
|
|
29
29
|
Requires-Dist: gspread ; extra == "google"
|
|
30
30
|
Requires-Dist: jsonpath-python (>=1.0.6,<2.0.0)
|
|
31
31
|
Requires-Dist: lxml (>=5.3.0,<6.0.0) ; extra == "all"
|
|
32
|
+
Requires-Dist: mixpanel (>=4.10.1,<5.0.0)
|
|
32
33
|
Requires-Dist: mkdocs ; extra == "docs"
|
|
33
34
|
Requires-Dist: mkdocs-autorefs (>=0.5.0,<0.6.0) ; extra == "docs"
|
|
34
35
|
Requires-Dist: mkdocs-git-authors-plugin ; extra == "docs"
|
|
@@ -40,13 +41,13 @@ Requires-Dist: mkdocs-material-extensions ; extra == "docs"
|
|
|
40
41
|
Requires-Dist: mkdocstrings[python] ; extra == "docs"
|
|
41
42
|
Requires-Dist: networkx (>=3.4.2,<4.0.0)
|
|
42
43
|
Requires-Dist: openpyxl
|
|
43
|
-
Requires-Dist: oxrdflib[oxigraph] (>=0.
|
|
44
|
+
Requires-Dist: oxrdflib[oxigraph] (>=0.4.0,<0.5.0) ; extra == "oxi" or extra == "all"
|
|
44
45
|
Requires-Dist: packaging (>=22.0,<25.0)
|
|
45
46
|
Requires-Dist: pandas
|
|
46
47
|
Requires-Dist: prometheus-client (>=0,<1) ; extra == "service" or extra == "all"
|
|
47
48
|
Requires-Dist: pydantic (>=2,<3)
|
|
48
49
|
Requires-Dist: pymdown-extensions ; extra == "docs"
|
|
49
|
-
Requires-Dist: pyoxigraph (==0.3
|
|
50
|
+
Requires-Dist: pyoxigraph (==0.4.3) ; extra == "oxi" or extra == "all"
|
|
50
51
|
Requires-Dist: python-multipart (==0.0.9) ; extra == "service" or extra == "all"
|
|
51
52
|
Requires-Dist: pyvis (>=0.3.2,<0.4.0)
|
|
52
53
|
Requires-Dist: rdflib
|
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from collections.abc import Sequence
|
|
3
|
+
from graphlib import TopologicalSorter
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar, cast
|
|
5
|
+
|
|
6
|
+
from cognite.client.data_classes import filters
|
|
7
|
+
from cognite.client.data_classes._base import (
|
|
8
|
+
CogniteResourceList,
|
|
9
|
+
T_CogniteResourceList,
|
|
10
|
+
T_WritableCogniteResource,
|
|
11
|
+
T_WriteClass,
|
|
12
|
+
WriteableCogniteResourceList,
|
|
13
|
+
)
|
|
14
|
+
from cognite.client.data_classes.data_modeling import (
|
|
15
|
+
Container,
|
|
16
|
+
ContainerApply,
|
|
17
|
+
ContainerApplyList,
|
|
18
|
+
ContainerList,
|
|
19
|
+
DataModel,
|
|
20
|
+
DataModelApply,
|
|
21
|
+
DataModelApplyList,
|
|
22
|
+
DataModelList,
|
|
23
|
+
EdgeConnection,
|
|
24
|
+
MappedProperty,
|
|
25
|
+
RequiresConstraint,
|
|
26
|
+
Space,
|
|
27
|
+
SpaceApply,
|
|
28
|
+
SpaceApplyList,
|
|
29
|
+
SpaceList,
|
|
30
|
+
View,
|
|
31
|
+
ViewApply,
|
|
32
|
+
ViewApplyList,
|
|
33
|
+
ViewList,
|
|
34
|
+
)
|
|
35
|
+
from cognite.client.data_classes.data_modeling.ids import (
|
|
36
|
+
ContainerId,
|
|
37
|
+
DataModelId,
|
|
38
|
+
NodeId,
|
|
39
|
+
ViewId,
|
|
40
|
+
)
|
|
41
|
+
from cognite.client.data_classes.data_modeling.views import (
|
|
42
|
+
EdgeConnectionApply,
|
|
43
|
+
MappedPropertyApply,
|
|
44
|
+
ReverseDirectRelation,
|
|
45
|
+
ReverseDirectRelationApply,
|
|
46
|
+
)
|
|
47
|
+
from cognite.client.exceptions import CogniteAPIError
|
|
48
|
+
from cognite.client.utils.useful_types import SequenceNotStr
|
|
49
|
+
|
|
50
|
+
from cognite.neat._shared import T_ID
|
|
51
|
+
|
|
52
|
+
if TYPE_CHECKING:
|
|
53
|
+
from cognite.neat._client._api_client import NeatClient
|
|
54
|
+
|
|
55
|
+
T_WritableCogniteResourceList = TypeVar("T_WritableCogniteResourceList", bound=WriteableCogniteResourceList)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ResourceLoader(
|
|
59
|
+
ABC,
|
|
60
|
+
Generic[T_ID, T_WriteClass, T_WritableCogniteResource, T_CogniteResourceList, T_WritableCogniteResourceList],
|
|
61
|
+
):
|
|
62
|
+
"""A resource loaders is a wrapper around the Cognite SDK that does a few things:
|
|
63
|
+
|
|
64
|
+
* Standardizes the CRUD operations for a given resource.
|
|
65
|
+
* Caches the items that have been retrieved from the CDF.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
resource_name: str
|
|
69
|
+
|
|
70
|
+
def __init__(self, client: "NeatClient") -> None:
|
|
71
|
+
# This is exposed to allow for disabling the cache.
|
|
72
|
+
self.cache = True
|
|
73
|
+
self._client = client
|
|
74
|
+
# This cache is used to store the items that have been retrieved from the CDF.
|
|
75
|
+
self._items_by_id: dict[T_ID, T_WritableCogniteResource] = {}
|
|
76
|
+
|
|
77
|
+
def bust_cache(self) -> None:
|
|
78
|
+
self._items_by_id = {}
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
@abstractmethod
|
|
82
|
+
def get_id(cls, item: T_WriteClass | T_WritableCogniteResource | dict | T_ID) -> T_ID:
|
|
83
|
+
raise NotImplementedError
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def get_ids(cls, items: Sequence[T_WriteClass | T_WritableCogniteResource]) -> list[T_ID]:
|
|
87
|
+
return [cls.get_id(item) for item in items]
|
|
88
|
+
|
|
89
|
+
def create(self, items: Sequence[T_WriteClass]) -> T_WritableCogniteResourceList:
|
|
90
|
+
created = self._create(items)
|
|
91
|
+
if self.cache:
|
|
92
|
+
self._items_by_id.update({self.get_id(item): item for item in created})
|
|
93
|
+
return created
|
|
94
|
+
|
|
95
|
+
def retrieve(self, ids: SequenceNotStr[T_ID]) -> T_WritableCogniteResourceList:
|
|
96
|
+
if not self.cache:
|
|
97
|
+
return self._retrieve(ids)
|
|
98
|
+
missing_ids = [id for id in ids if id not in self._items_by_id.keys()]
|
|
99
|
+
if missing_ids:
|
|
100
|
+
retrieved = self._retrieve(missing_ids)
|
|
101
|
+
self._items_by_id.update({self.get_id(item): item for item in retrieved})
|
|
102
|
+
return self._create_list([self._items_by_id[id] for id in ids])
|
|
103
|
+
|
|
104
|
+
def update(self, items: Sequence[T_WriteClass]) -> T_WritableCogniteResourceList:
|
|
105
|
+
if not self.cache:
|
|
106
|
+
return self._update(items)
|
|
107
|
+
updated = self._update(items)
|
|
108
|
+
self._items_by_id.update({self.get_id(item): item for item in updated})
|
|
109
|
+
return updated
|
|
110
|
+
|
|
111
|
+
def delete(self, ids: SequenceNotStr[T_ID] | Sequence[T_WriteClass]) -> list[T_ID]:
|
|
112
|
+
id_list = [self.get_id(item) for item in ids]
|
|
113
|
+
if not self.cache:
|
|
114
|
+
return self._delete(id_list)
|
|
115
|
+
ids = [self.get_id(item) for item in ids]
|
|
116
|
+
deleted = self._delete(id_list)
|
|
117
|
+
for id in deleted:
|
|
118
|
+
self._items_by_id.pop(id, None)
|
|
119
|
+
return deleted
|
|
120
|
+
|
|
121
|
+
@abstractmethod
|
|
122
|
+
def _create(self, items: Sequence[T_WriteClass]) -> T_WritableCogniteResourceList:
|
|
123
|
+
raise NotImplementedError
|
|
124
|
+
|
|
125
|
+
@abstractmethod
|
|
126
|
+
def _retrieve(self, ids: SequenceNotStr[T_ID]) -> T_WritableCogniteResourceList:
|
|
127
|
+
raise NotImplementedError
|
|
128
|
+
|
|
129
|
+
@abstractmethod
|
|
130
|
+
def _update(self, items: Sequence[T_WriteClass]) -> T_WritableCogniteResourceList:
|
|
131
|
+
raise NotImplementedError
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def _delete(self, ids: SequenceNotStr[T_ID]) -> list[T_ID]:
|
|
135
|
+
raise NotImplementedError
|
|
136
|
+
|
|
137
|
+
@abstractmethod
|
|
138
|
+
def _create_list(self, items: Sequence[T_WritableCogniteResource]) -> T_WritableCogniteResourceList:
|
|
139
|
+
raise NotImplementedError
|
|
140
|
+
|
|
141
|
+
def are_equal(self, local: T_WriteClass, remote: T_WritableCogniteResource) -> bool:
|
|
142
|
+
return local == remote.as_write()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class DataModelingLoader(
|
|
146
|
+
ResourceLoader[T_ID, T_WriteClass, T_WritableCogniteResource, T_CogniteResourceList, T_WritableCogniteResourceList],
|
|
147
|
+
ABC,
|
|
148
|
+
):
|
|
149
|
+
@classmethod
|
|
150
|
+
def in_space(cls, item: T_WriteClass | T_WritableCogniteResource | T_ID, space: set[str]) -> bool:
|
|
151
|
+
if hasattr(item, "space"):
|
|
152
|
+
return item.space in space
|
|
153
|
+
raise ValueError(f"Item {item} does not have a space attribute")
|
|
154
|
+
|
|
155
|
+
def sort_by_dependencies(self, items: list[T_WriteClass]) -> list[T_WriteClass]:
|
|
156
|
+
return items
|
|
157
|
+
|
|
158
|
+
def create(
|
|
159
|
+
self, items: Sequence[T_WriteClass], existing_handling: Literal["fail", "skip", "update", "force"] = "fail"
|
|
160
|
+
) -> T_WritableCogniteResourceList:
|
|
161
|
+
if existing_handling != "force":
|
|
162
|
+
return super().create(items)
|
|
163
|
+
|
|
164
|
+
created = self._create_force(items, set())
|
|
165
|
+
if self.cache:
|
|
166
|
+
self._items_by_id.update({self.get_id(item): item for item in created})
|
|
167
|
+
return created
|
|
168
|
+
|
|
169
|
+
def _create_force(
|
|
170
|
+
self,
|
|
171
|
+
items: Sequence[T_WriteClass],
|
|
172
|
+
tried_force_deploy: set[T_ID],
|
|
173
|
+
) -> T_WritableCogniteResourceList:
|
|
174
|
+
try:
|
|
175
|
+
return self._create(items)
|
|
176
|
+
except CogniteAPIError as e:
|
|
177
|
+
failed_ids = {self.get_id(failed) for failed in e.failed}
|
|
178
|
+
to_redeploy = [
|
|
179
|
+
item
|
|
180
|
+
for item in items
|
|
181
|
+
if self.get_id(item) in failed_ids and self.get_id(item) not in tried_force_deploy
|
|
182
|
+
]
|
|
183
|
+
if not to_redeploy:
|
|
184
|
+
# Avoid infinite loop
|
|
185
|
+
raise e
|
|
186
|
+
tried_force_deploy.update([self.get_id(item) for item in to_redeploy])
|
|
187
|
+
self.delete(to_redeploy)
|
|
188
|
+
return self._create_force(to_redeploy, tried_force_deploy)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class SpaceLoader(DataModelingLoader[str, SpaceApply, Space, SpaceApplyList, SpaceList]):
|
|
192
|
+
resource_name = "spaces"
|
|
193
|
+
|
|
194
|
+
@classmethod
|
|
195
|
+
def get_id(cls, item: Space | SpaceApply | str | dict) -> str:
|
|
196
|
+
if isinstance(item, Space | SpaceApply):
|
|
197
|
+
return item.space
|
|
198
|
+
if isinstance(item, dict):
|
|
199
|
+
return item["space"]
|
|
200
|
+
return item
|
|
201
|
+
|
|
202
|
+
def _create(self, items: Sequence[SpaceApply]) -> SpaceList:
|
|
203
|
+
return self._client.data_modeling.spaces.apply(items)
|
|
204
|
+
|
|
205
|
+
def _retrieve(self, ids: SequenceNotStr[str]) -> SpaceList:
|
|
206
|
+
return self._client.data_modeling.spaces.retrieve(ids)
|
|
207
|
+
|
|
208
|
+
def _update(self, items: Sequence[SpaceApply]) -> SpaceList:
|
|
209
|
+
return self._create(items)
|
|
210
|
+
|
|
211
|
+
def _delete(self, ids: SequenceNotStr[str] | Sequence[Space | SpaceApply]) -> list[str]:
|
|
212
|
+
if all(isinstance(item, Space) for item in ids) or all(isinstance(item, SpaceApply) for item in ids):
|
|
213
|
+
ids = [cast(Space | SpaceApply, item).space for item in ids]
|
|
214
|
+
return self._client.data_modeling.spaces.delete(cast(SequenceNotStr[str], ids))
|
|
215
|
+
|
|
216
|
+
def _create_list(self, items: Sequence[Space]) -> SpaceList:
|
|
217
|
+
return SpaceList(items)
|
|
218
|
+
|
|
219
|
+
def clean(self, space: str) -> None:
|
|
220
|
+
"""Deletes all data in a space.
|
|
221
|
+
|
|
222
|
+
This means all nodes, edges, views, containers, and data models located in the given space.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
client: Connected CogniteClient
|
|
226
|
+
space: The space to delete.
|
|
227
|
+
|
|
228
|
+
"""
|
|
229
|
+
edges = self._client.data_modeling.instances.list(
|
|
230
|
+
"edge", limit=-1, filter=filters.Equals(["edge", "space"], space)
|
|
231
|
+
)
|
|
232
|
+
if edges:
|
|
233
|
+
instances = self._client.data_modeling.instances.delete(edges=edges.as_ids())
|
|
234
|
+
print(f"Deleted {len(instances.edges)} edges")
|
|
235
|
+
nodes = self._client.data_modeling.instances.list(
|
|
236
|
+
"node", limit=-1, filter=filters.Equals(["node", "space"], space)
|
|
237
|
+
)
|
|
238
|
+
node_types = {NodeId(node.type.space, node.type.external_id) for node in nodes if node.type}
|
|
239
|
+
node_data = set(nodes.as_ids()) - node_types
|
|
240
|
+
if node_data:
|
|
241
|
+
instances = self._client.data_modeling.instances.delete(nodes=list(node_data))
|
|
242
|
+
print(f"Deleted {len(instances.nodes)} nodes")
|
|
243
|
+
if node_types:
|
|
244
|
+
instances = self._client.data_modeling.instances.delete(nodes=list(node_types))
|
|
245
|
+
print(f"Deleted {len(instances.nodes)} node types")
|
|
246
|
+
views = self._client.data_modeling.views.list(limit=-1, space=space)
|
|
247
|
+
if views:
|
|
248
|
+
deleted_views = self._client.data_modeling.views.delete(views.as_ids())
|
|
249
|
+
print(f"Deleted {len(deleted_views)} views")
|
|
250
|
+
containers = self._client.data_modeling.containers.list(limit=-1, space=space)
|
|
251
|
+
if containers:
|
|
252
|
+
deleted_containers = self._client.data_modeling.containers.delete(containers.as_ids())
|
|
253
|
+
print(f"Deleted {len(deleted_containers)} containers")
|
|
254
|
+
if data_models := self._client.data_modeling.data_models.list(limit=-1, space=space):
|
|
255
|
+
deleted_data_models = self._client.data_modeling.data_models.delete(data_models.as_ids())
|
|
256
|
+
print(f"Deleted {len(deleted_data_models)} data models")
|
|
257
|
+
deleted_space = self._client.data_modeling.spaces.delete(space)
|
|
258
|
+
print(f"Deleted space {deleted_space}")
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class ViewLoader(DataModelingLoader[ViewId, ViewApply, View, ViewApplyList, ViewList]):
|
|
262
|
+
resource_name = "views"
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def get_id(cls, item: View | ViewApply | ViewId | dict) -> ViewId:
|
|
266
|
+
if isinstance(item, View | ViewApply):
|
|
267
|
+
return item.as_id()
|
|
268
|
+
if isinstance(item, dict):
|
|
269
|
+
return ViewId.load(item)
|
|
270
|
+
return item
|
|
271
|
+
|
|
272
|
+
def _create(self, items: Sequence[ViewApply]) -> ViewList:
|
|
273
|
+
return self._client.data_modeling.views.apply(items)
|
|
274
|
+
|
|
275
|
+
def retrieve(
|
|
276
|
+
self, ids: SequenceNotStr[ViewId], include_connections: bool = False, include_ancestor: bool = False
|
|
277
|
+
) -> ViewList:
|
|
278
|
+
if not include_connections and not include_ancestor:
|
|
279
|
+
return super().retrieve(ids)
|
|
280
|
+
# Retrieve recursively updates the cache.
|
|
281
|
+
return self._retrieve_recursive(ids, include_connections, include_ancestor)
|
|
282
|
+
|
|
283
|
+
def _retrieve(self, ids: SequenceNotStr[ViewId]) -> ViewList:
|
|
284
|
+
return self._client.data_modeling.views.retrieve(cast(Sequence, ids))
|
|
285
|
+
|
|
286
|
+
def _update(self, items: Sequence[ViewApply]) -> ViewList:
|
|
287
|
+
return self._create(items)
|
|
288
|
+
|
|
289
|
+
def _delete(self, ids: SequenceNotStr[ViewId]) -> list[ViewId]:
|
|
290
|
+
return self._client.data_modeling.views.delete(cast(Sequence, ids))
|
|
291
|
+
|
|
292
|
+
def _as_write_raw(self, view: View) -> dict[str, Any]:
|
|
293
|
+
dumped = view.as_write().dump()
|
|
294
|
+
if view.properties:
|
|
295
|
+
# All read version of views have all the properties of their parent views.
|
|
296
|
+
# We need to remove these properties to compare with the local view.
|
|
297
|
+
parents = self._retrieve_recursive(view.implements or [], include_connections=False, include_ancestors=True)
|
|
298
|
+
for parent in parents:
|
|
299
|
+
for prop_name, prop in (parent.as_write().properties or {}).items():
|
|
300
|
+
existing = dumped["properties"].get(prop_name)
|
|
301
|
+
if existing is None:
|
|
302
|
+
continue
|
|
303
|
+
if existing == prop.dump():
|
|
304
|
+
dumped["properties"].pop(prop_name, None)
|
|
305
|
+
# If the child overrides the parent, we keep the child's property.
|
|
306
|
+
|
|
307
|
+
if "properties" in dumped and not dumped["properties"]:
|
|
308
|
+
# All properties were removed, so we remove the properties key.
|
|
309
|
+
dumped.pop("properties", None)
|
|
310
|
+
return dumped
|
|
311
|
+
|
|
312
|
+
def are_equal(self, local: ViewApply, remote: View) -> bool:
|
|
313
|
+
local_dumped = local.dump()
|
|
314
|
+
if not remote.implements:
|
|
315
|
+
return local_dumped == remote.as_write().dump()
|
|
316
|
+
|
|
317
|
+
cdf_resource_dumped = self._as_write_raw(remote)
|
|
318
|
+
|
|
319
|
+
if "properties" in local_dumped and not local_dumped["properties"]:
|
|
320
|
+
# In case the local properties are set to an empty dict.
|
|
321
|
+
local_dumped.pop("properties", None)
|
|
322
|
+
|
|
323
|
+
return local_dumped == cdf_resource_dumped
|
|
324
|
+
|
|
325
|
+
def as_write(self, view: View) -> ViewApply:
|
|
326
|
+
return ViewApply.load(self._as_write_raw(view))
|
|
327
|
+
|
|
328
|
+
def _retrieve_recursive(
|
|
329
|
+
self, view_ids: SequenceNotStr[ViewId], include_connections: bool, include_ancestors: bool
|
|
330
|
+
) -> ViewList:
|
|
331
|
+
"""Retrieves all views with the
|
|
332
|
+
|
|
333
|
+
This will mutate the cache passed in, and return a list of views that are the ancestors
|
|
334
|
+
of the views in the parents list.
|
|
335
|
+
|
|
336
|
+
Args:
|
|
337
|
+
view_ids: The views to retrieve.
|
|
338
|
+
include_connections: Whether to include all connected views.
|
|
339
|
+
include_ancestors: Whether to include all ancestors.
|
|
340
|
+
"""
|
|
341
|
+
last_batch = list(view_ids)
|
|
342
|
+
found = ViewList([])
|
|
343
|
+
found_ids: set[ViewId] = set()
|
|
344
|
+
while last_batch:
|
|
345
|
+
to_retrieve_from_cdf: set[ViewId] = set()
|
|
346
|
+
batch_ids: list[ViewId] = []
|
|
347
|
+
for view_id in last_batch:
|
|
348
|
+
if view_id in found_ids:
|
|
349
|
+
continue
|
|
350
|
+
elif view_id in self._items_by_id:
|
|
351
|
+
view = self._items_by_id[view_id]
|
|
352
|
+
found.append(view)
|
|
353
|
+
batch_ids.extend(self.get_connected_views(view, include_ancestors, include_connections, found_ids))
|
|
354
|
+
else:
|
|
355
|
+
to_retrieve_from_cdf.add(view_id)
|
|
356
|
+
|
|
357
|
+
if to_retrieve_from_cdf:
|
|
358
|
+
retrieved_batch = self._client.data_modeling.views.retrieve(list(to_retrieve_from_cdf))
|
|
359
|
+
self._items_by_id.update({view.as_id(): view for view in retrieved_batch})
|
|
360
|
+
found.extend(retrieved_batch)
|
|
361
|
+
found_ids.update({view.as_id() for view in retrieved_batch})
|
|
362
|
+
for view in retrieved_batch:
|
|
363
|
+
batch_ids.extend(self.get_connected_views(view, include_ancestors, include_connections, found_ids))
|
|
364
|
+
|
|
365
|
+
last_batch = batch_ids
|
|
366
|
+
|
|
367
|
+
if self.cache is False:
|
|
368
|
+
# We must update the cache to retrieve recursively.
|
|
369
|
+
# If the cache is disabled, bust the cache to avoid storing the retrieved views.
|
|
370
|
+
self.bust_cache()
|
|
371
|
+
return found
|
|
372
|
+
|
|
373
|
+
@staticmethod
|
|
374
|
+
def get_connected_views(
|
|
375
|
+
view: View | ViewApply,
|
|
376
|
+
include_parents: bool = True,
|
|
377
|
+
include_connections: bool = True,
|
|
378
|
+
skip_ids: set[ViewId] | None = None,
|
|
379
|
+
) -> list[ViewId]:
|
|
380
|
+
connected_ids: set[ViewId] = set(view.implements or []) if include_parents else set()
|
|
381
|
+
if include_connections:
|
|
382
|
+
for prop in (view.properties or {}).values():
|
|
383
|
+
if isinstance(prop, MappedProperty | MappedPropertyApply) and prop.source:
|
|
384
|
+
connected_ids.add(prop.source)
|
|
385
|
+
elif isinstance(
|
|
386
|
+
prop, EdgeConnection | EdgeConnectionApply | ReverseDirectRelation | ReverseDirectRelationApply
|
|
387
|
+
):
|
|
388
|
+
connected_ids.add(prop.source)
|
|
389
|
+
|
|
390
|
+
if isinstance(prop, EdgeConnection | EdgeConnectionApply) and prop.edge_source:
|
|
391
|
+
connected_ids.add(prop.edge_source)
|
|
392
|
+
elif isinstance(prop, ReverseDirectRelation | ReverseDirectRelationApply) and isinstance(
|
|
393
|
+
prop.through.source, ViewId
|
|
394
|
+
):
|
|
395
|
+
connected_ids.add(prop.through.source)
|
|
396
|
+
if skip_ids:
|
|
397
|
+
return [view_id for view_id in connected_ids if view_id not in skip_ids]
|
|
398
|
+
return list(connected_ids)
|
|
399
|
+
|
|
400
|
+
def _create_list(self, items: Sequence[View]) -> ViewList:
|
|
401
|
+
return ViewList(items)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class ContainerLoader(DataModelingLoader[ContainerId, ContainerApply, Container, ContainerApplyList, ContainerList]):
|
|
405
|
+
resource_name = "containers"
|
|
406
|
+
|
|
407
|
+
@classmethod
|
|
408
|
+
def get_id(cls, item: Container | ContainerApply | ContainerId | dict) -> ContainerId:
|
|
409
|
+
if isinstance(item, Container | ContainerApply):
|
|
410
|
+
return item.as_id()
|
|
411
|
+
if isinstance(item, dict):
|
|
412
|
+
return ContainerId.load(item)
|
|
413
|
+
return item
|
|
414
|
+
|
|
415
|
+
def sort_by_dependencies(self, items: Sequence[ContainerApply]) -> list[ContainerApply]:
|
|
416
|
+
container_by_id = {container.as_id(): container for container in items}
|
|
417
|
+
container_dependencies = {
|
|
418
|
+
container.as_id(): {
|
|
419
|
+
const.require
|
|
420
|
+
for const in container.constraints.values()
|
|
421
|
+
if isinstance(const, RequiresConstraint) and const.require in container_by_id
|
|
422
|
+
}
|
|
423
|
+
for container in items
|
|
424
|
+
}
|
|
425
|
+
return [
|
|
426
|
+
container_by_id[container_id] for container_id in TopologicalSorter(container_dependencies).static_order()
|
|
427
|
+
]
|
|
428
|
+
|
|
429
|
+
def _create(self, items: Sequence[ContainerApply]) -> ContainerList:
|
|
430
|
+
return self._client.data_modeling.containers.apply(items)
|
|
431
|
+
|
|
432
|
+
def _retrieve(self, ids: SequenceNotStr[ContainerId]) -> ContainerList:
|
|
433
|
+
return self._client.data_modeling.containers.retrieve(cast(Sequence, ids))
|
|
434
|
+
|
|
435
|
+
def _update(self, items: Sequence[ContainerApply]) -> ContainerList:
|
|
436
|
+
return self._create(items)
|
|
437
|
+
|
|
438
|
+
def _delete(self, ids: SequenceNotStr[ContainerId]) -> list[ContainerId]:
|
|
439
|
+
return self._client.data_modeling.containers.delete(cast(Sequence, ids))
|
|
440
|
+
|
|
441
|
+
def _create_list(self, items: Sequence[Container]) -> ContainerList:
|
|
442
|
+
return ContainerList(items)
|
|
443
|
+
|
|
444
|
+
def are_equal(self, local: ContainerApply, remote: Container) -> bool:
|
|
445
|
+
local_dumped = local.dump(camel_case=True)
|
|
446
|
+
if "usedFor" not in local_dumped:
|
|
447
|
+
# Setting used_for to "node" as it is the default value in the CDF.
|
|
448
|
+
local_dumped["usedFor"] = "node"
|
|
449
|
+
|
|
450
|
+
return local_dumped == remote.as_write().dump(camel_case=True)
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
class DataModelLoader(DataModelingLoader[DataModelId, DataModelApply, DataModel, DataModelApplyList, DataModelList]):
|
|
454
|
+
resource_name = "data_models"
|
|
455
|
+
|
|
456
|
+
@classmethod
|
|
457
|
+
def get_id(cls, item: DataModel | DataModelApply | DataModelId | dict) -> DataModelId:
|
|
458
|
+
if isinstance(item, DataModel | DataModelApply):
|
|
459
|
+
return item.as_id()
|
|
460
|
+
if isinstance(item, dict):
|
|
461
|
+
return DataModelId.load(item)
|
|
462
|
+
return item
|
|
463
|
+
|
|
464
|
+
def _create(self, items: Sequence[DataModelApply]) -> DataModelList:
|
|
465
|
+
return self._client.data_modeling.data_models.apply(items)
|
|
466
|
+
|
|
467
|
+
def _retrieve(self, ids: SequenceNotStr[DataModelId]) -> DataModelList:
|
|
468
|
+
return self._client.data_modeling.data_models.retrieve(cast(Sequence, ids))
|
|
469
|
+
|
|
470
|
+
def _update(self, items: Sequence[DataModelApply]) -> DataModelList:
|
|
471
|
+
return self._create(items)
|
|
472
|
+
|
|
473
|
+
def _delete(self, ids: SequenceNotStr[DataModelId]) -> list[DataModelId]:
|
|
474
|
+
return self._client.data_modeling.data_models.delete(cast(Sequence, ids))
|
|
475
|
+
|
|
476
|
+
def _create_list(self, items: Sequence[DataModel]) -> DataModelList:
|
|
477
|
+
return DataModelList(items)
|
|
478
|
+
|
|
479
|
+
def are_equal(self, local: DataModelApply, remote: DataModel) -> bool:
|
|
480
|
+
local_dumped = local.dump()
|
|
481
|
+
cdf_resource_dumped = remote.as_write().dump()
|
|
482
|
+
|
|
483
|
+
# Data models that have the same views, but in different order, are considered equal.
|
|
484
|
+
# We also account for whether views are given as IDs or View objects.
|
|
485
|
+
local_dumped["views"] = sorted(
|
|
486
|
+
(v if isinstance(v, ViewId) else v.as_id()).as_tuple() for v in local.views or []
|
|
487
|
+
)
|
|
488
|
+
cdf_resource_dumped["views"] = sorted(
|
|
489
|
+
(v if isinstance(v, ViewId) else v.as_id()).as_tuple() for v in remote.views or []
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
return local_dumped == cdf_resource_dumped
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
class DataModelLoaderAPI:
|
|
496
|
+
def __init__(self, client: "NeatClient") -> None:
|
|
497
|
+
self._client = client
|
|
498
|
+
self.spaces = SpaceLoader(client)
|
|
499
|
+
self.views = ViewLoader(client)
|
|
500
|
+
self.containers = ContainerLoader(client)
|
|
501
|
+
self.data_models = DataModelLoader(client)
|
|
502
|
+
|
|
503
|
+
def get_loader(self, items: Any) -> DataModelingLoader:
|
|
504
|
+
if isinstance(items, CogniteResourceList):
|
|
505
|
+
resource_name = type(items).__name__.casefold().removesuffix("list").removesuffix("apply")
|
|
506
|
+
elif isinstance(items, str):
|
|
507
|
+
resource_name = items
|
|
508
|
+
else:
|
|
509
|
+
raise ValueError(f"Cannot determine resource name from {items}")
|
|
510
|
+
if resource_name[-1] != "s":
|
|
511
|
+
resource_name += "s"
|
|
512
|
+
return getattr(self, resource_name)
|
|
@@ -0,0 +1,50 @@
|
|
|
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, 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_connections=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
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from cognite.client import ClientConfig, CogniteClient
|
|
2
|
+
|
|
3
|
+
from cognite.neat._utils.auth import _CLIENT_NAME
|
|
4
|
+
|
|
5
|
+
from ._api.data_modeling_loaders import DataModelLoaderAPI
|
|
6
|
+
from ._api.schema import SchemaAPI
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NeatClient(CogniteClient):
|
|
10
|
+
def __init__(self, config: ClientConfig | CogniteClient | None = None) -> None:
|
|
11
|
+
if isinstance(config, CogniteClient):
|
|
12
|
+
config = config.config
|
|
13
|
+
super().__init__(config=config)
|
|
14
|
+
if self._config is not None:
|
|
15
|
+
self._config.client_name = _CLIENT_NAME
|
|
16
|
+
self.loaders = DataModelLoaderAPI(self)
|
|
17
|
+
self.schema = SchemaAPI(self)
|