cognite-neat 0.123.2__py3-none-any.whl → 0.127.30__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 +2 -2
- cognite/neat/_client/__init__.py +4 -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 +125 -0
- cognite/neat/_client/data_classes.py +44 -0
- cognite/neat/_client/data_model_api.py +115 -0
- cognite/neat/_client/spaces_api.py +115 -0
- cognite/neat/_client/statistics_api.py +24 -0
- cognite/neat/_client/views_api.py +129 -0
- cognite/neat/_config.py +185 -0
- cognite/neat/_data_model/_analysis.py +196 -0
- cognite/neat/_data_model/_constants.py +67 -0
- cognite/neat/_data_model/_identifiers.py +61 -0
- cognite/neat/_data_model/_shared.py +41 -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 +529 -0
- cognite/neat/_data_model/deployer/deployer.py +401 -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 +421 -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 +295 -0
- cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
- cognite/neat/_data_model/importers/_table_importer/reader.py +1063 -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 +135 -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 +282 -0
- cognite/neat/_data_model/models/dms/_view_property.py +235 -0
- cognite/neat/_data_model/models/dms/_views.py +210 -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 +364 -0
- cognite/neat/_data_model/validation/dms/_base.py +307 -0
- cognite/neat/_data_model/validation/dms/_connections.py +638 -0
- cognite/neat/_data_model/validation/dms/_consistency.py +57 -0
- cognite/neat/_data_model/validation/dms/_containers.py +174 -0
- cognite/neat/_data_model/validation/dms/_limits.py +420 -0
- cognite/neat/_data_model/validation/dms/_orchestrator.py +222 -0
- cognite/neat/_data_model/validation/dms/_views.py +103 -0
- cognite/neat/_exceptions.py +56 -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 +303 -0
- cognite/neat/_session/_html/static/deployment.js +150 -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 +75 -0
- cognite/neat/_session/_html/templates/issues.html +45 -0
- cognite/neat/_session/_issues.py +81 -0
- cognite/neat/_session/_opt.py +35 -0
- cognite/neat/_session/_physical.py +261 -0
- cognite/neat/_session/_result.py +236 -0
- cognite/neat/_session/_session.py +88 -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 +82 -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 +81 -0
- cognite/neat/_store/_store.py +156 -0
- cognite/neat/_utils/__init__.py +0 -0
- cognite/neat/_utils/_reader.py +194 -0
- cognite/neat/_utils/auxiliary.py +39 -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/text.py +71 -0
- cognite/neat/_utils/useful_types.py +37 -0
- cognite/neat/_utils/validation.py +154 -0
- cognite/neat/_version.py +1 -1
- 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 +86 -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 +10 -3
- cognite/neat/v0/core/_data_model/__init__.py +0 -0
- cognite/neat/{core → v0/core}/_data_model/_constants.py +9 -6
- cognite/neat/{core → v0/core}/_data_model/_shared.py +5 -5
- cognite/neat/{core → v0/core}/_data_model/analysis/_base.py +12 -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 +13 -13
- 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 -133
- cognite/neat/{core → v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
- cognite/neat/{core → v0/core}/_data_model/importers/__init__.py +4 -6
- 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 +6 -6
- cognite/neat/{core → v0/core}/_data_model/importers/_dms2data_model.py +19 -16
- cognite/neat/v0/core/_data_model/importers/_graph2data_model.py +299 -0
- cognite/neat/v0/core/_data_model/importers/_rdf/__init__.py +4 -0
- cognite/neat/{core → v0/core}/_data_model/importers/_rdf/_base.py +13 -13
- cognite/neat/{core → v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
- cognite/neat/v0/core/_data_model/importers/_rdf/_owl2data_model.py +144 -0
- cognite/neat/v0/core/_data_model/importers/_rdf/_shared.py +255 -0
- cognite/neat/{core → v0/core}/_data_model/importers/_spreadsheet2data_model.py +94 -13
- 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/v0/core/_data_model/models/_import_contexts.py +82 -0
- cognite/neat/{core → v0/core}/_data_model/models/_types.py +5 -5
- cognite/neat/{core → v0/core}/_data_model/models/conceptual/_unverified.py +18 -12
- cognite/neat/v0/core/_data_model/models/conceptual/_validation.py +308 -0
- cognite/neat/{core → v0/core}/_data_model/models/conceptual/_verified.py +13 -11
- 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 +28 -21
- cognite/neat/{core → v0/core}/_data_model/models/physical/_unverified.py +141 -38
- cognite/neat/{core → v0/core}/_data_model/models/physical/_validation.py +190 -24
- cognite/neat/{core → v0/core}/_data_model/models/physical/_verified.py +135 -15
- cognite/neat/{core → v0/core}/_data_model/transformers/__init__.py +2 -0
- cognite/neat/{core → v0/core}/_data_model/transformers/_base.py +4 -4
- cognite/neat/{core → v0/core}/_data_model/transformers/_converters.py +39 -32
- cognite/neat/{core → v0/core}/_data_model/transformers/_mapping.py +7 -7
- cognite/neat/v0/core/_data_model/transformers/_union_conceptual.py +208 -0
- 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 +1 -1
- 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 +11 -6
- cognite/neat/{core → v0/core}/_issues/_contextmanagers.py +8 -6
- cognite/neat/{core → v0/core}/_issues/_factory.py +11 -8
- cognite/neat/{core → v0/core}/_issues/errors/__init__.py +3 -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 +12 -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 +5 -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 +39 -4
- cognite/neat/{core → v0/core}/_issues/warnings/_properties.py +13 -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 +13 -12
- cognite/neat/{core → v0/core}/_store/_instance.py +45 -12
- 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 +1 -1
- cognite/neat/{core → v0/core}/_utils/auxiliary.py +7 -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 +38 -14
- cognite/neat/{core → v0/core}/_utils/reader/_base.py +1 -1
- cognite/neat/{core → v0/core}/_utils/spreadsheet.py +22 -4
- cognite/neat/v0/core/_utils/tarjan.py +44 -0
- cognite/neat/{core → v0/core}/_utils/text.py +1 -1
- cognite/neat/{core → v0/core}/_utils/upload.py +3 -3
- 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 -10
- 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 +33 -43
- 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 +22 -8
- 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}/engine/_load.py +1 -1
- cognite/neat/{session → v0/session}/exceptions.py +5 -5
- cognite/neat/v1.py +3 -0
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/METADATA +9 -8
- cognite_neat-0.127.30.dist-info/RECORD +319 -0
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/WHEEL +1 -1
- cognite/neat/core/_data_model/importers/_dtdl2data_model/__init__.py +0 -3
- cognite/neat/core/_data_model/importers/_dtdl2data_model/_unit_lookup.py +0 -224
- cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_converter.py +0 -320
- cognite/neat/core/_data_model/importers/_dtdl2data_model/dtdl_importer.py +0 -155
- cognite/neat/core/_data_model/importers/_dtdl2data_model/spec.py +0 -363
- cognite/neat/core/_data_model/importers/_rdf/__init__.py +0 -5
- cognite/neat/core/_data_model/importers/_rdf/_imf2data_model.py +0 -98
- cognite/neat/core/_data_model/importers/_rdf/_owl2data_model.py +0 -87
- cognite/neat/core/_data_model/importers/_rdf/_shared.py +0 -168
- cognite/neat/core/_data_model/models/conceptual/_validation.py +0 -294
- 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-0.123.2.dist-info/RECORD +0 -197
- /cognite/neat/{core → _data_model}/__init__.py +0 -0
- /cognite/neat/{core/_client/_api → _data_model/deployer}/__init__.py +0 -0
- /cognite/neat/{core/_client/data_classes → _data_model/exporters/_table_exporter}/__init__.py +0 -0
- /cognite/neat/{core/_data_model → _data_model/importers/_table_importer}/__init__.py +0 -0
- /cognite/neat/{core/_instances → _data_model/models}/__init__.py +0 -0
- /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models/conceptual}/__init__.py +0 -0
- /cognite/neat/{core/_utils → _data_model/validation}/__init__.py +0 -0
- /cognite/neat/{plugins/data_model → _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/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}/_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/time_.py +0 -0
- /cognite/neat/{core → v0/core}/_utils/xml_.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
- /cognite/neat/{session → v0/session}/engine/__init__.py +0 -0
- /cognite/neat/{session → v0/session}/engine/_import.py +0 -0
- /cognite/neat/{session → v0/session}/engine/_interface.py +0 -0
- {cognite_neat-0.123.2.dist-info → cognite_neat-0.127.30.dist-info}/licenses/LICENSE +0 -0
|
@@ -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
|
|
|
@@ -172,7 +173,7 @@ class NeatInstanceStore:
|
|
|
172
173
|
local_import("pyoxigraph", "oxi")
|
|
173
174
|
local_import("oxrdflib", "oxi")
|
|
174
175
|
import oxrdflib
|
|
175
|
-
import pyoxigraph
|
|
176
|
+
import pyoxigraph # type: ignore[import-untyped]
|
|
176
177
|
|
|
177
178
|
try:
|
|
178
179
|
oxi_store = pyoxigraph.Store(path=str(storage_dir) if storage_dir else None)
|
|
@@ -347,7 +348,7 @@ class NeatInstanceStore:
|
|
|
347
348
|
)
|
|
348
349
|
return issue_list
|
|
349
350
|
_start = datetime.now(timezone.utc)
|
|
350
|
-
with catch_issues(
|
|
351
|
+
with catch_issues() as transform_issues:
|
|
351
352
|
transformer.transform(self.graph(named_graph))
|
|
352
353
|
issue_list.extend(transform_issues)
|
|
353
354
|
self.provenance.append(
|
|
@@ -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
|
|
|
@@ -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 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:
|
|
@@ -161,3 +161,9 @@ def get_parameters_by_method(obj: object, prefix: str = "") -> dict[str, dict[st
|
|
|
161
161
|
def get_parameters(obj: Callable) -> dict[str, type]:
|
|
162
162
|
annotations = inspect.get_annotations(obj)
|
|
163
163
|
return {name: annotations[name] for name in annotations if name != "return"}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def filter_kwargs_by_method(kwargs: dict[str, Any], method: Callable) -> dict[str, Any]:
|
|
167
|
+
"""Filter kwargs by method parameters."""
|
|
168
|
+
signature = inspect.signature(method)
|
|
169
|
+
return {k: v for k, v in kwargs.items() if k in signature.parameters}
|
|
@@ -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
|
|
|
@@ -147,19 +147,6 @@ def as_neat_compliant_uri(uri: URIRef) -> URIRef:
|
|
|
147
147
|
return URIRef(f"{namespace}{compliant_uri}")
|
|
148
148
|
|
|
149
149
|
|
|
150
|
-
def convert_rdflib_content(content: RdfLiteral | URIRef | dict | list, remove_namespace: bool = False) -> Any:
|
|
151
|
-
if isinstance(content, RdfLiteral):
|
|
152
|
-
return content.toPython()
|
|
153
|
-
elif isinstance(content, URIRef):
|
|
154
|
-
return remove_namespace_from_uri(content) if remove_namespace else content.toPython()
|
|
155
|
-
elif isinstance(content, dict):
|
|
156
|
-
return {key: convert_rdflib_content(value, remove_namespace) for key, value in content.items()}
|
|
157
|
-
elif isinstance(content, list):
|
|
158
|
-
return [convert_rdflib_content(item, remove_namespace) for item in content]
|
|
159
|
-
else:
|
|
160
|
-
return content
|
|
161
|
-
|
|
162
|
-
|
|
163
150
|
def uri_to_short_form(URI: URIRef, prefixes: dict[str, Namespace]) -> str | URIRef:
|
|
164
151
|
"""Returns the short form of a URI if its namespace is present in the prefixes dict,
|
|
165
152
|
otherwise returns the URI itself
|
|
@@ -179,6 +166,43 @@ def uri_to_short_form(URI: URIRef, prefixes: dict[str, Namespace]) -> str | URIR
|
|
|
179
166
|
return min(uris, key=len)
|
|
180
167
|
|
|
181
168
|
|
|
169
|
+
def uri_to_entity_components(uri: URIRef, prefixes: dict[str, Namespace]) -> tuple[str, str, str, str] | None:
|
|
170
|
+
"""Converts a URI to its components: space, data_model_id, version, and entity_id.
|
|
171
|
+
Args:
|
|
172
|
+
uri: URI to be converted
|
|
173
|
+
prefixes: dict of prefixes
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
tuple of space, data_model_id, version, and entity_id if found,
|
|
177
|
+
otherwise None
|
|
178
|
+
|
|
179
|
+
!!! note "URI Format"
|
|
180
|
+
The URI is expected to be in the form of `.../<space>/<data_model_id>/<version>/<entity_id>` to
|
|
181
|
+
be able to extract the components correctly.
|
|
182
|
+
|
|
183
|
+
An example of a valid entity URI is:
|
|
184
|
+
|
|
185
|
+
`https://cognitedata.com/cdf_cdm/CogniteCore/v1/CogniteAsset` , where:
|
|
186
|
+
|
|
187
|
+
- space is `cdf_cdm`
|
|
188
|
+
- data_model_id is `CogniteCore`
|
|
189
|
+
- version is `v1`
|
|
190
|
+
- entity_id is `CogniteAsset`
|
|
191
|
+
|
|
192
|
+
to be able to parse the URI correctly, the prefixes dict must have
|
|
193
|
+
the corresponding prefix registered:
|
|
194
|
+
{'cdf_cdm': Namespace('https://cognitedata.com/cdf_cdm/CogniteCore/v1/')}
|
|
195
|
+
|
|
196
|
+
for this method to return the correct components.
|
|
197
|
+
"""
|
|
198
|
+
for prefix, namespace in prefixes.items():
|
|
199
|
+
if uri.startswith(namespace):
|
|
200
|
+
remainder = str(uri)[len(str(namespace)) :]
|
|
201
|
+
if (components := remainder.split("/")) and len(components) == 3 and all(components):
|
|
202
|
+
return prefix, components[0], components[1], components[2]
|
|
203
|
+
return None
|
|
204
|
+
|
|
205
|
+
|
|
182
206
|
def _traverse(hierarchy: dict, graph: dict, names: list[str]) -> dict:
|
|
183
207
|
"""traverse the graph and return the hierarchy"""
|
|
184
208
|
for name in names:
|
|
@@ -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
|
|
@@ -98,6 +98,10 @@ def read_individual_sheet(
|
|
|
98
98
|
# Special handling for Value Type column, #N/A is treated specially by NEAT it means Unknown
|
|
99
99
|
raw["Value Type"] = raw["Value Type"].replace(float("nan"), "#N/A")
|
|
100
100
|
|
|
101
|
+
if "Concept" in raw.columns:
|
|
102
|
+
# Special handling for Concept column, #N/A is treated specially by NEAT it means Unknown
|
|
103
|
+
raw["Concept"] = raw["Concept"].replace(float("nan"), "#N/A")
|
|
104
|
+
|
|
101
105
|
output = raw.replace(float("nan"), None).to_dict(orient="records")
|
|
102
106
|
if return_read_info:
|
|
103
107
|
# If no rows are skipped, row 1 is the header row.
|
|
@@ -139,13 +143,27 @@ def _get_row_number(sheet: Worksheet, values_to_find: list[str]) -> int | None:
|
|
|
139
143
|
return None
|
|
140
144
|
|
|
141
145
|
|
|
142
|
-
|
|
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]:
|
|
143
161
|
for row in sheet.iter_rows():
|
|
144
162
|
for cell in row:
|
|
145
163
|
if cell.value and isinstance(cell.value, str) and cell.value.lower() == value.lower():
|
|
146
|
-
return cell.column_letter
|
|
164
|
+
return (cell.column_letter, cell.row) if column_letter else (cell.column, cell.row)
|
|
147
165
|
|
|
148
|
-
return None
|
|
166
|
+
return None, None
|
|
149
167
|
|
|
150
168
|
|
|
151
169
|
def generate_data_validation(sheet: str, column: str, total_header_rows: int, validation_range: int) -> DataValidation:
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from typing import TypeVar
|
|
2
|
+
|
|
3
|
+
T = TypeVar("T")
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def tarjan(dependencies_by_id: dict[T, set[T]]) -> list[set[T]]:
|
|
7
|
+
"""Returns the strongly connected components of the dependency graph
|
|
8
|
+
in topological order.
|
|
9
|
+
Args:
|
|
10
|
+
dependencies_by_id: A dictionary where the keys are ids and the values are sets of ids that the key depends on.
|
|
11
|
+
Returns:
|
|
12
|
+
A list of sets of ids that are strongly connected components in the dependency graph.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
stack = []
|
|
16
|
+
stack_set = set()
|
|
17
|
+
index: dict[T, int] = {}
|
|
18
|
+
lowlink = {}
|
|
19
|
+
result = []
|
|
20
|
+
|
|
21
|
+
def visit(v: T) -> None:
|
|
22
|
+
index[v] = len(index)
|
|
23
|
+
lowlink[v] = index[v]
|
|
24
|
+
stack.append(v)
|
|
25
|
+
stack_set.add(v)
|
|
26
|
+
for w in dependencies_by_id.get(v, []):
|
|
27
|
+
if w not in index:
|
|
28
|
+
visit(w)
|
|
29
|
+
lowlink[v] = min(lowlink[w], lowlink[v])
|
|
30
|
+
elif w in stack_set:
|
|
31
|
+
lowlink[v] = min(lowlink[v], index[w])
|
|
32
|
+
if lowlink[v] == index[v]:
|
|
33
|
+
scc = set()
|
|
34
|
+
dependency: T | None = None
|
|
35
|
+
while v != dependency:
|
|
36
|
+
dependency = stack.pop()
|
|
37
|
+
scc.add(dependency)
|
|
38
|
+
stack_set.remove(dependency)
|
|
39
|
+
result.append(scc)
|
|
40
|
+
|
|
41
|
+
for view_id in dependencies_by_id.keys():
|
|
42
|
+
if view_id not in index:
|
|
43
|
+
visit(view_id)
|
|
44
|
+
return result
|
|
@@ -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
|
|
@@ -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,27 @@ 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
26
|
|
|
27
27
|
from ._collector import _COLLECTOR, Collector
|
|
28
|
+
from ._diff import DiffAPI
|
|
28
29
|
from ._drop import DropAPI
|
|
29
30
|
from ._explore import ExploreAPI
|
|
30
31
|
from ._fix import FixAPI
|
|
@@ -110,6 +111,7 @@ class NeatSession:
|
|
|
110
111
|
self.template = TemplateAPI(self._state)
|
|
111
112
|
self._explore = ExploreAPI(self._state)
|
|
112
113
|
self.plugins = PluginAPI(self._state)
|
|
114
|
+
self._diff = DiffAPI(self._state)
|
|
113
115
|
self.opt = OptAPI()
|
|
114
116
|
self.opt._display()
|
|
115
117
|
if load_engine != "skip" and (engine_version := load_neat_engine(client, load_engine)):
|
|
@@ -173,6 +175,7 @@ class NeatSession:
|
|
|
173
175
|
"Convert to physical",
|
|
174
176
|
has_physical_data_model=False,
|
|
175
177
|
has_conceptual_data_model=True,
|
|
178
|
+
can_convert_to_physical_data_model=True,
|
|
176
179
|
)
|
|
177
180
|
converter = ConceptualToPhysical(reserved_properties=reserved_properties, client=self._state.client)
|
|
178
181
|
|
|
@@ -11,7 +11,7 @@ from typing import Any
|
|
|
11
11
|
from mixpanel import Consumer, Mixpanel # type: ignore[import-untyped]
|
|
12
12
|
|
|
13
13
|
from cognite.neat._version import __version__
|
|
14
|
-
from cognite.neat.core._constants import IN_NOTEBOOK, IN_PYODIDE
|
|
14
|
+
from cognite.neat.v0.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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from cognite.neat.core._data_model.transformers import (
|
|
1
|
+
from cognite.neat.v0.core._data_model.transformers import (
|
|
2
2
|
ToCompliantEntities,
|
|
3
3
|
)
|
|
4
|
-
from cognite.neat.core._issues._base import IssueList
|
|
4
|
+
from cognite.neat.v0.core._issues._base import IssueList
|
|
5
5
|
|
|
6
6
|
from ._state import SessionState
|
|
7
7
|
from .exceptions import session_class_wrapper
|