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
|
@@ -8,24 +8,22 @@ from pydantic import BaseModel, ConfigDict, ValidationInfo, field_validator
|
|
|
8
8
|
from rdflib import DCTERMS, OWL, RDF, RDFS, XSD, BNode, Graph, Literal, Namespace, URIRef
|
|
9
9
|
from rdflib.collection import Collection as GraphCollection
|
|
10
10
|
|
|
11
|
-
from cognite.neat.core._constants import DEFAULT_NAMESPACE as NEAT_NAMESPACE
|
|
12
|
-
from cognite.neat.core._data_model._constants import EntityTypes
|
|
13
|
-
from cognite.neat.core._data_model.analysis import DataModelAnalysis
|
|
14
|
-
from cognite.neat.core._data_model.models.conceptual import (
|
|
11
|
+
from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE as NEAT_NAMESPACE
|
|
12
|
+
from cognite.neat.v0.core._data_model._constants import EntityTypes
|
|
13
|
+
from cognite.neat.v0.core._data_model.analysis import DataModelAnalysis
|
|
14
|
+
from cognite.neat.v0.core._data_model.models.conceptual import (
|
|
15
15
|
Concept,
|
|
16
16
|
ConceptualDataModel,
|
|
17
17
|
ConceptualMetadata,
|
|
18
18
|
ConceptualProperty,
|
|
19
19
|
)
|
|
20
|
-
from cognite.neat.core._data_model.models.
|
|
21
|
-
from cognite.neat.core._data_model.models.
|
|
22
|
-
from cognite.neat.core.
|
|
23
|
-
from cognite.neat.core._issues import MultiValueError
|
|
24
|
-
from cognite.neat.core._issues.errors import (
|
|
20
|
+
from cognite.neat.v0.core._data_model.models.data_types import DataType
|
|
21
|
+
from cognite.neat.v0.core._data_model.models.entities import ConceptEntity
|
|
22
|
+
from cognite.neat.v0.core._issues.errors import (
|
|
25
23
|
PropertyDefinitionDuplicatedError,
|
|
26
24
|
)
|
|
27
|
-
from cognite.neat.core._issues.warnings import PropertyDefinitionDuplicatedWarning
|
|
28
|
-
from cognite.neat.core._utils.rdf_ import remove_namespace_from_uri
|
|
25
|
+
from cognite.neat.v0.core._issues.warnings import PropertyDefinitionDuplicatedWarning
|
|
26
|
+
from cognite.neat.v0.core._utils.rdf_ import remove_namespace_from_uri
|
|
29
27
|
|
|
30
28
|
from ._base import BaseExporter
|
|
31
29
|
|
|
@@ -34,6 +32,8 @@ if sys.version_info >= (3, 11):
|
|
|
34
32
|
else:
|
|
35
33
|
from typing_extensions import Self
|
|
36
34
|
|
|
35
|
+
SHACL = Namespace("http://www.w3.org/ns/shacl#")
|
|
36
|
+
|
|
37
37
|
|
|
38
38
|
class GraphExporter(BaseExporter[ConceptualDataModel, Graph], ABC):
|
|
39
39
|
def export_to_file(self, data_model: ConceptualDataModel, filepath: Path) -> None:
|
|
@@ -44,7 +44,7 @@ class OWLExporter(GraphExporter):
|
|
|
44
44
|
"""Exports verified conceptual data model to an OWL ontology."""
|
|
45
45
|
|
|
46
46
|
def export(self, data_model: ConceptualDataModel) -> Graph:
|
|
47
|
-
return Ontology.from_data_model(data_model).
|
|
47
|
+
return Ontology.from_data_model(data_model).graph
|
|
48
48
|
|
|
49
49
|
@property
|
|
50
50
|
def description(self) -> str:
|
|
@@ -55,44 +55,31 @@ class SHACLExporter(GraphExporter):
|
|
|
55
55
|
"""Exports data_model to a SHACL graph."""
|
|
56
56
|
|
|
57
57
|
def export(self, data_model: ConceptualDataModel) -> Graph:
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
@property
|
|
61
|
-
def description(self) -> str:
|
|
62
|
-
return "Export verified information model to SHACL."
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class SemanticDataModelExporter(GraphExporter):
|
|
66
|
-
"""Exports verified information model to a semantic data model."""
|
|
67
|
-
|
|
68
|
-
def export(self, data_model: ConceptualDataModel) -> Graph:
|
|
69
|
-
return Ontology.from_data_model(data_model).as_semantic_data_model()
|
|
58
|
+
return ShaclShapes.from_data_model(data_model).graph
|
|
70
59
|
|
|
71
60
|
@property
|
|
72
61
|
def description(self) -> str:
|
|
73
|
-
return "Export verified
|
|
62
|
+
return "Export verified conceptual data model to SHACL."
|
|
74
63
|
|
|
75
64
|
|
|
76
|
-
class
|
|
65
|
+
class _ModelConfig(BaseModel):
|
|
77
66
|
model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True, strict=False, extra="allow")
|
|
78
67
|
|
|
79
68
|
|
|
80
|
-
class Ontology(
|
|
69
|
+
class Ontology(_ModelConfig):
|
|
81
70
|
"""
|
|
82
71
|
Represents an ontology. This class is used to generate an OWL ontology from conceptual data model.
|
|
83
72
|
|
|
84
73
|
Args:
|
|
85
74
|
properties: A list of OWL properties.
|
|
86
75
|
classes: A list of OWL classes.
|
|
87
|
-
shapes: A list of SHACL node shapes.
|
|
88
76
|
metadata: Metadata about the ontology.
|
|
89
77
|
prefixes: A dictionary of prefixes and namespaces.
|
|
90
78
|
"""
|
|
91
79
|
|
|
80
|
+
metadata: "OWLMetadata"
|
|
92
81
|
properties: list["OWLProperty"]
|
|
93
82
|
classes: list["OWLClass"]
|
|
94
|
-
shapes: list["SHACLNodeShape"]
|
|
95
|
-
metadata: "OWLMetadata"
|
|
96
83
|
prefixes: dict[str, Namespace]
|
|
97
84
|
|
|
98
85
|
@classmethod
|
|
@@ -106,23 +93,7 @@ class Ontology(OntologyModel):
|
|
|
106
93
|
Returns:
|
|
107
94
|
An instance of Ontology.
|
|
108
95
|
"""
|
|
109
|
-
if duplicates := duplicated_properties(data_model.properties):
|
|
110
|
-
errors = []
|
|
111
|
-
for (concept, property_), definitions in duplicates.items():
|
|
112
|
-
errors.append(
|
|
113
|
-
PropertyDefinitionDuplicatedError(
|
|
114
|
-
concept,
|
|
115
|
-
"concept",
|
|
116
|
-
property_,
|
|
117
|
-
frozenset({str(definition[1].value_type) for definition in definitions}),
|
|
118
|
-
tuple(definition[0] for definition in definitions),
|
|
119
|
-
"rows",
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
raise MultiValueError(errors)
|
|
123
|
-
|
|
124
96
|
analysis = DataModelAnalysis(data_model)
|
|
125
|
-
concept_by_suffix = analysis.concept_by_suffix()
|
|
126
97
|
return cls(
|
|
127
98
|
properties=[
|
|
128
99
|
OWLProperty.from_list_of_properties(definition, data_model.metadata.namespace)
|
|
@@ -132,46 +103,12 @@ class Ontology(OntologyModel):
|
|
|
132
103
|
OWLClass.from_concept(definition, data_model.metadata.namespace, data_model.prefixes)
|
|
133
104
|
for definition in data_model.concepts
|
|
134
105
|
],
|
|
135
|
-
shapes=[
|
|
136
|
-
SHACLNodeShape.from_data_model(
|
|
137
|
-
concept_by_suffix[str(concept.suffix)],
|
|
138
|
-
list(properties.values()),
|
|
139
|
-
data_model.metadata.namespace,
|
|
140
|
-
)
|
|
141
|
-
for concept, properties in analysis.properties_by_id_by_concept().items()
|
|
142
|
-
]
|
|
143
|
-
+ [
|
|
144
|
-
SHACLNodeShape.from_data_model(
|
|
145
|
-
concept,
|
|
146
|
-
[],
|
|
147
|
-
data_model.metadata.namespace,
|
|
148
|
-
)
|
|
149
|
-
for concept in concept_by_suffix.values()
|
|
150
|
-
],
|
|
151
106
|
metadata=OWLMetadata(**data_model.metadata.model_dump()),
|
|
152
107
|
prefixes=data_model.prefixes,
|
|
153
108
|
)
|
|
154
109
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
Generates a SHACL graph from the ontology.
|
|
158
|
-
|
|
159
|
-
Returns:
|
|
160
|
-
A SHACL graph.
|
|
161
|
-
"""
|
|
162
|
-
|
|
163
|
-
shacl = Graph()
|
|
164
|
-
shacl.bind(self.metadata.prefix, self.metadata.namespace)
|
|
165
|
-
for prefix, namespace in self.prefixes.items():
|
|
166
|
-
shacl.bind(prefix, namespace)
|
|
167
|
-
|
|
168
|
-
for shape in self.shapes:
|
|
169
|
-
for triple in shape.triples:
|
|
170
|
-
shacl.add(triple) # type: ignore[arg-type]
|
|
171
|
-
|
|
172
|
-
return shacl
|
|
173
|
-
|
|
174
|
-
def as_owl(self) -> Graph:
|
|
110
|
+
@property
|
|
111
|
+
def graph(self) -> Graph:
|
|
175
112
|
"""
|
|
176
113
|
Generates an OWL graph from the ontology.
|
|
177
114
|
|
|
@@ -197,33 +134,6 @@ class Ontology(OntologyModel):
|
|
|
197
134
|
|
|
198
135
|
return owl
|
|
199
136
|
|
|
200
|
-
def as_semantic_data_model(self) -> Graph:
|
|
201
|
-
return self.as_owl() + self.as_shacl()
|
|
202
|
-
|
|
203
|
-
@property
|
|
204
|
-
def owl_triples(self) -> list[tuple]:
|
|
205
|
-
return list(self.as_owl())
|
|
206
|
-
|
|
207
|
-
@property
|
|
208
|
-
def shacl_triples(self) -> list[tuple]:
|
|
209
|
-
return list(self.as_shacl())
|
|
210
|
-
|
|
211
|
-
@property
|
|
212
|
-
def triples(self) -> list[tuple]:
|
|
213
|
-
return self.owl_triples + self.shacl_triples
|
|
214
|
-
|
|
215
|
-
@property
|
|
216
|
-
def ontology(self) -> str:
|
|
217
|
-
return self.as_owl().serialize()
|
|
218
|
-
|
|
219
|
-
@property
|
|
220
|
-
def constraints(self) -> str:
|
|
221
|
-
return self.as_shacl().serialize()
|
|
222
|
-
|
|
223
|
-
@property
|
|
224
|
-
def semantic_data_model(self) -> str:
|
|
225
|
-
return (self.as_owl() + self.as_shacl()).serialize()
|
|
226
|
-
|
|
227
137
|
|
|
228
138
|
class OWLMetadata(ConceptualMetadata):
|
|
229
139
|
@property
|
|
@@ -250,7 +160,7 @@ class OWLMetadata(ConceptualMetadata):
|
|
|
250
160
|
return triples
|
|
251
161
|
|
|
252
162
|
|
|
253
|
-
class OWLClass(
|
|
163
|
+
class OWLClass(_ModelConfig):
|
|
254
164
|
id_: URIRef
|
|
255
165
|
type_: URIRef = OWL.Class
|
|
256
166
|
label: str | None
|
|
@@ -323,7 +233,7 @@ class OWLClass(OntologyModel):
|
|
|
323
233
|
)
|
|
324
234
|
|
|
325
235
|
|
|
326
|
-
class OWLProperty(
|
|
236
|
+
class OWLProperty(_ModelConfig):
|
|
327
237
|
id_: URIRef
|
|
328
238
|
type_: set[URIRef]
|
|
329
239
|
label: set[str]
|
|
@@ -527,10 +437,78 @@ class OWLProperty(OntologyModel):
|
|
|
527
437
|
)
|
|
528
438
|
|
|
529
439
|
|
|
530
|
-
|
|
440
|
+
class ShaclShapes(_ModelConfig):
|
|
441
|
+
"""
|
|
442
|
+
Represents a SHACL shapes. This class is used to generate a SHACL graph from conceptual data model.
|
|
443
|
+
|
|
444
|
+
Args:
|
|
445
|
+
shapes: A list of SHACL node shapes.
|
|
446
|
+
prefixes: A dictionary of prefixes and namespaces.
|
|
447
|
+
"""
|
|
448
|
+
|
|
449
|
+
shapes: list["SHACLNodeShape"]
|
|
450
|
+
prefixes: dict[str, Namespace]
|
|
451
|
+
|
|
452
|
+
@classmethod
|
|
453
|
+
def from_data_model(cls, data_model: ConceptualDataModel) -> Self:
|
|
454
|
+
"""
|
|
455
|
+
Generates shacl shapes from a conceptual data model.
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
data_model: The data_model to generate the shacl shapes from.
|
|
459
|
+
|
|
460
|
+
Returns:
|
|
461
|
+
An instance of ShaclShapes.
|
|
462
|
+
"""
|
|
463
|
+
analysis = DataModelAnalysis(data_model)
|
|
464
|
+
concepts_by_concept_entity = analysis.concept_by_concept_entity
|
|
465
|
+
properties_by_concept_entity = analysis.properties_by_concepts()
|
|
466
|
+
return cls(
|
|
467
|
+
shapes=[
|
|
468
|
+
# shapes that have property shapes as well
|
|
469
|
+
SHACLNodeShape.from_concept(
|
|
470
|
+
concept_entity,
|
|
471
|
+
concepts_by_concept_entity,
|
|
472
|
+
properties,
|
|
473
|
+
data_model.metadata.namespace,
|
|
474
|
+
)
|
|
475
|
+
for concept_entity, properties in properties_by_concept_entity.items()
|
|
476
|
+
]
|
|
477
|
+
+ [
|
|
478
|
+
# shapes without any property shapes
|
|
479
|
+
SHACLNodeShape.from_concept(
|
|
480
|
+
concept_entity,
|
|
481
|
+
concepts_by_concept_entity,
|
|
482
|
+
[],
|
|
483
|
+
data_model.metadata.namespace,
|
|
484
|
+
)
|
|
485
|
+
for concept_entity in concepts_by_concept_entity.keys()
|
|
486
|
+
if concept_entity not in properties_by_concept_entity
|
|
487
|
+
],
|
|
488
|
+
prefixes=data_model.prefixes,
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
@property
|
|
492
|
+
def graph(self) -> Graph:
|
|
493
|
+
"""
|
|
494
|
+
Generates a SHACL graph from the class instance.
|
|
531
495
|
|
|
496
|
+
Returns:
|
|
497
|
+
A SHACL graph.
|
|
498
|
+
"""
|
|
532
499
|
|
|
533
|
-
|
|
500
|
+
shacl = Graph()
|
|
501
|
+
for prefix, namespace in self.prefixes.items():
|
|
502
|
+
shacl.bind(prefix, namespace)
|
|
503
|
+
|
|
504
|
+
for shape in self.shapes:
|
|
505
|
+
for triple in shape.triples:
|
|
506
|
+
shacl.add(triple) # type: ignore[arg-type]
|
|
507
|
+
|
|
508
|
+
return shacl
|
|
509
|
+
|
|
510
|
+
|
|
511
|
+
class SHACLNodeShape(_ModelConfig):
|
|
534
512
|
id_: URIRef
|
|
535
513
|
type_: URIRef = SHACL.NodeShape
|
|
536
514
|
target_class: URIRef
|
|
@@ -572,26 +550,33 @@ class SHACLNodeShape(OntologyModel):
|
|
|
572
550
|
)
|
|
573
551
|
|
|
574
552
|
@classmethod
|
|
575
|
-
def
|
|
553
|
+
def from_concept(
|
|
576
554
|
cls,
|
|
577
|
-
|
|
578
|
-
|
|
555
|
+
concept_entity: ConceptEntity,
|
|
556
|
+
concepts_by_concept_entity: dict[ConceptEntity, Concept],
|
|
557
|
+
properties: list[ConceptualProperty],
|
|
579
558
|
namespace: Namespace,
|
|
580
559
|
) -> "SHACLNodeShape":
|
|
581
|
-
if
|
|
582
|
-
|
|
560
|
+
if not (concept := concepts_by_concept_entity.get(concept_entity)):
|
|
561
|
+
raise ValueError(f"Concept {concept_entity} not found in data model!")
|
|
562
|
+
|
|
563
|
+
if concept.implements:
|
|
564
|
+
parent = [namespace[str(parent.suffix) + "Shape"] for parent in concept.implements]
|
|
583
565
|
else:
|
|
584
566
|
parent = None
|
|
585
567
|
return cls(
|
|
586
|
-
id_=namespace[f"{
|
|
587
|
-
target_class=namespace[str(
|
|
568
|
+
id_=namespace[f"{concept.concept.suffix!s}Shape"],
|
|
569
|
+
target_class=concept.instance_source or namespace[str(concept.concept.suffix)],
|
|
588
570
|
parent=parent,
|
|
589
|
-
property_shapes=[
|
|
571
|
+
property_shapes=[
|
|
572
|
+
SHACLPropertyShape.from_property(property_, concepts_by_concept_entity, namespace)
|
|
573
|
+
for property_ in properties
|
|
574
|
+
],
|
|
590
575
|
namespace=namespace,
|
|
591
576
|
)
|
|
592
577
|
|
|
593
578
|
|
|
594
|
-
class SHACLPropertyShape(
|
|
579
|
+
class SHACLPropertyShape(_ModelConfig):
|
|
595
580
|
id_: BNode
|
|
596
581
|
type_: URIRef = SHACL.property
|
|
597
582
|
path: URIRef # URIRef to property in OWL
|
|
@@ -631,23 +616,31 @@ class SHACLPropertyShape(OntologyModel):
|
|
|
631
616
|
return self.path_triples + self.node_kind_triples + self.cardinality_triples
|
|
632
617
|
|
|
633
618
|
@classmethod
|
|
634
|
-
def from_property(
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
619
|
+
def from_property(
|
|
620
|
+
cls,
|
|
621
|
+
property_: ConceptualProperty,
|
|
622
|
+
concepts_by_concept_entity: dict[ConceptEntity, Concept],
|
|
623
|
+
namespace: Namespace,
|
|
624
|
+
) -> "SHACLPropertyShape":
|
|
625
|
+
if isinstance(property_.value_type, ConceptEntity):
|
|
626
|
+
concept = concepts_by_concept_entity.get(property_.value_type)
|
|
627
|
+
value_type_uri = concept.instance_source if concept else None
|
|
628
|
+
expected_value_type = value_type_uri or namespace[f"{property_.value_type.suffix}"]
|
|
629
|
+
elif isinstance(property_.value_type, DataType):
|
|
630
|
+
expected_value_type = XSD[property_.value_type.xsd]
|
|
640
631
|
else:
|
|
641
|
-
raise
|
|
632
|
+
raise NotImplementedError(f"Value type {property_.value_type.type_} is not supported yet")
|
|
642
633
|
|
|
643
634
|
return cls(
|
|
644
635
|
id_=BNode(),
|
|
645
|
-
path=
|
|
646
|
-
|
|
636
|
+
path=property_.instance_source[0]
|
|
637
|
+
if property_.instance_source and len(property_.instance_source) == 1
|
|
638
|
+
else namespace[property_.property_],
|
|
639
|
+
node_kind=SHACL.IRI if property_.type_ == EntityTypes.object_property else SHACL.Literal,
|
|
647
640
|
expected_value_type=expected_value_type,
|
|
648
|
-
min_count=
|
|
641
|
+
min_count=property_.min_count,
|
|
649
642
|
max_count=(
|
|
650
|
-
int(
|
|
643
|
+
int(property_.max_count) if property_.max_count and property_.max_count != float("inf") else None
|
|
651
644
|
),
|
|
652
645
|
namespace=namespace,
|
|
653
646
|
)
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
from ._base import BaseImporter
|
|
2
2
|
from ._dict2data_model import DictImporter
|
|
3
3
|
from ._dms2data_model import DMSImporter
|
|
4
|
-
from .
|
|
5
|
-
from ._rdf import
|
|
4
|
+
from ._graph2data_model import GraphImporter
|
|
5
|
+
from ._rdf import InferenceImporter, OWLImporter, SubclassInferenceImporter
|
|
6
6
|
from ._spreadsheet2data_model import ExcelImporter
|
|
7
7
|
|
|
8
8
|
__all__ = [
|
|
9
9
|
"BaseImporter",
|
|
10
10
|
"DMSImporter",
|
|
11
|
-
"DTDLImporter",
|
|
12
11
|
"DictImporter",
|
|
13
12
|
"ExcelImporter",
|
|
14
|
-
"
|
|
13
|
+
"GraphImporter",
|
|
15
14
|
"InferenceImporter",
|
|
16
15
|
"OWLImporter",
|
|
17
16
|
"SubclassInferenceImporter",
|
|
@@ -19,13 +18,12 @@ __all__ = [
|
|
|
19
18
|
|
|
20
19
|
DataModelImporters = (
|
|
21
20
|
OWLImporter
|
|
22
|
-
| IMFImporter
|
|
23
21
|
| DMSImporter
|
|
24
22
|
| ExcelImporter
|
|
25
|
-
| DTDLImporter
|
|
26
23
|
| DictImporter
|
|
27
24
|
| InferenceImporter
|
|
28
25
|
| SubclassInferenceImporter
|
|
26
|
+
| GraphImporter
|
|
29
27
|
)
|
|
30
28
|
|
|
31
29
|
|
|
@@ -5,15 +5,15 @@ from typing import TYPE_CHECKING, Any, Generic
|
|
|
5
5
|
|
|
6
6
|
from rdflib import URIRef
|
|
7
7
|
|
|
8
|
-
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
9
|
-
from cognite.neat.core._data_model._shared import (
|
|
8
|
+
from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE
|
|
9
|
+
from cognite.neat.v0.core._data_model._shared import (
|
|
10
10
|
ImportedDataModel,
|
|
11
11
|
T_UnverifiedDataModel,
|
|
12
12
|
)
|
|
13
|
-
from cognite.neat.core._utils.auxiliary import class_html_doc
|
|
13
|
+
from cognite.neat.v0.core._utils.auxiliary import class_html_doc
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
16
|
-
from cognite.neat.core._store._provenance import Agent as ProvenanceAgent
|
|
16
|
+
from cognite.neat.v0.core._store._provenance import Agent as ProvenanceAgent
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class BaseImporter(ABC, Generic[T_UnverifiedDataModel]):
|
|
@@ -51,7 +51,7 @@ class BaseImporter(ABC, Generic[T_UnverifiedDataModel]):
|
|
|
51
51
|
@property
|
|
52
52
|
def agent(self) -> "ProvenanceAgent":
|
|
53
53
|
"""Provenance agent for the importer."""
|
|
54
|
-
from cognite.neat.core._store._provenance import Agent as ProvenanceAgent
|
|
54
|
+
from cognite.neat.v0.core._store._provenance import Agent as ProvenanceAgent
|
|
55
55
|
|
|
56
56
|
return ProvenanceAgent(id_=DEFAULT_NAMESPACE[f"agent/{type(self).__name__}"])
|
|
57
57
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
2
|
from typing import Protocol, TypeVar
|
|
3
3
|
|
|
4
|
-
from cognite.neat.core._issues import NeatIssue
|
|
5
|
-
from cognite.neat.core._issues.errors import (
|
|
4
|
+
from cognite.neat.v0.core._issues import NeatIssue
|
|
5
|
+
from cognite.neat.v0.core._issues.errors import (
|
|
6
6
|
FileNotAFileError,
|
|
7
7
|
FileNotFoundNeatError,
|
|
8
8
|
FileTypeUnexpectedError,
|
|
@@ -3,20 +3,20 @@ from typing import Any, cast
|
|
|
3
3
|
|
|
4
4
|
import yaml
|
|
5
5
|
|
|
6
|
-
from cognite.neat.core._data_model._shared import (
|
|
6
|
+
from cognite.neat.v0.core._data_model._shared import (
|
|
7
7
|
ImportedDataModel,
|
|
8
8
|
T_UnverifiedDataModel,
|
|
9
9
|
)
|
|
10
|
-
from cognite.neat.core._data_model.models import (
|
|
10
|
+
from cognite.neat.v0.core._data_model.models import (
|
|
11
11
|
UNVERIFIED_DATA_MODEL_BY_ROLE,
|
|
12
12
|
RoleTypes,
|
|
13
13
|
)
|
|
14
|
-
from cognite.neat.core._issues import IssueList, MultiValueError, NeatIssue
|
|
15
|
-
from cognite.neat.core._issues.errors import (
|
|
14
|
+
from cognite.neat.v0.core._issues import IssueList, MultiValueError, NeatIssue
|
|
15
|
+
from cognite.neat.v0.core._issues.errors import (
|
|
16
16
|
FileMissingRequiredFieldError,
|
|
17
17
|
FileReadError,
|
|
18
18
|
)
|
|
19
|
-
from cognite.neat.core._issues.warnings import NeatValueWarning
|
|
19
|
+
from cognite.neat.v0.core._issues.warnings import NeatValueWarning
|
|
20
20
|
|
|
21
21
|
from ._base import BaseImporter
|
|
22
22
|
from ._base_file_reader import BaseFileReader
|
|
@@ -128,4 +128,4 @@ class DictImporter(BaseImporter[T_UnverifiedDataModel]):
|
|
|
128
128
|
if self._read_issues.has_errors:
|
|
129
129
|
raise MultiValueError(self._read_issues.errors)
|
|
130
130
|
|
|
131
|
-
return ImportedDataModel[T_UnverifiedDataModel](data_model
|
|
131
|
+
return ImportedDataModel[T_UnverifiedDataModel](data_model)
|
|
@@ -28,23 +28,23 @@ from cognite.client.data_classes.data_modeling.views import (
|
|
|
28
28
|
)
|
|
29
29
|
from cognite.client.utils import ms_to_datetime
|
|
30
30
|
|
|
31
|
-
from cognite.neat.core._client import NeatClient
|
|
32
|
-
from cognite.neat.core._constants import (
|
|
31
|
+
from cognite.neat.v0.core._client import NeatClient
|
|
32
|
+
from cognite.neat.v0.core._constants import (
|
|
33
33
|
DMS_DIRECT_RELATION_LIST_DEFAULT_LIMIT,
|
|
34
34
|
DMS_PRIMITIVE_LIST_DEFAULT_LIMIT,
|
|
35
35
|
)
|
|
36
|
-
from cognite.neat.core._data_model._shared import ImportedDataModel
|
|
37
|
-
from cognite.neat.core._data_model.importers._base import BaseImporter
|
|
38
|
-
from cognite.neat.core._data_model.models import (
|
|
36
|
+
from cognite.neat.v0.core._data_model._shared import ImportedDataModel
|
|
37
|
+
from cognite.neat.v0.core._data_model.importers._base import BaseImporter
|
|
38
|
+
from cognite.neat.v0.core._data_model.models import (
|
|
39
39
|
DMSSchema,
|
|
40
40
|
UnverifiedPhysicalDataModel,
|
|
41
41
|
)
|
|
42
|
-
from cognite.neat.core._data_model.models.conceptual import (
|
|
42
|
+
from cognite.neat.v0.core._data_model.models.conceptual import (
|
|
43
43
|
UnverifiedConcept,
|
|
44
44
|
UnverifiedConceptualProperty,
|
|
45
45
|
)
|
|
46
|
-
from cognite.neat.core._data_model.models.data_types import DataType, Enum, String
|
|
47
|
-
from cognite.neat.core._data_model.models.entities import (
|
|
46
|
+
from cognite.neat.v0.core._data_model.models.data_types import DataType, Enum, String
|
|
47
|
+
from cognite.neat.v0.core._data_model.models.entities import (
|
|
48
48
|
ConceptEntity,
|
|
49
49
|
ContainerEntity,
|
|
50
50
|
ContainerIndexEntity,
|
|
@@ -54,7 +54,8 @@ from cognite.neat.core._data_model.models.entities import (
|
|
|
54
54
|
ReverseConnectionEntity,
|
|
55
55
|
ViewEntity,
|
|
56
56
|
)
|
|
57
|
-
from cognite.neat.core._data_model.models.
|
|
57
|
+
from cognite.neat.v0.core._data_model.models.entities._single_value import ContainerConstraintEntity
|
|
58
|
+
from cognite.neat.v0.core._data_model.models.physical import (
|
|
58
59
|
UnverifiedPhysicalContainer,
|
|
59
60
|
UnverifiedPhysicalEnum,
|
|
60
61
|
UnverifiedPhysicalMetadata,
|
|
@@ -62,13 +63,13 @@ from cognite.neat.core._data_model.models.physical import (
|
|
|
62
63
|
UnverifiedPhysicalProperty,
|
|
63
64
|
UnverifiedPhysicalView,
|
|
64
65
|
)
|
|
65
|
-
from cognite.neat.core._issues import (
|
|
66
|
+
from cognite.neat.v0.core._issues import (
|
|
66
67
|
IssueList,
|
|
67
68
|
MultiValueError,
|
|
68
69
|
NeatIssue,
|
|
69
70
|
catch_issues,
|
|
70
71
|
)
|
|
71
|
-
from cognite.neat.core._issues.errors import (
|
|
72
|
+
from cognite.neat.v0.core._issues.errors import (
|
|
72
73
|
FileNotFoundNeatError,
|
|
73
74
|
FileTypeUnexpectedError,
|
|
74
75
|
NeatValueError,
|
|
@@ -76,7 +77,7 @@ from cognite.neat.core._issues.errors import (
|
|
|
76
77
|
ResourceMissingIdentifierError,
|
|
77
78
|
ResourceRetrievalError,
|
|
78
79
|
)
|
|
79
|
-
from cognite.neat.core._issues.warnings import (
|
|
80
|
+
from cognite.neat.v0.core._issues.warnings import (
|
|
80
81
|
MissingCogniteClientWarning,
|
|
81
82
|
NeatValueWarning,
|
|
82
83
|
PropertyNotFoundWarning,
|
|
@@ -276,7 +277,7 @@ class DMSImporter(BaseImporter[UnverifiedPhysicalDataModel]):
|
|
|
276
277
|
self.issue_list.trigger_warnings()
|
|
277
278
|
if self.issue_list.has_errors:
|
|
278
279
|
raise MultiValueError(self.issue_list.errors)
|
|
279
|
-
return ImportedDataModel(user_data_model,
|
|
280
|
+
return ImportedDataModel(user_data_model, None)
|
|
280
281
|
|
|
281
282
|
def _create_data_model_components(
|
|
282
283
|
self,
|
|
@@ -446,6 +447,8 @@ class DMSImporter(BaseImporter[UnverifiedPhysicalDataModel]):
|
|
|
446
447
|
return ViewEntity.from_id(prop.source)
|
|
447
448
|
elif isinstance(prop_type, PropertyTypeWithUnit) and prop_type.unit:
|
|
448
449
|
return DataType.load(f"{prop_type._type}(unit={prop_type.unit.external_id})")
|
|
450
|
+
elif isinstance(prop_type, dm.Text) and prop_type.max_text_size is not None:
|
|
451
|
+
return DataType.load(f"{prop_type._type}(maxTextSize={prop_type.max_text_size})")
|
|
449
452
|
elif isinstance(prop_type, DMSEnum):
|
|
450
453
|
if enum_collection_by_container_property is None:
|
|
451
454
|
return String()
|
|
@@ -569,17 +572,17 @@ class DMSImporter(BaseImporter[UnverifiedPhysicalDataModel]):
|
|
|
569
572
|
index.append(ContainerIndexEntity(prefix="inverted", suffix=index_name, order=order))
|
|
570
573
|
return index or None
|
|
571
574
|
|
|
572
|
-
def _get_constraint(self, prop: ViewPropertyApply, prop_id: str) -> list[
|
|
575
|
+
def _get_constraint(self, prop: ViewPropertyApply, prop_id: str) -> list[ContainerConstraintEntity] | None:
|
|
573
576
|
if not isinstance(prop, dm.MappedPropertyApply):
|
|
574
577
|
return None
|
|
575
578
|
container = self._all_containers_by_id[prop.container]
|
|
576
|
-
unique_constraints: list[
|
|
579
|
+
unique_constraints: list[ContainerConstraintEntity] = []
|
|
577
580
|
for constraint_name, constraint_obj in (container.constraints or {}).items():
|
|
578
581
|
if isinstance(constraint_obj, dm.RequiresConstraint):
|
|
579
582
|
# This is handled in the .from_container method of DMSContainer
|
|
580
583
|
continue
|
|
581
584
|
elif isinstance(constraint_obj, dm.UniquenessConstraint) and prop_id in constraint_obj.properties:
|
|
582
|
-
unique_constraints.append(constraint_name)
|
|
585
|
+
unique_constraints.append(ContainerConstraintEntity(prefix="uniqueness", suffix=constraint_name))
|
|
583
586
|
elif isinstance(constraint_obj, dm.UniquenessConstraint):
|
|
584
587
|
# This does not apply to this property
|
|
585
588
|
continue
|