cognite-neat 0.85.12__tar.gz → 0.87.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.85.12 → cognite_neat-0.87.0}/PKG-INFO +1 -1
- cognite_neat-0.87.0/cognite/neat/_version.py +1 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/core.py +4 -4
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/constants.py +11 -9
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_mock_graph_generator.py +8 -9
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/loaders/__init__.py +5 -2
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/loaders/_base.py +13 -5
- cognite_neat-0.87.0/cognite/neat/graph/loaders/_rdf2asset.py +197 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/loaders/_rdf2dms.py +3 -16
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/queries/_base.py +58 -5
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/queries/_construct.py +17 -15
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/queries/_shared.py +20 -6
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/stores/_base.py +19 -10
- cognite_neat-0.87.0/cognite/neat/graph/transformers/_rdfpath.py +7 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/extractors/_dexpi.py +0 -5
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_base.py +24 -8
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_graphdb_store.py +3 -2
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_memory_store.py +3 -3
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_oxigraph_store.py +8 -4
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_rdf_to_graph.py +5 -3
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/transformations/query_generator/sparql.py +48 -15
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_graph2rules.py +34 -7
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/raw_rules.py +18 -6
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/rules.py +32 -12
- cognite_neat-0.87.0/cognite/neat/rules/_shared.py +10 -0
- cognite_neat-0.87.0/cognite/neat/rules/analysis/__init__.py +6 -0
- cognite_neat-0.87.0/cognite/neat/rules/analysis/_asset.py +128 -0
- cognite_neat-0.87.0/cognite/neat/rules/analysis/_base.py +392 -0
- cognite_neat-0.87.0/cognite/neat/rules/analysis/_information.py +155 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_base.py +4 -4
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_rules2dms.py +1 -1
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_rules2ontology.py +5 -5
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_base.py +4 -4
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +2 -8
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_inference2rules.py +2 -2
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +1 -1
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_spreadsheet2rules.py +5 -5
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/__init__.py +3 -3
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_base.py +10 -10
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/_rules.py +9 -10
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_converter.py +4 -5
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_rules.py +6 -3
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/domain.py +5 -2
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/entities.py +2 -9
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/_converter.py +3 -3
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/_rules.py +13 -11
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/_rules_input.py +1 -2
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/_validation.py +1 -1
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/utils.py +54 -18
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/graph_store.py +28 -8
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/graph_extractor.py +129 -27
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/graph_store.py +4 -4
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/pyproject.toml +1 -1
- cognite_neat-0.85.12/cognite/neat/_version.py +0 -1
- cognite_neat-0.85.12/cognite/neat/graph/loaders/_rdf2asset.py +0 -123
- cognite_neat-0.85.12/cognite/neat/rules/_shared.py +0 -5
- cognite_neat-0.85.12/cognite/neat/rules/analysis/__init__.py +0 -6
- cognite_neat-0.85.12/cognite/neat/rules/analysis/_base.py +0 -13
- cognite_neat-0.85.12/cognite/neat/rules/analysis/_information_rules.py +0 -469
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/LICENSE +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/README.md +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/configuration.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/explorer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/configuration.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/crud.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/data_exploration.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/metrics.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/routers/workflows.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/utils/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/utils/logging.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/main.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/monitoring/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/monitoring/metrics.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/index.html +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.LICENSE.txt +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.map +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/config.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/_shared.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/_tracking/base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/_tracking/log.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/examples/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/issues/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/issues/loader.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/models.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/queries/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/stores/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/stores/_provenance.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/transformers/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/transformers/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/transformers/_classic_cdf.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/issues.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/examples/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/extractors/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/extractors/_graph_capturing_sheet.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/_asset_loader.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/_exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/core/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/core/labels.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/core/models.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/rdf_to_dms.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/loaders/validator.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/models.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/transformations/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/transformations/entity_matcher.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/transformations/query_generator/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/graph/transformations/transformer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/analysis.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/Rules-Nordic44.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/power-grid-containers.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/power-grid-example.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/power-grid-model.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/rules-template.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/skos-rules.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_core/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_core/rules2labels.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2graphql.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_rules2triples.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_dict2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_json2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_xsd2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/rdfpath.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/tables.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/rules/models/value_types.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/py.typed +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/examples/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_rules2excel.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_owl2rules/_owl2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/dms.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/fileread.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/formatters.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/importing.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/spreadsheet.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/issues/spreadsheet_file.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_constants.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_rdfpath.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_types/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_types/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/_types/_field.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/_converter.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/_rules_input.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/_serializer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/asset/_validation.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/data_types.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_exporter.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_rules_input.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_schema.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_serializer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/dms/_validation.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/information/_serializer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/rules/models/wrapped_entities.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/auth.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/auxiliary.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_classes.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_loaders/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_loaders/_base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_loaders/_data_modeling.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_loaders/_ingestion.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/cdf_loaders/data_classes.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/spreadsheet.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/text.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/upload.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/utils/xml_.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/_exceptions.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/base.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/cdf_store.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/manager.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/migration/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/migration/steps.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/migration/wf_manifests.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/model.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/rules_exporter.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/rules_importer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/current/rules_validator.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/__init__.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/graph_contextualization.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/graph_loader.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/graph_transformer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/rules_exporter.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/lib/legacy/rules_importer.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps/step_model.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/steps_registry.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/tasks.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/triggers.py +0 -0
- {cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/workflows/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.87.0"
|
|
@@ -31,21 +31,21 @@ async def convert_data_model_to_rules(file: UploadFile):
|
|
|
31
31
|
|
|
32
32
|
# read as Excel rules
|
|
33
33
|
if suffix == ".xlsx":
|
|
34
|
-
rules, issues = importers.ExcelImporter(filepath=temp_filepath).to_rules(role=RoleTypes.
|
|
34
|
+
rules, issues = importers.ExcelImporter(filepath=temp_filepath).to_rules(role=RoleTypes.dms)
|
|
35
35
|
|
|
36
36
|
# load as OWL
|
|
37
37
|
elif suffix in [".ttl", ".owl"]:
|
|
38
|
-
rules, issues = importers.OWLImporter(filepath=temp_filepath).to_rules(role=RoleTypes.
|
|
38
|
+
rules, issues = importers.OWLImporter(filepath=temp_filepath).to_rules(role=RoleTypes.dms)
|
|
39
39
|
|
|
40
40
|
# load as YAML
|
|
41
41
|
elif suffix in [".yml", ".yaml"]:
|
|
42
|
-
rules, issues = importers.YAMLImporter.from_file(temp_filepath).to_rules(role=RoleTypes.
|
|
42
|
+
rules, issues = importers.YAMLImporter.from_file(temp_filepath).to_rules(role=RoleTypes.dms)
|
|
43
43
|
|
|
44
44
|
# load as JSON
|
|
45
45
|
elif suffix == ".json":
|
|
46
46
|
with temp_filepath.open() as temp:
|
|
47
47
|
json_data = json.load(temp)
|
|
48
|
-
rules, issues = importers.YAMLImporter(raw_data=json.loads(json_data)).to_rules(role=RoleTypes.
|
|
48
|
+
rules, issues = importers.YAMLImporter(raw_data=json.loads(json_data)).to_rules(role=RoleTypes.dms)
|
|
49
49
|
|
|
50
50
|
# Remove the temporary file
|
|
51
51
|
temp_filepath.unlink()
|
|
@@ -14,15 +14,17 @@ EXAMPLE_WORKFLOWS = PACKAGE_DIRECTORY / "workflows" / "examples"
|
|
|
14
14
|
|
|
15
15
|
DEFAULT_NAMESPACE = Namespace("http://purl.org/cognite/neat#")
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
|
|
18
|
+
def get_default_prefixes() -> dict[str, Namespace]:
|
|
19
|
+
return {
|
|
20
|
+
"rdf": RDF._NS,
|
|
21
|
+
"rdfs": RDFS._NS,
|
|
22
|
+
"dct": DCTERMS._NS,
|
|
23
|
+
"skos": SKOS._NS,
|
|
24
|
+
"owl": OWL._NS,
|
|
25
|
+
"xsd": XSD._NS,
|
|
26
|
+
"pav": Namespace("http://purl.org/pav/"),
|
|
27
|
+
}
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
DEFAULT_URI = ""
|
{cognite_neat-0.85.12 → cognite_neat-0.87.0}/cognite/neat/graph/extractors/_mock_graph_generator.py
RENAMED
|
@@ -12,7 +12,7 @@ import pandas as pd
|
|
|
12
12
|
from rdflib import RDF, Literal, Namespace, URIRef
|
|
13
13
|
|
|
14
14
|
from cognite.neat.graph.models import Triple
|
|
15
|
-
from cognite.neat.rules.analysis import
|
|
15
|
+
from cognite.neat.rules.analysis import InformationAnalysis
|
|
16
16
|
from cognite.neat.rules.models import DMSRules, InformationRules
|
|
17
17
|
from cognite.neat.rules.models.data_types import DataType
|
|
18
18
|
from cognite.neat.rules.models.entities import ClassEntity, EntityTypes
|
|
@@ -42,7 +42,7 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
42
42
|
allow_isolated_classes: bool = True,
|
|
43
43
|
):
|
|
44
44
|
if isinstance(rules, DMSRules):
|
|
45
|
-
self.rules = rules.
|
|
45
|
+
self.rules = rules.as_information_rules()
|
|
46
46
|
elif isinstance(rules, InformationRules):
|
|
47
47
|
self.rules = rules
|
|
48
48
|
else:
|
|
@@ -50,8 +50,7 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
50
50
|
|
|
51
51
|
if not class_count:
|
|
52
52
|
self.class_count = {
|
|
53
|
-
class_: 1
|
|
54
|
-
for class_ in InformationArchitectRulesAnalysis(self.rules).defined_classes(consider_inheritance=True)
|
|
53
|
+
class_: 1 for class_ in InformationAnalysis(self.rules).defined_classes(consider_inheritance=True)
|
|
55
54
|
}
|
|
56
55
|
elif all(isinstance(key, str) for key in class_count.keys()):
|
|
57
56
|
self.class_count = {
|
|
@@ -101,7 +100,7 @@ def generate_triples(
|
|
|
101
100
|
"""
|
|
102
101
|
|
|
103
102
|
namespace = rules.metadata.namespace
|
|
104
|
-
defined_classes =
|
|
103
|
+
defined_classes = InformationAnalysis(rules).defined_classes(consider_inheritance=True)
|
|
105
104
|
|
|
106
105
|
if non_existing_classes := set(class_count.keys()) - defined_classes:
|
|
107
106
|
msg = f"Class count contains classes {non_existing_classes} for which properties are not defined in Data Model!"
|
|
@@ -115,16 +114,16 @@ def generate_triples(
|
|
|
115
114
|
|
|
116
115
|
# Subset data model to only classes that are defined in class count
|
|
117
116
|
rules = (
|
|
118
|
-
|
|
117
|
+
InformationAnalysis(rules).subset_rules(set(class_count.keys()))
|
|
119
118
|
if defined_classes != set(class_count.keys())
|
|
120
119
|
else rules
|
|
121
120
|
)
|
|
122
121
|
|
|
123
|
-
class_linkage =
|
|
122
|
+
class_linkage = InformationAnalysis(rules).class_linkage().to_pandas()
|
|
124
123
|
|
|
125
124
|
# Remove one of symmetric pairs from class linkage to maintain proper linking
|
|
126
125
|
# among instances of symmetrically linked classes
|
|
127
|
-
if sym_pairs :=
|
|
126
|
+
if sym_pairs := InformationAnalysis(rules).symmetrically_connected_classes():
|
|
128
127
|
class_linkage = _remove_higher_occurring_sym_pair(class_linkage, sym_pairs)
|
|
129
128
|
|
|
130
129
|
# Remove any of symmetric pairs containing classes that are not present class count
|
|
@@ -134,7 +133,7 @@ def generate_triples(
|
|
|
134
133
|
generation_order = _prettify_generation_order(_get_generation_order(class_linkage))
|
|
135
134
|
|
|
136
135
|
# Generated simple view of data model
|
|
137
|
-
class_property_pairs =
|
|
136
|
+
class_property_pairs = InformationAnalysis(rules).classes_with_properties(consider_inheritance=True)
|
|
138
137
|
|
|
139
138
|
# pregenerate instance ids for each remaining class
|
|
140
139
|
instance_ids = {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from ._base import BaseLoader, CDFLoader
|
|
2
|
+
from ._rdf2asset import AssetLoader
|
|
2
3
|
from ._rdf2dms import DMSLoader
|
|
3
4
|
|
|
4
|
-
__all__ = ["BaseLoader", "CDFLoader", "DMSLoader"]
|
|
5
|
+
__all__ = ["BaseLoader", "CDFLoader", "DMSLoader", "AssetLoader"]
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def _repr_html_() -> str:
|
|
@@ -11,7 +12,9 @@ def _repr_html_() -> str:
|
|
|
11
12
|
[
|
|
12
13
|
{
|
|
13
14
|
"Loader": name,
|
|
14
|
-
"Description":
|
|
15
|
+
"Description": (
|
|
16
|
+
globals()[name].__doc__.strip().split("\n")[0] if globals()[name].__doc__ else "Missing"
|
|
17
|
+
),
|
|
15
18
|
}
|
|
16
19
|
for name in __all__
|
|
17
20
|
if name not in ("BaseLoader", "CDFLoader")
|
|
@@ -15,6 +15,11 @@ from cognite.neat.utils.upload import UploadResult, UploadResultList
|
|
|
15
15
|
T_Output = TypeVar("T_Output")
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
# Sentinel value to indicate in the load method that all instances of a class have been loaded.
|
|
19
|
+
# https://en.wikipedia.org/wiki/Sentinel_value
|
|
20
|
+
class _END_OF_CLASS: ...
|
|
21
|
+
|
|
22
|
+
|
|
18
23
|
class BaseLoader(ABC, Generic[T_Output]):
|
|
19
24
|
_new_line = "\n"
|
|
20
25
|
_encoding = "utf-8"
|
|
@@ -28,10 +33,10 @@ class BaseLoader(ABC, Generic[T_Output]):
|
|
|
28
33
|
|
|
29
34
|
def load(self, stop_on_exception: bool = False) -> Iterable[T_Output | NeatIssue]:
|
|
30
35
|
"""Load the graph with data."""
|
|
31
|
-
return self._load(stop_on_exception)
|
|
36
|
+
return (item for item in self._load(stop_on_exception) if item is not _END_OF_CLASS) # type: ignore[misc]
|
|
32
37
|
|
|
33
38
|
@abstractmethod
|
|
34
|
-
def _load(self, stop_on_exception: bool = False) -> Iterable[T_Output | NeatIssue]:
|
|
39
|
+
def _load(self, stop_on_exception: bool = False) -> Iterable[T_Output | NeatIssue | type[_END_OF_CLASS]]:
|
|
35
40
|
"""Load the graph with data."""
|
|
36
41
|
pass
|
|
37
42
|
|
|
@@ -58,13 +63,16 @@ class CDFLoader(BaseLoader[T_Output]):
|
|
|
58
63
|
|
|
59
64
|
issues = NeatIssueList[NeatIssue]()
|
|
60
65
|
items: list[T_Output] = []
|
|
61
|
-
for result in self.
|
|
66
|
+
for result in self._load(stop_on_exception=False):
|
|
62
67
|
if isinstance(result, NeatIssue):
|
|
63
68
|
issues.append(result)
|
|
69
|
+
elif result is _END_OF_CLASS:
|
|
70
|
+
...
|
|
64
71
|
else:
|
|
65
|
-
|
|
72
|
+
# MyPy does not understand else means the item will be of type T_Output
|
|
73
|
+
items.append(result) # type: ignore[arg-type]
|
|
66
74
|
|
|
67
|
-
if len(items) >= self._UPLOAD_BATCH_SIZE:
|
|
75
|
+
if len(items) >= self._UPLOAD_BATCH_SIZE or result is _END_OF_CLASS:
|
|
68
76
|
yield from self._upload_to_cdf(client, items, dry_run, issues)
|
|
69
77
|
issues = NeatIssueList[NeatIssue]()
|
|
70
78
|
items = []
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
from collections import defaultdict
|
|
2
|
+
from collections.abc import Iterable, Sequence
|
|
3
|
+
from dataclasses import dataclass, fields
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from cognite.client import CogniteClient
|
|
7
|
+
from cognite.client.data_classes import AssetWrite
|
|
8
|
+
from cognite.client.data_classes.capabilities import Capability
|
|
9
|
+
|
|
10
|
+
from cognite.neat.graph._tracking.base import Tracker
|
|
11
|
+
from cognite.neat.graph._tracking.log import LogTracker
|
|
12
|
+
from cognite.neat.graph.issues import loader as loader_issues
|
|
13
|
+
from cognite.neat.graph.stores import NeatGraphStore
|
|
14
|
+
from cognite.neat.issues import NeatIssue, NeatIssueList
|
|
15
|
+
from cognite.neat.rules.analysis._asset import AssetAnalysis
|
|
16
|
+
from cognite.neat.rules.models import AssetRules
|
|
17
|
+
from cognite.neat.utils.upload import UploadResult
|
|
18
|
+
|
|
19
|
+
from ._base import _END_OF_CLASS, CDFLoader
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class AssetLoaderMetadataKeys:
|
|
24
|
+
"""Class holding mapping between NEAT metadata key names and their desired names
|
|
25
|
+
in CDF Asset metadata
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
start_time: Start time key name
|
|
29
|
+
end_time: End time key name
|
|
30
|
+
update_time: Update time key name
|
|
31
|
+
resurrection_time: Resurrection time key name
|
|
32
|
+
identifier: Identifier key name
|
|
33
|
+
active: Active key name
|
|
34
|
+
type: Type key name
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
start_time: str = "start_time"
|
|
38
|
+
end_time: str = "end_time"
|
|
39
|
+
update_time: str = "update_time"
|
|
40
|
+
resurrection_time: str = "resurrection_time"
|
|
41
|
+
identifier: str = "identifier"
|
|
42
|
+
active: str = "active"
|
|
43
|
+
type: str = "type"
|
|
44
|
+
|
|
45
|
+
def as_aliases(self) -> dict[str, str]:
|
|
46
|
+
return {str(field.default): getattr(self, field.name) for field in fields(self)}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class AssetLoader(CDFLoader[AssetWrite]):
|
|
50
|
+
"""Load Assets from NeatGraph to Cognite Data Fusions.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
graph_store (NeatGraphStore): The graph store to load the data into.
|
|
54
|
+
rules (AssetRules): The rules to load the assets with.
|
|
55
|
+
data_set_id (int): The CDF data set id to load the Assets into.
|
|
56
|
+
use_orphanage (bool): Whether to use an orphanage for assets that are not part
|
|
57
|
+
of the hierarchy. Defaults to False.
|
|
58
|
+
use_labels (bool): Whether to use labels for assets. Defaults to False.
|
|
59
|
+
asset_external_id_prefix (str | None): The prefix to use for the external id of the assets.
|
|
60
|
+
Defaults to None.
|
|
61
|
+
metadata_keys (AssetLoaderMetadataKeys | None): Mapping between NEAT metadata key names and
|
|
62
|
+
their desired names in CDF Asset metadata. Defaults to None.
|
|
63
|
+
create_issues (Sequence[NeatIssue] | None): A list of issues that occurred during reading. Defaults to None.
|
|
64
|
+
tracker (type[Tracker] | None): The tracker to use. Defaults to None.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
graph_store: NeatGraphStore,
|
|
70
|
+
rules: AssetRules,
|
|
71
|
+
data_set_id: int,
|
|
72
|
+
use_orphanage: bool = False,
|
|
73
|
+
use_labels: bool = False,
|
|
74
|
+
asset_external_id_prefix: str | None = None,
|
|
75
|
+
metadata_keys: AssetLoaderMetadataKeys | None = None,
|
|
76
|
+
create_issues: Sequence[NeatIssue] | None = None,
|
|
77
|
+
tracker: type[Tracker] | None = None,
|
|
78
|
+
):
|
|
79
|
+
super().__init__(graph_store)
|
|
80
|
+
|
|
81
|
+
self.rules = rules
|
|
82
|
+
self.data_set_id = data_set_id
|
|
83
|
+
self.use_labels = use_labels
|
|
84
|
+
self.use_orphanage = use_orphanage
|
|
85
|
+
|
|
86
|
+
self.orphanage_external_id = (
|
|
87
|
+
f"{asset_external_id_prefix or ''}orphanage-{data_set_id}" if use_orphanage else None
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
self.asset_external_id_prefix = asset_external_id_prefix
|
|
91
|
+
self.metadata_keys = metadata_keys or AssetLoaderMetadataKeys()
|
|
92
|
+
|
|
93
|
+
self._issues = NeatIssueList[NeatIssue](create_issues or [])
|
|
94
|
+
self._tracker: type[Tracker] = tracker or LogTracker
|
|
95
|
+
|
|
96
|
+
def _create_validation_classes(self) -> None:
|
|
97
|
+
# need to get back class-property pairs where are definition of
|
|
98
|
+
# asset implementations, extend InformationRulesAnalysis make it generic
|
|
99
|
+
|
|
100
|
+
# by default if there is not explicitly stated external_id
|
|
101
|
+
# use rdf:type and drop the prefix
|
|
102
|
+
|
|
103
|
+
# based on those create pydantic model AssetDefinition
|
|
104
|
+
# which will have .to_asset_write()
|
|
105
|
+
|
|
106
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
107
|
+
|
|
108
|
+
def categorize_assets(self, client: CogniteClient) -> None:
|
|
109
|
+
"""Categorize assets to those to be created, updated, decommissioned, or resurrected"""
|
|
110
|
+
|
|
111
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
112
|
+
|
|
113
|
+
def _load(self, stop_on_exception: bool = False) -> Iterable[AssetWrite | NeatIssue | type[_END_OF_CLASS]]:
|
|
114
|
+
if self._issues.has_errors and stop_on_exception:
|
|
115
|
+
raise self._issues.as_exception()
|
|
116
|
+
elif self._issues.has_errors:
|
|
117
|
+
yield from self._issues
|
|
118
|
+
return
|
|
119
|
+
if not self.rules:
|
|
120
|
+
# There should already be an error in this case.
|
|
121
|
+
return
|
|
122
|
+
|
|
123
|
+
class_ids = [repr(class_.class_.id) for class_ in self.rules.classes]
|
|
124
|
+
tracker = self._tracker(type(self).__name__, class_ids, "classes")
|
|
125
|
+
|
|
126
|
+
for class_ in self.rules.classes:
|
|
127
|
+
tracker.start(repr(class_.class_.id))
|
|
128
|
+
|
|
129
|
+
property_renaming_config = AssetAnalysis(self.rules).define_property_renaming_config(class_.class_)
|
|
130
|
+
|
|
131
|
+
for identifier, properties in self.graph_store.read(class_.class_.suffix):
|
|
132
|
+
fields = _process_properties(properties, property_renaming_config)
|
|
133
|
+
# set data set id and external id
|
|
134
|
+
fields["data_set_id"] = self.data_set_id
|
|
135
|
+
fields["external_id"] = identifier
|
|
136
|
+
|
|
137
|
+
try:
|
|
138
|
+
yield AssetWrite.load(fields)
|
|
139
|
+
except KeyError as e:
|
|
140
|
+
error = loader_issues.InvalidInstanceError(type_="asset", identifier=identifier, reason=str(e))
|
|
141
|
+
tracker.issue(error)
|
|
142
|
+
if stop_on_exception:
|
|
143
|
+
raise error.as_exception() from e
|
|
144
|
+
yield error
|
|
145
|
+
yield _END_OF_CLASS
|
|
146
|
+
|
|
147
|
+
def load_to_cdf(self, client: CogniteClient, dry_run: bool = False) -> Sequence[AssetWrite]:
|
|
148
|
+
# generate assets
|
|
149
|
+
# check for circular asset hierarchy
|
|
150
|
+
# check for orphaned assets
|
|
151
|
+
# batch upsert of assets to CDF (otherwise we will hit the API rate limit)
|
|
152
|
+
|
|
153
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
154
|
+
|
|
155
|
+
@classmethod
|
|
156
|
+
def _check_for_circular_asset_hierarchy(cls, assets: list[AssetWrite]) -> None:
|
|
157
|
+
"""Check for circular references in the asset rules"""
|
|
158
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
159
|
+
|
|
160
|
+
@classmethod
|
|
161
|
+
def _check_for_orphaned_assets(cls, assets: list[AssetWrite]) -> None:
|
|
162
|
+
"""Check for circular references in the asset rules"""
|
|
163
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
164
|
+
|
|
165
|
+
def _get_required_capabilities(self) -> list[Capability]:
|
|
166
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
167
|
+
|
|
168
|
+
def _upload_to_cdf(
|
|
169
|
+
self,
|
|
170
|
+
client: CogniteClient,
|
|
171
|
+
items: list[AssetWrite],
|
|
172
|
+
dry_run: bool,
|
|
173
|
+
read_issues: NeatIssueList,
|
|
174
|
+
) -> Iterable[UploadResult]:
|
|
175
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
176
|
+
|
|
177
|
+
def write_to_file(self, filepath: Path) -> None:
|
|
178
|
+
raise NotImplementedError("Not implemented yet, this is placeholder")
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _process_properties(properties: dict[str, list[str]], property_renaming_config: dict[str, str]) -> dict:
|
|
182
|
+
metadata: dict[str, str] = defaultdict(str)
|
|
183
|
+
fields: dict[str, str | dict] = {}
|
|
184
|
+
|
|
185
|
+
for original_property, values in properties.items():
|
|
186
|
+
if renamed_property := property_renaming_config.get(original_property, None):
|
|
187
|
+
if renamed_property.startswith("metadata."):
|
|
188
|
+
# Asset metadata contains only string values
|
|
189
|
+
metadata[original_property] = ", ".join(values)
|
|
190
|
+
else:
|
|
191
|
+
# Asset fields can contain only one value
|
|
192
|
+
fields[renamed_property] = values[0]
|
|
193
|
+
|
|
194
|
+
if metadata:
|
|
195
|
+
fields["metadata"] = metadata
|
|
196
|
+
|
|
197
|
+
return fields
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from collections import defaultdict
|
|
3
2
|
from collections.abc import Iterable, Sequence
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from typing import Any, get_args
|
|
@@ -28,7 +27,7 @@ from ._base import CDFLoader
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
31
|
-
"""
|
|
30
|
+
"""Loads Instances to Cognite Data Fusion Data Model Service from NeatGraph.
|
|
32
31
|
|
|
33
32
|
Args:
|
|
34
33
|
graph_store (NeatGraphStore): The graph store to load the data into.
|
|
@@ -106,8 +105,8 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
106
105
|
yield from issues
|
|
107
106
|
tracker.issue(issues)
|
|
108
107
|
class_name = self.class_by_view_id.get(view.as_id(), view.external_id)
|
|
109
|
-
|
|
110
|
-
for identifier, properties in
|
|
108
|
+
|
|
109
|
+
for identifier, properties in self.graph_store.read(class_name):
|
|
111
110
|
try:
|
|
112
111
|
yield self._create_node(identifier, properties, pydantic_cls, view_id)
|
|
113
112
|
except ValueError as e:
|
|
@@ -318,15 +317,3 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
318
317
|
|
|
319
318
|
def _get_field_value_types(cls, info):
|
|
320
319
|
return [type_.__name__ for type_ in get_args(cls.model_fields[info.field_name].annotation)]
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
def _triples2dictionary(
|
|
324
|
-
triples: Iterable[tuple[str, str, str]],
|
|
325
|
-
) -> dict[str, dict[str, list[str]]]:
|
|
326
|
-
"""Converts list of triples to dictionary"""
|
|
327
|
-
values_by_property_by_identifier: dict[str, dict[str, list[str]]] = defaultdict(lambda: defaultdict(list))
|
|
328
|
-
for id_, property_, value in triples:
|
|
329
|
-
# avoid issue with strings "None", "nan", "null" being treated as values
|
|
330
|
-
if value.lower() not in ["", "None", "nan", "null"]:
|
|
331
|
-
values_by_property_by_identifier[id_][property_].append(value)
|
|
332
|
-
return values_by_property_by_identifier
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import warnings
|
|
2
|
+
from collections import defaultdict
|
|
2
3
|
from typing import Literal, cast, overload
|
|
3
4
|
|
|
4
5
|
from rdflib import RDF, Graph, URIRef
|
|
@@ -93,12 +94,63 @@ class Queries:
|
|
|
93
94
|
)
|
|
94
95
|
return []
|
|
95
96
|
|
|
96
|
-
def
|
|
97
|
+
def describe(
|
|
98
|
+
self,
|
|
99
|
+
instance_id: URIRef,
|
|
100
|
+
property_renaming_config: dict | None = None,
|
|
101
|
+
) -> tuple[str, dict[str, list[str]]]:
|
|
102
|
+
"""DESCRIBE instance for a given class from the graph store
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
instance_id: Instance id for which we want to generate query
|
|
106
|
+
property_rename_config: Dictionary to rename properties, default None
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Dictionary of instance properties
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
property_values: dict[str, list[str]] = defaultdict(list)
|
|
113
|
+
|
|
114
|
+
for subject, predicate, object_ in cast(list[ResultRow], self.graph.query(f"DESCRIBE <{instance_id}>")):
|
|
115
|
+
# We cannot include the RDF.type in case there is a neat:type property
|
|
116
|
+
# or if the object is empty
|
|
117
|
+
if predicate != RDF.type and object_.lower() not in [
|
|
118
|
+
"",
|
|
119
|
+
"none",
|
|
120
|
+
"nan",
|
|
121
|
+
"null",
|
|
122
|
+
]:
|
|
123
|
+
# we are skipping deep validation with Pydantic to remove namespace here
|
|
124
|
+
# as it reduce time to process triples by 10-15x
|
|
125
|
+
identifier, property_, value = cast( # type: ignore[misc]
|
|
126
|
+
(str, str, str),
|
|
127
|
+
remove_namespace_from_uri(*(subject, predicate, object_), validation="prefix"),
|
|
128
|
+
) # type: ignore[misc, index]
|
|
129
|
+
|
|
130
|
+
if property_renaming_config:
|
|
131
|
+
property_ = property_renaming_config.get(property_, property_)
|
|
132
|
+
|
|
133
|
+
property_values[property_].append(value)
|
|
134
|
+
if property_values:
|
|
135
|
+
return (
|
|
136
|
+
identifier,
|
|
137
|
+
property_values,
|
|
138
|
+
)
|
|
139
|
+
else:
|
|
140
|
+
return () # type: ignore [return-value]
|
|
141
|
+
|
|
142
|
+
def construct_instances_of_class(
|
|
143
|
+
self,
|
|
144
|
+
class_: str,
|
|
145
|
+
properties_optional: bool = True,
|
|
146
|
+
instance_id: URIRef | None = None,
|
|
147
|
+
) -> list[tuple[str, str, str]]:
|
|
97
148
|
"""CONSTRUCT instances for a given class from the graph store
|
|
98
149
|
|
|
99
150
|
Args:
|
|
100
151
|
class_: Class entity for which we want to generate query
|
|
101
152
|
properties_optional: Whether to make all properties optional, default True
|
|
153
|
+
instance_ids: List of instance ids to filter on, default None (all)
|
|
102
154
|
|
|
103
155
|
Returns:
|
|
104
156
|
List of triples for instances of the given class
|
|
@@ -106,10 +158,11 @@ class Queries:
|
|
|
106
158
|
|
|
107
159
|
if self.rules and (
|
|
108
160
|
query := build_construct_query(
|
|
109
|
-
ClassEntity(prefix=self.rules.metadata.prefix, suffix=class_),
|
|
110
|
-
self.graph,
|
|
111
|
-
self.rules,
|
|
112
|
-
properties_optional,
|
|
161
|
+
class_=ClassEntity(prefix=self.rules.metadata.prefix, suffix=class_),
|
|
162
|
+
graph=self.graph,
|
|
163
|
+
rules=self.rules,
|
|
164
|
+
properties_optional=properties_optional,
|
|
165
|
+
instance_id=instance_id,
|
|
113
166
|
)
|
|
114
167
|
):
|
|
115
168
|
result = self.graph.query(query)
|
|
@@ -3,7 +3,7 @@ from typing import cast
|
|
|
3
3
|
|
|
4
4
|
from rdflib import Graph, URIRef
|
|
5
5
|
|
|
6
|
-
from cognite.neat.rules.analysis import
|
|
6
|
+
from cognite.neat.rules.analysis import InformationAnalysis
|
|
7
7
|
from cognite.neat.rules.models._rdfpath import (
|
|
8
8
|
AllReferences,
|
|
9
9
|
Hop,
|
|
@@ -18,8 +18,8 @@ from cognite.neat.utils.utils import most_occurring_element
|
|
|
18
18
|
from ._shared import Triple, hop2property_path
|
|
19
19
|
|
|
20
20
|
_QUERY_TEMPLATE = """CONSTRUCT {{ {graph_template} }}
|
|
21
|
-
WHERE {{ {
|
|
22
|
-
{
|
|
21
|
+
WHERE {{ {bind_instance_id}
|
|
22
|
+
{graph_pattern}
|
|
23
23
|
}}"""
|
|
24
24
|
|
|
25
25
|
|
|
@@ -28,7 +28,7 @@ def build_construct_query(
|
|
|
28
28
|
graph: Graph,
|
|
29
29
|
rules: InformationRules,
|
|
30
30
|
properties_optional: bool = True,
|
|
31
|
-
|
|
31
|
+
instance_id: URIRef | None = None,
|
|
32
32
|
) -> str | None:
|
|
33
33
|
"""Builds a CONSTRUCT query for a given class and rules and optionally filters by class instances.
|
|
34
34
|
|
|
@@ -53,8 +53,9 @@ def build_construct_query(
|
|
|
53
53
|
This is the reason why there is an option to make all properties optional, so that
|
|
54
54
|
the query will return all instances that have at least one property defined.
|
|
55
55
|
"""
|
|
56
|
+
|
|
56
57
|
if (
|
|
57
|
-
transformations :=
|
|
58
|
+
transformations := InformationAnalysis(rules)
|
|
58
59
|
.class_property_pairs(only_rdfpath=True, consider_inheritance=True)
|
|
59
60
|
.get(class_, None)
|
|
60
61
|
):
|
|
@@ -63,22 +64,20 @@ def build_construct_query(
|
|
|
63
64
|
)
|
|
64
65
|
|
|
65
66
|
return _QUERY_TEMPLATE.format(
|
|
67
|
+
bind_instance_id=(f"BIND(<{instance_id}> AS ?instance)" if instance_id else ""),
|
|
66
68
|
graph_template="\n".join(triples2sparql_statement(templates)),
|
|
67
69
|
graph_pattern="\n".join(triples2sparql_statement(patterns)),
|
|
68
|
-
filter="" if not class_instances else add_filter(class_instances),
|
|
69
70
|
)
|
|
70
71
|
|
|
71
72
|
else:
|
|
72
73
|
return None
|
|
73
74
|
|
|
74
75
|
|
|
75
|
-
def add_filter(class_instances: list[URIRef]):
|
|
76
|
-
class_instances_formatted = [f"<{instance}>" for instance in class_instances]
|
|
77
|
-
return f"FILTER (?instance IN ({', '.join(class_instances_formatted)}))"
|
|
78
|
-
|
|
79
|
-
|
|
80
76
|
def to_construct_triples(
|
|
81
|
-
graph: Graph,
|
|
77
|
+
graph: Graph,
|
|
78
|
+
transformations: list[InformationProperty],
|
|
79
|
+
prefixes: dict,
|
|
80
|
+
properties_optional: bool = True,
|
|
82
81
|
) -> tuple[list[Triple], list[Triple]]:
|
|
83
82
|
"""Converts transformations of a class to CONSTRUCT triples which are used to generate CONSTRUCT query
|
|
84
83
|
|
|
@@ -124,7 +123,10 @@ def to_construct_triples(
|
|
|
124
123
|
# use case AllReferences: binding instance to certain rdf property
|
|
125
124
|
if isinstance(traversal, AllReferences):
|
|
126
125
|
graph_pattern_triple = Triple(
|
|
127
|
-
subject="BIND(?instance",
|
|
126
|
+
subject="BIND(?instance",
|
|
127
|
+
predicate="AS",
|
|
128
|
+
object=f"{graph_template_triple.object})",
|
|
129
|
+
optional=False,
|
|
128
130
|
)
|
|
129
131
|
|
|
130
132
|
# use case SingleProperty: simple property traversal
|
|
@@ -133,7 +135,7 @@ def to_construct_triples(
|
|
|
133
135
|
subject=graph_template_triple.subject,
|
|
134
136
|
predicate=traversal.property.id,
|
|
135
137
|
object=graph_template_triple.object,
|
|
136
|
-
optional=True if properties_optional else not transformation.is_mandatory,
|
|
138
|
+
optional=(True if properties_optional else not transformation.is_mandatory),
|
|
137
139
|
)
|
|
138
140
|
|
|
139
141
|
# use case Hop: property traversal with multiple hops turned into property path
|
|
@@ -143,7 +145,7 @@ def to_construct_triples(
|
|
|
143
145
|
subject="?instance",
|
|
144
146
|
predicate=hop2property_path(graph, traversal, prefixes),
|
|
145
147
|
object=graph_template_triple.object,
|
|
146
|
-
optional=True if properties_optional else not transformation.is_mandatory,
|
|
148
|
+
optional=(True if properties_optional else not transformation.is_mandatory),
|
|
147
149
|
)
|
|
148
150
|
|
|
149
151
|
# other type of rdfpaths are skipped
|