cognite-neat 0.74.0__tar.gz → 0.75.2__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.74.0 → cognite_neat-0.75.2}/PKG-INFO +1 -1
- cognite_neat-0.75.2/cognite/neat/_version.py +1 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/core.py +1 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/data_exploration.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/rules.py +13 -7
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/constants.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/extractors/_mock_graph_generator.py +4 -4
- cognite_neat-0.75.2/cognite/neat/graph/stores/_base.py +363 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/__init__.py +3 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +20182 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +20163 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/examples/__init__.py +7 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/exceptions.py +91 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/graph/extractors/_base.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/graph/extractor → cognite_neat-0.75.2/cognite/neat/legacy/graph/extractors}/_dexpi.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/graph/extractor → cognite_neat-0.75.2/cognite/neat/legacy/graph/extractors}/_graph_capturing_sheet.py +6 -6
- {cognite_neat-0.74.0/cognite/neat/graph/extractor → cognite_neat-0.75.2/cognite/neat/legacy/graph/extractors}/_mock_graph_generator.py +6 -5
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/__init__.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/_asset_loader.py +3 -3
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/_base.py +4 -4
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/core/labels.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/core/models.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/core/rdf_to_assets.py +3 -3
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/core/rdf_to_relationships.py +5 -5
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/rdf_to_dms.py +5 -5
- cognite_neat-0.75.2/cognite/neat/legacy/graph/models.py +6 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/__init__.py +13 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/graph/stores/_base.py +5 -5
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/_graphdb_store.py +51 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/_memory_store.py +43 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/_oxigraph_store.py +147 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/_oxrdflib.py +247 -0
- cognite_neat-0.75.2/cognite/neat/legacy/graph/stores/_rdf_to_graph.py +40 -0
- {cognite_neat-0.74.0/cognite/neat/graph/transformation → cognite_neat-0.75.2/cognite/neat/legacy/graph/transformations}/entity_matcher.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/graph/transformation → cognite_neat-0.75.2/cognite/neat/legacy/graph/transformations}/query_generator/sparql.py +9 -7
- {cognite_neat-0.74.0/cognite/neat/graph/transformation → cognite_neat-0.75.2/cognite/neat/legacy/graph/transformations}/transformer.py +12 -5
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/analysis.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_base.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_core/rules2labels.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2dms.py +6 -6
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2excel.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2graphql.py +5 -5
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2ontology.py +6 -6
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2pydantic_models.py +8 -8
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2rules.py +3 -2
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_rules2triples.py +3 -2
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_validation.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_base.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_dict2rules.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_dms2rules.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_graph2rules.py +5 -4
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_owl2rules/_owl2metadata.py +11 -7
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_owl2rules/_owl2rules.py +5 -5
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_spreadsheet2rules.py +2 -2
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_xsd2rules.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_yaml2rules.py +1 -1
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/raw_rules.py +4 -4
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/rdfpath.py +1 -1
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/rules.py +4 -4
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/value_types.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/_shared.py +1 -1
- cognite_neat-0.75.2/cognite/neat/rules/analysis/__init__.py +3 -0
- {cognite_neat-0.74.0/cognite/neat/rules/_analysis → cognite_neat-0.75.2/cognite/neat/rules/analysis}/_base.py +1 -1
- {cognite_neat-0.74.0/cognite/neat/rules/_analysis → cognite_neat-0.75.2/cognite/neat/rules/analysis}/_information_rules.py +3 -3
- cognite_neat-0.75.2/cognite/neat/rules/examples/__init__.py +9 -0
- cognite_neat-0.75.2/cognite/neat/rules/examples/wind-energy.owl +1511 -0
- cognite_neat-0.75.2/cognite/neat/rules/exceptions.py +2972 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_base.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_rules2dms.py +4 -4
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_rules2excel.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_rules2ontology.py +4 -4
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_rules2yaml.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_validation.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_base.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dms2rules.py +10 -10
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +3 -3
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dtdl2rules/spec.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_owl2rules/_owl2classes.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +6 -6
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_owl2rules/_owl2properties.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_owl2rules/_owl2rules.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_spreadsheet2rules.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_yaml2rules.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/dms.py +1 -1
- cognite_neat-0.75.2/cognite/neat/rules/models/_entity.py +142 -0
- cognite_neat-0.75.2/cognite/neat/rules/models/rdfpath.py +236 -0
- {cognite_neat-0.74.0/cognite/neat/rules/models/_rules → cognite_neat-0.75.2/cognite/neat/rules/models/rules}/__init__.py +5 -5
- cognite_neat-0.74.0/cognite/neat/rules/models/_rules/base.py → cognite_neat-0.75.2/cognite/neat/rules/models/rules/_base.py +1 -1
- cognite_neat-0.74.0/cognite/neat/rules/models/_rules/dms_architect_rules.py → cognite_neat-0.75.2/cognite/neat/rules/models/rules/_dms_architect_rules.py +5 -5
- cognite_neat-0.74.0/cognite/neat/rules/models/_rules/dms_schema.py → cognite_neat-0.75.2/cognite/neat/rules/models/rules/_dms_schema.py +12 -4
- cognite_neat-0.74.0/cognite/neat/rules/models/_rules/domain_rules.py → cognite_neat-0.75.2/cognite/neat/rules/models/rules/_domain_rules.py +2 -2
- cognite_neat-0.74.0/cognite/neat/rules/models/_rules/information_rules.py → cognite_neat-0.75.2/cognite/neat/rules/models/rules/_information_rules.py +15 -15
- {cognite_neat-0.74.0/cognite/neat/rules/models/_rules → cognite_neat-0.75.2/cognite/neat/rules/models/rules}/_types/_base.py +18 -134
- cognite_neat-0.75.2/cognite/neat/workflows/steps/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/data_contracts.py +4 -4
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/graph_store.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/rules_exporter.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/rules_importer.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/rules_validator.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/graph_contextualization.py +1 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/graph_extractor.py +5 -5
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/graph_loader.py +7 -7
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/graph_store.py +7 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/graph_transformer.py +2 -2
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/rules_exporter.py +7 -7
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/rules_importer.py +13 -13
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/pyproject.toml +1 -1
- cognite_neat-0.74.0/cognite/neat/_version.py +0 -1
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/LICENSE +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/README.md +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/asgi/metrics.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/configuration.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/context_manager/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/context_manager/manager.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/data_classes/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/data_classes/configuration.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/data_classes/rest.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/explorer.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/configuration.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/crud.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/metrics.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/workflows.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/utils/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/utils/data_mapping.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/utils/logging.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/utils/query_templates.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/main.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/monitoring/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/monitoring/metrics.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/index.html +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/.gitignore +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/README.md +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/index.html +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/manifest.json +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/robots.txt +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/js/main.25d27396.js +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/js/main.25d27396.js.LICENSE.txt +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/js/main.25d27396.js.map +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/config.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/exceptions.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/examples/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/exceptions.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/extractors/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/extractor → cognite_neat-0.75.2/cognite/neat/graph/extractors}/_base.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/models.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/_graphdb_store.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/_memory_store.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/_oxigraph_store.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/_oxrdflib.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/stores/_rdf_to_graph.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/loader/core → cognite_neat-0.75.2/cognite/neat/legacy}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/extractor → cognite_neat-0.75.2/cognite/neat/legacy/graph/extractors}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/_exceptions.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/transformation → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders/core}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/loader → cognite_neat-0.75.2/cognite/neat/legacy/graph/loaders}/validator.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules → cognite_neat-0.75.2/cognite/neat/legacy/graph/transformations}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/graph/transformation → cognite_neat-0.75.2/cognite/neat/legacy/graph/transformations}/query_generator/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/_analysis → cognite_neat-0.75.2/cognite/neat/legacy/rules}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/Rules-Nordic44-to-TNT.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/power-grid-containers.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/power-grid-example.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/power-grid-model.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/rules-template.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/skos-rules.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/examples/wind-energy.owl +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/exceptions.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/exporter → cognite_neat-0.75.2/cognite/neat/legacy/rules/exporters}/_core/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_json2rules.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_owl2rules/_owl2classes.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/importer → cognite_neat-0.75.2/cognite/neat/legacy/rules/importers}/_owl2rules/_owl2properties.py +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/_base.py +0 -0
- {cognite_neat-0.74.0/cognite/neat → cognite_neat-0.75.2/cognite/neat/legacy}/rules/models/tables.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/py.typed +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/migration → cognite_neat-0.75.2/cognite/neat/rules}/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/exporters/_models.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/importers/_owl2rules/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/base.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/fileread.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/formatters.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/importing.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/spreadsheet.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/rules/issues/spreadsheet_file.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/models/_rules → cognite_neat-0.75.2/cognite/neat/rules/models/rules}/_types/__init__.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/models/_rules → cognite_neat-0.75.2/cognite/neat/rules/models/rules}/_types/_field.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/rules/models/_rules → cognite_neat-0.75.2/cognite/neat/rules/models/rules}/_types/_value.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/auxiliary.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf_loaders/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf_loaders/_base.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf_loaders/_data_modeling.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf_loaders/_ingestion.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/cdf_loaders/data_classes.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/exceptions.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/spreadsheet.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/text.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/utils.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/utils/xml.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/_exceptions.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/base.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/cdf_store.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Export DMS → cognite_neat-0.75.2/cognite/neat/workflows/examples/Export_DMS}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Export Rules to Ontology → cognite_neat-0.75.2/cognite/neat/workflows/examples/Export_Rules_to_Ontology}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Extract DEXPI Graph and Export Rules → cognite_neat-0.75.2/cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Extract RDF Graph and Generate Assets → cognite_neat-0.75.2/cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Import DMS → cognite_neat-0.75.2/cognite/neat/workflows/examples/Import_DMS}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Ontology to Data Model → cognite_neat-0.75.2/cognite/neat/workflows/examples/Ontology_to_Data_Model}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Validate Rules → cognite_neat-0.75.2/cognite/neat/workflows/examples/Validate_Rules}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Validate Solution Model → cognite_neat-0.75.2/cognite/neat/workflows/examples/Validate_Solution_Model}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Visualize Data Model Using Mock Graph → cognite_neat-0.75.2/cognite/neat/workflows/examples/Visualize_Data_Model_Using_Mock_Graph}/workflow.yaml +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/examples/Visualize Semantic Data Model → cognite_neat-0.75.2/cognite/neat/workflows/examples/Visualize_Semantic_Data_Model}/workflow.yaml +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/manager.py +0 -0
- {cognite_neat-0.74.0/cognite/neat/workflows/steps → cognite_neat-0.75.2/cognite/neat/workflows/migration}/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/migration/steps.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/migration/wf_manifests.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/model.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/graph_extractor.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/graph_loader.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/io_steps.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/lib/v1/__init__.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps/step_model.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/steps_registry.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/tasks.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/triggers.py +0 -0
- {cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/workflows/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.75.2"
|
|
@@ -9,8 +9,7 @@ from fastapi import APIRouter, UploadFile
|
|
|
9
9
|
|
|
10
10
|
from cognite.neat.app.api.configuration import NEAT_APP
|
|
11
11
|
from cognite.neat.rules import exporters, importers
|
|
12
|
-
from cognite.neat.rules.models.
|
|
13
|
-
from cognite.neat.rules.models._rules.base import RoleTypes
|
|
12
|
+
from cognite.neat.rules.models.rules import DMSRules, RoleTypes
|
|
14
13
|
|
|
15
14
|
router = APIRouter()
|
|
16
15
|
|
{cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/app/api/routers/data_exploration.py
RENAMED
|
@@ -16,7 +16,7 @@ from cognite.neat.app.api.data_classes.rest import (
|
|
|
16
16
|
)
|
|
17
17
|
from cognite.neat.app.api.utils.data_mapping import rdf_result_to_api_response
|
|
18
18
|
from cognite.neat.app.api.utils.query_templates import query_templates
|
|
19
|
-
from cognite.neat.graph.
|
|
19
|
+
from cognite.neat.legacy.graph.transformations import query_generator
|
|
20
20
|
from cognite.neat.utils.utils import remove_namespace
|
|
21
21
|
from cognite.neat.workflows.steps.data_contracts import RulesData, SolutionGraph, SourceGraph
|
|
22
22
|
|
|
@@ -7,10 +7,12 @@ from rdflib import Namespace
|
|
|
7
7
|
|
|
8
8
|
from cognite.neat.app.api.configuration import NEAT_APP
|
|
9
9
|
from cognite.neat.app.api.data_classes.rest import TransformationRulesUpdateRequest
|
|
10
|
-
from cognite.neat.rules import
|
|
11
|
-
from cognite.neat.rules
|
|
12
|
-
from cognite.neat.rules.models.
|
|
13
|
-
from cognite.neat.rules.models.rules import Class, Classes, Metadata, Properties, Property, Rules
|
|
10
|
+
from cognite.neat.legacy.rules import exporters as legacy_exporters
|
|
11
|
+
from cognite.neat.legacy.rules import importers as legacy_importers
|
|
12
|
+
from cognite.neat.legacy.rules.models._base import EntityTypes
|
|
13
|
+
from cognite.neat.legacy.rules.models.rules import Class, Classes, Metadata, Properties, Property, Rules
|
|
14
|
+
from cognite.neat.rules import importers
|
|
15
|
+
from cognite.neat.rules.models.rules import RoleTypes
|
|
14
16
|
from cognite.neat.workflows.steps.data_contracts import RulesData
|
|
15
17
|
from cognite.neat.workflows.steps.lib.rules_exporter import RulesToExcel
|
|
16
18
|
from cognite.neat.workflows.steps.lib.rules_importer import ExcelToRules
|
|
@@ -90,7 +92,9 @@ def get_rules(
|
|
|
90
92
|
try:
|
|
91
93
|
# Trying to load rules V1
|
|
92
94
|
if rules_schema_version == "" or rules_schema_version == "v1":
|
|
93
|
-
rules = cast(
|
|
95
|
+
rules = cast(
|
|
96
|
+
Rules, legacy_importers.ExcelImporter(path).to_rules(return_report=False, skip_validation=False)
|
|
97
|
+
)
|
|
94
98
|
properties = [
|
|
95
99
|
{
|
|
96
100
|
"class": value.class_id,
|
|
@@ -148,7 +152,9 @@ def get_rules(
|
|
|
148
152
|
def get_original_rules_from_file(file_name: str):
|
|
149
153
|
# """Endpoint for retrieving raw transformation from file"""
|
|
150
154
|
path = Path(NEAT_APP.config.rules_store_path) / file_name
|
|
151
|
-
rules = cast(
|
|
155
|
+
rules = cast(
|
|
156
|
+
Rules, legacy_importers.ExcelImporter(filepath=path).to_rules(return_report=False, skip_validation=False)
|
|
157
|
+
)
|
|
152
158
|
return Response(content=rules.model_dump_json(), media_type="application/json")
|
|
153
159
|
|
|
154
160
|
|
|
@@ -193,5 +199,5 @@ def upsert_rules(request: TransformationRulesUpdateRequest):
|
|
|
193
199
|
else:
|
|
194
200
|
path = Path(NEAT_APP.config.data_store_path) / rules_file
|
|
195
201
|
|
|
196
|
-
|
|
202
|
+
legacy_exporters.ExcelExporter(rules=rules).export_to_file(path)
|
|
197
203
|
return {"status": "ok"}
|
|
@@ -7,8 +7,8 @@ from cognite import neat
|
|
|
7
7
|
PACKAGE_DIRECTORY = Path(neat.__file__).parent
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
EXAMPLE_RULES = PACKAGE_DIRECTORY / "rules" / "examples"
|
|
11
|
-
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "graph" / "examples"
|
|
10
|
+
EXAMPLE_RULES = PACKAGE_DIRECTORY / "legacy" / "rules" / "examples"
|
|
11
|
+
EXAMPLE_GRAPHS = PACKAGE_DIRECTORY / "legacy" / "graph" / "examples"
|
|
12
12
|
EXAMPLE_WORKFLOWS = PACKAGE_DIRECTORY / "workflows" / "examples"
|
|
13
13
|
|
|
14
14
|
DEFAULT_NAMESPACE = Namespace("http://purl.org/cognite/neat#")
|
{cognite_neat-0.74.0 → cognite_neat-0.75.2}/cognite/neat/graph/extractors/_mock_graph_generator.py
RENAMED
|
@@ -13,10 +13,10 @@ import pandas as pd
|
|
|
13
13
|
from rdflib import RDF, Literal, Namespace, URIRef
|
|
14
14
|
|
|
15
15
|
from cognite.neat.graph.models import Triple
|
|
16
|
-
from cognite.neat.rules.
|
|
17
|
-
from cognite.neat.rules.models.
|
|
18
|
-
from cognite.neat.rules.models.
|
|
19
|
-
from cognite.neat.rules.models.
|
|
16
|
+
from cognite.neat.rules.analysis import InformationArchitectRulesAnalysis
|
|
17
|
+
from cognite.neat.rules.models.rules import DMSRules, InformationRules
|
|
18
|
+
from cognite.neat.rules.models.rules._information_rules import InformationProperty
|
|
19
|
+
from cognite.neat.rules.models.rules._types import ClassEntity, EntityTypes, XSDValueType
|
|
20
20
|
from cognite.neat.utils.utils import remove_namespace
|
|
21
21
|
|
|
22
22
|
from ._base import BaseExtractor
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
from collections.abc import Iterable, Iterator
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Literal, TypeAlias, cast
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
from prometheus_client import Gauge, Summary
|
|
11
|
+
from rdflib import Graph, Namespace, URIRef
|
|
12
|
+
from rdflib.query import Result, ResultRow
|
|
13
|
+
|
|
14
|
+
from cognite.neat.constants import DEFAULT_NAMESPACE, PREFIXES
|
|
15
|
+
from cognite.neat.graph.models import Triple
|
|
16
|
+
from cognite.neat.graph.stores._rdf_to_graph import rdf_file_to_graph
|
|
17
|
+
|
|
18
|
+
if sys.version_info >= (3, 11):
|
|
19
|
+
pass
|
|
20
|
+
else:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
prom_qsm = Summary("store_query_time_summary", "Time spent processing queries", ["query"])
|
|
24
|
+
prom_sq = Gauge("store_single_query_time", "Time spent processing a single query", ["query"])
|
|
25
|
+
|
|
26
|
+
MIMETypes: TypeAlias = Literal[
|
|
27
|
+
"application/rdf+xml", "text/turtle", "application/n-triple", "application/n-quads", "application/trig"
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class NeatGraphStoreBase(ABC):
|
|
32
|
+
"""NeatGraphStore is a class that stores the graph and provides methods to read/write data it contains
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
graph : Instance of rdflib.Graph class for graph storage
|
|
37
|
+
base_prefix : Used as a base prefix for graph namespace, allowing querying graph data using a shortform of a URI
|
|
38
|
+
namespace : Namespace (aka URI) used to resolve any relative URI in the graph
|
|
39
|
+
prefixes : Dictionary of additional prefixes used and bounded to the graph
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
rdf_store_type: str
|
|
43
|
+
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
graph: Graph | None = None,
|
|
47
|
+
base_prefix: str = "", # usually empty
|
|
48
|
+
namespace: Namespace = DEFAULT_NAMESPACE,
|
|
49
|
+
prefixes: dict = PREFIXES,
|
|
50
|
+
):
|
|
51
|
+
self.graph = graph or Graph()
|
|
52
|
+
self.base_prefix: str = base_prefix
|
|
53
|
+
self.namespace: Namespace = namespace
|
|
54
|
+
self.prefixes: dict[str, Namespace] = prefixes
|
|
55
|
+
|
|
56
|
+
self.rdf_store_query_url: str | None = None
|
|
57
|
+
self.rdf_store_update_url: str | None = None
|
|
58
|
+
self.returnFormat: str | None = None
|
|
59
|
+
self.df_cache: pd.DataFrame | None = None
|
|
60
|
+
self.internal_storage_dir: Path | None = None
|
|
61
|
+
self.graph_name: str | None = None
|
|
62
|
+
self.internal_storage_dir_orig: Path | None = None
|
|
63
|
+
self.storage_dirs_to_delete: list[Path] = []
|
|
64
|
+
self.queries = _Queries(self)
|
|
65
|
+
|
|
66
|
+
@abstractmethod
|
|
67
|
+
def _set_graph(self) -> None:
|
|
68
|
+
raise NotImplementedError()
|
|
69
|
+
|
|
70
|
+
def init_graph(
|
|
71
|
+
self,
|
|
72
|
+
rdf_store_query_url: str | None = None,
|
|
73
|
+
rdf_store_update_url: str | None = None,
|
|
74
|
+
graph_name: str | None = None,
|
|
75
|
+
base_prefix: str | None = None,
|
|
76
|
+
returnFormat: str = "csv",
|
|
77
|
+
internal_storage_dir: Path | None = None,
|
|
78
|
+
):
|
|
79
|
+
"""Initializes the graph.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
rdf_store_query_url : URL towards which SPARQL query is executed, by default None
|
|
83
|
+
rdf_store_update_url : URL towards which SPARQL update is executed, by default None
|
|
84
|
+
graph_name : Name of graph, by default None
|
|
85
|
+
base_prefix : Base prefix for graph namespace to change if needed, by default None
|
|
86
|
+
returnFormat : Transport format of graph data between, by default "csv"
|
|
87
|
+
internal_storage_dir : Path to directory where internal storage is located,
|
|
88
|
+
by default None (in-memory storage).
|
|
89
|
+
|
|
90
|
+
!!! note "internal_storage_dir"
|
|
91
|
+
Used only for Oxigraph
|
|
92
|
+
"""
|
|
93
|
+
logging.info("Initializing NeatGraphStore")
|
|
94
|
+
self.rdf_store_query_url = rdf_store_query_url
|
|
95
|
+
self.rdf_store_update_url = rdf_store_update_url
|
|
96
|
+
self.graph_name = graph_name
|
|
97
|
+
self.returnFormat = returnFormat
|
|
98
|
+
self.internal_storage_dir = Path(internal_storage_dir) if internal_storage_dir else None
|
|
99
|
+
self.internal_storage_dir_orig = (
|
|
100
|
+
self.internal_storage_dir if self.internal_storage_dir_orig is None else self.internal_storage_dir_orig
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
self._set_graph()
|
|
104
|
+
|
|
105
|
+
if self.prefixes:
|
|
106
|
+
for prefix, namespace in self.prefixes.items():
|
|
107
|
+
logging.info("Adding prefix %s with namespace %s", prefix, namespace)
|
|
108
|
+
self.graph.bind(prefix, namespace)
|
|
109
|
+
|
|
110
|
+
if base_prefix:
|
|
111
|
+
self.base_prefix = base_prefix
|
|
112
|
+
|
|
113
|
+
self.graph.bind(self.base_prefix, self.namespace)
|
|
114
|
+
logging.info("Adding prefix %s with namespace %s", self.base_prefix, self.namespace)
|
|
115
|
+
logging.info("Graph initialized")
|
|
116
|
+
|
|
117
|
+
def reinitialize_graph(self):
|
|
118
|
+
"""Reinitialize the graph."""
|
|
119
|
+
self.init_graph(
|
|
120
|
+
self.rdf_store_query_url,
|
|
121
|
+
self.rdf_store_update_url,
|
|
122
|
+
self.graph_name,
|
|
123
|
+
self.base_prefix,
|
|
124
|
+
self.returnFormat,
|
|
125
|
+
self.internal_storage_dir,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def upsert_prefixes(self, prefixes: dict[str, Namespace]) -> None:
|
|
129
|
+
"""Adds prefixes to the graph store."""
|
|
130
|
+
self.prefixes.update(prefixes)
|
|
131
|
+
for prefix, namespace in prefixes.items():
|
|
132
|
+
logging.info("Adding prefix %s with namespace %s", prefix, namespace)
|
|
133
|
+
self.graph.bind(prefix, namespace)
|
|
134
|
+
|
|
135
|
+
def close(self) -> None:
|
|
136
|
+
"""Closes the graph."""
|
|
137
|
+
# Can be overridden in subclasses
|
|
138
|
+
return None
|
|
139
|
+
|
|
140
|
+
def restart(self) -> None:
|
|
141
|
+
"""Restarts the graph"""
|
|
142
|
+
# Can be overridden in subclasses
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
def import_from_file(
|
|
146
|
+
self, graph_file: Path, mime_type: MIMETypes = "application/rdf+xml", add_base_iri: bool = True
|
|
147
|
+
) -> None:
|
|
148
|
+
"""Imports graph data from file.
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
graph_file : File path to file containing graph data, by default None
|
|
152
|
+
mime_type : MIME type of graph data, by default "application/rdf+xml"
|
|
153
|
+
add_base_iri : Add base IRI to graph, by default True
|
|
154
|
+
"""
|
|
155
|
+
if add_base_iri:
|
|
156
|
+
self.graph = rdf_file_to_graph(
|
|
157
|
+
self.graph, graph_file, base_namespace=self.namespace, prefixes=self.prefixes
|
|
158
|
+
)
|
|
159
|
+
else:
|
|
160
|
+
self.graph = rdf_file_to_graph(self.graph, graph_file, prefixes=self.prefixes)
|
|
161
|
+
return None
|
|
162
|
+
|
|
163
|
+
def get_graph(self) -> Graph:
|
|
164
|
+
"""Returns the graph."""
|
|
165
|
+
return self.graph
|
|
166
|
+
|
|
167
|
+
def set_graph(self, graph: Graph):
|
|
168
|
+
"""Sets the graph."""
|
|
169
|
+
self.graph = graph
|
|
170
|
+
|
|
171
|
+
def query(self, query: str) -> Result:
|
|
172
|
+
"""Returns the result of the query."""
|
|
173
|
+
start_time = time.perf_counter()
|
|
174
|
+
result = self.graph.query(query)
|
|
175
|
+
stop_time = time.perf_counter()
|
|
176
|
+
elapsed_time = stop_time - start_time
|
|
177
|
+
prom_qsm.labels("query").observe(elapsed_time)
|
|
178
|
+
prom_sq.labels("query").set(elapsed_time)
|
|
179
|
+
return result
|
|
180
|
+
|
|
181
|
+
def serialize(self, *args, **kwargs):
|
|
182
|
+
"""Serializes the graph."""
|
|
183
|
+
return self.graph.serialize(*args, **kwargs)
|
|
184
|
+
|
|
185
|
+
def query_delayed(self, query) -> Iterable[Triple]:
|
|
186
|
+
"""Returns the result of the query, but does not execute it immediately.
|
|
187
|
+
|
|
188
|
+
The query is not executed until the result is iterated over.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
query: SPARQL query to execute
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
An iterable of triples
|
|
195
|
+
|
|
196
|
+
"""
|
|
197
|
+
return _DelayedQuery(self.graph, query)
|
|
198
|
+
|
|
199
|
+
@abstractmethod
|
|
200
|
+
def drop(self) -> None:
|
|
201
|
+
"""Drops the graph."""
|
|
202
|
+
raise NotImplementedError()
|
|
203
|
+
|
|
204
|
+
def garbage_collector(self) -> None:
|
|
205
|
+
"""Garbage collection of the graph store."""
|
|
206
|
+
# Can be overridden in subclasses
|
|
207
|
+
return None
|
|
208
|
+
|
|
209
|
+
def query_to_dataframe(
|
|
210
|
+
self,
|
|
211
|
+
query: str,
|
|
212
|
+
column_mapping: dict | None = None,
|
|
213
|
+
save_to_cache: bool = False,
|
|
214
|
+
index_column: str = "instance",
|
|
215
|
+
) -> pd.DataFrame:
|
|
216
|
+
"""Returns the result of the query as a dataframe.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
query: SPARQL query to execute
|
|
220
|
+
column_mapping: Columns name mapping, by default None
|
|
221
|
+
save_to_cache: Save result of query to cache, by default False
|
|
222
|
+
index_column: Indexing column , by default "instance"
|
|
223
|
+
|
|
224
|
+
Returns:
|
|
225
|
+
Dataframe with result of query
|
|
226
|
+
"""
|
|
227
|
+
|
|
228
|
+
if column_mapping is None:
|
|
229
|
+
column_mapping = {0: "instance", 1: "property", 2: "value"}
|
|
230
|
+
|
|
231
|
+
result = self.graph.query(query, DEBUG=False)
|
|
232
|
+
df_cache = pd.DataFrame(list(result))
|
|
233
|
+
df_cache.rename(columns=column_mapping, inplace=True)
|
|
234
|
+
df_cache[index_column] = df_cache[index_column].apply(lambda x: str(x))
|
|
235
|
+
if save_to_cache:
|
|
236
|
+
self.df_cache = df_cache
|
|
237
|
+
return df_cache
|
|
238
|
+
|
|
239
|
+
def commit(self):
|
|
240
|
+
"""Commits the graph."""
|
|
241
|
+
self.graph.commit()
|
|
242
|
+
|
|
243
|
+
def get_df(self) -> pd.DataFrame:
|
|
244
|
+
"""Returns the cached dataframe."""
|
|
245
|
+
if self.df_cache is None:
|
|
246
|
+
raise ValueError("Cache is empty. Run query_to_dataframe() first with save_to_cache.")
|
|
247
|
+
return self.df_cache
|
|
248
|
+
|
|
249
|
+
def get_instance_properties_from_cache(self, instance_id: str) -> pd.DataFrame:
|
|
250
|
+
"""Returns the properties of an instance."""
|
|
251
|
+
if self.df_cache is None:
|
|
252
|
+
raise ValueError("Cache is empty. Run query_to_dataframe() first with save_to_cache.")
|
|
253
|
+
return self.df_cache.loc[self.df_cache["instance"] == instance_id]
|
|
254
|
+
|
|
255
|
+
def print_triples(self):
|
|
256
|
+
"""Prints the triples of the graph."""
|
|
257
|
+
for subj, pred, obj in self.graph:
|
|
258
|
+
logging.info(f"Triple: {subj} {pred} {obj}")
|
|
259
|
+
|
|
260
|
+
def diagnostic_report(self):
|
|
261
|
+
"""Returns the dictionary representation graph diagnostic data ."""
|
|
262
|
+
return {
|
|
263
|
+
"rdf_store_type": self.rdf_store_type,
|
|
264
|
+
"base_prefix": self.base_prefix,
|
|
265
|
+
"namespace": self.namespace,
|
|
266
|
+
"prefixes": self.prefixes,
|
|
267
|
+
"internal_storage_dir": self.internal_storage_dir,
|
|
268
|
+
"rdf_store_query_url": self.rdf_store_query_url,
|
|
269
|
+
"rdf_store_update_url": self.rdf_store_update_url,
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
def add_triples(self, triples: list[Triple] | set[Triple], batch_size: int = 10_000, verbose: bool = False):
|
|
273
|
+
"""Adds triples to the graph store in batches.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
triples: list of triples to be added to the graph store
|
|
277
|
+
batch_size: Batch size of triples per commit, by default 10_000
|
|
278
|
+
verbose: Verbose mode, by default False
|
|
279
|
+
"""
|
|
280
|
+
|
|
281
|
+
commit_counter = 0
|
|
282
|
+
if verbose:
|
|
283
|
+
logging.info(f"Committing total of {len(triples)} triples to knowledge graph!")
|
|
284
|
+
total_number_of_triples = len(triples)
|
|
285
|
+
number_of_uploaded_triples = 0
|
|
286
|
+
|
|
287
|
+
def check_commit(force_commit: bool = False):
|
|
288
|
+
"""Commit nodes to the graph if batch counter is reached or if force_commit is True"""
|
|
289
|
+
nonlocal commit_counter
|
|
290
|
+
nonlocal number_of_uploaded_triples
|
|
291
|
+
if force_commit:
|
|
292
|
+
number_of_uploaded_triples += commit_counter
|
|
293
|
+
self.graph.commit()
|
|
294
|
+
if verbose:
|
|
295
|
+
logging.info(f"Committed {number_of_uploaded_triples} of {total_number_of_triples} triples")
|
|
296
|
+
return
|
|
297
|
+
commit_counter += 1
|
|
298
|
+
if commit_counter >= batch_size:
|
|
299
|
+
number_of_uploaded_triples += commit_counter
|
|
300
|
+
self.graph.commit()
|
|
301
|
+
if verbose:
|
|
302
|
+
logging.info(f"Committed {number_of_uploaded_triples} of {total_number_of_triples} triples")
|
|
303
|
+
commit_counter = 0
|
|
304
|
+
|
|
305
|
+
for triple in triples:
|
|
306
|
+
self.graph.add(triple)
|
|
307
|
+
check_commit()
|
|
308
|
+
|
|
309
|
+
check_commit(force_commit=True)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
class _DelayedQuery(Iterable):
|
|
313
|
+
def __init__(self, graph_ref: Graph, query: str):
|
|
314
|
+
self.graph_ref = graph_ref
|
|
315
|
+
self.query = query
|
|
316
|
+
|
|
317
|
+
def __iter__(self) -> Iterator[Triple]:
|
|
318
|
+
start_time = time.perf_counter()
|
|
319
|
+
result = self.graph_ref.query(self.query)
|
|
320
|
+
stop_time = time.perf_counter()
|
|
321
|
+
elapsed_time = stop_time - start_time
|
|
322
|
+
prom_qsm.labels("query").observe(elapsed_time)
|
|
323
|
+
prom_sq.labels("query").set(elapsed_time)
|
|
324
|
+
return cast(Iterator[Triple], iter(result))
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class _Queries:
|
|
328
|
+
"""Helper class for storing standard queries for the graph store."""
|
|
329
|
+
|
|
330
|
+
def __init__(self, store: NeatGraphStoreBase):
|
|
331
|
+
self.store = store
|
|
332
|
+
|
|
333
|
+
def list_instances_ids_of_class(self, class_uri: URIRef, limit: int = -1) -> list[URIRef]:
|
|
334
|
+
"""Get instances ids for a given class
|
|
335
|
+
|
|
336
|
+
Args:
|
|
337
|
+
class_uri: Class for which instances are to be found
|
|
338
|
+
limit: Max number of instances to return, by default -1 meaning all instances
|
|
339
|
+
|
|
340
|
+
Returns:
|
|
341
|
+
List of class instance URIs
|
|
342
|
+
"""
|
|
343
|
+
query_statement = "SELECT DISTINCT ?subject WHERE { ?subject a <class> .} LIMIT X".replace(
|
|
344
|
+
"class", class_uri
|
|
345
|
+
).replace("LIMIT X", "" if limit == -1 else f"LIMIT {limit}")
|
|
346
|
+
return [cast(tuple, res)[0] for res in list(self.store.query(query_statement))]
|
|
347
|
+
|
|
348
|
+
def list_instances_of_type(self, class_uri: URIRef) -> list[ResultRow]:
|
|
349
|
+
"""Get all triples for instances of a given class
|
|
350
|
+
|
|
351
|
+
Args:
|
|
352
|
+
class_uri: Class for which instances are to be found
|
|
353
|
+
|
|
354
|
+
Returns:
|
|
355
|
+
List of triples for instances of the given class
|
|
356
|
+
"""
|
|
357
|
+
query = (
|
|
358
|
+
f"SELECT ?instance ?prop ?value "
|
|
359
|
+
f"WHERE {{ ?instance rdf:type <{class_uri}> . ?instance ?prop ?value . }} order by ?instance "
|
|
360
|
+
)
|
|
361
|
+
logging.info(query)
|
|
362
|
+
# Select queries gives an iterable of result rows
|
|
363
|
+
return cast(list[ResultRow], list(self.store.query(query)))
|