cognite-neat 0.88.3__tar.gz → 0.90.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.88.3 → cognite_neat-0.90.0}/PKG-INFO +1 -1
- cognite_neat-0.90.0/cognite/neat/_version.py +1 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/constants.py +6 -3
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/__init__.py +2 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_base.py +2 -2
- cognite_neat-0.90.0/cognite/neat/graph/extractors/_dms.py +158 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_mock_graph_generator.py +50 -9
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/loaders/_rdf2dms.py +16 -13
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/models.py +1 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/queries/_base.py +4 -2
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/_base.py +3 -1
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/__init__.py +2 -1
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/_general.py +7 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/__init__.py +2 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/_models.py +1 -1
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/_properties.py +12 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/user_modeling.py +1 -1
- cognite_neat-0.90.0/cognite/neat/rules/_shared.py +61 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/analysis/_base.py +1 -1
- cognite_neat-0.90.0/cognite/neat/rules/exporters/_base.py +40 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/_rules2dms.py +8 -18
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/_rules2excel.py +5 -12
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/_rules2ontology.py +9 -19
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/_rules2yaml.py +3 -6
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_base.py +7 -52
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dms2rules.py +172 -116
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +26 -18
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +14 -30
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_imf2rules/_imf2classes.py +7 -3
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_imf2rules/_imf2metadata.py +3 -3
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_imf2rules/_imf2properties.py +18 -11
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_imf2rules/_imf2rules.py +9 -18
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_inference2rules.py +37 -65
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +9 -20
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_shared.py +1 -1
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_spreadsheet2rules.py +22 -86
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_yaml2rules.py +14 -41
- cognite_neat-0.90.0/cognite/neat/rules/models/__init__.py +46 -0
- cognite_neat-0.90.0/cognite/neat/rules/models/_base_input.py +162 -0
- cognite_neat-0.88.3/cognite/neat/rules/models/_base.py → cognite_neat-0.90.0/cognite/neat/rules/models/_base_rules.py +1 -12
- cognite_neat-0.90.0/cognite/neat/rules/models/asset/__init__.py +13 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/asset/_rules.py +2 -20
- cognite_neat-0.90.0/cognite/neat/rules/models/asset/_rules_input.py +96 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/asset/_validation.py +1 -1
- cognite_neat-0.90.0/cognite/neat/rules/models/data_types.py +388 -0
- cognite_neat-0.90.0/cognite/neat/rules/models/dms/__init__.py +30 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/dms/_exporter.py +82 -39
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/dms/_rules.py +42 -155
- cognite_neat-0.90.0/cognite/neat/rules/models/dms/_rules_input.py +293 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/dms/_serializer.py +44 -3
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/dms/_validation.py +3 -4
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/domain.py +52 -1
- cognite_neat-0.90.0/cognite/neat/rules/models/entities/__init__.py +63 -0
- cognite_neat-0.90.0/cognite/neat/rules/models/entities/_constants.py +73 -0
- cognite_neat-0.90.0/cognite/neat/rules/models/entities/_loaders.py +76 -0
- cognite_neat-0.90.0/cognite/neat/rules/models/entities/_multi_value.py +67 -0
- cognite_neat-0.88.3/cognite/neat/rules/models/entities.py → cognite_neat-0.90.0/cognite/neat/rules/models/entities/_single_value.py +74 -232
- cognite_neat-0.90.0/cognite/neat/rules/models/entities/_types.py +86 -0
- cognite_neat-0.88.3/cognite/neat/rules/models/wrapped_entities.py → cognite_neat-0.90.0/cognite/neat/rules/models/entities/_wrapped.py +1 -1
- cognite_neat-0.90.0/cognite/neat/rules/models/information/__init__.py +18 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/information/_rules.py +3 -14
- cognite_neat-0.90.0/cognite/neat/rules/models/information/_rules_input.py +146 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/information/_validation.py +1 -1
- cognite_neat-0.90.0/cognite/neat/rules/transformers/__init__.py +21 -0
- cognite_neat-0.90.0/cognite/neat/rules/transformers/_base.py +81 -0
- cognite_neat-0.88.3/cognite/neat/rules/models/information/_converter.py → cognite_neat-0.90.0/cognite/neat/rules/transformers/_converters.py +226 -21
- cognite_neat-0.90.0/cognite/neat/rules/transformers/_map_onto.py +97 -0
- cognite_neat-0.90.0/cognite/neat/rules/transformers/_pipelines.py +61 -0
- cognite_neat-0.90.0/cognite/neat/rules/transformers/_verification.py +136 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/store/_base.py +2 -2
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/store/_provenance.py +10 -1
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/cdf/data_classes.py +20 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/regex_patterns.py +6 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/rules_exporter.py +106 -37
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/rules_importer.py +24 -22
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/pyproject.toml +1 -1
- cognite_neat-0.88.3/cognite/neat/_version.py +0 -1
- cognite_neat-0.88.3/cognite/neat/rules/_shared.py +0 -18
- cognite_neat-0.88.3/cognite/neat/rules/exporters/_base.py +0 -51
- cognite_neat-0.88.3/cognite/neat/rules/models/__init__.py +0 -30
- cognite_neat-0.88.3/cognite/neat/rules/models/_constants.py +0 -2
- cognite_neat-0.88.3/cognite/neat/rules/models/_types/__init__.py +0 -19
- cognite_neat-0.88.3/cognite/neat/rules/models/asset/__init__.py +0 -10
- cognite_neat-0.88.3/cognite/neat/rules/models/asset/_converter.py +0 -4
- cognite_neat-0.88.3/cognite/neat/rules/models/asset/_rules_input.py +0 -171
- cognite_neat-0.88.3/cognite/neat/rules/models/data_types.py +0 -282
- cognite_neat-0.88.3/cognite/neat/rules/models/dms/__init__.py +0 -18
- cognite_neat-0.88.3/cognite/neat/rules/models/dms/_converter.py +0 -143
- cognite_neat-0.88.3/cognite/neat/rules/models/dms/_rules_input.py +0 -361
- cognite_neat-0.88.3/cognite/neat/rules/models/information/__init__.py +0 -10
- cognite_neat-0.88.3/cognite/neat/rules/models/information/_rules_input.py +0 -293
- cognite_neat-0.88.3/cognite/neat/rules/transformers/_base.py +0 -15
- cognite_neat-0.88.3/cognite/neat/workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/LICENSE +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/README.md +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/configuration.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/explorer.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/routers/configuration.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/routers/crud.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/routers/metrics.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/routers/workflows.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/utils/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/utils/logging.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/main.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/monitoring/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/monitoring/metrics.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/index.html +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/config.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/_shared.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/_tracking/base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/_tracking/log.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/examples/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_dexpi.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/loaders/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/loaders/_base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/loaders/_rdf2asset.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/queries/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/queries/_construct.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/queries/_shared.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/transformers/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/transformers/_base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/transformers/_classic_cdf.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/transformers/_rdfpath.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/_external.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/_properties.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/_resources.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/errors/_workflow.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/formatters.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/_external.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/_general.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/issues/warnings/_resources.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/py.typed +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/analysis/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/analysis/_asset.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/analysis/_information.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/examples/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/exporters/_validation.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_imf2rules/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_owl2rules/_owl2metadata.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/importers/_rdf/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/_rdfpath.py +0 -0
- /cognite_neat-0.88.3/cognite/neat/rules/models/_types/_field.py → /cognite_neat-0.90.0/cognite/neat/rules/models/_types.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/asset/_serializer.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/dms/_schema.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/rules/models/information/_serializer.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/store/__init__.py +0 -0
- {cognite_neat-0.88.3/cognite/neat/rules/transformers → cognite_neat-0.90.0/cognite/neat/utils}/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/auth.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/auxiliary.py +0 -0
- {cognite_neat-0.88.3/cognite/neat/utils → cognite_neat-0.90.0/cognite/neat/utils/cdf}/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/cdf/loaders/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/cdf/loaders/_base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/cdf/loaders/_data_modeling.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/cdf/loaders/_ingestion.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/collection_.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/rdf_.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/spreadsheet.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/text.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/time_.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/upload.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/utils/xml_.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/base.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/cdf_store.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Export_DMS/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Import_DMS/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Validate_Rules/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/manager.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/model.py +0 -0
- {cognite_neat-0.88.3/cognite/neat/utils/cdf → cognite_neat-0.90.0/cognite/neat/workflows/steps}/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/data_contracts.py +0 -0
- {cognite_neat-0.88.3/cognite/neat/workflows/steps → cognite_neat-0.90.0/cognite/neat/workflows/steps/lib}/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/graph_extractor.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/graph_loader.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/graph_store.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/current/rules_validator.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/io/__init__.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/lib/io/io_steps.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps/step_model.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/steps_registry.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/tasks.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/triggers.py +0 -0
- {cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/workflows/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.90.0"
|
|
@@ -7,11 +7,11 @@ from cognite import neat
|
|
|
7
7
|
PACKAGE_DIRECTORY = Path(neat.__file__).parent
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
EXAMPLE_RULES = PACKAGE_DIRECTORY / "
|
|
11
|
-
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "
|
|
12
|
-
_OLD_WORKFLOWS = PACKAGE_DIRECTORY / "legacy" / "workflows" / "examples"
|
|
10
|
+
EXAMPLE_RULES = PACKAGE_DIRECTORY / "rules" / "examples"
|
|
11
|
+
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "graph" / "examples"
|
|
13
12
|
EXAMPLE_WORKFLOWS = PACKAGE_DIRECTORY / "workflows" / "examples"
|
|
14
13
|
|
|
14
|
+
DEFAULT_SPACE_URI = "http://purl.org/cognite/{space}#"
|
|
15
15
|
DEFAULT_NAMESPACE = Namespace("http://purl.org/cognite/neat#")
|
|
16
16
|
|
|
17
17
|
|
|
@@ -30,3 +30,6 @@ def get_default_prefixes() -> dict[str, Namespace]:
|
|
|
30
30
|
DEFAULT_URI = ""
|
|
31
31
|
|
|
32
32
|
DEFAULT_DOCS_URL = "https://cognite-neat.readthedocs-hosted.com/en/latest/"
|
|
33
|
+
|
|
34
|
+
DMS_CONTAINER_PROPERTY_SIZE_LIMIT = 100
|
|
35
|
+
DMS_VIEW_CONTAINER_SIZE_LIMIT = 10
|
|
@@ -7,6 +7,7 @@ from ._classic_cdf._relationships import RelationshipsExtractor
|
|
|
7
7
|
from ._classic_cdf._sequences import SequencesExtractor
|
|
8
8
|
from ._classic_cdf._timeseries import TimeSeriesExtractor
|
|
9
9
|
from ._dexpi import DexpiExtractor
|
|
10
|
+
from ._dms import DMSExtractor
|
|
10
11
|
from ._mock_graph_generator import MockGraphGenerator
|
|
11
12
|
from ._rdf_file import RdfFileExtractor
|
|
12
13
|
|
|
@@ -22,6 +23,7 @@ __all__ = [
|
|
|
22
23
|
"LabelsExtractor",
|
|
23
24
|
"RdfFileExtractor",
|
|
24
25
|
"DexpiExtractor",
|
|
26
|
+
"DMSExtractor",
|
|
25
27
|
]
|
|
26
28
|
|
|
27
29
|
|
{cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_classic_cdf/_base.py
RENAMED
|
@@ -5,7 +5,7 @@ from collections.abc import Callable, Iterable, Set
|
|
|
5
5
|
from typing import Generic, TypeVar
|
|
6
6
|
|
|
7
7
|
from cognite.client.data_classes._base import CogniteResource
|
|
8
|
-
from rdflib import Literal, Namespace, URIRef
|
|
8
|
+
from rdflib import XSD, Literal, Namespace, URIRef
|
|
9
9
|
|
|
10
10
|
from cognite.neat.constants import DEFAULT_NAMESPACE
|
|
11
11
|
from cognite.neat.graph.extractors._base import BaseExtractor
|
|
@@ -93,7 +93,7 @@ class ClassicCDFExtractor(BaseExtractor, ABC, Generic[T_CogniteResource]):
|
|
|
93
93
|
Literal(string_to_ideal_type(value)),
|
|
94
94
|
)
|
|
95
95
|
else:
|
|
96
|
-
yield id_, self.namespace.metadata, Literal(json.dumps(metadata))
|
|
96
|
+
yield id_, self.namespace.metadata, Literal(json.dumps(metadata), datatype=XSD._NS["json"])
|
|
97
97
|
|
|
98
98
|
def _get_rdf_type(self, item: T_CogniteResource) -> str:
|
|
99
99
|
type_ = self._default_rdf_type
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
from collections.abc import Iterable, Iterator
|
|
2
|
+
from typing import cast
|
|
3
|
+
|
|
4
|
+
from cognite.client import CogniteClient
|
|
5
|
+
from cognite.client import data_modeling as dm
|
|
6
|
+
from cognite.client.data_classes.data_modeling import DataModelIdentifier
|
|
7
|
+
from cognite.client.data_classes.data_modeling.instances import Instance, PropertyValue
|
|
8
|
+
from rdflib import RDF, XSD, Literal, Namespace, URIRef
|
|
9
|
+
|
|
10
|
+
from cognite.neat.constants import DEFAULT_SPACE_URI
|
|
11
|
+
from cognite.neat.graph.models import Triple
|
|
12
|
+
from cognite.neat.issues.errors import ResourceRetrievalError
|
|
13
|
+
|
|
14
|
+
from ._base import BaseExtractor
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DMSExtractor(BaseExtractor):
|
|
18
|
+
"""Extract data from Cognite Data Fusion DMS instances into Neat.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
items: The items to extract.
|
|
22
|
+
total: The total number of items to extract. If provided, this will be used to estimate the progress.
|
|
23
|
+
limit: The maximum number of items to extract.
|
|
24
|
+
overwrite_namespace: If provided, this will overwrite the space of the extracted items.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
items: Iterable[Instance],
|
|
30
|
+
total: int | None = None,
|
|
31
|
+
limit: int | None = None,
|
|
32
|
+
overwrite_namespace: Namespace | None = None,
|
|
33
|
+
) -> None:
|
|
34
|
+
self.items = items
|
|
35
|
+
self.total = total
|
|
36
|
+
self.limit = limit
|
|
37
|
+
self.overwrite_namespace = overwrite_namespace
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def from_data_model(
|
|
41
|
+
cls, client: CogniteClient, data_model: DataModelIdentifier, limit: int | None = None
|
|
42
|
+
) -> "DMSExtractor":
|
|
43
|
+
"""Create an extractor from a data model.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
client: The Cognite client to use.
|
|
47
|
+
data_model: The data model to extract.
|
|
48
|
+
limit: The maximum number of instances to extract.
|
|
49
|
+
"""
|
|
50
|
+
retrieved = client.data_modeling.data_models.retrieve(data_model, inline_views=True)
|
|
51
|
+
if not retrieved:
|
|
52
|
+
raise ResourceRetrievalError(dm.DataModelId.load(data_model), "data model", "Data Model is missing in CDF")
|
|
53
|
+
return cls.from_views(client, retrieved.latest_version().views, limit)
|
|
54
|
+
|
|
55
|
+
@classmethod
|
|
56
|
+
def from_views(cls, client: CogniteClient, views: Iterable[dm.View], limit: int | None = None) -> "DMSExtractor":
|
|
57
|
+
"""Create an extractor from a set of views.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
client: The Cognite client to use.
|
|
61
|
+
views: The views to extract.
|
|
62
|
+
limit: The maximum number of instances to extract.
|
|
63
|
+
"""
|
|
64
|
+
return cls(_InstanceIterator(client, views), total=None, limit=limit)
|
|
65
|
+
|
|
66
|
+
def extract(self) -> Iterable[Triple]:
|
|
67
|
+
for count, item in enumerate(self.items, 1):
|
|
68
|
+
if self.limit and count > self.limit:
|
|
69
|
+
break
|
|
70
|
+
yield from self._extract_instance(item)
|
|
71
|
+
|
|
72
|
+
def _extract_instance(self, instance: Instance) -> Iterable[Triple]:
|
|
73
|
+
if isinstance(instance, dm.Edge):
|
|
74
|
+
if not instance.properties:
|
|
75
|
+
yield (
|
|
76
|
+
self._as_uri_ref(instance.start_node),
|
|
77
|
+
self._as_uri_ref(instance.type),
|
|
78
|
+
self._as_uri_ref(instance.end_node),
|
|
79
|
+
)
|
|
80
|
+
return
|
|
81
|
+
else:
|
|
82
|
+
# If the edge has properties, we create a node for the edge and connect it to the start and end nodes.
|
|
83
|
+
id_ = self._as_uri_ref(instance)
|
|
84
|
+
yield id_, RDF.type, self._as_uri_ref(instance.type)
|
|
85
|
+
yield id_, RDF.type, self._get_namespace(instance.space).Edge
|
|
86
|
+
yield (
|
|
87
|
+
id_,
|
|
88
|
+
self._as_uri_ref(dm.DirectRelationReference(instance.space, "startNode")),
|
|
89
|
+
self._as_uri_ref(instance.start_node),
|
|
90
|
+
)
|
|
91
|
+
yield (
|
|
92
|
+
id_,
|
|
93
|
+
self._as_uri_ref(dm.DirectRelationReference(instance.space, "endNode")),
|
|
94
|
+
self._as_uri_ref(instance.end_node),
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
elif isinstance(instance, dm.Node):
|
|
98
|
+
id_ = self._as_uri_ref(instance)
|
|
99
|
+
if instance.type:
|
|
100
|
+
type_ = self._as_uri_ref(cast(dm.DirectRelationReference, instance.type))
|
|
101
|
+
else:
|
|
102
|
+
type_ = self._get_namespace(instance.space).Node
|
|
103
|
+
|
|
104
|
+
yield id_, RDF.type, type_
|
|
105
|
+
else:
|
|
106
|
+
raise NotImplementedError(f"Unknown instance type {type(instance)}")
|
|
107
|
+
|
|
108
|
+
for view_id, properties in instance.properties.items():
|
|
109
|
+
namespace = self._get_namespace(view_id.space)
|
|
110
|
+
for key, value in properties.items():
|
|
111
|
+
for object_ in self._get_objects(value):
|
|
112
|
+
yield id_, namespace[key], object_
|
|
113
|
+
|
|
114
|
+
def _get_objects(self, value: PropertyValue) -> Iterable[Literal | URIRef]:
|
|
115
|
+
if isinstance(value, str | float | bool | int):
|
|
116
|
+
yield Literal(value)
|
|
117
|
+
elif isinstance(value, dict) and "space" in value and "externalId" in value:
|
|
118
|
+
yield self._as_uri_ref(dm.DirectRelationReference.load(value))
|
|
119
|
+
elif isinstance(value, dict):
|
|
120
|
+
# This object is a json object.
|
|
121
|
+
yield Literal(str(value), datatype=XSD._NS["json"])
|
|
122
|
+
elif isinstance(value, list):
|
|
123
|
+
for item in value:
|
|
124
|
+
yield from self._get_objects(item)
|
|
125
|
+
|
|
126
|
+
def _as_uri_ref(self, instance: Instance | dm.DirectRelationReference) -> URIRef:
|
|
127
|
+
return self._get_namespace(instance.space)[instance.external_id]
|
|
128
|
+
|
|
129
|
+
def _get_namespace(self, space: str) -> Namespace:
|
|
130
|
+
if self.overwrite_namespace:
|
|
131
|
+
return self.overwrite_namespace
|
|
132
|
+
return Namespace(DEFAULT_SPACE_URI.format(space=space))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class _InstanceIterator(Iterator[Instance]):
|
|
136
|
+
def __init__(self, client: CogniteClient, views: Iterable[dm.View]):
|
|
137
|
+
self.client = client
|
|
138
|
+
self.views = views
|
|
139
|
+
|
|
140
|
+
def __iter__(self) -> Iterator[Instance]:
|
|
141
|
+
return self
|
|
142
|
+
|
|
143
|
+
def __next__(self) -> Instance: # type: ignore[misc]
|
|
144
|
+
for view in self.views:
|
|
145
|
+
# All nodes and edges with properties
|
|
146
|
+
yield from self.client.data_modeling.instances(chunk_size=None, instance_type="node", sources=[view])
|
|
147
|
+
yield from self.client.data_modeling.instances(chunk_size=None, instance_type="edge", sources=[view])
|
|
148
|
+
|
|
149
|
+
for prop in view.properties.values():
|
|
150
|
+
if isinstance(prop, dm.EdgeConnection):
|
|
151
|
+
# Get all edges with properties
|
|
152
|
+
yield from self.client.data_modeling.instances(
|
|
153
|
+
chunk_size=None,
|
|
154
|
+
instance_type="edge",
|
|
155
|
+
filter=dm.filters.Equals(
|
|
156
|
+
["edge", "type"], {"space": prop.type.space, "externalId": prop.type.external_id}
|
|
157
|
+
),
|
|
158
|
+
)
|
{cognite_neat-0.88.3 → cognite_neat-0.90.0}/cognite/neat/graph/extractors/_mock_graph_generator.py
RENAMED
|
@@ -42,7 +42,10 @@ class MockGraphGenerator(BaseExtractor):
|
|
|
42
42
|
allow_isolated_classes: bool = True,
|
|
43
43
|
):
|
|
44
44
|
if isinstance(rules, DMSRules):
|
|
45
|
-
|
|
45
|
+
# fixes potential issues with circular dependencies
|
|
46
|
+
from cognite.neat.rules.transformers import DMSToInformation
|
|
47
|
+
|
|
48
|
+
self.rules = DMSToInformation().transform(rules).rules
|
|
46
49
|
elif isinstance(rules, InformationRules):
|
|
47
50
|
self.rules = rules
|
|
48
51
|
else:
|
|
@@ -151,21 +154,33 @@ def generate_triples(
|
|
|
151
154
|
# generate triples for connected classes
|
|
152
155
|
for class_ in generation_order:
|
|
153
156
|
triples += _generate_triples_per_class(
|
|
154
|
-
class_,
|
|
157
|
+
class_,
|
|
158
|
+
class_property_pairs,
|
|
159
|
+
sym_pairs,
|
|
160
|
+
instance_ids,
|
|
161
|
+
namespace,
|
|
162
|
+
stop_on_exception,
|
|
155
163
|
)
|
|
156
164
|
|
|
157
165
|
# generate triples for isolated classes
|
|
158
166
|
if allow_isolated_classes:
|
|
159
167
|
for class_ in set(class_count.keys()) - set(generation_order):
|
|
160
168
|
triples += _generate_triples_per_class(
|
|
161
|
-
class_,
|
|
169
|
+
class_,
|
|
170
|
+
class_property_pairs,
|
|
171
|
+
sym_pairs,
|
|
172
|
+
instance_ids,
|
|
173
|
+
namespace,
|
|
174
|
+
stop_on_exception,
|
|
162
175
|
)
|
|
163
176
|
|
|
164
177
|
return triples
|
|
165
178
|
|
|
166
179
|
|
|
167
180
|
def _get_generation_order(
|
|
168
|
-
class_linkage: pd.DataFrame,
|
|
181
|
+
class_linkage: pd.DataFrame,
|
|
182
|
+
parent_col: str = "source_class",
|
|
183
|
+
child_col: str = "target_class",
|
|
169
184
|
) -> dict:
|
|
170
185
|
parent_child_list: list[list[str]] = class_linkage[[parent_col, child_col]].values.tolist()
|
|
171
186
|
# Build a directed graph and a list of all names that have no parent
|
|
@@ -243,7 +258,10 @@ def _remove_non_requested_sym_pairs(class_linkage: pd.DataFrame, class_count: di
|
|
|
243
258
|
|
|
244
259
|
|
|
245
260
|
def _generate_mock_data_property_triples(
|
|
246
|
-
instance_ids: list[URIRef],
|
|
261
|
+
instance_ids: list[URIRef],
|
|
262
|
+
property_: str,
|
|
263
|
+
namespace: Namespace,
|
|
264
|
+
value_type: DataType,
|
|
247
265
|
) -> list[tuple[URIRef, URIRef, Literal]]:
|
|
248
266
|
"""Generates triples for data properties."""
|
|
249
267
|
|
|
@@ -253,7 +271,13 @@ def _generate_mock_data_property_triples(
|
|
|
253
271
|
if python_type is int:
|
|
254
272
|
triples.append((id_, URIRef(namespace[property_]), Literal(random.randint(1, 1983))))
|
|
255
273
|
elif python_type is float:
|
|
256
|
-
triples.append(
|
|
274
|
+
triples.append(
|
|
275
|
+
(
|
|
276
|
+
id_,
|
|
277
|
+
URIRef(namespace[property_]),
|
|
278
|
+
Literal(numpy.float32(random.uniform(1, 1983))),
|
|
279
|
+
)
|
|
280
|
+
)
|
|
257
281
|
# generate string
|
|
258
282
|
else:
|
|
259
283
|
triples.append(
|
|
@@ -292,7 +316,12 @@ def _generate_mock_object_property_triples(
|
|
|
292
316
|
|
|
293
317
|
if tuple((class_, property_definition.value_type)) in sym_pairs:
|
|
294
318
|
symmetric_class_properties = class_property_pairs[cast(ClassEntity, property_definition.value_type)]
|
|
295
|
-
candidates = list(
|
|
319
|
+
candidates = list(
|
|
320
|
+
filter(
|
|
321
|
+
lambda instance: instance.value_type == class_,
|
|
322
|
+
symmetric_class_properties,
|
|
323
|
+
)
|
|
324
|
+
)
|
|
296
325
|
symmetric_property = candidates[0]
|
|
297
326
|
if len(candidates) > 1:
|
|
298
327
|
warnings.warn(
|
|
@@ -309,10 +338,22 @@ def _generate_mock_object_property_triples(
|
|
|
309
338
|
target = instance_ids[cast(ClassEntity, property_definition.value_type)][
|
|
310
339
|
i % len(instance_ids[cast(ClassEntity, property_definition.value_type)])
|
|
311
340
|
]
|
|
312
|
-
triples += [
|
|
341
|
+
triples += [
|
|
342
|
+
(
|
|
343
|
+
URIRef(source),
|
|
344
|
+
URIRef(namespace[property_definition.property_]),
|
|
345
|
+
URIRef(target),
|
|
346
|
+
)
|
|
347
|
+
]
|
|
313
348
|
|
|
314
349
|
if symmetric_property:
|
|
315
|
-
triples += [
|
|
350
|
+
triples += [
|
|
351
|
+
(
|
|
352
|
+
URIRef(target),
|
|
353
|
+
URIRef(namespace[symmetric_property.property_]),
|
|
354
|
+
URIRef(source),
|
|
355
|
+
)
|
|
356
|
+
]
|
|
316
357
|
|
|
317
358
|
if symmetric_property:
|
|
318
359
|
class_property_pairs[cast(ClassEntity, property_definition.value_type)].remove(symmetric_property)
|
|
@@ -13,8 +13,10 @@ from cognite.client.data_classes.data_modeling.ids import InstanceId
|
|
|
13
13
|
from cognite.client.data_classes.data_modeling.views import SingleEdgeConnection
|
|
14
14
|
from cognite.client.exceptions import CogniteAPIError
|
|
15
15
|
from pydantic import BaseModel, ValidationInfo, create_model, field_validator
|
|
16
|
+
from rdflib import RDF
|
|
16
17
|
|
|
17
18
|
from cognite.neat.graph._tracking import LogTracker, Tracker
|
|
19
|
+
from cognite.neat.graph.models import InstanceType
|
|
18
20
|
from cognite.neat.issues import IssueList, NeatIssue, NeatIssueList
|
|
19
21
|
from cognite.neat.issues.errors import (
|
|
20
22
|
ResourceConvertionError,
|
|
@@ -108,7 +110,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
108
110
|
for view in self.data_model.views:
|
|
109
111
|
view_id = view.as_id()
|
|
110
112
|
tracker.start(repr(view_id))
|
|
111
|
-
pydantic_cls,
|
|
113
|
+
pydantic_cls, edge_by_type, issues = self._create_validation_classes(view) # type: ignore[var-annotated]
|
|
112
114
|
yield from issues
|
|
113
115
|
tracker.issue(issues)
|
|
114
116
|
class_name = self.class_by_view_id.get(view.as_id(), view.external_id)
|
|
@@ -122,7 +124,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
122
124
|
if stop_on_exception:
|
|
123
125
|
raise error from e
|
|
124
126
|
yield error
|
|
125
|
-
yield from self._create_edges(identifier, properties,
|
|
127
|
+
yield from self._create_edges(identifier, properties, edge_by_type, tracker)
|
|
126
128
|
tracker.finish(repr(view_id))
|
|
127
129
|
|
|
128
130
|
def write_to_file(self, filepath: Path) -> None:
|
|
@@ -147,16 +149,16 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
147
149
|
|
|
148
150
|
def _create_validation_classes(
|
|
149
151
|
self, view: dm.View
|
|
150
|
-
) -> tuple[type[BaseModel], dict[str, dm.EdgeConnection], NeatIssueList]:
|
|
152
|
+
) -> tuple[type[BaseModel], dict[str, tuple[str, dm.EdgeConnection]], NeatIssueList]:
|
|
151
153
|
issues = IssueList()
|
|
152
154
|
field_definitions: dict[str, tuple[type, Any]] = {}
|
|
153
|
-
edge_by_property: dict[str, dm.EdgeConnection] = {}
|
|
155
|
+
edge_by_property: dict[str, tuple[str, dm.EdgeConnection]] = {}
|
|
154
156
|
validators: dict[str, classmethod] = {}
|
|
155
157
|
direct_relation_by_property: dict[str, dm.DirectRelation] = {}
|
|
156
158
|
json_fields: list[str] = []
|
|
157
159
|
for prop_name, prop in view.properties.items():
|
|
158
160
|
if isinstance(prop, dm.EdgeConnection):
|
|
159
|
-
edge_by_property[
|
|
161
|
+
edge_by_property[prop.type.external_id] = prop_name, prop
|
|
160
162
|
if isinstance(prop, dm.MappedProperty):
|
|
161
163
|
if isinstance(prop.type, dm.DirectRelation):
|
|
162
164
|
direct_relation_by_property[prop_name] = prop.type
|
|
@@ -215,7 +217,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
215
217
|
|
|
216
218
|
def parse_direct_relation(cls, value: list, info: ValidationInfo) -> dict | list[dict]:
|
|
217
219
|
# We validate above that we only get one value for single direct relations.
|
|
218
|
-
if
|
|
220
|
+
if list.__name__ in _get_field_value_types(cls, info):
|
|
219
221
|
return [{"space": self.instance_space, "externalId": v} for v in value]
|
|
220
222
|
elif value:
|
|
221
223
|
return {"space": self.instance_space, "externalId": value[0]}
|
|
@@ -231,16 +233,17 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
231
233
|
def _create_node(
|
|
232
234
|
self,
|
|
233
235
|
identifier: str,
|
|
234
|
-
properties: dict[str, list[str]],
|
|
236
|
+
properties: dict[str | InstanceType, list[str]],
|
|
235
237
|
pydantic_cls: type[BaseModel],
|
|
236
238
|
view_id: dm.ViewId,
|
|
237
239
|
) -> dm.InstanceApply:
|
|
240
|
+
type_ = properties.pop(RDF.type, [None])[0]
|
|
238
241
|
created = pydantic_cls.model_validate(properties)
|
|
239
242
|
|
|
240
243
|
return dm.NodeApply(
|
|
241
244
|
space=self.instance_space,
|
|
242
245
|
external_id=identifier,
|
|
243
|
-
|
|
246
|
+
type=dm.DirectRelationReference(view_id.space, type_) if type_ is not None else None,
|
|
244
247
|
sources=[dm.NodeOrEdgeData(source=view_id, properties=dict(created.model_dump().items()))],
|
|
245
248
|
)
|
|
246
249
|
|
|
@@ -248,13 +251,13 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
248
251
|
self,
|
|
249
252
|
identifier: str,
|
|
250
253
|
properties: dict[str, list[str]],
|
|
251
|
-
|
|
254
|
+
edge_by_type: dict[str, tuple[str, dm.EdgeConnection]],
|
|
252
255
|
tracker: Tracker,
|
|
253
256
|
) -> Iterable[dm.EdgeApply | NeatIssue]:
|
|
254
|
-
for
|
|
255
|
-
if
|
|
257
|
+
for predicate, values in properties.items():
|
|
258
|
+
if predicate not in edge_by_type:
|
|
256
259
|
continue
|
|
257
|
-
edge =
|
|
260
|
+
prop_id, edge = edge_by_type[predicate]
|
|
258
261
|
if isinstance(edge, SingleEdgeConnection) and len(values) > 1:
|
|
259
262
|
error = ResourceDuplicatedError(
|
|
260
263
|
resource_type="edge",
|
|
@@ -264,7 +267,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
264
267
|
tracker.issue(error)
|
|
265
268
|
yield error
|
|
266
269
|
for target in values:
|
|
267
|
-
external_id = f"{identifier}.{
|
|
270
|
+
external_id = f"{identifier}.{prop_id}.{target}"
|
|
268
271
|
yield dm.EdgeApply(
|
|
269
272
|
space=self.instance_space,
|
|
270
273
|
external_id=(external_id if len(external_id) < 256 else create_sha256_hash(external_id)),
|
|
@@ -6,6 +6,7 @@ from rdflib import RDF, Graph, URIRef
|
|
|
6
6
|
from rdflib import Literal as RdfLiteral
|
|
7
7
|
from rdflib.query import ResultRow
|
|
8
8
|
|
|
9
|
+
from cognite.neat.graph.models import InstanceType
|
|
9
10
|
from cognite.neat.rules.models.entities import ClassEntity
|
|
10
11
|
from cognite.neat.rules.models.information import InformationRules
|
|
11
12
|
from cognite.neat.utils.rdf_ import remove_namespace_from_uri
|
|
@@ -98,7 +99,7 @@ class Queries:
|
|
|
98
99
|
self,
|
|
99
100
|
instance_id: URIRef,
|
|
100
101
|
property_renaming_config: dict | None = None,
|
|
101
|
-
) -> tuple[str, dict[str, list[str]]] | None:
|
|
102
|
+
) -> tuple[str, dict[str | InstanceType, list[str]]] | None:
|
|
102
103
|
"""DESCRIBE instance for a given class from the graph store
|
|
103
104
|
|
|
104
105
|
Args:
|
|
@@ -126,7 +127,8 @@ class Queries:
|
|
|
126
127
|
# losing the namespace from the predicate!
|
|
127
128
|
if not property_renaming_config and predicate != RDF.type:
|
|
128
129
|
property_values[remove_namespace_from_uri(predicate, validation="prefix")].append(value)
|
|
129
|
-
|
|
130
|
+
elif predicate == RDF.type:
|
|
131
|
+
property_values[RDF.type].append(value)
|
|
130
132
|
# use-case: calling describe with renaming properties
|
|
131
133
|
# renaming the property to the new name, if the property is defined
|
|
132
134
|
# in the RULES sheet
|
|
@@ -45,11 +45,13 @@ ResourceType: TypeAlias = (
|
|
|
45
45
|
"container property",
|
|
46
46
|
"space",
|
|
47
47
|
"class",
|
|
48
|
+
"property",
|
|
48
49
|
"asset",
|
|
49
50
|
"relationship",
|
|
50
51
|
"data model",
|
|
51
52
|
"edge",
|
|
52
53
|
"node",
|
|
54
|
+
"enum collection",
|
|
53
55
|
"unknown",
|
|
54
56
|
]
|
|
55
57
|
# String to handle all unknown types in different importers.
|
|
@@ -339,7 +341,7 @@ class DefaultWarning(NeatWarning):
|
|
|
339
341
|
T_NeatIssue = TypeVar("T_NeatIssue", bound=NeatIssue)
|
|
340
342
|
|
|
341
343
|
|
|
342
|
-
class NeatIssueList(UserList[T_NeatIssue], ABC):
|
|
344
|
+
class NeatIssueList(UserList[T_NeatIssue], Sequence[T_NeatIssue], ABC):
|
|
343
345
|
"""This is a generic list of NeatIssues."""
|
|
344
346
|
|
|
345
347
|
def __init__(self, issues: Sequence[T_NeatIssue] | None = None, title: str | None = None):
|
|
@@ -9,7 +9,7 @@ from ._external import (
|
|
|
9
9
|
FileTypeUnexpectedError,
|
|
10
10
|
NeatYamlError,
|
|
11
11
|
)
|
|
12
|
-
from ._general import NeatImportError, NeatValueError, RegexViolationError
|
|
12
|
+
from ._general import NeatImportError, NeatTypeError, NeatValueError, RegexViolationError
|
|
13
13
|
from ._properties import (
|
|
14
14
|
PropertyDefinitionDuplicatedError,
|
|
15
15
|
PropertyDefinitionError,
|
|
@@ -67,6 +67,7 @@ __all__ = [
|
|
|
67
67
|
"DefaultPydanticError",
|
|
68
68
|
"PropertyMappingDuplicatedError",
|
|
69
69
|
"RowError",
|
|
70
|
+
"NeatTypeError",
|
|
70
71
|
]
|
|
71
72
|
|
|
72
73
|
_NEAT_ERRORS_BY_NAME = {error.__name__: error for error in _get_subclasses(NeatError, include_base=True)}
|
|
@@ -10,6 +10,13 @@ class NeatValueError(NeatError, ValueError):
|
|
|
10
10
|
raw_message: str
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class NeatTypeError(NeatError, TypeError):
|
|
15
|
+
"""{raw_message}"""
|
|
16
|
+
|
|
17
|
+
raw_message: str
|
|
18
|
+
|
|
19
|
+
|
|
13
20
|
@dataclass(frozen=True)
|
|
14
21
|
class RegexViolationError(NeatError, ValueError):
|
|
15
22
|
"""Value, {value} failed regex, {regex}, validation. Make sure that the name follows the regex pattern."""
|
|
@@ -26,6 +26,7 @@ from ._properties import (
|
|
|
26
26
|
PropertyDefinitionDuplicatedWarning,
|
|
27
27
|
PropertyNotFoundWarning,
|
|
28
28
|
PropertyTypeNotSupportedWarning,
|
|
29
|
+
PropertyValueTypeUndefinedWarning,
|
|
29
30
|
)
|
|
30
31
|
from ._resources import (
|
|
31
32
|
ResourceNeatWarning,
|
|
@@ -49,6 +50,7 @@ __all__ = [
|
|
|
49
50
|
"PropertyDefinitionDuplicatedWarning",
|
|
50
51
|
"PropertyTypeNotSupportedWarning",
|
|
51
52
|
"PropertyNotFoundWarning",
|
|
53
|
+
"PropertyValueTypeUndefinedWarning",
|
|
52
54
|
"ResourceNeatWarning",
|
|
53
55
|
"ResourcesDuplicatedWarning",
|
|
54
56
|
"RegexViolationWarning",
|
|
@@ -4,8 +4,8 @@ from typing import ClassVar
|
|
|
4
4
|
|
|
5
5
|
from cognite.client.data_classes.data_modeling import ViewId
|
|
6
6
|
|
|
7
|
+
from cognite.neat.constants import DMS_VIEW_CONTAINER_SIZE_LIMIT
|
|
7
8
|
from cognite.neat.issues import NeatWarning
|
|
8
|
-
from cognite.neat.rules.models._constants import DMS_VIEW_CONTAINER_SIZE_LIMIT
|
|
9
9
|
|
|
10
10
|
_BASE_URL = "https://cognite-neat.readthedocs-hosted.com/en/latest/data-modeling-principles.html"
|
|
11
11
|
|
|
@@ -42,3 +42,15 @@ class PropertyDefinitionDuplicatedWarning(PropertyWarning[T_Identifier]):
|
|
|
42
42
|
values: frozenset[str]
|
|
43
43
|
default_action: str
|
|
44
44
|
recommended_action: str | None = None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(frozen=True)
|
|
48
|
+
class PropertyValueTypeUndefinedWarning(PropertyWarning[T_Identifier]):
|
|
49
|
+
"""The {resource_type} with identifier {identifier} has a property {property_name}
|
|
50
|
+
which has undefined value type. This may result in unexpected behavior when exporting rules.
|
|
51
|
+
{default_action}"""
|
|
52
|
+
|
|
53
|
+
extra = "Recommended action: {recommended_action}"
|
|
54
|
+
|
|
55
|
+
default_action: str
|
|
56
|
+
recommended_action: str | None = None
|
|
@@ -7,7 +7,7 @@ from dataclasses import dataclass
|
|
|
7
7
|
|
|
8
8
|
from cognite.client.data_classes.data_modeling import ContainerId, ViewId
|
|
9
9
|
|
|
10
|
-
from cognite.neat.
|
|
10
|
+
from cognite.neat.constants import DMS_CONTAINER_PROPERTY_SIZE_LIMIT
|
|
11
11
|
|
|
12
12
|
from ._models import UserModelingWarning
|
|
13
13
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any, Generic, TypeAlias, TypeVar
|
|
4
|
+
|
|
5
|
+
from cognite.neat.issues import IssueList
|
|
6
|
+
from cognite.neat.rules.models import (
|
|
7
|
+
AssetRules,
|
|
8
|
+
DMSRules,
|
|
9
|
+
DomainRules,
|
|
10
|
+
InformationRules,
|
|
11
|
+
)
|
|
12
|
+
from cognite.neat.rules.models.asset._rules_input import AssetInputRules
|
|
13
|
+
from cognite.neat.rules.models.dms._rules_input import DMSInputRules
|
|
14
|
+
from cognite.neat.rules.models.information._rules_input import InformationInputRules
|
|
15
|
+
|
|
16
|
+
VerifiedRules: TypeAlias = DomainRules | InformationRules | DMSRules | AssetRules
|
|
17
|
+
InputRules: TypeAlias = AssetInputRules | DMSInputRules | InformationInputRules
|
|
18
|
+
Rules: TypeAlias = (
|
|
19
|
+
AssetInputRules | DMSInputRules | InformationInputRules | DomainRules | InformationRules | DMSRules | AssetRules
|
|
20
|
+
)
|
|
21
|
+
T_Rules = TypeVar("T_Rules", bound=Rules)
|
|
22
|
+
T_VerifiedRules = TypeVar("T_VerifiedRules", bound=VerifiedRules)
|
|
23
|
+
T_InputRules = TypeVar("T_InputRules", bound=InputRules)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class OutRules(Generic[T_Rules], ABC):
|
|
28
|
+
"""This is a base class for all rule states."""
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def get_rules(self) -> T_Rules | None:
|
|
32
|
+
"""Get the rules from the state."""
|
|
33
|
+
raise NotImplementedError()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@dataclass
|
|
37
|
+
class JustRules(OutRules[T_Rules]):
|
|
38
|
+
"""This represents a rule that exists"""
|
|
39
|
+
|
|
40
|
+
rules: T_Rules
|
|
41
|
+
|
|
42
|
+
def get_rules(self) -> T_Rules:
|
|
43
|
+
return self.rules
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class MaybeRules(OutRules[T_Rules]):
|
|
48
|
+
"""This represents a rule that may or may not exist"""
|
|
49
|
+
|
|
50
|
+
rules: T_Rules | None
|
|
51
|
+
issues: IssueList
|
|
52
|
+
|
|
53
|
+
def get_rules(self) -> T_Rules | None:
|
|
54
|
+
return self.rules
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@dataclass
|
|
58
|
+
class ReadRules(MaybeRules[T_Rules]):
|
|
59
|
+
"""This represents a rule that does not exist"""
|
|
60
|
+
|
|
61
|
+
read_context: dict[str, Any]
|
|
@@ -9,7 +9,7 @@ from typing import Generic, TypeVar
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from pydantic import BaseModel
|
|
11
11
|
|
|
12
|
-
from cognite.neat.rules.models.
|
|
12
|
+
from cognite.neat.rules.models._base_rules import BaseRules
|
|
13
13
|
from cognite.neat.rules.models._rdfpath import RDFPath
|
|
14
14
|
from cognite.neat.rules.models.entities import (
|
|
15
15
|
ClassEntity,
|