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
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
from typing import cast
|
|
2
|
-
|
|
3
|
-
from rdflib import BNode, Graph
|
|
4
|
-
from rdflib.plugins.sparql import prepareQuery
|
|
5
|
-
from rdflib.query import ResultRow
|
|
6
|
-
|
|
7
|
-
from cognite.neat.core._issues._base import IssueList
|
|
8
|
-
from cognite.neat.core._issues.errors._general import NeatValueError
|
|
9
|
-
from cognite.neat.core._issues.warnings._resources import (
|
|
10
|
-
ResourceRedefinedWarning,
|
|
11
|
-
ResourceRetrievalWarning,
|
|
12
|
-
)
|
|
13
|
-
from cognite.neat.core._utils.rdf_ import convert_rdflib_content
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def parse_concepts(graph: Graph, query: str, language: str, issue_list: IssueList) -> tuple[dict, IssueList]:
|
|
17
|
-
"""Parse concepts from graph
|
|
18
|
-
|
|
19
|
-
Args:
|
|
20
|
-
graph: Graph containing concept definitions
|
|
21
|
-
language: Language to use for parsing, by default "en"
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
Dataframe containing owl classes
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
concepts: dict[str, dict] = {}
|
|
28
|
-
|
|
29
|
-
query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
|
|
30
|
-
expected_keys = [str(v) for v in query.algebra._vars]
|
|
31
|
-
|
|
32
|
-
for raw in graph.query(query):
|
|
33
|
-
res: dict = convert_rdflib_content(cast(ResultRow, raw).asdict(), True)
|
|
34
|
-
res = {key: res.get(key, None) for key in expected_keys}
|
|
35
|
-
|
|
36
|
-
concept_id = res["concept"]
|
|
37
|
-
|
|
38
|
-
# Safeguarding against incomplete semantic definitions
|
|
39
|
-
if res["implements"] and isinstance(res["implements"], BNode):
|
|
40
|
-
issue_list.append(
|
|
41
|
-
ResourceRetrievalWarning(
|
|
42
|
-
concept_id,
|
|
43
|
-
"implements",
|
|
44
|
-
error=("Unable to determine concept that is being implemented"),
|
|
45
|
-
)
|
|
46
|
-
)
|
|
47
|
-
continue
|
|
48
|
-
|
|
49
|
-
if concept_id not in concepts:
|
|
50
|
-
concepts[concept_id] = res
|
|
51
|
-
else:
|
|
52
|
-
# Handling implements
|
|
53
|
-
if concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], list):
|
|
54
|
-
if res["implements"] not in concepts[concept_id]["implements"]:
|
|
55
|
-
concepts[concept_id]["implements"].append(res["implements"])
|
|
56
|
-
|
|
57
|
-
elif concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], str):
|
|
58
|
-
concepts[concept_id]["implements"] = [concepts[concept_id]["implements"]]
|
|
59
|
-
|
|
60
|
-
if res["implements"] not in concepts[concept_id]["implements"]:
|
|
61
|
-
concepts[concept_id]["implements"].append(res["implements"])
|
|
62
|
-
elif res["implements"]:
|
|
63
|
-
concepts[concept_id]["implements"] = [res["implements"]]
|
|
64
|
-
|
|
65
|
-
handle_meta("concept", concepts, concept_id, res, "name", issue_list)
|
|
66
|
-
handle_meta("concept", concepts, concept_id, res, "description", issue_list)
|
|
67
|
-
|
|
68
|
-
if not concepts:
|
|
69
|
-
issue_list.append(NeatValueError("Unable to parse concepts"))
|
|
70
|
-
|
|
71
|
-
return concepts, issue_list
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def parse_properties(graph: Graph, query: str, language: str, issue_list: IssueList) -> tuple[dict, IssueList]:
|
|
75
|
-
"""Parse properties from graph
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
graph: Graph containing owl classes
|
|
79
|
-
language: Language to use for parsing, by default "en"
|
|
80
|
-
|
|
81
|
-
Returns:
|
|
82
|
-
Dataframe containing owl classes
|
|
83
|
-
"""
|
|
84
|
-
|
|
85
|
-
properties: dict[str, dict] = {}
|
|
86
|
-
|
|
87
|
-
query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
|
|
88
|
-
expected_keys = [str(v) for v in query.algebra._vars]
|
|
89
|
-
|
|
90
|
-
for raw in graph.query(query):
|
|
91
|
-
res: dict = convert_rdflib_content(cast(ResultRow, raw).asdict(), True)
|
|
92
|
-
res = {key: res.get(key, None) for key in expected_keys}
|
|
93
|
-
|
|
94
|
-
property_id = res["property_"]
|
|
95
|
-
|
|
96
|
-
# Safeguarding against incomplete semantic definitions
|
|
97
|
-
if not res["concept"] or isinstance(res["concept"], BNode):
|
|
98
|
-
issue_list.append(
|
|
99
|
-
ResourceRetrievalWarning(
|
|
100
|
-
property_id,
|
|
101
|
-
"property",
|
|
102
|
-
error=("Unable to determine to what concept property is being defined"),
|
|
103
|
-
)
|
|
104
|
-
)
|
|
105
|
-
continue
|
|
106
|
-
|
|
107
|
-
# Safeguarding against incomplete semantic definitions
|
|
108
|
-
if not res["value_type"] or isinstance(res["value_type"], BNode):
|
|
109
|
-
issue_list.append(
|
|
110
|
-
ResourceRetrievalWarning(
|
|
111
|
-
property_id,
|
|
112
|
-
"property",
|
|
113
|
-
error=("Unable to determine value type of property"),
|
|
114
|
-
)
|
|
115
|
-
)
|
|
116
|
-
continue
|
|
117
|
-
|
|
118
|
-
id_ = f"{res['concept']}.{res['property_']}"
|
|
119
|
-
|
|
120
|
-
if id_ not in properties:
|
|
121
|
-
properties[id_] = res
|
|
122
|
-
properties[id_]["value_type"] = [properties[id_]["value_type"]]
|
|
123
|
-
else:
|
|
124
|
-
handle_meta("property", properties, id_, res, "name", issue_list)
|
|
125
|
-
handle_meta(
|
|
126
|
-
"property",
|
|
127
|
-
properties,
|
|
128
|
-
id_,
|
|
129
|
-
res,
|
|
130
|
-
"description",
|
|
131
|
-
issue_list,
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
# Handling multi-value types
|
|
135
|
-
if res["value_type"] not in properties[id_]["value_type"]:
|
|
136
|
-
properties[id_]["value_type"].append(res["value_type"])
|
|
137
|
-
|
|
138
|
-
for prop in properties.values():
|
|
139
|
-
prop["value_type"] = ", ".join(prop["value_type"])
|
|
140
|
-
|
|
141
|
-
if not properties:
|
|
142
|
-
issue_list.append(NeatValueError("Unable to parse properties"))
|
|
143
|
-
|
|
144
|
-
return properties, issue_list
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def handle_meta(
|
|
148
|
-
resource_type: str,
|
|
149
|
-
resources: dict[str, dict],
|
|
150
|
-
resource_id: str,
|
|
151
|
-
res: dict,
|
|
152
|
-
feature: str,
|
|
153
|
-
issue_list: IssueList,
|
|
154
|
-
) -> None:
|
|
155
|
-
if not resources[resource_id][feature] and res[feature]:
|
|
156
|
-
resources[resource_id][feature] = res[feature]
|
|
157
|
-
|
|
158
|
-
# RAISE warning only if the feature is being redefined
|
|
159
|
-
elif resources[resource_id][feature] and res[feature]:
|
|
160
|
-
issue_list.append(
|
|
161
|
-
ResourceRedefinedWarning(
|
|
162
|
-
identifier=resource_id,
|
|
163
|
-
resource_type=resource_type,
|
|
164
|
-
feature=feature,
|
|
165
|
-
current_value=resources[resource_id][feature],
|
|
166
|
-
new_value=res[feature],
|
|
167
|
-
)
|
|
168
|
-
)
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
import itertools
|
|
2
|
-
from collections import Counter, defaultdict
|
|
3
|
-
from collections.abc import Iterable
|
|
4
|
-
|
|
5
|
-
from cognite.neat.core._data_model._constants import PATTERNS, EntityTypes
|
|
6
|
-
from cognite.neat.core._data_model.models.entities import ConceptEntity, UnknownEntity
|
|
7
|
-
from cognite.neat.core._data_model.models.entities._multi_value import MultiValueTypeInfo
|
|
8
|
-
from cognite.neat.core._issues import IssueList
|
|
9
|
-
from cognite.neat.core._issues.errors import NeatValueError
|
|
10
|
-
from cognite.neat.core._issues.errors._resources import (
|
|
11
|
-
ResourceDuplicatedError,
|
|
12
|
-
ResourceNotDefinedError,
|
|
13
|
-
)
|
|
14
|
-
from cognite.neat.core._issues.warnings._models import UndefinedConceptWarning
|
|
15
|
-
from cognite.neat.core._issues.warnings._resources import (
|
|
16
|
-
ResourceNotDefinedWarning,
|
|
17
|
-
ResourceRegexViolationWarning,
|
|
18
|
-
)
|
|
19
|
-
from cognite.neat.core._utils.spreadsheet import SpreadsheetRead
|
|
20
|
-
from cognite.neat.core._utils.text import humanize_collection
|
|
21
|
-
|
|
22
|
-
from ._verified import ConceptualDataModel, ConceptualProperty
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class ConceptualValidation:
|
|
26
|
-
"""This class does all the validation of the conceptual data model that have dependencies
|
|
27
|
-
between components."""
|
|
28
|
-
|
|
29
|
-
def __init__(
|
|
30
|
-
self,
|
|
31
|
-
data_model: ConceptualDataModel,
|
|
32
|
-
read_info_by_spreadsheet: dict[str, SpreadsheetRead] | None = None,
|
|
33
|
-
):
|
|
34
|
-
self.data_model = data_model
|
|
35
|
-
self._read_info_by_spreadsheet = read_info_by_spreadsheet or {}
|
|
36
|
-
self._metadata = data_model.metadata
|
|
37
|
-
self._properties = data_model.properties
|
|
38
|
-
self._concepts = data_model.concepts
|
|
39
|
-
self.issue_list = IssueList()
|
|
40
|
-
|
|
41
|
-
def validate(self) -> IssueList:
|
|
42
|
-
self._duplicated_resources()
|
|
43
|
-
self._namespaces_reassigned()
|
|
44
|
-
self._classes_without_properties()
|
|
45
|
-
self._undefined_classes()
|
|
46
|
-
self._parent_concept_defined()
|
|
47
|
-
self._referenced_classes_exist()
|
|
48
|
-
self._referenced_value_types_exist()
|
|
49
|
-
self._regex_compliance_with_dms()
|
|
50
|
-
|
|
51
|
-
return self.issue_list
|
|
52
|
-
|
|
53
|
-
def _duplicated_resources(self) -> None:
|
|
54
|
-
properties_sheet = self._read_info_by_spreadsheet.get("Properties")
|
|
55
|
-
concepts_sheet = self._read_info_by_spreadsheet.get("Concepts")
|
|
56
|
-
|
|
57
|
-
visited = defaultdict(list)
|
|
58
|
-
for row_no, property_ in enumerate(self._properties):
|
|
59
|
-
visited[property_._identifier()].append(
|
|
60
|
-
properties_sheet.adjusted_row_number(row_no) if properties_sheet else row_no + 1
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
for identifier, rows in visited.items():
|
|
64
|
-
if len(rows) == 1:
|
|
65
|
-
continue
|
|
66
|
-
self.issue_list.append(
|
|
67
|
-
ResourceDuplicatedError(
|
|
68
|
-
identifier[1],
|
|
69
|
-
"property",
|
|
70
|
-
(
|
|
71
|
-
"the Properties sheet at row "
|
|
72
|
-
f"{humanize_collection(rows)}"
|
|
73
|
-
" if data model is read from a spreadsheet."
|
|
74
|
-
),
|
|
75
|
-
)
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
visited = defaultdict(list)
|
|
79
|
-
for row_no, concept in enumerate(self._concepts):
|
|
80
|
-
visited[concept._identifier()].append(
|
|
81
|
-
concepts_sheet.adjusted_row_number(row_no) if concepts_sheet else row_no + 1
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
for identifier, rows in visited.items():
|
|
85
|
-
if len(rows) == 1:
|
|
86
|
-
continue
|
|
87
|
-
self.issue_list.append(
|
|
88
|
-
ResourceDuplicatedError(
|
|
89
|
-
identifier[0],
|
|
90
|
-
"concept",
|
|
91
|
-
(f"the Classes sheet at row {humanize_collection(rows)} if data model is read from a spreadsheet."),
|
|
92
|
-
)
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
def _classes_without_properties(self) -> None:
|
|
96
|
-
defined_concepts = {concept.concept for concept in self._concepts}
|
|
97
|
-
referred_classes = {property_.concept for property_ in self._properties}
|
|
98
|
-
concept_parent_pairs = self._concept_parent_pairs()
|
|
99
|
-
|
|
100
|
-
if concepts_without_properties := defined_concepts.difference(referred_classes):
|
|
101
|
-
for concept in concepts_without_properties:
|
|
102
|
-
# USE CASE: class has no direct properties and no parents with properties
|
|
103
|
-
# and it is a class in the prefix of data model, as long as it is in the
|
|
104
|
-
# same prefix, meaning same space
|
|
105
|
-
if not concept_parent_pairs[concept] and concept.prefix == self._metadata.prefix:
|
|
106
|
-
self.issue_list.append(
|
|
107
|
-
ResourceNotDefinedWarning(
|
|
108
|
-
resource_type="concept",
|
|
109
|
-
identifier=concept,
|
|
110
|
-
location="Properties sheet",
|
|
111
|
-
)
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
def _undefined_classes(self) -> None:
|
|
115
|
-
defined_concept = {concept.concept for concept in self._concepts}
|
|
116
|
-
referred_concepts = {property_.concept for property_ in self._properties}
|
|
117
|
-
|
|
118
|
-
if undefined_concepts := referred_concepts.difference(defined_concept):
|
|
119
|
-
for concept in undefined_concepts:
|
|
120
|
-
self.issue_list.append(
|
|
121
|
-
ResourceNotDefinedError(
|
|
122
|
-
identifier=concept,
|
|
123
|
-
resource_type="concept",
|
|
124
|
-
location="Concepts sheet",
|
|
125
|
-
)
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
def _parent_concept_defined(self) -> None:
|
|
129
|
-
"""This is a validation to check if the parent concept is defined."""
|
|
130
|
-
concept_parent_pairs = self._concept_parent_pairs()
|
|
131
|
-
concepts = set(concept_parent_pairs.keys())
|
|
132
|
-
parents = set(itertools.chain.from_iterable(concept_parent_pairs.values()))
|
|
133
|
-
|
|
134
|
-
if undefined_parents := parents.difference(concepts):
|
|
135
|
-
for parent in undefined_parents:
|
|
136
|
-
if parent.prefix != self._metadata.prefix:
|
|
137
|
-
self.issue_list.append(UndefinedConceptWarning(concept_id=str(parent)))
|
|
138
|
-
else:
|
|
139
|
-
self.issue_list.append(
|
|
140
|
-
ResourceNotDefinedWarning(
|
|
141
|
-
resource_type="concept",
|
|
142
|
-
identifier=parent,
|
|
143
|
-
location="Concepts sheet",
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
def _referenced_classes_exist(self) -> None:
|
|
148
|
-
# needs to be complete for this validation to pass
|
|
149
|
-
defined_concept = {concept.concept for concept in self._concepts}
|
|
150
|
-
classes_with_explicit_properties = {property_.concept for property_ in self._properties}
|
|
151
|
-
|
|
152
|
-
# USE CASE: models are complete
|
|
153
|
-
if missing_classes := classes_with_explicit_properties.difference(defined_concept):
|
|
154
|
-
for concept in missing_classes:
|
|
155
|
-
self.issue_list.append(
|
|
156
|
-
ResourceNotDefinedWarning(
|
|
157
|
-
resource_type="concept",
|
|
158
|
-
identifier=concept,
|
|
159
|
-
location="Concepts sheet",
|
|
160
|
-
)
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
def _referenced_value_types_exist(self) -> None:
|
|
164
|
-
# adding UnknownEntity to the set of defined classes to handle the case where a property references an unknown
|
|
165
|
-
defined_classes = {concept.concept for concept in self._concepts} | {UnknownEntity()}
|
|
166
|
-
referred_object_types = {
|
|
167
|
-
property_.value_type
|
|
168
|
-
for property_ in self.data_model.properties
|
|
169
|
-
if property_.type_ == EntityTypes.object_property
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if missing_value_types := referred_object_types.difference(defined_classes):
|
|
173
|
-
# Todo: include row and column number
|
|
174
|
-
for missing in missing_value_types:
|
|
175
|
-
self.issue_list.append(
|
|
176
|
-
ResourceNotDefinedWarning(
|
|
177
|
-
resource_type="concept",
|
|
178
|
-
identifier=missing,
|
|
179
|
-
location="Concepts sheet",
|
|
180
|
-
)
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
def _regex_compliance_with_dms(self) -> None:
|
|
184
|
-
"""Check regex compliance with DMS of properties, classes and value types."""
|
|
185
|
-
|
|
186
|
-
for prop_ in self._properties:
|
|
187
|
-
if not PATTERNS.physical_property_id_compliance.match(prop_.property_):
|
|
188
|
-
self.issue_list.append(
|
|
189
|
-
ResourceRegexViolationWarning(
|
|
190
|
-
prop_.property_,
|
|
191
|
-
"Property",
|
|
192
|
-
"Properties sheet, Property column",
|
|
193
|
-
PATTERNS.physical_property_id_compliance.pattern,
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
if not PATTERNS.view_id_compliance.match(prop_.concept.suffix):
|
|
197
|
-
self.issue_list.append(
|
|
198
|
-
ResourceRegexViolationWarning(
|
|
199
|
-
prop_.concept,
|
|
200
|
-
"Concept",
|
|
201
|
-
"Properties sheet, Concept column",
|
|
202
|
-
PATTERNS.view_id_compliance.pattern,
|
|
203
|
-
)
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
# Handling Value Type
|
|
207
|
-
if (
|
|
208
|
-
isinstance(prop_.value_type, ConceptEntity)
|
|
209
|
-
and prop_.value_type != UnknownEntity()
|
|
210
|
-
and not PATTERNS.view_id_compliance.match(prop_.value_type.suffix)
|
|
211
|
-
):
|
|
212
|
-
self.issue_list.append(
|
|
213
|
-
ResourceRegexViolationWarning(
|
|
214
|
-
prop_.value_type,
|
|
215
|
-
"Value Type",
|
|
216
|
-
"Properties sheet, Value Type column",
|
|
217
|
-
PATTERNS.view_id_compliance.pattern,
|
|
218
|
-
)
|
|
219
|
-
)
|
|
220
|
-
if isinstance(prop_.value_type, MultiValueTypeInfo):
|
|
221
|
-
for value_type in prop_.value_type.types:
|
|
222
|
-
if (
|
|
223
|
-
isinstance(prop_.value_type, ConceptEntity)
|
|
224
|
-
and prop_.value_type != UnknownEntity()
|
|
225
|
-
and not PATTERNS.view_id_compliance.match(value_type.suffix)
|
|
226
|
-
):
|
|
227
|
-
self.issue_list.append(
|
|
228
|
-
ResourceRegexViolationWarning(
|
|
229
|
-
value_type,
|
|
230
|
-
"Value Type",
|
|
231
|
-
"Properties sheet, Value Type column",
|
|
232
|
-
PATTERNS.view_id_compliance.pattern,
|
|
233
|
-
)
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
for concepts in self._concepts:
|
|
237
|
-
if not PATTERNS.view_id_compliance.match(concepts.concept.suffix):
|
|
238
|
-
self.issue_list.append(
|
|
239
|
-
ResourceRegexViolationWarning(
|
|
240
|
-
concepts.concept,
|
|
241
|
-
"Concept",
|
|
242
|
-
"Concepts sheet, Class column",
|
|
243
|
-
PATTERNS.view_id_compliance.pattern,
|
|
244
|
-
)
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
if concepts.implements:
|
|
248
|
-
for parent in concepts.implements:
|
|
249
|
-
if not PATTERNS.view_id_compliance.match(parent.suffix):
|
|
250
|
-
self.issue_list.append(
|
|
251
|
-
ResourceRegexViolationWarning(
|
|
252
|
-
parent,
|
|
253
|
-
"Concept",
|
|
254
|
-
"Concepts sheet, Implements column",
|
|
255
|
-
PATTERNS.view_id_compliance.pattern,
|
|
256
|
-
)
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
def _concept_parent_pairs(self) -> dict[ConceptEntity, list[ConceptEntity]]:
|
|
260
|
-
concept_parent_pairs: dict[ConceptEntity, list[ConceptEntity]] = {}
|
|
261
|
-
concepts = self.data_model.model_copy(deep=True).concepts
|
|
262
|
-
|
|
263
|
-
for concept in concepts:
|
|
264
|
-
concept_parent_pairs[concept.concept] = []
|
|
265
|
-
if concept.implements is None:
|
|
266
|
-
continue
|
|
267
|
-
concept_parent_pairs[concept.concept].extend(concept.implements)
|
|
268
|
-
|
|
269
|
-
return concept_parent_pairs
|
|
270
|
-
|
|
271
|
-
def _namespaces_reassigned(self) -> None:
|
|
272
|
-
prefixes = self.data_model.prefixes.copy()
|
|
273
|
-
prefixes[self.data_model.metadata.namespace.prefix] = self.data_model.metadata.namespace
|
|
274
|
-
|
|
275
|
-
if len(set(prefixes.values())) != len(prefixes):
|
|
276
|
-
reused_namespaces = [value for value, count in Counter(prefixes.values()).items() if count > 1]
|
|
277
|
-
impacted_prefixes = [key for key, value in prefixes.items() if value in reused_namespaces]
|
|
278
|
-
self.issue_list.append(
|
|
279
|
-
NeatValueError(
|
|
280
|
-
"Namespace collision detected. The following prefixes "
|
|
281
|
-
f"are assigned to the same namespace: {impacted_prefixes}"
|
|
282
|
-
f"\nImpacted namespaces: {reused_namespaces}"
|
|
283
|
-
"\nMake sure that each unique namespace is assigned to a unique prefix"
|
|
284
|
-
)
|
|
285
|
-
)
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
def duplicated_properties(
|
|
289
|
-
properties: Iterable[ConceptualProperty],
|
|
290
|
-
) -> dict[tuple[ConceptEntity, str], list[tuple[int, ConceptualProperty]]]:
|
|
291
|
-
concept_properties_by_id: dict[tuple[ConceptEntity, str], list[tuple[int, ConceptualProperty]]] = defaultdict(list)
|
|
292
|
-
for prop_no, prop in enumerate(properties):
|
|
293
|
-
concept_properties_by_id[(prop.concept, prop.property_)].append((prop_no, prop))
|
|
294
|
-
return {k: v for k, v in concept_properties_by_id.items() if len(v) > 1}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
from typing import Literal
|
|
2
|
-
|
|
3
|
-
from cognite.neat.core._data_model.models.data_types import DataType
|
|
4
|
-
from cognite.neat.core._issues.errors import NeatTypeError
|
|
5
|
-
|
|
6
|
-
from ._multi_value import MultiValueTypeInfo
|
|
7
|
-
from ._single_value import (
|
|
8
|
-
ConceptEntity,
|
|
9
|
-
EdgeEntity,
|
|
10
|
-
PhysicalUnknownEntity,
|
|
11
|
-
ReverseConnectionEntity,
|
|
12
|
-
Unknown,
|
|
13
|
-
UnknownEntity,
|
|
14
|
-
ViewEntity,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def load_value_type(
|
|
19
|
-
raw: str | MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity,
|
|
20
|
-
default_prefix: str,
|
|
21
|
-
) -> MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity:
|
|
22
|
-
if isinstance(raw, MultiValueTypeInfo | DataType | ConceptEntity | UnknownEntity):
|
|
23
|
-
return raw
|
|
24
|
-
elif isinstance(raw, str):
|
|
25
|
-
# property holding xsd data type
|
|
26
|
-
# check if it is multi value type
|
|
27
|
-
if "," in raw:
|
|
28
|
-
value_type = MultiValueTypeInfo.load(raw)
|
|
29
|
-
value_type.set_default_prefix(default_prefix)
|
|
30
|
-
return value_type
|
|
31
|
-
elif DataType.is_data_type(raw):
|
|
32
|
-
return DataType.load(raw)
|
|
33
|
-
|
|
34
|
-
# unknown value type
|
|
35
|
-
elif raw == str(Unknown):
|
|
36
|
-
return UnknownEntity()
|
|
37
|
-
|
|
38
|
-
# property holding link to class
|
|
39
|
-
else:
|
|
40
|
-
return ConceptEntity.load(raw, prefix=default_prefix)
|
|
41
|
-
else:
|
|
42
|
-
raise NeatTypeError(f"Invalid value type: {type(raw)}")
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def load_dms_value_type(
|
|
46
|
-
raw: str | DataType | ViewEntity | PhysicalUnknownEntity,
|
|
47
|
-
default_space: str,
|
|
48
|
-
default_version: str,
|
|
49
|
-
) -> DataType | ViewEntity | PhysicalUnknownEntity:
|
|
50
|
-
if isinstance(raw, DataType | ViewEntity | PhysicalUnknownEntity):
|
|
51
|
-
return raw
|
|
52
|
-
elif isinstance(raw, str):
|
|
53
|
-
if DataType.is_data_type(raw):
|
|
54
|
-
return DataType.load(raw)
|
|
55
|
-
elif raw == str(Unknown):
|
|
56
|
-
return PhysicalUnknownEntity()
|
|
57
|
-
else:
|
|
58
|
-
return ViewEntity.load(raw, space=default_space, version=default_version)
|
|
59
|
-
raise NeatTypeError(f"Invalid value type: {type(raw)}")
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def load_connection(
|
|
63
|
-
raw: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | str | None,
|
|
64
|
-
default_space: str,
|
|
65
|
-
default_version: str,
|
|
66
|
-
) -> Literal["direct"] | ReverseConnectionEntity | EdgeEntity | None:
|
|
67
|
-
if isinstance(raw, str) and raw.lower() == "direct":
|
|
68
|
-
return "direct" # type: ignore[return-value]
|
|
69
|
-
elif isinstance(raw, EdgeEntity | ReverseConnectionEntity) or raw is None:
|
|
70
|
-
return raw # type: ignore[return-value]
|
|
71
|
-
elif isinstance(raw, str) and raw.startswith("edge"):
|
|
72
|
-
return EdgeEntity.load(raw, space=default_space, version=default_version) # type: ignore[return-value]
|
|
73
|
-
elif isinstance(raw, str) and raw.startswith("reverse"):
|
|
74
|
-
return ReverseConnectionEntity.load(raw) # type: ignore[return-value]
|
|
75
|
-
raise NeatTypeError(f"Invalid connection: {type(raw)}")
|
cognite/neat/plugins/__init__.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Any
|
|
3
|
-
|
|
4
|
-
from cognite.neat.core._data_model.importers._base import BaseImporter
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class DataModelImporterPlugin:
|
|
8
|
-
"""This class is used an interface for data model import plugins.
|
|
9
|
-
Any plugin that is used for importing data models should inherit from this class.
|
|
10
|
-
It is expected to implement the `configure` method which returns a configured importer.
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def configure(self, io: str | Path | None, **kwargs: Any) -> BaseImporter:
|
|
14
|
-
"""Return a configure plugin for data model import.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
io (str | Path | None): The input/output interface for the plugin.
|
|
18
|
-
**kwargs (Any): Additional keyword arguments for configuration.
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
BaseImporter: A configured instance of the BaseImporter.
|
|
22
|
-
|
|
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()
|