cognite-neat 0.119.2__tar.gz → 0.119.3__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.119.2 → cognite_neat-0.119.3}/PKG-INFO +37 -2
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/README.md +36 -1
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_constants.py +34 -70
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/__init__.py +0 -6
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/loaders/_rdf2dms.py +5 -5
- cognite_neat-0.119.3/cognite/neat/_graph/queries/__init__.py +3 -0
- cognite_neat-0.119.3/cognite/neat/_graph/queries/_base.py +16 -0
- cognite_neat-0.119.3/cognite/neat/_graph/queries/_queries.py +16 -0
- cognite_neat-0.119.2/cognite/neat/_graph/queries/_base.py → cognite_neat-0.119.3/cognite/neat/_graph/queries/_select.py +55 -85
- cognite_neat-0.119.3/cognite/neat/_graph/queries/_update.py +37 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_rules2excel.py +240 -107
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/_base_rules.py +16 -1
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/dms/_validation.py +10 -1
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/transformers/_converters.py +16 -6
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_drop.py +2 -2
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_explore.py +4 -4
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_prepare.py +5 -5
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_read.py +6 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_set.py +3 -3
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_show.py +1 -1
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_template.py +21 -2
- cognite_neat-0.119.3/cognite/neat/_state/README.md +23 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_store/_graph_store.py +5 -5
- cognite_neat-0.119.3/cognite/neat/_version.py +2 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/pyproject.toml +1 -1
- cognite_neat-0.119.2/cognite/neat/_graph/extractors/_dexpi.py +0 -234
- cognite_neat-0.119.2/cognite/neat/_graph/extractors/_iodd.py +0 -403
- cognite_neat-0.119.2/cognite/neat/_graph/queries/__init__.py +0 -3
- cognite_neat-0.119.2/cognite/neat/_graph/transformers/_iodd.py +0 -30
- cognite_neat-0.119.2/cognite/neat/_version.py +0 -2
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/LICENSE +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_alpha.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/_api/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/_api/data_modeling_loaders.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/_api/neat_instances.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/_api/schema.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/_api_client.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/data_classes/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/data_classes/data_modeling.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/data_classes/neat_sequence.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/data_classes/schema.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_client/testing.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_config.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/_shared.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/_tracking/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/_tracking/base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/_tracking/log.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/examples/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_assets.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_classic.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_data_sets.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_events.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_files.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_labels.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_relationships.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_classic_cdf/_timeseries.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_dict.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_dms.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_dms_graph.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_mock_graph_generator.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_raw.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/extractors/_rdf_file.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/loaders/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/loaders/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/_classic_cdf.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/_prune_graph.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/_rdfpath.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_graph/transformers/_value_type.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/_contextmanagers.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/_factory.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/_external.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/_general.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/_properties.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/_resources.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/errors/_wrapper.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/formatters.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/_external.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/_general.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/_models.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/_properties.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/_resources.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_issues/warnings/user_modeling.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/_constants.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/_shared.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/analysis/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/analysis/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/catalog/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/catalog/classic_model.xlsx +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/catalog/hello_world_pump.xlsx +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_rules2dms.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_rules2instance_template.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_rules2ontology.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_rules2yaml.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/exporters/_validation.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dms2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_converter.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dtdl2rules/dtdl_importer.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_dtdl2rules/spec.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/_imf2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/_inference2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/_owl2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_rdf/_shared.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_spreadsheet2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/importers/_yaml2rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/_base_input.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/_types.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/data_types.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/dms/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/dms/_exporter.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/dms/_rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/dms/_rules_input.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_constants.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_loaders.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_multi_value.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_single_value.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_types.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/entities/_wrapped.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/information/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/information/_rules.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/information/_rules_input.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/information/_validation.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/mapping/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/mapping/_classic2core.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/models/mapping/_classic2core.yaml +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/transformers/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/transformers/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/transformers/_mapping.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_rules/transformers/_verification.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_collector.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_fix.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_inspect.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_mapping.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_state.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_subset.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_to.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/_wizard.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/engine/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/engine/_import.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/engine/_interface.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/engine/_load.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_session/exceptions.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_shared.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_store/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_store/_provenance.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_store/_rules_store.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_store/exceptions.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/auth.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/auxiliary.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/collection_.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/graph_transformations_report.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/io_.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/rdf_.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/reader/__init__.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/reader/_base.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/spreadsheet.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/text.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/time_.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/upload.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/_utils/xml_.py +0 -0
- {cognite_neat-0.119.2 → cognite_neat-0.119.3}/cognite/neat/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: cognite-neat
|
|
3
|
-
Version: 0.119.
|
|
3
|
+
Version: 0.119.3
|
|
4
4
|
Summary: Knowledge graph transformation
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Author: Nikola Vasiljevic
|
|
@@ -80,7 +80,42 @@ NEAT is a domain expert centric and developer friendly solution for rapid:
|
|
|
80
80
|
NEAT is using open and globally recognized standards maintained by the [World Wide Web Consortium (W3C)](https://www.w3.org/RDF/).
|
|
81
81
|
NEAT represents an essential tool for creation of standardized, machine-actionable, linked and semantic (meta)data.
|
|
82
82
|
|
|
83
|
-
> NEAT is
|
|
83
|
+
> NEAT is a funny acronym derived from k**N**owl**Ed**ge gr**A**ph **T**ransformer produced using [ACRONIMIFY](https://acronymify.com/NEAT/?q=knowledge+graph+transformer).
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## History
|
|
87
|
+
|
|
88
|
+
NEAT emerged from years of experience in semantic tooling and knowledge graph development. The foundation was laid in 2020 with [sheet2rdf](https://github.com/nikokaoja/sheet2rdf), an Excel-based tool that trained data stewards to build domain-specific knowledge graphs and supported CI/CD processes in the Dutch Covid program and european wind energy community.
|
|
89
|
+
|
|
90
|
+
By mid of 2022, sheet2rdf was used in several POCs in Cognite. As Cognite's Data Modeling Service (DMS) development progressed, the need for simplified data modeling experience led to demonstration of proto-NEAT, known as [sheet2fdm](https://github.com/cognitedata/sheet2fdm), an extension of sheet2rdf, enabling semantic data model definitions in OWL, SHACL, Python and GraphQL (see e.g., [wind energy data model](https://cognitedata.github.io/wind-energy-data-model/)) using a simplified version of sheet2rdf Excel template.
|
|
91
|
+
|
|
92
|
+
Presented in various forums in 2022, this approach paved the way for NEAT’s formal development in November 2022 to enable cost-saving and empowerment of Cognite customers to self-sufficiently maintain and onboard knowledge graphs to Cognite Data Fusion.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Authorship
|
|
96
|
+
|
|
97
|
+
### Authors
|
|
98
|
+
The plot below shows the NEAT authorship from the start until present day.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
#### Current authors
|
|
103
|
+
- [Nikola Vasiljević](www.linkedin.com/in/thisisnikola)
|
|
104
|
+
- [Anders Albert](https://www.linkedin.com/in/anders-albert-00790483/)
|
|
105
|
+
- [Rogerio Júnior](https://www.linkedin.com/in/rogerio-saboia-j%C3%BAnior-087118a7/)
|
|
106
|
+
|
|
107
|
+
#### Former authors
|
|
108
|
+
- [Aleksandrs Livincovs](https://www.linkedin.com/in/aleksandrslivincovs/)
|
|
109
|
+
- [Julia Graham](https://www.linkedin.com/in/julia-graham-959a78a7/)
|
|
110
|
+
|
|
111
|
+
### Contributors
|
|
112
|
+
We are very grateful for the contributions made by:
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
- [Marie Solvik Lepoutre](https://www.linkedin.com/in/mslepoutre/), who improved RDF triples projections to Cognite Data Fusion
|
|
116
|
+
- [Bård Henning Tvedt](https://www.linkedin.com/in/bhtvedt/), who implemented IMF importer
|
|
117
|
+
- [Kristina Tomičić](https://www.linkedin.com/in/kristina-tomicic-6bb443108/), who implemented Data Model and Instances visualization
|
|
118
|
+
|
|
84
119
|
|
|
85
120
|
## Installation
|
|
86
121
|
|
|
@@ -20,7 +20,42 @@ NEAT is a domain expert centric and developer friendly solution for rapid:
|
|
|
20
20
|
NEAT is using open and globally recognized standards maintained by the [World Wide Web Consortium (W3C)](https://www.w3.org/RDF/).
|
|
21
21
|
NEAT represents an essential tool for creation of standardized, machine-actionable, linked and semantic (meta)data.
|
|
22
22
|
|
|
23
|
-
> NEAT is
|
|
23
|
+
> NEAT is a funny acronym derived from k**N**owl**Ed**ge gr**A**ph **T**ransformer produced using [ACRONIMIFY](https://acronymify.com/NEAT/?q=knowledge+graph+transformer).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## History
|
|
27
|
+
|
|
28
|
+
NEAT emerged from years of experience in semantic tooling and knowledge graph development. The foundation was laid in 2020 with [sheet2rdf](https://github.com/nikokaoja/sheet2rdf), an Excel-based tool that trained data stewards to build domain-specific knowledge graphs and supported CI/CD processes in the Dutch Covid program and european wind energy community.
|
|
29
|
+
|
|
30
|
+
By mid of 2022, sheet2rdf was used in several POCs in Cognite. As Cognite's Data Modeling Service (DMS) development progressed, the need for simplified data modeling experience led to demonstration of proto-NEAT, known as [sheet2fdm](https://github.com/cognitedata/sheet2fdm), an extension of sheet2rdf, enabling semantic data model definitions in OWL, SHACL, Python and GraphQL (see e.g., [wind energy data model](https://cognitedata.github.io/wind-energy-data-model/)) using a simplified version of sheet2rdf Excel template.
|
|
31
|
+
|
|
32
|
+
Presented in various forums in 2022, this approach paved the way for NEAT’s formal development in November 2022 to enable cost-saving and empowerment of Cognite customers to self-sufficiently maintain and onboard knowledge graphs to Cognite Data Fusion.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Authorship
|
|
36
|
+
|
|
37
|
+
### Authors
|
|
38
|
+
The plot below shows the NEAT authorship from the start until present day.
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
#### Current authors
|
|
43
|
+
- [Nikola Vasiljević](www.linkedin.com/in/thisisnikola)
|
|
44
|
+
- [Anders Albert](https://www.linkedin.com/in/anders-albert-00790483/)
|
|
45
|
+
- [Rogerio Júnior](https://www.linkedin.com/in/rogerio-saboia-j%C3%BAnior-087118a7/)
|
|
46
|
+
|
|
47
|
+
#### Former authors
|
|
48
|
+
- [Aleksandrs Livincovs](https://www.linkedin.com/in/aleksandrslivincovs/)
|
|
49
|
+
- [Julia Graham](https://www.linkedin.com/in/julia-graham-959a78a7/)
|
|
50
|
+
|
|
51
|
+
### Contributors
|
|
52
|
+
We are very grateful for the contributions made by:
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
- [Marie Solvik Lepoutre](https://www.linkedin.com/in/mslepoutre/), who improved RDF triples projections to Cognite Data Fusion
|
|
56
|
+
- [Bård Henning Tvedt](https://www.linkedin.com/in/bhtvedt/), who implemented IMF importer
|
|
57
|
+
- [Kristina Tomičić](https://www.linkedin.com/in/kristina-tomicic-6bb443108/), who implemented Data Model and Instances visualization
|
|
58
|
+
|
|
24
59
|
|
|
25
60
|
## Installation
|
|
26
61
|
|
|
@@ -65,76 +65,40 @@ COGNITE_SPACES = frozenset(
|
|
|
65
65
|
}
|
|
66
66
|
)
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
COGNITE_CORE_FEATURES = frozenset(
|
|
103
|
-
{
|
|
104
|
-
"CogniteDescribable",
|
|
105
|
-
"CogniteSourceable",
|
|
106
|
-
"CogniteSourceSystem",
|
|
107
|
-
"CogniteSchedulable",
|
|
108
|
-
"CogniteVisualizable",
|
|
109
|
-
}
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
COGNITE_3D_CONCEPTS = frozenset(
|
|
113
|
-
{
|
|
114
|
-
"Cognite3DModel",
|
|
115
|
-
"Cognite3DObject",
|
|
116
|
-
"Cognite3DRevision",
|
|
117
|
-
"Cognite3DTransformation",
|
|
118
|
-
"Cognite360Image",
|
|
119
|
-
"Cognite360ImageAnnotation",
|
|
120
|
-
"Cognite360ImageCollection",
|
|
121
|
-
"Cognite360ImageModel",
|
|
122
|
-
"Cognite360ImageStation",
|
|
123
|
-
"CogniteCADModel",
|
|
124
|
-
"CogniteCADNode",
|
|
125
|
-
"CogniteCADRevision",
|
|
126
|
-
"CogniteCubeMap",
|
|
127
|
-
"CognitePointCloudModel",
|
|
128
|
-
"CognitePointCloudRevision",
|
|
129
|
-
"CognitePointCloudVolume",
|
|
130
|
-
}
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
COGNITE_ANNOTATION = frozenset(
|
|
134
|
-
{
|
|
135
|
-
"CogniteAnnotation",
|
|
136
|
-
"CogniteDiagramAnnotation",
|
|
137
|
-
}
|
|
68
|
+
COGNITE_CONCEPTS = (
|
|
69
|
+
"CogniteAsset",
|
|
70
|
+
"CogniteEquipment",
|
|
71
|
+
"CogniteActivity",
|
|
72
|
+
"CogniteTimeSeries",
|
|
73
|
+
"CogniteFile",
|
|
74
|
+
"CogniteUnit",
|
|
75
|
+
"CogniteAssetClass",
|
|
76
|
+
"CogniteAssetType",
|
|
77
|
+
"CogniteEquipmentType",
|
|
78
|
+
"CogniteFileCategory",
|
|
79
|
+
"CogniteDescribable",
|
|
80
|
+
"CogniteSourceable",
|
|
81
|
+
"CogniteSourceSystem",
|
|
82
|
+
"CogniteSchedulable",
|
|
83
|
+
"CogniteVisualizable",
|
|
84
|
+
"CogniteAnnotation",
|
|
85
|
+
"CogniteDiagramAnnotation",
|
|
86
|
+
"CogniteCubeMap",
|
|
87
|
+
"CogniteCADRevision",
|
|
88
|
+
"CognitePointCloudVolume",
|
|
89
|
+
"Cognite360ImageAnnotation",
|
|
90
|
+
"Cognite3DObject",
|
|
91
|
+
"Cognite3DRevision",
|
|
92
|
+
"Cognite360Image",
|
|
93
|
+
"Cognite360ImageCollection",
|
|
94
|
+
"Cognite360ImageStation",
|
|
95
|
+
"CognitePointCloudModel",
|
|
96
|
+
"Cognite3DTransformation",
|
|
97
|
+
"Cognite360ImageModel",
|
|
98
|
+
"Cognite3DModel",
|
|
99
|
+
"CogniteCADModel",
|
|
100
|
+
"CognitePointCloudRevision",
|
|
101
|
+
"CogniteCADNode",
|
|
138
102
|
)
|
|
139
103
|
|
|
140
104
|
DMS_LISTABLE_PROPERTY_LIMIT = 1000
|
|
@@ -10,11 +10,9 @@ from ._classic_cdf._labels import LabelsExtractor
|
|
|
10
10
|
from ._classic_cdf._relationships import RelationshipsExtractor
|
|
11
11
|
from ._classic_cdf._sequences import SequencesExtractor
|
|
12
12
|
from ._classic_cdf._timeseries import TimeSeriesExtractor
|
|
13
|
-
from ._dexpi import DexpiExtractor
|
|
14
13
|
from ._dict import DictExtractor
|
|
15
14
|
from ._dms import DMSExtractor
|
|
16
15
|
from ._dms_graph import DMSGraphExtractor
|
|
17
|
-
from ._iodd import IODDExtractor
|
|
18
16
|
from ._mock_graph_generator import MockGraphGenerator
|
|
19
17
|
from ._raw import RAWExtractor
|
|
20
18
|
from ._rdf_file import RdfFileExtractor
|
|
@@ -26,11 +24,9 @@ __all__ = [
|
|
|
26
24
|
"DMSExtractor",
|
|
27
25
|
"DMSGraphExtractor",
|
|
28
26
|
"DataSetExtractor",
|
|
29
|
-
"DexpiExtractor",
|
|
30
27
|
"DictExtractor",
|
|
31
28
|
"EventsExtractor",
|
|
32
29
|
"FilesExtractor",
|
|
33
|
-
"IODDExtractor",
|
|
34
30
|
"KnowledgeGraphExtractor",
|
|
35
31
|
"LabelsExtractor",
|
|
36
32
|
"MockGraphGenerator",
|
|
@@ -52,8 +48,6 @@ TripleExtractors = (
|
|
|
52
48
|
| FilesExtractor
|
|
53
49
|
| LabelsExtractor
|
|
54
50
|
| RdfFileExtractor
|
|
55
|
-
| DexpiExtractor
|
|
56
|
-
| IODDExtractor
|
|
57
51
|
| DMSExtractor
|
|
58
52
|
| ClassicGraphExtractor
|
|
59
53
|
| DataSetExtractor
|
|
@@ -259,7 +259,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
259
259
|
"""Selects the views with data."""
|
|
260
260
|
view_iterations: dict[dm.ViewId, _ViewIterator] = {}
|
|
261
261
|
for view_id, query in view_query_by_id.items():
|
|
262
|
-
count = self.graph_store.queries.count_of_type(query.rdf_type)
|
|
262
|
+
count = self.graph_store.queries.select.count_of_type(query.rdf_type)
|
|
263
263
|
if count > 0:
|
|
264
264
|
view_iterations[view_id] = _ViewIterator(view_id, count, query)
|
|
265
265
|
return view_iterations
|
|
@@ -269,7 +269,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
269
269
|
if self._space_property is None:
|
|
270
270
|
return issues
|
|
271
271
|
total = sum(it.instance_count for it in view_iterations)
|
|
272
|
-
properties_by_uriref = self.graph_store.queries.properties()
|
|
272
|
+
properties_by_uriref = self.graph_store.queries.select.properties()
|
|
273
273
|
space_property_uri = next((k for k, v in properties_by_uriref.items() if v == self._space_property), None)
|
|
274
274
|
if space_property_uri is None:
|
|
275
275
|
error: ResourceNotFoundError[str, str] = ResourceNotFoundError(
|
|
@@ -282,7 +282,7 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
282
282
|
issues.append(error)
|
|
283
283
|
return issues
|
|
284
284
|
|
|
285
|
-
instance_iterable = self.graph_store.queries.list_instances_ids_by_space(space_property_uri)
|
|
285
|
+
instance_iterable = self.graph_store.queries.select.list_instances_ids_by_space(space_property_uri)
|
|
286
286
|
instance_iterable = iterate_progress_bar_if_above_config_threshold(
|
|
287
287
|
instance_iterable, total, f"Looking up spaces for {total} instances..."
|
|
288
288
|
)
|
|
@@ -308,8 +308,8 @@ class DMSLoader(CDFLoader[dm.InstanceApply]):
|
|
|
308
308
|
if not self.neat_prefix_by_type_uri:
|
|
309
309
|
return
|
|
310
310
|
|
|
311
|
-
count = sum(count for _, count in self.graph_store.queries.summarize_instances())
|
|
312
|
-
instance_iterable = self.graph_store.queries.list_instances_ids()
|
|
311
|
+
count = sum(count for _, count in self.graph_store.queries.select.summarize_instances())
|
|
312
|
+
instance_iterable = self.graph_store.queries.select.list_instances_ids()
|
|
313
313
|
instance_iterable = iterate_progress_bar_if_above_config_threshold(
|
|
314
314
|
instance_iterable, count, f"Looking up identifiers for {count} instances..."
|
|
315
315
|
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rdflib import Dataset, Graph, URIRef
|
|
2
|
+
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BaseQuery:
|
|
6
|
+
def __init__(
|
|
7
|
+
self,
|
|
8
|
+
dataset: Dataset,
|
|
9
|
+
default_named_graph: URIRef | None = None,
|
|
10
|
+
):
|
|
11
|
+
self.dataset = dataset
|
|
12
|
+
self.default_named_graph = default_named_graph or DATASET_DEFAULT_GRAPH_ID
|
|
13
|
+
|
|
14
|
+
def graph(self, named_graph: URIRef | None = None) -> Graph:
|
|
15
|
+
"""Get named graph from the dataset to query over"""
|
|
16
|
+
return self.dataset.graph(named_graph or self.default_named_graph)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from rdflib import Dataset, URIRef
|
|
2
|
+
|
|
3
|
+
from ._select import SelectQueries
|
|
4
|
+
from ._update import UpdateQueries
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Queries:
|
|
8
|
+
"""Helper class for storing standard queries for the graph store."""
|
|
9
|
+
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
dataset: Dataset,
|
|
13
|
+
default_named_graph: URIRef | None = None,
|
|
14
|
+
) -> None:
|
|
15
|
+
self.select = SelectQueries(dataset, default_named_graph)
|
|
16
|
+
self.update = UpdateQueries(self.select, dataset, default_named_graph)
|
|
@@ -3,39 +3,30 @@ from collections import defaultdict
|
|
|
3
3
|
from collections.abc import Iterable
|
|
4
4
|
from typing import Any, Literal, cast, overload
|
|
5
5
|
|
|
6
|
-
from rdflib import RDF, XSD,
|
|
6
|
+
from rdflib import RDF, XSD, Namespace, URIRef
|
|
7
7
|
from rdflib import Literal as RdfLiteral
|
|
8
|
-
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID
|
|
9
8
|
from rdflib.query import ResultRow
|
|
10
9
|
|
|
11
10
|
from cognite.neat._constants import NEAT
|
|
12
11
|
from cognite.neat._shared import InstanceType
|
|
13
|
-
from cognite.neat._utils.rdf_ import
|
|
12
|
+
from cognite.neat._utils.rdf_ import remove_namespace_from_uri
|
|
14
13
|
|
|
14
|
+
from ._base import BaseQuery
|
|
15
15
|
|
|
16
|
-
class Queries:
|
|
17
|
-
"""Helper class for storing standard queries for the graph store."""
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
):
|
|
24
|
-
self.dataset = dataset
|
|
25
|
-
self.default_named_graph = default_named_graph or DATASET_DEFAULT_GRAPH_ID
|
|
26
|
-
|
|
27
|
-
def graph(self, named_graph: URIRef | None = None) -> Graph:
|
|
28
|
-
"""Get named graph from the dataset to query over"""
|
|
29
|
-
return self.dataset.graph(named_graph or self.default_named_graph)
|
|
17
|
+
class SelectQueries(BaseQuery):
|
|
18
|
+
"""This class holds a set of SPARQL queries which are reading triples from the knowledge graph.
|
|
19
|
+
The read queries are executed against query endpoint, and typically start with SELECT statement.
|
|
20
|
+
"""
|
|
30
21
|
|
|
31
22
|
def summarize_instances(self, named_graph: URIRef | None = None) -> list[tuple[str, int]]:
|
|
32
23
|
"""Summarize instances in the graph store by class and count"""
|
|
33
24
|
query_statement = """ SELECT ?class (COUNT(?instance) AS ?instanceCount)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
WHERE {
|
|
26
|
+
?instance a ?class .
|
|
27
|
+
}
|
|
28
|
+
GROUP BY ?class
|
|
29
|
+
ORDER BY DESC(?instanceCount) """
|
|
39
30
|
|
|
40
31
|
return [ # type: ignore[misc]
|
|
41
32
|
(
|
|
@@ -48,7 +39,7 @@ class Queries:
|
|
|
48
39
|
def types(self, named_graph: URIRef | None = None) -> dict[URIRef, str]:
|
|
49
40
|
"""Types and their short form in the graph"""
|
|
50
41
|
query = """SELECT DISTINCT ?type
|
|
51
|
-
|
|
42
|
+
WHERE {?s a ?type .}"""
|
|
52
43
|
|
|
53
44
|
return { # type: ignore[misc, index, arg-type]
|
|
54
45
|
cast(URIRef, type_): remove_namespace_from_uri(cast(URIRef, type_))
|
|
@@ -67,7 +58,7 @@ class Queries:
|
|
|
67
58
|
|
|
68
59
|
"""
|
|
69
60
|
query = """SELECT DISTINCT ?property
|
|
70
|
-
|
|
61
|
+
WHERE {?s ?property ?o . FILTER(?property != rdf:type)}"""
|
|
71
62
|
return { # type: ignore[misc, index, arg-type]
|
|
72
63
|
cast(URIRef, type_): remove_namespace_from_uri(cast(URIRef, type_))
|
|
73
64
|
for (type_,) in list(self.graph(named_graph).query(query))
|
|
@@ -81,7 +72,7 @@ class Queries:
|
|
|
81
72
|
|
|
82
73
|
"""
|
|
83
74
|
query = """SELECT DISTINCT ?type ?property
|
|
84
|
-
|
|
75
|
+
WHERE {?s a ?type . ?s ?property ?o . FILTER(?property != rdf:type)}"""
|
|
85
76
|
properties_by_type: dict[URIRef, dict[URIRef, str]] = defaultdict(dict)
|
|
86
77
|
for type_, property_ in cast(ResultRow, list(self.graph(named_graph).query(query))):
|
|
87
78
|
properties_by_type[type_][property_] = remove_namespace_from_uri(property_) # type: ignore[index]
|
|
@@ -305,21 +296,21 @@ class Queries:
|
|
|
305
296
|
named_graph: URIRef | None = None,
|
|
306
297
|
) -> Iterable[tuple[URIRef, URIRef, list[URIRef]]]:
|
|
307
298
|
query = """SELECT ?sourceType ?property
|
|
308
|
-
|
|
299
|
+
(GROUP_CONCAT(DISTINCT STR(?valueType); SEPARATOR=",") AS ?valueTypes)
|
|
309
300
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
301
|
+
WHERE {{
|
|
302
|
+
?s ?property ?o .
|
|
303
|
+
?s a ?sourceType .
|
|
304
|
+
OPTIONAL {{ ?o a ?type }}
|
|
314
305
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
306
|
+
# Key part to determine value type: either object, data or unknown
|
|
307
|
+
BIND( IF(isLiteral(?o),DATATYPE(?o),
|
|
308
|
+
IF(BOUND(?type), ?type,
|
|
309
|
+
<{unknownType}>)) AS ?valueType)
|
|
310
|
+
}}
|
|
320
311
|
|
|
321
|
-
|
|
322
|
-
|
|
312
|
+
GROUP BY ?sourceType ?property
|
|
313
|
+
HAVING (COUNT(DISTINCT ?valueType) > 1)"""
|
|
323
314
|
|
|
324
315
|
for (
|
|
325
316
|
source_type,
|
|
@@ -331,27 +322,6 @@ class Queries:
|
|
|
331
322
|
):
|
|
332
323
|
yield cast(URIRef, source_type), cast(URIRef, property_), [URIRef(uri) for uri in value_types.split(",")]
|
|
333
324
|
|
|
334
|
-
def drop_types(
|
|
335
|
-
self,
|
|
336
|
-
type_: list[URIRef],
|
|
337
|
-
named_graph: URIRef | None = None,
|
|
338
|
-
) -> dict[URIRef, int]:
|
|
339
|
-
"""Drop types from the graph store
|
|
340
|
-
|
|
341
|
-
Args:
|
|
342
|
-
type_: List of types to drop
|
|
343
|
-
named_graph: Named graph to query over, default None (default graph
|
|
344
|
-
|
|
345
|
-
Returns:
|
|
346
|
-
Dictionary of dropped types
|
|
347
|
-
"""
|
|
348
|
-
dropped_types: dict[URIRef, int] = {}
|
|
349
|
-
for t in type_:
|
|
350
|
-
instance_ids = list(self.list_instances_ids(t))
|
|
351
|
-
dropped_types[t] = len(instance_ids)
|
|
352
|
-
remove_instance_ids_in_batch(self.graph(named_graph), instance_ids)
|
|
353
|
-
return dropped_types
|
|
354
|
-
|
|
355
325
|
def multi_type_instances(self, named_graph: URIRef | None = None) -> dict[str, list[str]]:
|
|
356
326
|
"""Find instances with multiple types
|
|
357
327
|
|
|
@@ -361,13 +331,13 @@ class Queries:
|
|
|
361
331
|
"""
|
|
362
332
|
|
|
363
333
|
query = """
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
334
|
+
SELECT ?instance (GROUP_CONCAT(str(?type); SEPARATOR=",") AS ?types)
|
|
335
|
+
WHERE {
|
|
336
|
+
?instance a ?type .
|
|
337
|
+
}
|
|
338
|
+
GROUP BY ?instance
|
|
339
|
+
HAVING (COUNT(?type) > 1)
|
|
340
|
+
"""
|
|
371
341
|
|
|
372
342
|
result = {}
|
|
373
343
|
for instance, types in self.graph(named_graph).query(query): # type: ignore
|
|
@@ -383,14 +353,14 @@ class Queries:
|
|
|
383
353
|
self, remove_namespace: bool = True, named_graph: URIRef | None = None
|
|
384
354
|
) -> list[dict[str, Any]]:
|
|
385
355
|
query = """
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
356
|
+
SELECT ?type (COUNT(DISTINCT ?instance) AS ?instanceCount) (COUNT(DISTINCT ?property) AS ?propertyCount)
|
|
357
|
+
WHERE {
|
|
358
|
+
?instance a ?type .
|
|
359
|
+
?instance ?property ?value .
|
|
360
|
+
FILTER(?property != rdf:type)
|
|
361
|
+
}
|
|
362
|
+
GROUP BY ?type
|
|
363
|
+
ORDER BY DESC(?instanceCount)"""
|
|
394
364
|
return [
|
|
395
365
|
{
|
|
396
366
|
"type": urllib.parse.unquote(remove_namespace_from_uri(type_)) if remove_namespace else type_,
|
|
@@ -410,13 +380,13 @@ class Queries:
|
|
|
410
380
|
for entry in self.types_with_instance_and_property_count(remove_namespace=False, named_graph=named_graph)
|
|
411
381
|
}
|
|
412
382
|
query = """SELECT ?type ?property (COUNT(DISTINCT ?instance) AS ?instanceCount)
|
|
413
|
-
WHERE {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
GROUP BY ?type ?property
|
|
419
|
-
ORDER BY ASC(?type) ASC(?property)"""
|
|
383
|
+
WHERE {
|
|
384
|
+
?instance a ?type .
|
|
385
|
+
?instance ?property ?value .
|
|
386
|
+
FILTER(?property != rdf:type)
|
|
387
|
+
}
|
|
388
|
+
GROUP BY ?type ?property
|
|
389
|
+
ORDER BY ASC(?type) ASC(?property)"""
|
|
420
390
|
return [
|
|
421
391
|
{
|
|
422
392
|
"type": urllib.parse.unquote(remove_namespace_from_uri(type_)) if remove_namespace else type_,
|
|
@@ -441,11 +411,11 @@ ORDER BY ASC(?type) ASC(?property)"""
|
|
|
441
411
|
self, type: URIRef, remove_namespace: bool = True, named_graph: URIRef | None = None
|
|
442
412
|
) -> dict[str, set[str]] | dict[URIRef, set[URIRef]]:
|
|
443
413
|
query = """SELECT DISTINCT ?instance ?property
|
|
444
|
-
WHERE {{
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}}"""
|
|
414
|
+
WHERE {{
|
|
415
|
+
?instance a <{type}> .
|
|
416
|
+
?instance ?property ?value .
|
|
417
|
+
FILTER(?property != rdf:type)
|
|
418
|
+
}}"""
|
|
449
419
|
result = defaultdict(set)
|
|
450
420
|
for instance, property_ in cast(Iterable[ResultRow], self.graph(named_graph).query(query.format(type=type))):
|
|
451
421
|
instance_str = urllib.parse.unquote(remove_namespace_from_uri(instance)) if remove_namespace else instance
|
|
@@ -458,7 +428,7 @@ WHERE {{
|
|
|
458
428
|
) -> Iterable[tuple[URIRef, str]]:
|
|
459
429
|
"""Returns instance ids by space"""
|
|
460
430
|
query = f"""SELECT DISTINCT ?instance ?space
|
|
461
|
-
|
|
431
|
+
WHERE {{?instance <{space_property}> ?space}}"""
|
|
462
432
|
|
|
463
433
|
for result in cast(Iterable[ResultRow], self.graph(named_graph).query(query)):
|
|
464
434
|
instance_id, space = cast(tuple[URIRef, URIRef | RdfLiteral], result)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from rdflib import Dataset, URIRef
|
|
2
|
+
|
|
3
|
+
from cognite.neat._utils.rdf_ import remove_instance_ids_in_batch
|
|
4
|
+
|
|
5
|
+
from ._base import BaseQuery
|
|
6
|
+
from ._select import SelectQueries
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class UpdateQueries(BaseQuery):
|
|
10
|
+
"""This class holds a set of SPARQL queries which are updating triples in the knowledge graph.
|
|
11
|
+
The update queries are executed against update endpoint, and typically start with UPDATE statement
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, read: SelectQueries, dataset: Dataset, default_named_graph: URIRef | None = None) -> None:
|
|
15
|
+
super().__init__(dataset, default_named_graph)
|
|
16
|
+
self._read = read
|
|
17
|
+
|
|
18
|
+
def drop_types(
|
|
19
|
+
self,
|
|
20
|
+
type_: list[URIRef],
|
|
21
|
+
named_graph: URIRef | None = None,
|
|
22
|
+
) -> dict[URIRef, int]:
|
|
23
|
+
"""Drop types from the graph store
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
type_: List of types to drop
|
|
27
|
+
named_graph: Named graph to query over, default None (default graph
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
Dictionary of dropped types
|
|
31
|
+
"""
|
|
32
|
+
dropped_types: dict[URIRef, int] = {}
|
|
33
|
+
for t in type_:
|
|
34
|
+
instance_ids = list(self._read.list_instances_ids(t))
|
|
35
|
+
dropped_types[t] = len(instance_ids)
|
|
36
|
+
remove_instance_ids_in_batch(self.graph(named_graph), instance_ids)
|
|
37
|
+
return dropped_types
|