cognite-neat 0.75.6__tar.gz → 0.75.7__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.
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/PKG-INFO +1 -1
- cognite_neat-0.75.7/cognite/neat/_version.py +1 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_models.py +6 -1
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_rules2dms.py +67 -14
- cognite_neat-0.75.7/cognite/neat/rules/models/data_types.py +259 -0
- cognite_neat-0.75.7/cognite/neat/rules/models/entities.py +299 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf_loaders/_data_modeling.py +4 -2
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/rules_exporter.py +97 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/pyproject.toml +1 -1
- cognite_neat-0.75.6/cognite/neat/_version.py +0 -1
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/LICENSE +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/README.md +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/configuration.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/data_classes/configuration.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/explorer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/configuration.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/core.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/crud.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/data_exploration.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/metrics.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/routers/workflows.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/utils/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/utils/logging.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/main.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/monitoring/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/monitoring/metrics.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/index.html +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/js/main.4345d42f.js +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/js/main.4345d42f.js.LICENSE.txt +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/js/main.4345d42f.js.map +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/config.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/constants.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/examples/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/extractors/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/models.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_graphdb_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_memory_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_oxigraph_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/graph/stores/_rdf_to_graph.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/examples/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/extractors/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/extractors/_graph_capturing_sheet.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/_asset_loader.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/_exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/core/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/core/labels.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/core/models.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/rdf_to_dms.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/loaders/validator.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/models.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_graphdb_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_memory_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_oxigraph_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/stores/_rdf_to_graph.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/transformations/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/transformations/entity_matcher.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/transformations/query_generator/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/transformations/query_generator/sparql.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/graph/transformations/transformer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/analysis.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/Rules-Nordic44-to-TNT.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/power-grid-containers.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/power-grid-example.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/power-grid-model.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/rules-template.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/skos-rules.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_core/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_core/rules2labels.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2graphql.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_rules2triples.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_dict2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_graph2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_json2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_xsd2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/raw_rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/rdfpath.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/tables.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/legacy/rules/models/value_types.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/py.typed +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/_shared.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/analysis/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/analysis/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/analysis/_information_rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/examples/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/dms.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/fileread.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/formatters.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/importing.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/spreadsheet.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/issues/spreadsheet_file.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/_entity.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rdfpath.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_dms_architect_rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_dms_schema.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_domain_rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_information_rules.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_types/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_types/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_types/_field.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/rules/models/rules/_types/_value.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/auxiliary.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf_loaders/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf_loaders/_base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf_loaders/_ingestion.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/cdf_loaders/data_classes.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/spreadsheet.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/text.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/utils.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/utils/xml.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/_exceptions.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/base.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/cdf_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/manager.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/migration/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/migration/steps.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/migration/wf_manifests.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/model.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/graph_extractor.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/graph_loader.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/graph_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/io_steps.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/rules_importer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/rules_validator.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/__init__.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/graph_contextualization.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/graph_extractor.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/graph_loader.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/graph_store.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/graph_transformer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/rules_exporter.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/lib/v1/rules_importer.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps/step_model.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/steps_registry.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/tasks.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/triggers.py +0 -0
- {cognite_neat-0.75.6 → cognite_neat-0.75.7}/cognite/neat/workflows/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.75.7"
|
|
@@ -30,6 +30,7 @@ class UploadResult(UploadResultCore):
|
|
|
30
30
|
skipped: int = 0
|
|
31
31
|
failed_created: int = 0
|
|
32
32
|
failed_changed: int = 0
|
|
33
|
+
failed_deleted: int = 0
|
|
33
34
|
error_messages: list[str] = field(default_factory=list)
|
|
34
35
|
|
|
35
36
|
@property
|
|
@@ -38,7 +39,7 @@ class UploadResult(UploadResultCore):
|
|
|
38
39
|
|
|
39
40
|
@property
|
|
40
41
|
def failed(self) -> int:
|
|
41
|
-
return self.failed_created + self.failed_changed
|
|
42
|
+
return self.failed_created + self.failed_changed + self.failed_deleted
|
|
42
43
|
|
|
43
44
|
def as_report_str(self) -> str:
|
|
44
45
|
line = []
|
|
@@ -50,9 +51,13 @@ class UploadResult(UploadResultCore):
|
|
|
50
51
|
line.append(f"skipped {self.skipped}")
|
|
51
52
|
if self.unchanged:
|
|
52
53
|
line.append(f"unchanged {self.unchanged}")
|
|
54
|
+
if self.deleted:
|
|
55
|
+
line.append(f"deleted {self.deleted}")
|
|
53
56
|
if self.failed_created:
|
|
54
57
|
line.append(f"failed to create {self.failed_created}")
|
|
55
58
|
if self.failed_changed:
|
|
56
59
|
line.append(f"failed to update {self.failed_changed}")
|
|
60
|
+
if self.failed_deleted:
|
|
61
|
+
line.append(f"failed to delete {self.failed_deleted}")
|
|
57
62
|
|
|
58
63
|
return f"{self.name.title()}: {', '.join(line)}"
|
|
@@ -151,21 +151,55 @@ class DMSExporter(CDFExporter[DMSSchema]):
|
|
|
151
151
|
schema.frozen_ids.update(set(reference_schema.node_types.as_ids()))
|
|
152
152
|
return schema
|
|
153
153
|
|
|
154
|
+
def delete_from_cdf(self, rules: Rules, client: CogniteClient, dry_run: bool = False) -> Iterable[UploadResult]:
|
|
155
|
+
schema, to_export = self._prepare_schema_and_exporters(rules, client)
|
|
156
|
+
|
|
157
|
+
# we need to reverse order in which we are picking up the items to delete
|
|
158
|
+
# as they are sorted in the order of creation and we need to delete them in reverse order
|
|
159
|
+
for all_items, loader in reversed(to_export):
|
|
160
|
+
all_item_ids = loader.get_ids(all_items)
|
|
161
|
+
skipped = sum(1 for item_id in all_item_ids if item_id in schema.frozen_ids)
|
|
162
|
+
item_ids = [item_id for item_id in all_item_ids if item_id not in schema.frozen_ids]
|
|
163
|
+
cdf_items = loader.retrieve(item_ids)
|
|
164
|
+
cdf_item_by_id = {loader.get_id(item): item for item in cdf_items}
|
|
165
|
+
items = [item for item in all_items if loader.get_id(item) in item_ids]
|
|
166
|
+
to_delete = []
|
|
167
|
+
|
|
168
|
+
for item in items:
|
|
169
|
+
if (
|
|
170
|
+
isinstance(loader, DataModelingLoader)
|
|
171
|
+
and self.include_space is not None
|
|
172
|
+
and not loader.in_space(item, self.include_space)
|
|
173
|
+
):
|
|
174
|
+
continue
|
|
175
|
+
|
|
176
|
+
cdf_item = cdf_item_by_id.get(loader.get_id(item))
|
|
177
|
+
if cdf_item:
|
|
178
|
+
to_delete.append(cdf_item)
|
|
179
|
+
|
|
180
|
+
deleted = len(to_delete)
|
|
181
|
+
failed_deleted = 0
|
|
182
|
+
|
|
183
|
+
error_messages: list[str] = []
|
|
184
|
+
if not dry_run:
|
|
185
|
+
if to_delete:
|
|
186
|
+
try:
|
|
187
|
+
loader.delete(to_delete)
|
|
188
|
+
except CogniteAPIError as e:
|
|
189
|
+
failed_deleted = len(e.failed) + len(e.unknown)
|
|
190
|
+
deleted -= failed_deleted
|
|
191
|
+
error_messages.append(f"Failed delete: {e.message}")
|
|
192
|
+
|
|
193
|
+
yield UploadResult(
|
|
194
|
+
name=loader.resource_name,
|
|
195
|
+
deleted=deleted,
|
|
196
|
+
skipped=skipped,
|
|
197
|
+
failed_deleted=failed_deleted,
|
|
198
|
+
error_messages=error_messages,
|
|
199
|
+
)
|
|
200
|
+
|
|
154
201
|
def export_to_cdf(self, rules: Rules, client: CogniteClient, dry_run: bool = False) -> Iterable[UploadResult]:
|
|
155
|
-
schema = self.
|
|
156
|
-
to_export: list[tuple[CogniteResourceList, ResourceLoader]] = []
|
|
157
|
-
if self.export_components.intersection({"all", "spaces"}):
|
|
158
|
-
to_export.append((schema.spaces, SpaceLoader(client)))
|
|
159
|
-
if self.export_components.intersection({"all", "containers"}):
|
|
160
|
-
to_export.append((schema.containers, ContainerLoader(client)))
|
|
161
|
-
if self.export_components.intersection({"all", "views"}):
|
|
162
|
-
to_export.append((schema.views, ViewLoader(client, self.existing_handling)))
|
|
163
|
-
if self.export_components.intersection({"all", "data_models"}):
|
|
164
|
-
to_export.append((schema.data_models, DataModelLoader(client)))
|
|
165
|
-
if isinstance(schema, PipelineSchema):
|
|
166
|
-
to_export.append((schema.databases, RawDatabaseLoader(client)))
|
|
167
|
-
to_export.append((schema.raw_tables, RawTableLoader(client)))
|
|
168
|
-
to_export.append((schema.transformations, TransformationLoader(client)))
|
|
202
|
+
schema, to_export = self._prepare_schema_and_exporters(rules, client)
|
|
169
203
|
|
|
170
204
|
# The conversion from DMS to GraphQL does not seem to be triggered even if the views
|
|
171
205
|
# are changed. This is a workaround to force the conversion.
|
|
@@ -254,3 +288,22 @@ class DMSExporter(CDFExporter[DMSSchema]):
|
|
|
254
288
|
|
|
255
289
|
if loader.resource_name == "views" and (created or changed) and not redeploy_data_model:
|
|
256
290
|
redeploy_data_model = True
|
|
291
|
+
|
|
292
|
+
def _prepare_schema_and_exporters(
|
|
293
|
+
self, rules, client
|
|
294
|
+
) -> tuple[DMSSchema, list[tuple[CogniteResourceList, ResourceLoader]]]:
|
|
295
|
+
schema = self.export(rules)
|
|
296
|
+
to_export: list[tuple[CogniteResourceList, ResourceLoader]] = []
|
|
297
|
+
if self.export_components.intersection({"all", "spaces"}):
|
|
298
|
+
to_export.append((schema.spaces, SpaceLoader(client)))
|
|
299
|
+
if self.export_components.intersection({"all", "containers"}):
|
|
300
|
+
to_export.append((schema.containers, ContainerLoader(client)))
|
|
301
|
+
if self.export_components.intersection({"all", "views"}):
|
|
302
|
+
to_export.append((schema.views, ViewLoader(client, self.existing_handling)))
|
|
303
|
+
if self.export_components.intersection({"all", "data_models"}):
|
|
304
|
+
to_export.append((schema.data_models, DataModelLoader(client)))
|
|
305
|
+
if isinstance(schema, PipelineSchema):
|
|
306
|
+
to_export.append((schema.databases, RawDatabaseLoader(client)))
|
|
307
|
+
to_export.append((schema.raw_tables, RawTableLoader(client)))
|
|
308
|
+
to_export.append((schema.transformations, TransformationLoader(client)))
|
|
309
|
+
return schema, to_export
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from datetime import date, datetime
|
|
3
|
+
from typing import Any, ClassVar
|
|
4
|
+
|
|
5
|
+
from cognite.client.data_classes import data_modeling as dms
|
|
6
|
+
from pydantic import BaseModel, model_serializer, model_validator
|
|
7
|
+
from pydantic.functional_validators import ModelWrapValidatorHandler
|
|
8
|
+
|
|
9
|
+
if sys.version_info >= (3, 11):
|
|
10
|
+
from typing import Self
|
|
11
|
+
else:
|
|
12
|
+
from typing_extensions import Self
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DataType(BaseModel):
|
|
16
|
+
name: ClassVar[str]
|
|
17
|
+
python: ClassVar[type]
|
|
18
|
+
dms: ClassVar[type[dms.PropertyType]]
|
|
19
|
+
graphql: ClassVar[str]
|
|
20
|
+
xsd: ClassVar[str]
|
|
21
|
+
sql: ClassVar[str]
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def load(cls, data: Any) -> Self:
|
|
25
|
+
return cls.model_validate(data)
|
|
26
|
+
|
|
27
|
+
def dump(self) -> dict[str, Any]:
|
|
28
|
+
return self.model_dump(by_alias=True)
|
|
29
|
+
|
|
30
|
+
@model_validator(mode="wrap")
|
|
31
|
+
def _load(cls, value: Any, handler: ModelWrapValidatorHandler["DataType"]) -> Any:
|
|
32
|
+
if isinstance(value, cls | dict):
|
|
33
|
+
return value
|
|
34
|
+
elif isinstance(value, str):
|
|
35
|
+
try:
|
|
36
|
+
return _DATA_TYPE_BY_NAME[value.casefold()]()
|
|
37
|
+
except KeyError:
|
|
38
|
+
raise ValueError(f"Unknown literal type: {value}") from None
|
|
39
|
+
raise ValueError(f"Cannot load {cls.__name__} from {value}")
|
|
40
|
+
|
|
41
|
+
@model_serializer(when_used="unless-none", return_type=str)
|
|
42
|
+
def as_str(self) -> str:
|
|
43
|
+
return str(self)
|
|
44
|
+
|
|
45
|
+
def __str__(self) -> str:
|
|
46
|
+
return self.name
|
|
47
|
+
|
|
48
|
+
def __eq__(self, other: Any) -> bool:
|
|
49
|
+
return isinstance(other, type(self))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Boolean(DataType):
|
|
53
|
+
name = "boolean"
|
|
54
|
+
python = bool
|
|
55
|
+
dms = dms.Boolean
|
|
56
|
+
graphql = "Boolean"
|
|
57
|
+
xsd = "xsd:boolean"
|
|
58
|
+
sql = "BOOLEAN"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Float(DataType):
|
|
62
|
+
name = "float"
|
|
63
|
+
python = float
|
|
64
|
+
dms = dms.Float32
|
|
65
|
+
graphql = "Float"
|
|
66
|
+
xsd = "xsd:float"
|
|
67
|
+
sql = "FLOAT"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class Double(DataType):
|
|
71
|
+
name = "double"
|
|
72
|
+
python = float
|
|
73
|
+
dms = dms.Float64
|
|
74
|
+
graphql = "Float"
|
|
75
|
+
xsd = "xsd:double"
|
|
76
|
+
sql = "FLOAT"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class Integer(DataType):
|
|
80
|
+
name = "integer"
|
|
81
|
+
python = int
|
|
82
|
+
dms = dms.Int32
|
|
83
|
+
graphql = "Int"
|
|
84
|
+
xsd = "xsd:integer"
|
|
85
|
+
sql = "INTEGER"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class NonPositiveInteger(DataType):
|
|
89
|
+
name = "nonPositiveInteger"
|
|
90
|
+
python = int
|
|
91
|
+
dms = dms.Int32
|
|
92
|
+
graphql = "Int"
|
|
93
|
+
xsd = "xsd:nonPositiveInteger"
|
|
94
|
+
sql = "INTEGER"
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class NonNegativeInteger(DataType):
|
|
98
|
+
name = "nonNegativeInteger"
|
|
99
|
+
python = int
|
|
100
|
+
dms = dms.Int32
|
|
101
|
+
graphql = "Int"
|
|
102
|
+
xsd = "xsd:nonNegativeInteger"
|
|
103
|
+
sql = "INTEGER"
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class NegativeInteger(DataType):
|
|
107
|
+
name = "negativeInteger"
|
|
108
|
+
python = int
|
|
109
|
+
dms = dms.Int32
|
|
110
|
+
graphql = "Int"
|
|
111
|
+
xsd = "xsd:negativeInteger"
|
|
112
|
+
sql = "INTEGER"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Long(DataType):
|
|
116
|
+
name = "long"
|
|
117
|
+
python = int
|
|
118
|
+
dms = dms.Int64
|
|
119
|
+
graphql = "Int"
|
|
120
|
+
xsd = "xsd:long"
|
|
121
|
+
sql = "BIGINT"
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
class String(DataType):
|
|
125
|
+
name = "string"
|
|
126
|
+
python = str
|
|
127
|
+
dms = dms.Text
|
|
128
|
+
graphql = "String"
|
|
129
|
+
xsd = "xsd:string"
|
|
130
|
+
sql = "STRING"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class LangString(DataType):
|
|
134
|
+
name = "langString"
|
|
135
|
+
python = str
|
|
136
|
+
dms = dms.Text
|
|
137
|
+
graphql = "String"
|
|
138
|
+
xsd = "xsd:string"
|
|
139
|
+
sql = "STRING"
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class AnyURI(DataType):
|
|
143
|
+
name = "anyURI"
|
|
144
|
+
python = str
|
|
145
|
+
dms = dms.Text
|
|
146
|
+
graphql = "String"
|
|
147
|
+
xsd = "xsd:anyURI"
|
|
148
|
+
sql = "STRING"
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class NormalizedString(DataType):
|
|
152
|
+
name = "normalizedString"
|
|
153
|
+
python = str
|
|
154
|
+
dms = dms.Text
|
|
155
|
+
graphql = "String"
|
|
156
|
+
xsd = "xsd:normalizedString"
|
|
157
|
+
sql = "STRING"
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class Token(DataType):
|
|
161
|
+
name = "token"
|
|
162
|
+
python = str
|
|
163
|
+
dms = dms.Text
|
|
164
|
+
graphql = "String"
|
|
165
|
+
xsd = "xsd:string"
|
|
166
|
+
sql = "STRING"
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class DateTime(DataType):
|
|
170
|
+
name = "dateTime"
|
|
171
|
+
python = datetime
|
|
172
|
+
dms = dms.Timestamp
|
|
173
|
+
graphql = "Timestamp"
|
|
174
|
+
xsd = "xsd:dateTimeStamp"
|
|
175
|
+
sql = "TIMESTAMP"
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class DateTimeStamp(DataType):
|
|
179
|
+
name = "dateTimeStamp"
|
|
180
|
+
python = datetime
|
|
181
|
+
dms = dms.Timestamp
|
|
182
|
+
graphql = "Timestamp"
|
|
183
|
+
xsd = "xsd:dateTimeStamp"
|
|
184
|
+
sql = "TIMESTAMP"
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class Timestamp(DataType):
|
|
188
|
+
name = "timestamp"
|
|
189
|
+
python = datetime
|
|
190
|
+
dms = dms.Timestamp
|
|
191
|
+
graphql = "Timestamp"
|
|
192
|
+
xsd = "xsd:dateTimeStamp"
|
|
193
|
+
sql = "TIMESTAMP"
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class Date(DataType):
|
|
197
|
+
name = "date"
|
|
198
|
+
python = date
|
|
199
|
+
dms = dms.Date
|
|
200
|
+
graphql = "String"
|
|
201
|
+
xsd = "xsd:date"
|
|
202
|
+
sql = "DATE"
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class PlainLiteral(DataType):
|
|
206
|
+
name = "PlainLiteral"
|
|
207
|
+
python = str
|
|
208
|
+
dms = dms.Text
|
|
209
|
+
graphql = "String"
|
|
210
|
+
xsd = "xsd:string"
|
|
211
|
+
sql = "STRING"
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class Literal(DataType):
|
|
215
|
+
name = "Literal"
|
|
216
|
+
python = str
|
|
217
|
+
dms = dms.Text
|
|
218
|
+
graphql = "String"
|
|
219
|
+
xsd = "xsd:string"
|
|
220
|
+
sql = "STRING"
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class Timeseries(DataType):
|
|
224
|
+
name = "timeseries"
|
|
225
|
+
python = dms.TimeSeriesReference
|
|
226
|
+
dms = dms.TimeSeriesReference
|
|
227
|
+
graphql = "TimeSeries"
|
|
228
|
+
xsd = "xsd:string"
|
|
229
|
+
sql = "STRING"
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class File(DataType):
|
|
233
|
+
name = "file"
|
|
234
|
+
python = dms.FileReference
|
|
235
|
+
dms = dms.FileReference
|
|
236
|
+
graphql = "File"
|
|
237
|
+
xsd = "xsd:string"
|
|
238
|
+
sql = "STRING"
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class Sequence(DataType):
|
|
242
|
+
name = "sequence"
|
|
243
|
+
python = dms.SequenceReference
|
|
244
|
+
dms = dms.SequenceReference
|
|
245
|
+
graphql = "Sequence"
|
|
246
|
+
xsd = "xsd:string"
|
|
247
|
+
sql = "STRING"
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class Json(DataType):
|
|
251
|
+
name = "json"
|
|
252
|
+
python = dms.Json
|
|
253
|
+
dms = dms.Json
|
|
254
|
+
graphql = "Json"
|
|
255
|
+
xsd = "xsd:string"
|
|
256
|
+
sql = "STRING"
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
_DATA_TYPE_BY_NAME = {cls.name.casefold(): cls for cls in DataType.__subclasses__()}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
import threading
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
from functools import total_ordering
|
|
6
|
+
from typing import Annotated, Any, ClassVar, Generic, TypeVar
|
|
7
|
+
|
|
8
|
+
from cognite.client.data_classes.data_modeling.ids import ContainerId, DataModelId, PropertyId, ViewId
|
|
9
|
+
from pydantic import BaseModel, BeforeValidator, Field, PlainSerializer, model_serializer, model_validator
|
|
10
|
+
|
|
11
|
+
if sys.version_info >= (3, 11):
|
|
12
|
+
from enum import StrEnum
|
|
13
|
+
from typing import Self
|
|
14
|
+
else:
|
|
15
|
+
from backports.strenum import StrEnum
|
|
16
|
+
from typing_extensions import Self
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class EntityTypes(StrEnum):
|
|
20
|
+
view_non_versioned = "view_non_versioned"
|
|
21
|
+
subject = "subject"
|
|
22
|
+
predicate = "predicate"
|
|
23
|
+
object = "object"
|
|
24
|
+
class_ = "class"
|
|
25
|
+
parent_class = "parent_class"
|
|
26
|
+
property_ = "property"
|
|
27
|
+
object_property = "ObjectProperty"
|
|
28
|
+
data_property = "DatatypeProperty"
|
|
29
|
+
annotation_property = "AnnotationProperty"
|
|
30
|
+
object_value_type = "object_value_type"
|
|
31
|
+
data_value_type = "data_value_type" # these are strings, floats, ...
|
|
32
|
+
xsd_value_type = "xsd_value_type"
|
|
33
|
+
dms_value_type = "dms_value_type"
|
|
34
|
+
view = "view"
|
|
35
|
+
reference_entity = "reference_entity"
|
|
36
|
+
container = "container"
|
|
37
|
+
datamodel = "datamodel"
|
|
38
|
+
undefined = "undefined"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# ALLOWED
|
|
42
|
+
_ALLOWED_PATTERN = r"[^a-zA-Z0-9-_.]"
|
|
43
|
+
|
|
44
|
+
# FOR PARSING STRINGS:
|
|
45
|
+
_PREFIX_REGEX = r"[a-zA-Z]+[a-zA-Z0-9-_.]*[a-zA-Z0-9]+"
|
|
46
|
+
_SUFFIX_REGEX = r"[a-zA-Z0-9-_.]+[a-zA-Z0-9]|[-_.]*[a-zA-Z0-9]+"
|
|
47
|
+
_VERSION_REGEX = r"[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?"
|
|
48
|
+
_PROPERTY_REGEX = r"[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]?"
|
|
49
|
+
_ENTITY_ID_REGEX = rf"{_PREFIX_REGEX}:({_SUFFIX_REGEX})"
|
|
50
|
+
_ENTITY_ID_REGEX_COMPILED = re.compile(rf"^(?P<prefix>{_PREFIX_REGEX}):(?P<suffix>{_SUFFIX_REGEX})$")
|
|
51
|
+
_VERSIONED_ENTITY_REGEX_COMPILED = re.compile(
|
|
52
|
+
rf"^(?P<prefix>{_PREFIX_REGEX}):(?P<suffix>{_SUFFIX_REGEX})\(version=(?P<version>{_VERSION_REGEX})\)$"
|
|
53
|
+
)
|
|
54
|
+
_CLASS_ID_REGEX = rf"(?P<{EntityTypes.class_}>{_ENTITY_ID_REGEX})"
|
|
55
|
+
_CLASS_ID_REGEX_COMPILED = re.compile(rf"^{_CLASS_ID_REGEX}$")
|
|
56
|
+
_PROPERTY_ID_REGEX = rf"\((?P<{EntityTypes.property_}>{_ENTITY_ID_REGEX})\)"
|
|
57
|
+
|
|
58
|
+
_ENTITY_PATTERN = re.compile(r"^(?P<prefix>.*?):?(?P<suffix>[^(:]*)(\((?P<content>[^)]+)\))?$")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class _Undefined(BaseModel):
|
|
62
|
+
...
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class _Unknown(BaseModel):
|
|
66
|
+
def __str__(self) -> str:
|
|
67
|
+
return "#N/A"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# This is a trick to make Undefined and Unknown singletons
|
|
71
|
+
Undefined = _Undefined()
|
|
72
|
+
Unknown = _Unknown()
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@total_ordering
|
|
76
|
+
class Entity(BaseModel):
|
|
77
|
+
"""Entity is a class or property in OWL/RDF sense."""
|
|
78
|
+
|
|
79
|
+
type_: ClassVar[EntityTypes] = EntityTypes.undefined
|
|
80
|
+
prefix: str | _Undefined = Undefined
|
|
81
|
+
suffix: str | _Unknown
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def load(cls, data: Any) -> Self:
|
|
85
|
+
return cls.model_validate(data)
|
|
86
|
+
|
|
87
|
+
@model_validator(mode="before")
|
|
88
|
+
def _load(cls, data: Any) -> dict:
|
|
89
|
+
if isinstance(data, cls):
|
|
90
|
+
return data.model_dump()
|
|
91
|
+
elif isinstance(data, dict):
|
|
92
|
+
return data
|
|
93
|
+
elif hasattr(data, "versioned_id"):
|
|
94
|
+
# Todo: Remove. Is here for backwards compatibility
|
|
95
|
+
data = data.versioned_id
|
|
96
|
+
elif not isinstance(data, str):
|
|
97
|
+
raise ValueError(f"Cannot load {cls.__name__} from {data}")
|
|
98
|
+
|
|
99
|
+
return cls._parse(data)
|
|
100
|
+
|
|
101
|
+
@model_serializer(when_used="unless-none", return_type=str)
|
|
102
|
+
def as_str(self) -> str:
|
|
103
|
+
return str(self)
|
|
104
|
+
|
|
105
|
+
@classmethod
|
|
106
|
+
def _parse(cls, raw: str) -> dict:
|
|
107
|
+
if not (result := _ENTITY_PATTERN.match(raw)):
|
|
108
|
+
return dict(prefix=Undefined, suffix=Unknown)
|
|
109
|
+
prefix = result.group("prefix") or Undefined
|
|
110
|
+
suffix = result.group("suffix")
|
|
111
|
+
content = result.group("content")
|
|
112
|
+
if content is None:
|
|
113
|
+
return dict(prefix=prefix, suffix=suffix)
|
|
114
|
+
extra_args = dict(pair.strip().split("=") for pair in content.split(","))
|
|
115
|
+
expected_args = {field_.alias or field_name for field_name, field_ in cls.model_fields.items()}
|
|
116
|
+
for key in list(extra_args):
|
|
117
|
+
if key not in expected_args:
|
|
118
|
+
# Todo Warning about unknown key
|
|
119
|
+
del extra_args[key]
|
|
120
|
+
return dict(prefix=prefix, suffix=suffix, **extra_args)
|
|
121
|
+
|
|
122
|
+
def dump(self) -> str:
|
|
123
|
+
return str(self)
|
|
124
|
+
|
|
125
|
+
def as_tuple(self) -> tuple[str, ...]:
|
|
126
|
+
# We haver overwritten the serialization to str, so we need to do it manually
|
|
127
|
+
extra: tuple[str, ...] = tuple(
|
|
128
|
+
[
|
|
129
|
+
str(v or "")
|
|
130
|
+
for field_name in self.model_fields
|
|
131
|
+
if isinstance(v := getattr(self, field_name), str | None) and field_name not in {"prefix", "suffix"}
|
|
132
|
+
]
|
|
133
|
+
)
|
|
134
|
+
if isinstance(self.prefix, _Undefined):
|
|
135
|
+
return str(self.suffix), *extra
|
|
136
|
+
else:
|
|
137
|
+
return self.prefix, str(self.suffix), *extra
|
|
138
|
+
|
|
139
|
+
def __lt__(self, other: object) -> bool:
|
|
140
|
+
if not isinstance(other, Entity):
|
|
141
|
+
return NotImplemented
|
|
142
|
+
return self.as_tuple() < other.as_tuple()
|
|
143
|
+
|
|
144
|
+
def __eq__(self, other: object) -> bool:
|
|
145
|
+
if not isinstance(other, Entity):
|
|
146
|
+
return NotImplemented
|
|
147
|
+
return self.as_tuple() == other.as_tuple()
|
|
148
|
+
|
|
149
|
+
def __hash__(self) -> int:
|
|
150
|
+
return hash(str(self))
|
|
151
|
+
|
|
152
|
+
def __str__(self) -> str:
|
|
153
|
+
return self.id
|
|
154
|
+
|
|
155
|
+
def __repr__(self) -> str:
|
|
156
|
+
# We have overwritten the serialization to str, so we need to do it manually
|
|
157
|
+
model_dump = ((k, v) for k in self.model_fields if (v := getattr(self, k)) is not None)
|
|
158
|
+
args = ",".join([f"{k}={v}" for k, v in model_dump])
|
|
159
|
+
return f"{self.type_.value}({args})"
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def id(self) -> str:
|
|
163
|
+
# We have overwritten the serialization to str, so we need to do it manually
|
|
164
|
+
model_dump = (
|
|
165
|
+
(field.alias or field_name, v)
|
|
166
|
+
for field_name, field in self.model_fields.items()
|
|
167
|
+
if (v := getattr(self, field_name)) is not None and field_name not in {"prefix", "suffix"}
|
|
168
|
+
)
|
|
169
|
+
args = ",".join([f"{k}={v}" for k, v in model_dump])
|
|
170
|
+
if self.prefix is Undefined:
|
|
171
|
+
base_id = str(self.suffix)
|
|
172
|
+
else:
|
|
173
|
+
base_id = f"{self.prefix}:{self.suffix!s}"
|
|
174
|
+
if args:
|
|
175
|
+
return f"{base_id}({args})"
|
|
176
|
+
else:
|
|
177
|
+
return base_id
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def versioned_id(self) -> str:
|
|
181
|
+
# Todo: Remove. Is here for backwards compatibility
|
|
182
|
+
return self.id
|
|
183
|
+
|
|
184
|
+
def as_non_versioned_entity(self) -> str:
|
|
185
|
+
# Todo: Remove. Is here for backwards compatibility
|
|
186
|
+
if self.prefix is Undefined:
|
|
187
|
+
return f"{self.suffix!s}"
|
|
188
|
+
return f"{self.prefix}:{self.suffix!s}"
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
class ClassEntity(Entity):
|
|
192
|
+
type_: ClassVar[EntityTypes] = EntityTypes.class_
|
|
193
|
+
version: str | None = None
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class ParentClassEntity(ClassEntity):
|
|
197
|
+
type_: ClassVar[EntityTypes] = EntityTypes.parent_class
|
|
198
|
+
|
|
199
|
+
def as_class_entity(self) -> ClassEntity:
|
|
200
|
+
return ClassEntity(prefix=self.prefix, suffix=self.suffix, version=self.version)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
T_ID = TypeVar("T_ID", bound=ContainerId | ViewId | DataModelId | PropertyId)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class DMSEntity(Entity, Generic[T_ID], ABC):
|
|
207
|
+
type_: ClassVar[EntityTypes] = EntityTypes.undefined
|
|
208
|
+
default_space_by_thread: ClassVar[dict[threading.Thread, str]] = {}
|
|
209
|
+
suffix: str
|
|
210
|
+
|
|
211
|
+
@classmethod
|
|
212
|
+
def set_default_space(cls, space: str) -> None:
|
|
213
|
+
cls.default_space_by_thread[threading.current_thread()] = space
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def space(self) -> str:
|
|
217
|
+
"""Returns entity space in CDF."""
|
|
218
|
+
if isinstance(self.prefix, _Undefined):
|
|
219
|
+
return self.default_space_by_thread.get(threading.current_thread(), "MISSING")
|
|
220
|
+
else:
|
|
221
|
+
return self.prefix
|
|
222
|
+
|
|
223
|
+
@property
|
|
224
|
+
def external_id(self) -> str:
|
|
225
|
+
"""Returns entity external id in CDF."""
|
|
226
|
+
return self.suffix
|
|
227
|
+
|
|
228
|
+
@abstractmethod
|
|
229
|
+
def as_id(self) -> T_ID:
|
|
230
|
+
raise NotImplementedError("Method as_id must be implemented in subclasses")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class ContainerEntity(DMSEntity[ContainerId]):
|
|
234
|
+
type_: ClassVar[EntityTypes] = EntityTypes.container
|
|
235
|
+
|
|
236
|
+
def as_id(self) -> ContainerId:
|
|
237
|
+
return ContainerId(space=self.space, external_id=self.external_id)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class DMSVersionedEntity(DMSEntity[T_ID], ABC):
|
|
241
|
+
version: str | None = None
|
|
242
|
+
default_version_by_thread: ClassVar[dict[threading.Thread, str]] = {}
|
|
243
|
+
|
|
244
|
+
@property
|
|
245
|
+
def version_with_fallback(self) -> str:
|
|
246
|
+
if self.version is not None:
|
|
247
|
+
return self.version
|
|
248
|
+
return self.default_version_by_thread.get(threading.current_thread(), "MISSING")
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
class ViewEntity(DMSVersionedEntity[ViewId]):
|
|
252
|
+
type_: ClassVar[EntityTypes] = EntityTypes.view
|
|
253
|
+
|
|
254
|
+
def as_id(
|
|
255
|
+
self,
|
|
256
|
+
) -> ViewId:
|
|
257
|
+
return ViewId(space=self.space, external_id=self.external_id, version=self.version_with_fallback)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class PropertyEntity(DMSVersionedEntity[PropertyId]):
|
|
261
|
+
type_: ClassVar[EntityTypes] = EntityTypes.property_
|
|
262
|
+
property_: str = Field(alias="property")
|
|
263
|
+
|
|
264
|
+
def as_id(self) -> PropertyId:
|
|
265
|
+
return PropertyId(
|
|
266
|
+
source=ViewId(self.space, self.external_id, self.version_with_fallback), property=self.property_
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class DataModelEntity(DMSVersionedEntity[DataModelId]):
|
|
271
|
+
type_: ClassVar[EntityTypes] = EntityTypes.datamodel
|
|
272
|
+
|
|
273
|
+
def as_id(self) -> DataModelId:
|
|
274
|
+
return DataModelId(space=self.space, external_id=self.external_id, version=self.version_with_fallback)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class ReferenceEntity(PropertyEntity):
|
|
278
|
+
type_: ClassVar[EntityTypes] = EntityTypes.reference_entity
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def _split_str(v: Any) -> list[str]:
|
|
282
|
+
if isinstance(v, str):
|
|
283
|
+
return v.replace(", ", ",").split(",")
|
|
284
|
+
return v
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def _join_str(v: list[ClassEntity]) -> str | None:
|
|
288
|
+
return ",".join([entry.id for entry in v]) if v else None
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
ParentEntityList = Annotated[
|
|
292
|
+
list[ParentClassEntity],
|
|
293
|
+
BeforeValidator(_split_str),
|
|
294
|
+
PlainSerializer(
|
|
295
|
+
_join_str,
|
|
296
|
+
return_type=str,
|
|
297
|
+
when_used="unless-none",
|
|
298
|
+
),
|
|
299
|
+
]
|