cognite-neat 0.123.26__py3-none-any.whl → 1.0.22__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cognite/neat/__init__.py +4 -3
- cognite/neat/_client/__init__.py +5 -0
- cognite/neat/_client/api.py +8 -0
- cognite/neat/_client/client.py +21 -0
- cognite/neat/_client/config.py +40 -0
- cognite/neat/_client/containers_api.py +138 -0
- cognite/neat/_client/data_classes.py +44 -0
- cognite/neat/_client/data_model_api.py +115 -0
- cognite/neat/_client/init/credentials.py +70 -0
- cognite/neat/_client/init/env_vars.py +131 -0
- cognite/neat/_client/init/main.py +51 -0
- cognite/neat/_client/spaces_api.py +115 -0
- cognite/neat/_client/statistics_api.py +24 -0
- cognite/neat/_client/views_api.py +144 -0
- cognite/neat/_config.py +266 -0
- cognite/neat/_data_model/_analysis.py +571 -0
- cognite/neat/_data_model/_constants.py +74 -0
- cognite/neat/_data_model/_identifiers.py +61 -0
- cognite/neat/_data_model/_shared.py +41 -0
- cognite/neat/_data_model/_snapshot.py +134 -0
- cognite/neat/_data_model/deployer/_differ.py +140 -0
- cognite/neat/_data_model/deployer/_differ_container.py +360 -0
- cognite/neat/_data_model/deployer/_differ_data_model.py +54 -0
- cognite/neat/_data_model/deployer/_differ_space.py +9 -0
- cognite/neat/_data_model/deployer/_differ_view.py +299 -0
- cognite/neat/_data_model/deployer/data_classes.py +644 -0
- cognite/neat/_data_model/deployer/deployer.py +431 -0
- cognite/neat/_data_model/exporters/__init__.py +15 -0
- cognite/neat/_data_model/exporters/_api_exporter.py +37 -0
- cognite/neat/_data_model/exporters/_base.py +24 -0
- cognite/neat/_data_model/exporters/_table_exporter/exporter.py +128 -0
- cognite/neat/_data_model/exporters/_table_exporter/workbook.py +409 -0
- cognite/neat/_data_model/exporters/_table_exporter/writer.py +480 -0
- cognite/neat/_data_model/importers/__init__.py +5 -0
- cognite/neat/_data_model/importers/_api_importer.py +166 -0
- cognite/neat/_data_model/importers/_base.py +16 -0
- cognite/neat/_data_model/importers/_table_importer/data_classes.py +344 -0
- cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
- cognite/neat/_data_model/importers/_table_importer/reader.py +1102 -0
- cognite/neat/_data_model/importers/_table_importer/source.py +94 -0
- cognite/neat/_data_model/models/conceptual/_base.py +18 -0
- cognite/neat/_data_model/models/conceptual/_concept.py +67 -0
- cognite/neat/_data_model/models/conceptual/_data_model.py +51 -0
- cognite/neat/_data_model/models/conceptual/_properties.py +104 -0
- cognite/neat/_data_model/models/conceptual/_property.py +105 -0
- cognite/neat/_data_model/models/dms/__init__.py +206 -0
- cognite/neat/_data_model/models/dms/_base.py +31 -0
- cognite/neat/_data_model/models/dms/_constants.py +48 -0
- cognite/neat/_data_model/models/dms/_constraints.py +42 -0
- cognite/neat/_data_model/models/dms/_container.py +159 -0
- cognite/neat/_data_model/models/dms/_data_model.py +95 -0
- cognite/neat/_data_model/models/dms/_data_types.py +195 -0
- cognite/neat/_data_model/models/dms/_http.py +28 -0
- cognite/neat/_data_model/models/dms/_indexes.py +30 -0
- cognite/neat/_data_model/models/dms/_limits.py +96 -0
- cognite/neat/_data_model/models/dms/_references.py +141 -0
- cognite/neat/_data_model/models/dms/_schema.py +18 -0
- cognite/neat/_data_model/models/dms/_space.py +48 -0
- cognite/neat/_data_model/models/dms/_types.py +17 -0
- cognite/neat/_data_model/models/dms/_view_filter.py +310 -0
- cognite/neat/_data_model/models/dms/_view_property.py +235 -0
- cognite/neat/_data_model/models/dms/_views.py +216 -0
- cognite/neat/_data_model/models/entities/__init__.py +50 -0
- cognite/neat/_data_model/models/entities/_base.py +101 -0
- cognite/neat/_data_model/models/entities/_constants.py +22 -0
- cognite/neat/_data_model/models/entities/_data_types.py +144 -0
- cognite/neat/_data_model/models/entities/_identifiers.py +61 -0
- cognite/neat/_data_model/models/entities/_parser.py +226 -0
- cognite/neat/_data_model/validation/dms/__init__.py +75 -0
- cognite/neat/_data_model/validation/dms/_ai_readiness.py +381 -0
- cognite/neat/_data_model/validation/dms/_base.py +25 -0
- cognite/neat/_data_model/validation/dms/_connections.py +681 -0
- cognite/neat/_data_model/validation/dms/_consistency.py +58 -0
- cognite/neat/_data_model/validation/dms/_containers.py +199 -0
- cognite/neat/_data_model/validation/dms/_limits.py +368 -0
- cognite/neat/_data_model/validation/dms/_orchestrator.py +70 -0
- cognite/neat/_data_model/validation/dms/_views.py +164 -0
- cognite/neat/_exceptions.py +68 -0
- cognite/neat/_issues.py +68 -0
- cognite/neat/_session/__init__.py +3 -0
- cognite/neat/_session/_html/_render.py +30 -0
- cognite/neat/_session/_html/static/__init__.py +8 -0
- cognite/neat/_session/_html/static/deployment.css +476 -0
- cognite/neat/_session/_html/static/deployment.js +181 -0
- cognite/neat/_session/_html/static/issues.css +211 -0
- cognite/neat/_session/_html/static/issues.js +168 -0
- cognite/neat/_session/_html/static/shared.css +186 -0
- cognite/neat/_session/_html/templates/__init__.py +4 -0
- cognite/neat/_session/_html/templates/deployment.html +80 -0
- cognite/neat/_session/_html/templates/issues.html +45 -0
- cognite/neat/_session/_issues.py +81 -0
- cognite/neat/_session/_physical.py +294 -0
- cognite/neat/_session/_result/__init__.py +3 -0
- cognite/neat/_session/_result/_deployment/__init__.py +0 -0
- cognite/neat/_session/_result/_deployment/_physical/__init__.py +0 -0
- cognite/neat/_session/_result/_deployment/_physical/_changes.py +196 -0
- cognite/neat/_session/_result/_deployment/_physical/_statistics.py +180 -0
- cognite/neat/_session/_result/_deployment/_physical/serializer.py +35 -0
- cognite/neat/_session/_result/_result.py +31 -0
- cognite/neat/_session/_session.py +81 -0
- cognite/neat/_session/_usage_analytics/__init__.py +0 -0
- cognite/neat/_session/_usage_analytics/_collector.py +131 -0
- cognite/neat/_session/_usage_analytics/_constants.py +23 -0
- cognite/neat/_session/_usage_analytics/_storage.py +240 -0
- cognite/neat/_session/_wrappers.py +101 -0
- cognite/neat/_state_machine/__init__.py +10 -0
- cognite/neat/_state_machine/_base.py +37 -0
- cognite/neat/_state_machine/_states.py +52 -0
- cognite/neat/_store/__init__.py +3 -0
- cognite/neat/_store/_provenance.py +88 -0
- cognite/neat/_store/_store.py +220 -0
- cognite/neat/_utils/__init__.py +0 -0
- cognite/neat/_utils/_reader.py +194 -0
- cognite/neat/_utils/auxiliary.py +49 -0
- cognite/neat/_utils/collection.py +11 -0
- cognite/neat/_utils/http_client/__init__.py +39 -0
- cognite/neat/_utils/http_client/_client.py +245 -0
- cognite/neat/_utils/http_client/_config.py +19 -0
- cognite/neat/_utils/http_client/_data_classes.py +294 -0
- cognite/neat/_utils/http_client/_tracker.py +31 -0
- cognite/neat/_utils/repo.py +19 -0
- cognite/neat/_utils/text.py +71 -0
- cognite/neat/_utils/useful_types.py +37 -0
- cognite/neat/_utils/validation.py +154 -0
- cognite/neat/_v0/__init__.py +0 -0
- cognite/neat/_v0/core/__init__.py +0 -0
- cognite/neat/_v0/core/_client/_api/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_client/_api/data_modeling_loaders.py +8 -7
- cognite/neat/{core → _v0/core}/_client/_api/neat_instances.py +5 -5
- cognite/neat/{core → _v0/core}/_client/_api/schema.py +5 -5
- cognite/neat/{core → _v0/core}/_client/_api/statistics.py +3 -3
- cognite/neat/{core → _v0/core}/_client/_api_client.py +1 -1
- cognite/neat/_v0/core/_client/data_classes/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_client/data_classes/schema.py +4 -4
- cognite/neat/{core → _v0/core}/_client/testing.py +1 -1
- cognite/neat/{core → _v0/core}/_constants.py +5 -3
- cognite/neat/_v0/core/_data_model/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_data_model/_constants.py +7 -0
- cognite/neat/{core → _v0/core}/_data_model/_shared.py +4 -4
- cognite/neat/{core → _v0/core}/_data_model/analysis/_base.py +8 -8
- cognite/neat/{core → _v0/core}/_data_model/exporters/__init__.py +1 -2
- cognite/neat/{core → _v0/core}/_data_model/exporters/_base.py +7 -7
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2dms.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2excel.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2instance_template.py +4 -4
- cognite/neat/{core/_data_model/exporters/_data_model2ontology.py → _v0/core/_data_model/exporters/_data_model2semantic_model.py} +126 -116
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/importers/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/importers/_base_file_reader.py +2 -2
- cognite/neat/{core → _v0/core}/_data_model/importers/_dict2data_model.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/importers/_dms2data_model.py +18 -15
- cognite/neat/{core → _v0/core}/_data_model/importers/_graph2data_model.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_base.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_owl2data_model.py +41 -21
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_shared.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/importers/_spreadsheet2data_model.py +92 -12
- cognite/neat/{core → _v0/core}/_data_model/models/__init__.py +3 -3
- cognite/neat/{core → _v0/core}/_data_model/models/_base_verified.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/_import_contexts.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/models/_types.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_unverified.py +16 -10
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_validation.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_verified.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/models/data_types.py +14 -4
- cognite/neat/{core → _v0/core}/_data_model/models/entities/__init__.py +6 -0
- cognite/neat/_v0/core/_data_model/models/entities/_loaders.py +155 -0
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_multi_value.py +2 -2
- cognite/neat/_v0/core/_data_model/models/entities/_restrictions.py +230 -0
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_single_value.py +121 -16
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_types.py +10 -0
- cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/physical/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_exporter.py +26 -19
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_unverified.py +133 -37
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_validation.py +24 -20
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_verified.py +95 -24
- cognite/neat/{core → _v0/core}/_data_model/transformers/_base.py +4 -4
- cognite/neat/{core → _v0/core}/_data_model/transformers/_converters.py +35 -28
- cognite/neat/{core → _v0/core}/_data_model/transformers/_mapping.py +7 -7
- cognite/neat/{core → _v0/core}/_data_model/transformers/_union_conceptual.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/transformers/_verification.py +7 -7
- cognite/neat/_v0/core/_instances/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_instances/_tracking/base.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/_tracking/log.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/extractors/__init__.py +3 -2
- cognite/neat/{core → _v0/core}/_instances/extractors/_base.py +6 -6
- cognite/neat/_v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_base.py +7 -7
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_classic.py +12 -12
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_relationships.py +3 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_sequences.py +2 -2
- cognite/neat/{core → _v0/core}/_instances/extractors/_dict.py +6 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_dms.py +6 -6
- cognite/neat/{core → _v0/core}/_instances/extractors/_dms_graph.py +11 -11
- cognite/neat/{core → _v0/core}/_instances/extractors/_mock_graph_generator.py +10 -10
- cognite/neat/{core → _v0/core}/_instances/extractors/_raw.py +3 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_rdf_file.py +7 -7
- cognite/neat/{core → _v0/core}/_instances/loaders/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_instances/loaders/_rdf2dms.py +17 -17
- cognite/neat/{core → _v0/core}/_instances/loaders/_rdf_to_instance_space.py +11 -11
- cognite/neat/{core → _v0/core}/_instances/queries/_select.py +29 -3
- cognite/neat/{core → _v0/core}/_instances/queries/_update.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/transformers/_base.py +4 -4
- cognite/neat/{core → _v0/core}/_instances/transformers/_classic_cdf.py +6 -6
- cognite/neat/{core → _v0/core}/_instances/transformers/_prune_graph.py +4 -4
- cognite/neat/{core → _v0/core}/_instances/transformers/_rdfpath.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/transformers/_value_type.py +4 -4
- cognite/neat/{core → _v0/core}/_issues/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_issues/_contextmanagers.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/_factory.py +3 -3
- cognite/neat/{core → _v0/core}/_issues/errors/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_external.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_general.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_properties.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_resources.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/errors/_wrapper.py +7 -3
- cognite/neat/{core → _v0/core}/_issues/warnings/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_external.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_general.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_models.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/warnings/_properties.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/warnings/_resources.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/user_modeling.py +1 -1
- cognite/neat/{core → _v0/core}/_store/_data_model.py +12 -12
- cognite/neat/{core → _v0/core}/_store/_instance.py +43 -10
- cognite/neat/{core → _v0/core}/_store/_provenance.py +3 -3
- cognite/neat/{core → _v0/core}/_store/exceptions.py +4 -4
- cognite/neat/_v0/core/_utils/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_utils/auth.py +22 -12
- cognite/neat/{core → _v0/core}/_utils/auxiliary.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/collection_.py +2 -2
- cognite/neat/{core → _v0/core}/_utils/graph_transformations_report.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/rdf_.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/reader/_base.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/spreadsheet.py +18 -4
- cognite/neat/{core → _v0/core}/_utils/text.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/upload.py +3 -3
- cognite/neat/{session → _v0}/engine/_load.py +1 -1
- cognite/neat/_v0/plugins/__init__.py +4 -0
- cognite/neat/_v0/plugins/_base.py +9 -0
- cognite/neat/_v0/plugins/_data_model.py +48 -0
- cognite/neat/{plugins → _v0/plugins}/_issues.py +1 -1
- cognite/neat/{plugins → _v0/plugins}/_manager.py +7 -16
- cognite/neat/{session → _v0/session}/_base.py +13 -15
- cognite/neat/{session → _v0/session}/_collector.py +1 -1
- cognite/neat/_v0/session/_diff.py +51 -0
- cognite/neat/{session → _v0/session}/_drop.py +3 -3
- cognite/neat/{session → _v0/session}/_explore.py +2 -2
- cognite/neat/{session → _v0/session}/_fix.py +2 -2
- cognite/neat/{session → _v0/session}/_inspect.py +3 -3
- cognite/neat/{session → _v0/session}/_mapping.py +3 -3
- cognite/neat/{session → _v0/session}/_plugin.py +4 -5
- cognite/neat/{session → _v0/session}/_prepare.py +8 -8
- cognite/neat/{session → _v0/session}/_read.py +34 -21
- cognite/neat/{session → _v0/session}/_set.py +8 -8
- cognite/neat/{session → _v0/session}/_show.py +5 -5
- cognite/neat/{session → _v0/session}/_state.py +10 -10
- cognite/neat/{session → _v0/session}/_subset.py +4 -4
- cognite/neat/{session → _v0/session}/_template.py +11 -11
- cognite/neat/{session → _v0/session}/_to.py +12 -12
- cognite/neat/{session → _v0/session}/_wizard.py +1 -1
- cognite/neat/{session → _v0/session}/exceptions.py +5 -5
- cognite/neat/_version.py +1 -1
- cognite/neat/legacy.py +6 -0
- cognite_neat-1.0.22.dist-info/METADATA +123 -0
- cognite_neat-1.0.22.dist-info/RECORD +329 -0
- cognite_neat-1.0.22.dist-info/WHEEL +4 -0
- cognite/neat/core/_data_model/models/entities/_loaders.py +0 -75
- cognite/neat/plugins/__init__.py +0 -3
- cognite/neat/plugins/data_model/importers/__init__.py +0 -5
- cognite/neat/plugins/data_model/importers/_base.py +0 -28
- cognite/neat/session/_session/_data_model/__init__.py +0 -3
- cognite/neat/session/_session/_data_model/_read.py +0 -193
- cognite/neat/session/_session/_data_model/_routes.py +0 -45
- cognite/neat/session/_session/_data_model/_show.py +0 -147
- cognite/neat/session/_session/_data_model/_write.py +0 -335
- cognite_neat-0.123.26.dist-info/METADATA +0 -144
- cognite_neat-0.123.26.dist-info/RECORD +0 -201
- cognite_neat-0.123.26.dist-info/WHEEL +0 -4
- cognite_neat-0.123.26.dist-info/licenses/LICENSE +0 -201
- /cognite/neat/{core → _client/init}/__init__.py +0 -0
- /cognite/neat/{core/_client/_api → _data_model}/__init__.py +0 -0
- /cognite/neat/{core/_client/data_classes → _data_model/deployer}/__init__.py +0 -0
- /cognite/neat/{core/_data_model → _data_model/exporters/_table_exporter}/__init__.py +0 -0
- /cognite/neat/{core/_instances → _data_model/importers/_table_importer}/__init__.py +0 -0
- /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models}/__init__.py +0 -0
- /cognite/neat/{core/_utils → _data_model/models/conceptual}/__init__.py +0 -0
- /cognite/neat/{plugins/data_model → _data_model/validation}/__init__.py +0 -0
- /cognite/neat/{session/_session → _session/_html}/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/data_modeling.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/neat_sequence.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/statistics.py +0 -0
- /cognite/neat/{core → _v0/core}/_config.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/analysis/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/classic_model.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/hello_world_pump.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/importers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/_base_unverified.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/conceptual/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/entities/_constants.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/entities/_wrapped.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/mapping/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.yaml +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/transformers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/_shared.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/_tracking/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_assets.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_data_sets.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_events.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_files.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_labels.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_timeseries.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/loaders/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/_base.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/_queries.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/transformers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_issues/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_issues/formatters.py +0 -0
- /cognite/neat/{core → _v0/core}/_shared.py +0 -0
- /cognite/neat/{core → _v0/core}/_store/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/io_.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/reader/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/tarjan.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/time_.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/xml_.py +0 -0
- /cognite/neat/{session → _v0}/engine/__init__.py +0 -0
- /cognite/neat/{session → _v0}/engine/_import.py +0 -0
- /cognite/neat/{session → _v0}/engine/_interface.py +0 -0
- /cognite/neat/{session → _v0/session}/__init__.py +0 -0
- /cognite/neat/{session → _v0/session}/_experimental.py +0 -0
- /cognite/neat/{session → _v0/session}/_state/README.md +0 -0
|
@@ -10,25 +10,25 @@ from typing import Any, cast
|
|
|
10
10
|
import rdflib
|
|
11
11
|
from rdflib import URIRef
|
|
12
12
|
|
|
13
|
-
from cognite.neat.core._client import NeatClient
|
|
14
|
-
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
15
|
-
from cognite.neat.core._data_model._shared import T_VerifiedDataModel, VerifiedDataModel
|
|
16
|
-
from cognite.neat.core._data_model.exporters import BaseExporter
|
|
17
|
-
from cognite.neat.core._data_model.exporters._base import CDFExporter, T_Export
|
|
18
|
-
from cognite.neat.core._data_model.importers import BaseImporter
|
|
19
|
-
from cognite.neat.core._data_model.models import ConceptualDataModel, PhysicalDataModel
|
|
20
|
-
from cognite.neat.core._data_model.transformers import (
|
|
13
|
+
from cognite.neat._v0.core._client import NeatClient
|
|
14
|
+
from cognite.neat._v0.core._constants import DEFAULT_NAMESPACE
|
|
15
|
+
from cognite.neat._v0.core._data_model._shared import T_VerifiedDataModel, VerifiedDataModel
|
|
16
|
+
from cognite.neat._v0.core._data_model.exporters import BaseExporter
|
|
17
|
+
from cognite.neat._v0.core._data_model.exporters._base import CDFExporter, T_Export
|
|
18
|
+
from cognite.neat._v0.core._data_model.importers import BaseImporter
|
|
19
|
+
from cognite.neat._v0.core._data_model.models import ConceptualDataModel, PhysicalDataModel
|
|
20
|
+
from cognite.neat._v0.core._data_model.transformers import (
|
|
21
21
|
PhysicalToConceptual,
|
|
22
22
|
VerifiedDataModelTransformer,
|
|
23
23
|
VerifyAnyDataModel,
|
|
24
24
|
)
|
|
25
|
-
from cognite.neat.core._instances.extractors import (
|
|
25
|
+
from cognite.neat._v0.core._instances.extractors import (
|
|
26
26
|
DMSGraphExtractor,
|
|
27
27
|
KnowledgeGraphExtractor,
|
|
28
28
|
)
|
|
29
|
-
from cognite.neat.core._issues import IssueList, catch_issues
|
|
30
|
-
from cognite.neat.core._issues.errors import NeatValueError
|
|
31
|
-
from cognite.neat.core._utils.upload import UploadResultList
|
|
29
|
+
from cognite.neat._v0.core._issues import IssueList, catch_issues
|
|
30
|
+
from cognite.neat._v0.core._issues.errors import NeatValueError
|
|
31
|
+
from cognite.neat._v0.core._utils.upload import UploadResultList
|
|
32
32
|
|
|
33
33
|
from ._provenance import (
|
|
34
34
|
EXTERNAL_AGENT,
|
|
@@ -12,19 +12,20 @@ from rdflib import Dataset, Graph, Namespace, URIRef
|
|
|
12
12
|
from rdflib.graph import DATASET_DEFAULT_GRAPH_ID
|
|
13
13
|
from rdflib.plugins.stores.sparqlstore import SPARQLUpdateStore
|
|
14
14
|
|
|
15
|
-
from cognite.neat.core.
|
|
16
|
-
from cognite.neat.core._instances.
|
|
17
|
-
from cognite.neat.core._instances.
|
|
18
|
-
from cognite.neat.core._instances.
|
|
19
|
-
from cognite.neat.core.
|
|
20
|
-
from cognite.neat.core._issues
|
|
21
|
-
from cognite.neat.core.
|
|
22
|
-
from cognite.neat.core.
|
|
23
|
-
from cognite.neat.core._utils.
|
|
15
|
+
from cognite.neat._v0.core._constants import NAMED_GRAPH_NAMESPACE
|
|
16
|
+
from cognite.neat._v0.core._instances._shared import quad_formats, rdflib_to_oxi_type
|
|
17
|
+
from cognite.neat._v0.core._instances.extractors import RdfFileExtractor, TripleExtractors
|
|
18
|
+
from cognite.neat._v0.core._instances.queries import Queries
|
|
19
|
+
from cognite.neat._v0.core._instances.transformers import Transformers
|
|
20
|
+
from cognite.neat._v0.core._issues import IssueList, catch_issues
|
|
21
|
+
from cognite.neat._v0.core._issues.errors import NeatValueError, OxigraphStorageLockedError
|
|
22
|
+
from cognite.neat._v0.core._shared import InstanceType, Triple
|
|
23
|
+
from cognite.neat._v0.core._utils.auxiliary import local_import
|
|
24
|
+
from cognite.neat._v0.core._utils.rdf_ import (
|
|
24
25
|
add_triples_in_batch,
|
|
25
26
|
remove_namespace_from_uri,
|
|
26
27
|
)
|
|
27
|
-
from cognite.neat.core._utils.text import humanize_collection
|
|
28
|
+
from cognite.neat._v0.core._utils.text import humanize_collection
|
|
28
29
|
|
|
29
30
|
from ._provenance import Change, Entity, Provenance
|
|
30
31
|
|
|
@@ -450,3 +451,35 @@ class NeatInstanceStore:
|
|
|
450
451
|
def empty(self) -> bool:
|
|
451
452
|
"""Cheap way to check if the graph store is empty."""
|
|
452
453
|
return not self.queries.select.has_data()
|
|
454
|
+
|
|
455
|
+
def diff(self, current_named_graph: URIRef, new_named_graph: URIRef) -> None:
|
|
456
|
+
"""
|
|
457
|
+
Compare two named graphs and store diff results in dedicated named graphs.
|
|
458
|
+
|
|
459
|
+
Stores triples to add in DIFF_ADD and triples to delete in DIFF_DELETE.
|
|
460
|
+
|
|
461
|
+
Args:
|
|
462
|
+
current_named_graph: URI of the current named graph
|
|
463
|
+
new_named_graph: URI of the new/updated named graph
|
|
464
|
+
|
|
465
|
+
Raises:
|
|
466
|
+
NeatValueError: If either named graph doesn't exist in the store
|
|
467
|
+
"""
|
|
468
|
+
if current_named_graph not in self.named_graphs:
|
|
469
|
+
raise NeatValueError(f"Current named graph not found: {current_named_graph}")
|
|
470
|
+
if new_named_graph not in self.named_graphs:
|
|
471
|
+
raise NeatValueError(f"New named graph not found: {new_named_graph}")
|
|
472
|
+
|
|
473
|
+
# Clear previous diff results using SPARQL
|
|
474
|
+
self.dataset.update(f"CLEAR SILENT GRAPH <{NAMED_GRAPH_NAMESPACE['DIFF_ADD']}>")
|
|
475
|
+
self.dataset.update(f"CLEAR SILENT GRAPH <{NAMED_GRAPH_NAMESPACE['DIFF_DELETE']}>")
|
|
476
|
+
|
|
477
|
+
# Store new diff results
|
|
478
|
+
self._add_triples(
|
|
479
|
+
self.queries.select.get_graph_diff(new_named_graph, current_named_graph),
|
|
480
|
+
named_graph=NAMED_GRAPH_NAMESPACE["DIFF_ADD"],
|
|
481
|
+
)
|
|
482
|
+
self._add_triples(
|
|
483
|
+
self.queries.select.get_graph_diff(current_named_graph, new_named_graph),
|
|
484
|
+
named_graph=NAMED_GRAPH_NAMESPACE["DIFF_DELETE"],
|
|
485
|
+
)
|
|
@@ -24,9 +24,9 @@ from typing import Any, Generic, TypeVar
|
|
|
24
24
|
|
|
25
25
|
from rdflib import PROV, RDF, Literal, URIRef
|
|
26
26
|
|
|
27
|
-
from cognite.neat.core._constants import CDF_NAMESPACE, DEFAULT_NAMESPACE
|
|
28
|
-
from cognite.neat.core._issues import IssueList
|
|
29
|
-
from cognite.neat.core._shared import FrozenNeatObject, NeatList, Triple
|
|
27
|
+
from cognite.neat._v0.core._constants import CDF_NAMESPACE, DEFAULT_NAMESPACE
|
|
28
|
+
from cognite.neat._v0.core._issues import IssueList
|
|
29
|
+
from cognite.neat._v0.core._shared import FrozenNeatObject, NeatList, Triple
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
@dataclass(frozen=True)
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
|
|
5
|
-
from cognite.neat.core._data_model.importers import BaseImporter
|
|
6
|
-
from cognite.neat.core._data_model.transformers import VerifiedDataModelTransformer
|
|
7
|
-
from cognite.neat.core._instances.extractors import KnowledgeGraphExtractor
|
|
8
|
-
from cognite.neat.core._issues import IssueList
|
|
5
|
+
from cognite.neat._v0.core._data_model.importers import BaseImporter
|
|
6
|
+
from cognite.neat._v0.core._data_model.transformers import VerifiedDataModelTransformer
|
|
7
|
+
from cognite.neat._v0.core._instances.extractors import KnowledgeGraphExtractor
|
|
8
|
+
from cognite.neat._v0.core._issues import IssueList
|
|
9
9
|
|
|
10
10
|
from ._provenance import Activity
|
|
11
11
|
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ from cognite.client.config import global_config
|
|
|
11
11
|
from cognite.client.credentials import CredentialProvider, OAuthClientCredentials, OAuthInteractive, Token
|
|
12
12
|
|
|
13
13
|
from cognite.neat import _version
|
|
14
|
-
from cognite.neat.core._utils.auxiliary import local_import
|
|
14
|
+
from cognite.neat._v0.core._utils.auxiliary import local_import
|
|
15
15
|
|
|
16
16
|
__all__ = ["EnvironmentVariables", "get_cognite_client"]
|
|
17
17
|
|
|
@@ -93,7 +93,7 @@ class EnvironmentVariables:
|
|
|
93
93
|
LOGIN_FLOW: _LOGIN_FLOW = "infer"
|
|
94
94
|
IDP_CLIENT_ID: str | None = None
|
|
95
95
|
IDP_CLIENT_SECRET: str | None = None
|
|
96
|
-
|
|
96
|
+
CDF_TOKEN: str | None = None
|
|
97
97
|
|
|
98
98
|
IDP_TENANT_ID: str | None = None
|
|
99
99
|
IDP_TOKEN_URL: str | None = None
|
|
@@ -103,7 +103,7 @@ class EnvironmentVariables:
|
|
|
103
103
|
IDP_SCOPES: str | None = None
|
|
104
104
|
IDP_AUTHORITY_URL: str | None = None
|
|
105
105
|
CDF_MAX_WORKERS: int | None = None
|
|
106
|
-
|
|
106
|
+
CDF_CLIENT_TIMEOUT: int | None = None
|
|
107
107
|
CDF_REDIRECT_PORT: int = 53_000
|
|
108
108
|
|
|
109
109
|
def __post_init__(self) -> None:
|
|
@@ -155,7 +155,7 @@ class EnvironmentVariables:
|
|
|
155
155
|
LOGIN_FLOW=os.environ.get("LOGIN_FLOW", "infer"), # type: ignore[arg-type]
|
|
156
156
|
IDP_CLIENT_ID=os.environ.get("IDP_CLIENT_ID"),
|
|
157
157
|
IDP_CLIENT_SECRET=os.environ.get("IDP_CLIENT_SECRET"),
|
|
158
|
-
|
|
158
|
+
CDF_TOKEN=os.environ.get("CDF_TOKEN"),
|
|
159
159
|
CDF_URL=os.environ.get("CDF_URL"),
|
|
160
160
|
IDP_TOKEN_URL=os.environ.get("IDP_TOKEN_URL"),
|
|
161
161
|
IDP_TENANT_ID=os.environ.get("IDP_TENANT_ID"),
|
|
@@ -163,7 +163,7 @@ class EnvironmentVariables:
|
|
|
163
163
|
IDP_SCOPES=os.environ.get("IDP_SCOPES"),
|
|
164
164
|
IDP_AUTHORITY_URL=os.environ.get("IDP_AUTHORITY_URL"),
|
|
165
165
|
CDF_MAX_WORKERS=int(os.environ["CDF_MAX_WORKERS"]) if "CDF_MAX_WORKERS" in os.environ else None,
|
|
166
|
-
|
|
166
|
+
CDF_CLIENT_TIMEOUT=int(os.environ["CDF_CLIENT_TIMEOUT"]) if "CDF_CLIENT_TIMEOUT" in os.environ else None,
|
|
167
167
|
CDF_REDIRECT_PORT=int(os.environ.get("CDF_REDIRECT_PORT", 53_000)),
|
|
168
168
|
)
|
|
169
169
|
|
|
@@ -179,7 +179,7 @@ class EnvironmentVariables:
|
|
|
179
179
|
IDP_CLIENT_ID="neat",
|
|
180
180
|
IDP_CLIENT_SECRET="secret",
|
|
181
181
|
IDP_SCOPES="project:read,project:write",
|
|
182
|
-
|
|
182
|
+
CDF_CLIENT_TIMEOUT=60,
|
|
183
183
|
CDF_MAX_WORKERS=3,
|
|
184
184
|
)
|
|
185
185
|
|
|
@@ -228,9 +228,9 @@ class EnvironmentVariables:
|
|
|
228
228
|
)
|
|
229
229
|
|
|
230
230
|
def get_token(self) -> Token:
|
|
231
|
-
if not self.
|
|
232
|
-
raise KeyError("
|
|
233
|
-
return Token(self.
|
|
231
|
+
if not self.CDF_TOKEN:
|
|
232
|
+
raise KeyError("CDF_TOKEN must be set in the environment", "CDF_TOKEN")
|
|
233
|
+
return Token(self.CDF_TOKEN)
|
|
234
234
|
|
|
235
235
|
def get_client(self) -> CogniteClient:
|
|
236
236
|
config = ClientConfig(
|
|
@@ -239,7 +239,7 @@ class EnvironmentVariables:
|
|
|
239
239
|
credentials=self.get_credentials(),
|
|
240
240
|
base_url=self.cdf_url,
|
|
241
241
|
max_workers=self.CDF_MAX_WORKERS,
|
|
242
|
-
timeout=self.
|
|
242
|
+
timeout=self.CDF_CLIENT_TIMEOUT,
|
|
243
243
|
)
|
|
244
244
|
return CogniteClient(config)
|
|
245
245
|
|
|
@@ -267,12 +267,22 @@ def _from_dotenv(evn_file: Path) -> EnvironmentVariables:
|
|
|
267
267
|
raise FileNotFoundError(f"{evn_file} does not exist.")
|
|
268
268
|
content = evn_file.read_text()
|
|
269
269
|
valid_variables = {f.name for f in fields(EnvironmentVariables)}
|
|
270
|
-
|
|
270
|
+
int_variables = {"CDF_MAX_WORKERS", "CDF_CLIENT_TIMEOUT", "CDF_REDIRECT_PORT"}
|
|
271
|
+
variables: dict[str, str | int] = {}
|
|
272
|
+
value: str | int
|
|
271
273
|
for line in content.splitlines():
|
|
272
274
|
if line.startswith("#") or "=" not in line:
|
|
273
275
|
continue
|
|
274
276
|
key, value = line.split("=", 1)
|
|
275
277
|
if key in valid_variables:
|
|
278
|
+
if key in int_variables:
|
|
279
|
+
try:
|
|
280
|
+
value = int(value)
|
|
281
|
+
except ValueError as e:
|
|
282
|
+
raise ValueError(
|
|
283
|
+
f"Failed to parse {evn_file.as_posix()!r} file. "
|
|
284
|
+
f"Variable '{key}' must be an integer, but got '{value}'."
|
|
285
|
+
) from e
|
|
276
286
|
variables[key] = value
|
|
277
287
|
return EnvironmentVariables(**variables) # type: ignore[arg-type]
|
|
278
288
|
|
|
@@ -298,7 +308,7 @@ def _prompt_user() -> EnvironmentVariables:
|
|
|
298
308
|
variables.LOGIN_FLOW = login_flow # type: ignore[assignment]
|
|
299
309
|
if login_flow == "token":
|
|
300
310
|
token = Prompt.ask("Enter token")
|
|
301
|
-
variables.
|
|
311
|
+
variables.CDF_TOKEN = token
|
|
302
312
|
return variables
|
|
303
313
|
|
|
304
314
|
variables.IDP_CLIENT_ID = Prompt.ask("Enter IDP Client ID")
|
|
@@ -11,7 +11,7 @@ from typing import Any
|
|
|
11
11
|
|
|
12
12
|
from cognite.client.exceptions import CogniteDuplicatedError, CogniteReadTimeout
|
|
13
13
|
|
|
14
|
-
from cognite.neat.core._issues.errors._general import NeatImportError
|
|
14
|
+
from cognite.neat._v0.core._issues.errors._general import NeatImportError
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def local_import(module: str, extra: str) -> ModuleType:
|
|
@@ -2,8 +2,8 @@ from collections import Counter
|
|
|
2
2
|
from collections.abc import Iterable, Sequence
|
|
3
3
|
from typing import TypeVar
|
|
4
4
|
|
|
5
|
-
from cognite.neat.core._config import GLOBAL_CONFIG
|
|
6
|
-
from cognite.neat.core._constants import IN_PYODIDE
|
|
5
|
+
from cognite.neat._v0.core._config import GLOBAL_CONFIG
|
|
6
|
+
from cognite.neat._v0.core._constants import IN_PYODIDE
|
|
7
7
|
|
|
8
8
|
T_Element = TypeVar("T_Element")
|
|
9
9
|
|
|
@@ -8,7 +8,7 @@ from pydantic import HttpUrl, TypeAdapter, ValidationError
|
|
|
8
8
|
from rdflib import Graph, Namespace, URIRef
|
|
9
9
|
from rdflib import Literal as RdfLiteral
|
|
10
10
|
|
|
11
|
-
from cognite.neat.core._constants import SPACE_URI_PATTERN
|
|
11
|
+
from cognite.neat._v0.core._constants import SPACE_URI_PATTERN
|
|
12
12
|
|
|
13
13
|
Triple: TypeAlias = tuple[URIRef, URIRef, RdfLiteral | URIRef]
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ from openpyxl import load_workbook
|
|
|
8
8
|
from openpyxl.worksheet.datavalidation import DataValidation
|
|
9
9
|
from openpyxl.worksheet.worksheet import Worksheet
|
|
10
10
|
|
|
11
|
-
from cognite.neat.core._data_model._constants import get_internal_properties
|
|
11
|
+
from cognite.neat._v0.core._data_model._constants import get_internal_properties
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
@dataclass
|
|
@@ -143,13 +143,27 @@ def _get_row_number(sheet: Worksheet, values_to_find: list[str]) -> int | None:
|
|
|
143
143
|
return None
|
|
144
144
|
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
@overload
|
|
147
|
+
def find_column_and_row_with_value(
|
|
148
|
+
sheet: Worksheet, value: Any, column_letter: Literal[True] = True
|
|
149
|
+
) -> tuple[str, int] | tuple[None, None]: ...
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@overload
|
|
153
|
+
def find_column_and_row_with_value(
|
|
154
|
+
sheet: Worksheet, value: Any, column_letter: Literal[False]
|
|
155
|
+
) -> tuple[int, int] | tuple[None, None]: ...
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def find_column_and_row_with_value(
|
|
159
|
+
sheet: Worksheet, value: Any, column_letter: bool = True
|
|
160
|
+
) -> tuple[int, int] | tuple[str, int] | tuple[None, None]:
|
|
147
161
|
for row in sheet.iter_rows():
|
|
148
162
|
for cell in row:
|
|
149
163
|
if cell.value and isinstance(cell.value, str) and cell.value.lower() == value.lower():
|
|
150
|
-
return cell.column_letter
|
|
164
|
+
return (cell.column_letter, cell.row) if column_letter else (cell.column, cell.row)
|
|
151
165
|
|
|
152
|
-
return None
|
|
166
|
+
return None, None
|
|
153
167
|
|
|
154
168
|
|
|
155
169
|
def generate_data_validation(sheet: str, column: str, total_header_rows: int, validation_range: int) -> DataValidation:
|
|
@@ -4,7 +4,7 @@ from collections.abc import Collection, Set
|
|
|
4
4
|
from re import Pattern
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
from cognite.neat.core._data_model._constants import get_reserved_words
|
|
7
|
+
from cognite.neat._v0.core._data_model._constants import get_reserved_words
|
|
8
8
|
|
|
9
9
|
PREPOSITIONS = frozenset(
|
|
10
10
|
{
|
|
@@ -3,9 +3,9 @@ from dataclasses import dataclass, field
|
|
|
3
3
|
from functools import total_ordering
|
|
4
4
|
from typing import Any, Generic
|
|
5
5
|
|
|
6
|
-
from cognite.neat.core._issues import IssueList
|
|
7
|
-
from cognite.neat.core._issues.errors import NeatValueError
|
|
8
|
-
from cognite.neat.core._shared import T_ID, NeatList, NeatObject
|
|
6
|
+
from cognite.neat._v0.core._issues import IssueList
|
|
7
|
+
from cognite.neat._v0.core._issues.errors import NeatValueError
|
|
8
|
+
from cognite.neat._v0.core._shared import T_ID, NeatList, NeatObject
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@total_ordering
|
|
@@ -12,8 +12,8 @@ from cognite.client import CogniteClient
|
|
|
12
12
|
from packaging.version import Version
|
|
13
13
|
from packaging.version import parse as parse_version
|
|
14
14
|
|
|
15
|
+
from cognite.neat._v0.core._issues.errors import NeatValueError
|
|
15
16
|
from cognite.neat._version import __engine__
|
|
16
|
-
from cognite.neat.core._issues.errors import NeatValueError
|
|
17
17
|
|
|
18
18
|
ENVIRONMENT_VARIABLE = "NEATENGINE"
|
|
19
19
|
PACKAGE_NAME = "neatengine"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from cognite.neat._v0.core._data_model.importers._base import BaseImporter
|
|
5
|
+
from cognite.neat._v0.core._data_model.transformers._base import VerifiedDataModelTransformer
|
|
6
|
+
|
|
7
|
+
from ._base import NeatPlugin
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DataModelImporterPlugin(NeatPlugin):
|
|
11
|
+
"""This class is used an interface for data model import plugins.
|
|
12
|
+
Any plugin that is used for importing data models should inherit from this class.
|
|
13
|
+
It is expected to implement the `configure` method which returns a configured importer.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def configure(self, io: str | Path | None, **kwargs: Any) -> BaseImporter:
|
|
17
|
+
"""Return a configure plugin for data model import.
|
|
18
|
+
Args:
|
|
19
|
+
io (str | Path | None): The input/output interface for the plugin.
|
|
20
|
+
**kwargs (Any): Additional keyword arguments for configuration.
|
|
21
|
+
Returns:
|
|
22
|
+
BaseImporter: A configured instance of the BaseImporter.
|
|
23
|
+
!!! note "Returns"
|
|
24
|
+
The method must return an instance of `BaseImporter` or its subclasses
|
|
25
|
+
meaning it must implement the `BaseImporter` interface.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
raise NotImplementedError()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DataModelTransformerPlugin(NeatPlugin):
|
|
32
|
+
"""This class is used as an interface for data model transformer plugins.
|
|
33
|
+
Any plugin that is used for transforming data models should inherit from this class.
|
|
34
|
+
It is expected to implement the `configure` method which returns a configured transformer.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
def configure(self, **kwargs: Any) -> VerifiedDataModelTransformer:
|
|
38
|
+
"""Return a configure plugin for data model import.
|
|
39
|
+
Args:
|
|
40
|
+
**kwargs (Any): Additional keyword arguments for configuration.
|
|
41
|
+
Returns:
|
|
42
|
+
VerifiedDataModelTransformer: A configured instance of the VerifiedDataModelTransformer.
|
|
43
|
+
!!! note "Returns"
|
|
44
|
+
The method must return an instance of `VerifiedDataModelTransformer` or its subclasses
|
|
45
|
+
meaning it must implement the `VerifiedDataModelTransformer` interface.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
raise NotImplementedError()
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
"""Plugin manager for external plugins."""
|
|
2
2
|
|
|
3
3
|
from importlib import metadata
|
|
4
|
-
from typing import Any, ClassVar
|
|
4
|
+
from typing import Any, ClassVar
|
|
5
5
|
|
|
6
|
+
from ._base import NeatPlugin
|
|
7
|
+
from ._data_model import DataModelImporterPlugin, DataModelTransformerPlugin
|
|
6
8
|
from ._issues import PluginDuplicateError, PluginError, PluginLoadingError
|
|
7
|
-
from .data_model.importers import DataModelImporterPlugin
|
|
8
|
-
|
|
9
|
-
# Here we configure entry points where external plugins are going to be registered.
|
|
10
|
-
plugins_entry_points = {
|
|
11
|
-
"cognite.neat.plugins.data_model.importers": DataModelImporterPlugin,
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#: Type alias for all supported plugin types
|
|
15
|
-
NeatPlugin: TypeAlias = DataModelImporterPlugin
|
|
16
|
-
|
|
17
|
-
# Generic type variable for plugin types
|
|
18
|
-
T_NeatPlugin = TypeVar("T_NeatPlugin", bound=NeatPlugin)
|
|
19
9
|
|
|
20
10
|
|
|
21
11
|
class Plugin:
|
|
@@ -47,13 +37,14 @@ class PluginManager:
|
|
|
47
37
|
"""Plugin manager for external plugins."""
|
|
48
38
|
|
|
49
39
|
_plugins_entry_points: ClassVar[dict[str, type[NeatPlugin]]] = {
|
|
50
|
-
"cognite.neat.plugins.data_model.importers": DataModelImporterPlugin,
|
|
40
|
+
"cognite.neat._v0.plugins.data_model.importers": DataModelImporterPlugin,
|
|
41
|
+
"cognite.neat._v0.plugins.data_model.transformers": DataModelTransformerPlugin,
|
|
51
42
|
}
|
|
52
43
|
|
|
53
44
|
def __init__(self, plugins: dict[tuple[str, type[NeatPlugin]], Any]) -> None:
|
|
54
45
|
self._plugins = plugins
|
|
55
46
|
|
|
56
|
-
def get(self, name: str, type_: type[
|
|
47
|
+
def get(self, name: str, type_: type[NeatPlugin]) -> type[NeatPlugin]:
|
|
57
48
|
"""
|
|
58
49
|
Returns desired plugin
|
|
59
50
|
|
|
@@ -63,7 +54,7 @@ class PluginManager:
|
|
|
63
54
|
"""
|
|
64
55
|
try:
|
|
65
56
|
plugin_class = self._plugins[(name, type_)]
|
|
66
|
-
return
|
|
57
|
+
return plugin_class
|
|
67
58
|
except KeyError:
|
|
68
59
|
raise PluginError(plugin_name=name, plugin_type=type_.__name__) from None
|
|
69
60
|
|
|
@@ -5,26 +5,28 @@ from cognite.client import CogniteClient
|
|
|
5
5
|
from cognite.client import data_modeling as dm
|
|
6
6
|
|
|
7
7
|
from cognite.neat import _version
|
|
8
|
-
from cognite.neat.core._client import NeatClient
|
|
9
|
-
from cognite.neat.core._data_model import importers
|
|
10
|
-
from cognite.neat.core._data_model.models import PhysicalDataModel
|
|
11
|
-
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
8
|
+
from cognite.neat._v0.core._client import NeatClient
|
|
9
|
+
from cognite.neat._v0.core._data_model import importers
|
|
10
|
+
from cognite.neat._v0.core._data_model.models import PhysicalDataModel
|
|
11
|
+
from cognite.neat._v0.core._data_model.models.conceptual._verified import (
|
|
12
12
|
ConceptualDataModel,
|
|
13
13
|
)
|
|
14
|
-
from cognite.neat.core._data_model.transformers import (
|
|
14
|
+
from cognite.neat._v0.core._data_model.transformers import (
|
|
15
15
|
ConceptualToPhysical,
|
|
16
16
|
MergeConceptualDataModels,
|
|
17
17
|
MergePhysicalDataModels,
|
|
18
18
|
ToDMSCompliantEntities,
|
|
19
19
|
VerifyConceptualDataModel,
|
|
20
20
|
)
|
|
21
|
-
from cognite.neat.core._issues import IssueList
|
|
22
|
-
from cognite.neat.core._issues.errors import RegexViolationError
|
|
23
|
-
from cognite.neat.core._issues.errors._general import NeatImportError
|
|
24
|
-
from cognite.neat.core._store._data_model import DataModelEntity
|
|
25
|
-
from cognite.neat.core._utils.auxiliary import local_import
|
|
21
|
+
from cognite.neat._v0.core._issues import IssueList
|
|
22
|
+
from cognite.neat._v0.core._issues.errors import RegexViolationError
|
|
23
|
+
from cognite.neat._v0.core._issues.errors._general import NeatImportError
|
|
24
|
+
from cognite.neat._v0.core._store._data_model import DataModelEntity
|
|
25
|
+
from cognite.neat._v0.core._utils.auxiliary import local_import
|
|
26
|
+
from cognite.neat._v0.engine import load_neat_engine
|
|
26
27
|
|
|
27
28
|
from ._collector import _COLLECTOR, Collector
|
|
29
|
+
from ._diff import DiffAPI
|
|
28
30
|
from ._drop import DropAPI
|
|
29
31
|
from ._explore import ExploreAPI
|
|
30
32
|
from ._fix import FixAPI
|
|
@@ -33,14 +35,12 @@ from ._mapping import MappingAPI
|
|
|
33
35
|
from ._plugin import PluginAPI
|
|
34
36
|
from ._prepare import PrepareAPI
|
|
35
37
|
from ._read import ReadAPI
|
|
36
|
-
from ._session._data_model import DataModelAPI
|
|
37
38
|
from ._set import SetAPI
|
|
38
39
|
from ._show import ShowAPI
|
|
39
40
|
from ._state import SessionState
|
|
40
41
|
from ._subset import SubsetAPI
|
|
41
42
|
from ._template import TemplateAPI
|
|
42
43
|
from ._to import ToAPI
|
|
43
|
-
from .engine import load_neat_engine
|
|
44
44
|
from .exceptions import session_class_wrapper
|
|
45
45
|
|
|
46
46
|
|
|
@@ -111,14 +111,12 @@ class NeatSession:
|
|
|
111
111
|
self.template = TemplateAPI(self._state)
|
|
112
112
|
self._explore = ExploreAPI(self._state)
|
|
113
113
|
self.plugins = PluginAPI(self._state)
|
|
114
|
+
self._diff = DiffAPI(self._state)
|
|
114
115
|
self.opt = OptAPI()
|
|
115
116
|
self.opt._display()
|
|
116
117
|
if load_engine != "skip" and (engine_version := load_neat_engine(client, load_engine)):
|
|
117
118
|
print(f"Neat Engine {engine_version} loaded.")
|
|
118
119
|
|
|
119
|
-
# new API for data model operations
|
|
120
|
-
self.data_model = DataModelAPI(self._state)
|
|
121
|
-
|
|
122
120
|
def _select_most_performant_store(self) -> Literal["memory", "oxigraph"]:
|
|
123
121
|
"""Select the most performant store based on the current environment."""
|
|
124
122
|
|
|
@@ -10,8 +10,8 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from mixpanel import Consumer, Mixpanel # type: ignore[import-untyped]
|
|
12
12
|
|
|
13
|
+
from cognite.neat._v0.core._constants import IN_NOTEBOOK, IN_PYODIDE
|
|
13
14
|
from cognite.neat._version import __version__
|
|
14
|
-
from cognite.neat.core._constants import IN_NOTEBOOK, IN_PYODIDE
|
|
15
15
|
|
|
16
16
|
_NEAT_MIXPANEL_TOKEN: str = "bd630ad149d19999df3989c3a3750c4f"
|
|
17
17
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from typing import cast
|
|
2
|
+
|
|
3
|
+
from rdflib.query import ResultRow
|
|
4
|
+
|
|
5
|
+
from cognite.neat._v0.core._constants import NAMED_GRAPH_NAMESPACE
|
|
6
|
+
|
|
7
|
+
from ._state import SessionState
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class DiffAPI:
|
|
11
|
+
"""Compare RDF graphs (private API)."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, state: SessionState) -> None:
|
|
14
|
+
self._state = state
|
|
15
|
+
|
|
16
|
+
def instances(self, current_named_graph: str, new_named_graph: str) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Compare two named graphs and store diff results.
|
|
19
|
+
|
|
20
|
+
Results stored in DIFF_ADD and DIFF_DELETE named graphs.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
current_named_graph: Name of the current graph (e.g., "CURRENT")
|
|
24
|
+
new_named_graph: Name of the new graph (e.g., "NEW")
|
|
25
|
+
"""
|
|
26
|
+
current_uri = NAMED_GRAPH_NAMESPACE[current_named_graph]
|
|
27
|
+
new_uri = NAMED_GRAPH_NAMESPACE[new_named_graph]
|
|
28
|
+
|
|
29
|
+
self._state.instances.store.diff(current_uri, new_uri)
|
|
30
|
+
self._print_summary()
|
|
31
|
+
|
|
32
|
+
def _print_summary(self) -> None:
|
|
33
|
+
"""Print diff summary with triple counts."""
|
|
34
|
+
store = self._state.instances.store
|
|
35
|
+
|
|
36
|
+
add_query = (
|
|
37
|
+
f"SELECT (COUNT(*) as ?count) WHERE {{ GRAPH <{NAMED_GRAPH_NAMESPACE['DIFF_ADD']}> {{ ?s ?p ?o }} }}"
|
|
38
|
+
)
|
|
39
|
+
delete_query = (
|
|
40
|
+
f"SELECT (COUNT(*) as ?count) WHERE {{ GRAPH <{NAMED_GRAPH_NAMESPACE['DIFF_DELETE']}> {{ ?s ?p ?o }} }}"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
add_result = cast(ResultRow, next(iter(store.dataset.query(add_query))))
|
|
44
|
+
delete_result = cast(ResultRow, next(iter(store.dataset.query(delete_query))))
|
|
45
|
+
|
|
46
|
+
add_count = int(add_result[0])
|
|
47
|
+
delete_count = int(delete_result[0])
|
|
48
|
+
|
|
49
|
+
print("Diff complete:")
|
|
50
|
+
print(f" {add_count} triples to add (stored in DIFF_ADD)")
|
|
51
|
+
print(f" {delete_count} triples to delete (stored in DIFF_DELETE)")
|
|
@@ -5,9 +5,9 @@ from typing import Literal
|
|
|
5
5
|
from cognite.client.utils.useful_types import SequenceNotStr
|
|
6
6
|
from rdflib import URIRef
|
|
7
7
|
|
|
8
|
-
from cognite.neat.core._constants import COGNITE_MODELS
|
|
9
|
-
from cognite.neat.core._data_model.transformers import DropModelViews
|
|
10
|
-
from cognite.neat.core._issues import IssueList
|
|
8
|
+
from cognite.neat._v0.core._constants import COGNITE_MODELS
|
|
9
|
+
from cognite.neat._v0.core._data_model.transformers import DropModelViews
|
|
10
|
+
from cognite.neat._v0.core._issues import IssueList
|
|
11
11
|
|
|
12
12
|
from ._state import SessionState
|
|
13
13
|
from .exceptions import NeatSessionError, session_class_wrapper
|
|
@@ -3,8 +3,8 @@ from typing import cast
|
|
|
3
3
|
import pandas as pd
|
|
4
4
|
from rdflib import URIRef
|
|
5
5
|
|
|
6
|
-
from cognite.neat.core._utils.rdf_ import remove_namespace_from_uri
|
|
7
|
-
from cognite.neat.core._utils.text import humanize_collection
|
|
6
|
+
from cognite.neat._v0.core._utils.rdf_ import remove_namespace_from_uri
|
|
7
|
+
from cognite.neat._v0.core._utils.text import humanize_collection
|
|
8
8
|
|
|
9
9
|
from ._state import SessionState
|
|
10
10
|
from .exceptions import NeatSessionError, session_class_wrapper
|