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
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
from typing import Any, Literal, cast
|
|
2
|
+
from urllib.parse import quote
|
|
3
|
+
|
|
4
|
+
from rdflib import BNode, Graph, Namespace, URIRef
|
|
5
|
+
from rdflib import Literal as RdfLiteral
|
|
6
|
+
from rdflib.plugins.sparql import prepareQuery
|
|
7
|
+
from rdflib.query import ResultRow
|
|
8
|
+
|
|
9
|
+
from cognite.neat.v0.core._constants import cognite_prefixes
|
|
10
|
+
from cognite.neat.v0.core._data_model.models.entities._constants import Unknown
|
|
11
|
+
from cognite.neat.v0.core._data_model.models.entities._single_value import ConceptEntity
|
|
12
|
+
from cognite.neat.v0.core._issues._base import IssueList
|
|
13
|
+
from cognite.neat.v0.core._issues.errors._general import NeatValueError
|
|
14
|
+
from cognite.neat.v0.core._issues.warnings._resources import (
|
|
15
|
+
ResourceRedefinedWarning,
|
|
16
|
+
ResourceRetrievalWarning,
|
|
17
|
+
)
|
|
18
|
+
from cognite.neat.v0.core._utils.rdf_ import remove_namespace_from_uri, uri_to_entity_components
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def parse_concepts(
|
|
22
|
+
graph: Graph, query: str, parameters: set, language: str, issue_list: IssueList
|
|
23
|
+
) -> tuple[dict, IssueList]:
|
|
24
|
+
"""Parse concepts from graph
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
graph: Graph containing concept definitions
|
|
28
|
+
query: SPARQL query to use for parsing concepts
|
|
29
|
+
parameters: Set of parameters to extract from the query results
|
|
30
|
+
language: Language to use for parsing, by default "en"
|
|
31
|
+
issue_list: List to collect issues during parsing
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
Dataframe containing owl classes
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
concepts: dict[str, dict] = {}
|
|
38
|
+
|
|
39
|
+
query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
|
|
40
|
+
prefixes = cognite_prefixes()
|
|
41
|
+
|
|
42
|
+
for raw in graph.query(query):
|
|
43
|
+
res: dict = convert_rdflib_content(
|
|
44
|
+
cast(ResultRow, raw).asdict(), uri_handling="as-concept-entity", prefixes=prefixes
|
|
45
|
+
)
|
|
46
|
+
res = {key: res.get(key, None) for key in parameters}
|
|
47
|
+
|
|
48
|
+
# Safeguarding against incomplete semantic definitions
|
|
49
|
+
if res["implements"] and isinstance(res["implements"], BNode):
|
|
50
|
+
issue_list.append(
|
|
51
|
+
ResourceRetrievalWarning(
|
|
52
|
+
res["concept"],
|
|
53
|
+
"implements",
|
|
54
|
+
error=("Unable to determine concept that is being implemented"),
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
continue
|
|
58
|
+
|
|
59
|
+
# sanitize the concept and implements
|
|
60
|
+
res["concept"] = sanitize_entity(res["concept"])
|
|
61
|
+
res["implements"] = sanitize_entity(res["implements"]) if res["implements"] else None
|
|
62
|
+
|
|
63
|
+
concept_id = res["concept"]
|
|
64
|
+
|
|
65
|
+
if concept_id not in concepts:
|
|
66
|
+
concepts[concept_id] = res
|
|
67
|
+
else:
|
|
68
|
+
# Handling implements
|
|
69
|
+
if concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], list):
|
|
70
|
+
if res["implements"] and res["implements"] not in concepts[concept_id]["implements"]:
|
|
71
|
+
concepts[concept_id]["implements"].append(res["implements"])
|
|
72
|
+
|
|
73
|
+
elif concepts[concept_id]["implements"] and isinstance(concepts[concept_id]["implements"], str):
|
|
74
|
+
concepts[concept_id]["implements"] = [concepts[concept_id]["implements"]]
|
|
75
|
+
|
|
76
|
+
if res["implements"] and res["implements"] not in concepts[concept_id]["implements"]:
|
|
77
|
+
concepts[concept_id]["implements"].append(res["implements"])
|
|
78
|
+
elif res["implements"]:
|
|
79
|
+
concepts[concept_id]["implements"] = [res["implements"]]
|
|
80
|
+
|
|
81
|
+
handle_meta("concept", concepts, concept_id, res, "name", issue_list)
|
|
82
|
+
handle_meta("concept", concepts, concept_id, res, "description", issue_list)
|
|
83
|
+
if not concepts:
|
|
84
|
+
issue_list.append(NeatValueError("Unable to parse concepts"))
|
|
85
|
+
|
|
86
|
+
return concepts, issue_list
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def parse_properties(
|
|
90
|
+
graph: Graph, query: str, parameters: set, language: str, issue_list: IssueList
|
|
91
|
+
) -> tuple[dict, IssueList]:
|
|
92
|
+
"""Parse properties from graph
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
graph: Graph containing property definitions
|
|
96
|
+
query: SPARQL query to use for parsing properties
|
|
97
|
+
parameters: Set of parameters to extract from the query results
|
|
98
|
+
language: Language to use for parsing, by default "en"
|
|
99
|
+
issue_list: List to collect issues during parsing
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
Dataframe containing owl classes
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
properties: dict[str, dict] = {}
|
|
106
|
+
|
|
107
|
+
query = prepareQuery(query.format(language=language), initNs={k: v for k, v in graph.namespaces()})
|
|
108
|
+
prefixes = cognite_prefixes()
|
|
109
|
+
|
|
110
|
+
for raw in graph.query(query):
|
|
111
|
+
res: dict = convert_rdflib_content(
|
|
112
|
+
cast(ResultRow, raw).asdict(), uri_handling="as-concept-entity", prefixes=prefixes
|
|
113
|
+
)
|
|
114
|
+
res = {key: res.get(key, None) for key in parameters}
|
|
115
|
+
|
|
116
|
+
# Quote the concept id to ensure it is web-safe
|
|
117
|
+
res["property_"] = quote(res["property_"], safe="")
|
|
118
|
+
property_id = res["property_"]
|
|
119
|
+
|
|
120
|
+
# Skip Bnode
|
|
121
|
+
if isinstance(res["concept"], BNode):
|
|
122
|
+
issue_list.append(
|
|
123
|
+
ResourceRetrievalWarning(
|
|
124
|
+
property_id,
|
|
125
|
+
"property",
|
|
126
|
+
error="Cannot determine concept of property as it is a blank node",
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
continue
|
|
130
|
+
|
|
131
|
+
# Skip Bnode
|
|
132
|
+
if isinstance(res["value_type"], BNode):
|
|
133
|
+
issue_list.append(
|
|
134
|
+
ResourceRetrievalWarning(
|
|
135
|
+
property_id,
|
|
136
|
+
"property",
|
|
137
|
+
error="Unable to determine value type of property as it is a blank node",
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
continue
|
|
141
|
+
|
|
142
|
+
# Quote the concept and value_type if they exist if not signal neat that they are not available
|
|
143
|
+
res["concept"] = sanitize_entity(res["concept"]) if res["concept"] else str(Unknown)
|
|
144
|
+
res["value_type"] = sanitize_entity(res["value_type"]) if res["value_type"] else str(Unknown)
|
|
145
|
+
|
|
146
|
+
id_ = f"{res['concept']}.{res['property_']}"
|
|
147
|
+
|
|
148
|
+
if id_ not in properties:
|
|
149
|
+
properties[id_] = res
|
|
150
|
+
properties[id_]["value_type"] = [properties[id_]["value_type"]]
|
|
151
|
+
else:
|
|
152
|
+
handle_meta("property", properties, id_, res, "name", issue_list)
|
|
153
|
+
handle_meta(
|
|
154
|
+
"property",
|
|
155
|
+
properties,
|
|
156
|
+
id_,
|
|
157
|
+
res,
|
|
158
|
+
"description",
|
|
159
|
+
issue_list,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Handling multi-value types
|
|
163
|
+
if res["value_type"] not in properties[id_]["value_type"]:
|
|
164
|
+
properties[id_]["value_type"].append(res["value_type"])
|
|
165
|
+
|
|
166
|
+
for prop in properties.values():
|
|
167
|
+
prop["value_type"] = ", ".join(prop["value_type"])
|
|
168
|
+
|
|
169
|
+
if not properties:
|
|
170
|
+
issue_list.append(NeatValueError("Unable to parse properties"))
|
|
171
|
+
|
|
172
|
+
return properties, issue_list
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def handle_meta(
|
|
176
|
+
resource_type: str,
|
|
177
|
+
resources: dict[str, dict],
|
|
178
|
+
resource_id: str,
|
|
179
|
+
res: dict,
|
|
180
|
+
feature: str,
|
|
181
|
+
issue_list: IssueList,
|
|
182
|
+
) -> None:
|
|
183
|
+
if not resources[resource_id][feature] and res[feature]:
|
|
184
|
+
resources[resource_id][feature] = res[feature]
|
|
185
|
+
|
|
186
|
+
current_value = resources[resource_id][feature]
|
|
187
|
+
new_value = res[feature]
|
|
188
|
+
|
|
189
|
+
if not current_value and new_value:
|
|
190
|
+
resources[resource_id][feature] = new_value
|
|
191
|
+
elif current_value and new_value and current_value != new_value:
|
|
192
|
+
issue_list.append(
|
|
193
|
+
ResourceRedefinedWarning(
|
|
194
|
+
identifier=resource_id,
|
|
195
|
+
resource_type=resource_type,
|
|
196
|
+
feature=feature,
|
|
197
|
+
current_value=current_value,
|
|
198
|
+
new_value=new_value,
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def convert_rdflib_content(
|
|
204
|
+
content: RdfLiteral | URIRef | dict | list,
|
|
205
|
+
uri_handling: Literal["skip", "remove-namespace", "as-concept-entity"] = "skip",
|
|
206
|
+
prefixes: dict[str, Namespace] | None = None,
|
|
207
|
+
) -> Any:
|
|
208
|
+
"""Converts rdflib content to a more Python-friendly format.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
content: The content to convert, can be a RdfLiteral, URIRef, dict, or list.
|
|
212
|
+
uri_handling: How to handle URIs. Options are:
|
|
213
|
+
- "skip": Leave URIs as is.
|
|
214
|
+
- "remove-namespace": Remove the namespace from URIs.
|
|
215
|
+
- "short-form": Convert URIs to a short form using prefixes.
|
|
216
|
+
|
|
217
|
+
"""
|
|
218
|
+
if isinstance(content, RdfLiteral):
|
|
219
|
+
return content.toPython()
|
|
220
|
+
elif isinstance(content, URIRef):
|
|
221
|
+
if uri_handling == "remove-namespace":
|
|
222
|
+
return remove_namespace_from_uri(content)
|
|
223
|
+
elif uri_handling == "as-concept-entity":
|
|
224
|
+
if components := uri_to_entity_components(content, prefixes or {}):
|
|
225
|
+
return ConceptEntity(prefix=components[0], suffix=components[3], version=components[2])
|
|
226
|
+
# fallback to "remove-namespace"
|
|
227
|
+
else:
|
|
228
|
+
return convert_rdflib_content(content, uri_handling="remove-namespace", prefixes=prefixes)
|
|
229
|
+
else:
|
|
230
|
+
return content.toPython()
|
|
231
|
+
elif isinstance(content, dict):
|
|
232
|
+
return {key: convert_rdflib_content(value, uri_handling, prefixes) for key, value in content.items()}
|
|
233
|
+
elif isinstance(content, list):
|
|
234
|
+
return [convert_rdflib_content(item, uri_handling, prefixes) for item in content]
|
|
235
|
+
else:
|
|
236
|
+
return content
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def sanitize_entity(entity: str | ConceptEntity, safe: str = "") -> str:
|
|
240
|
+
"""Sanitize an entity to ensure it yields entity form that will pass downstream validation.
|
|
241
|
+
|
|
242
|
+
Args:
|
|
243
|
+
entity: The entity to sanitize. Can be a string or a ConceptEntity.
|
|
244
|
+
safe: Characters that should not be quoted during sanitization.
|
|
245
|
+
|
|
246
|
+
Returns:
|
|
247
|
+
A web-safe string representation of the entity
|
|
248
|
+
"""
|
|
249
|
+
if isinstance(entity, str):
|
|
250
|
+
return quote(entity, safe=safe)
|
|
251
|
+
# if it already we dont need to quote it so we return its string representation
|
|
252
|
+
elif isinstance(entity, ConceptEntity):
|
|
253
|
+
return str(entity)
|
|
254
|
+
else:
|
|
255
|
+
raise ValueError(f"Invalid entity type: {type(entity)}. Expected str, ConceptEntity.")
|
|
@@ -10,27 +10,35 @@ import pandas as pd
|
|
|
10
10
|
from openpyxl import load_workbook
|
|
11
11
|
from openpyxl.worksheet.worksheet import Worksheet
|
|
12
12
|
from pandas import ExcelFile
|
|
13
|
+
from pydantic import ValidationError
|
|
13
14
|
from rdflib import Namespace, URIRef
|
|
14
15
|
|
|
15
|
-
from cognite.neat.core._data_model.
|
|
16
|
+
from cognite.neat.v0.core._data_model._constants import SPLIT_ON_COMMA_PATTERN
|
|
17
|
+
from cognite.neat.v0.core._data_model._shared import (
|
|
16
18
|
ImportedDataModel,
|
|
17
19
|
T_UnverifiedDataModel,
|
|
18
20
|
)
|
|
19
|
-
from cognite.neat.core._data_model.models import (
|
|
21
|
+
from cognite.neat.v0.core._data_model.models import (
|
|
20
22
|
UNVERIFIED_DATA_MODEL_BY_ROLE,
|
|
21
23
|
VERIFIED_DATA_MODEL_BY_ROLE,
|
|
22
24
|
RoleTypes,
|
|
23
25
|
SchemaCompleteness,
|
|
24
26
|
)
|
|
25
|
-
from cognite.neat.core.
|
|
26
|
-
from cognite.neat.core.
|
|
27
|
+
from cognite.neat.v0.core._data_model.models._import_contexts import SpreadsheetContext
|
|
28
|
+
from cognite.neat.v0.core._data_model.models.entities._single_value import ContainerConstraintEntity, ContainerEntity
|
|
29
|
+
from cognite.neat.v0.core._issues import IssueList, MultiValueError
|
|
30
|
+
from cognite.neat.v0.core._issues.errors import (
|
|
27
31
|
FileMissingRequiredFieldError,
|
|
28
32
|
FileNotFoundNeatError,
|
|
29
33
|
FileReadError,
|
|
30
34
|
)
|
|
31
|
-
from cognite.neat.core._issues.warnings import FileMissingRequiredFieldWarning
|
|
32
|
-
from cognite.neat.core._utils.spreadsheet import
|
|
33
|
-
|
|
35
|
+
from cognite.neat.v0.core._issues.warnings import FileMissingRequiredFieldWarning
|
|
36
|
+
from cognite.neat.v0.core._utils.spreadsheet import (
|
|
37
|
+
SpreadsheetRead,
|
|
38
|
+
find_column_and_row_with_value,
|
|
39
|
+
read_individual_sheet,
|
|
40
|
+
)
|
|
41
|
+
from cognite.neat.v0.core._utils.text import humanize_collection
|
|
34
42
|
|
|
35
43
|
from ._base import BaseImporter
|
|
36
44
|
|
|
@@ -271,7 +279,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
|
|
|
271
279
|
raise MultiValueError(issue_list.errors)
|
|
272
280
|
|
|
273
281
|
if user_read is None:
|
|
274
|
-
return ImportedDataModel(None,
|
|
282
|
+
return ImportedDataModel(None, None)
|
|
275
283
|
|
|
276
284
|
sheets = user_read.sheets
|
|
277
285
|
original_role = user_read.role
|
|
@@ -287,7 +295,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
|
|
|
287
295
|
except Exception as e:
|
|
288
296
|
issue_list.append(FileReadError(self.filepath, f"Failed to delete temporary file: {e}"))
|
|
289
297
|
|
|
290
|
-
return ImportedDataModel(data_model, read_info_by_sheet)
|
|
298
|
+
return ImportedDataModel(data_model, SpreadsheetContext(read_info_by_sheet))
|
|
291
299
|
|
|
292
300
|
@property
|
|
293
301
|
def description(self) -> str:
|
|
@@ -305,7 +313,7 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
|
|
|
305
313
|
|
|
306
314
|
"""
|
|
307
315
|
|
|
308
|
-
workbook = load_workbook(filepath)
|
|
316
|
+
workbook = load_workbook(filepath, data_only=True)
|
|
309
317
|
|
|
310
318
|
if "Classes" in workbook.sheetnames:
|
|
311
319
|
print(
|
|
@@ -322,13 +330,17 @@ class ExcelImporter(BaseImporter[T_UnverifiedDataModel]):
|
|
|
322
330
|
if "Properties" in workbook.sheetnames:
|
|
323
331
|
_replace_class_with_concept_cell(workbook["Properties"])
|
|
324
332
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
elif "Containers" in workbook.sheetnames:
|
|
334
|
+
_replace_legacy_constraint_form(workbook["Containers"])
|
|
335
|
+
_replace_legacy_constraint_form(workbook["Properties"])
|
|
328
336
|
|
|
329
337
|
else:
|
|
330
338
|
return filepath
|
|
331
339
|
|
|
340
|
+
with tempfile.NamedTemporaryFile(prefix="temp_neat_file", suffix=".xlsx", delete=False) as temp_file:
|
|
341
|
+
workbook.save(temp_file.name)
|
|
342
|
+
return Path(temp_file.name)
|
|
343
|
+
|
|
332
344
|
|
|
333
345
|
def _replace_class_with_concept_cell(sheet: Worksheet) -> None:
|
|
334
346
|
"""
|
|
@@ -341,3 +353,72 @@ def _replace_class_with_concept_cell(sheet: Worksheet) -> None:
|
|
|
341
353
|
for cell in row:
|
|
342
354
|
if cell.value == "Class":
|
|
343
355
|
cell.value = "Concept"
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def _replace_legacy_constraint_form(sheet: Worksheet) -> None:
|
|
359
|
+
"""
|
|
360
|
+
Replaces the legacy form of container constraints with the new form in the given sheet.
|
|
361
|
+
|
|
362
|
+
Args:
|
|
363
|
+
sheet (Worksheet): The sheet in which to replace the old form of container constraints.
|
|
364
|
+
"""
|
|
365
|
+
column, row = find_column_and_row_with_value(sheet, "Constraint", False)
|
|
366
|
+
|
|
367
|
+
if not column or not row:
|
|
368
|
+
return None
|
|
369
|
+
|
|
370
|
+
# Iterate over values in the constraint column and replace old form with new form
|
|
371
|
+
replaced: bool = False
|
|
372
|
+
for cell_row in sheet.iter_rows(min_row=row + 1, min_col=column, max_col=column):
|
|
373
|
+
cell = cell_row[0]
|
|
374
|
+
if cell.value is not None: # Skip empty cells
|
|
375
|
+
# Container sheet update
|
|
376
|
+
if sheet.title.lower() == "containers":
|
|
377
|
+
constraints = []
|
|
378
|
+
for constraint in SPLIT_ON_COMMA_PATTERN.split(str(cell.value)):
|
|
379
|
+
# latest format, do nothing
|
|
380
|
+
if "require" in constraint.lower():
|
|
381
|
+
constraints.append(constraint)
|
|
382
|
+
continue
|
|
383
|
+
|
|
384
|
+
try:
|
|
385
|
+
container = ContainerEntity.load(constraint, space="default")
|
|
386
|
+
container_str = container.external_id if container.space == "default" else str(container)
|
|
387
|
+
constraints.append(
|
|
388
|
+
f"requires:{container.space}_{container.external_id}(require={container_str})"
|
|
389
|
+
)
|
|
390
|
+
replaced = True
|
|
391
|
+
except ValidationError:
|
|
392
|
+
constraints.append(constraint)
|
|
393
|
+
|
|
394
|
+
cell.value = ",".join(constraints)
|
|
395
|
+
|
|
396
|
+
# Properties sheet update
|
|
397
|
+
elif sheet.title.lower() == "properties":
|
|
398
|
+
constraints = []
|
|
399
|
+
for constraint in SPLIT_ON_COMMA_PATTERN.split(str(cell.value)):
|
|
400
|
+
try:
|
|
401
|
+
constraint_entity = ContainerConstraintEntity.load(constraint)
|
|
402
|
+
|
|
403
|
+
if constraint_entity.prefix in ["uniqueness", "requires"]:
|
|
404
|
+
constraints.append(constraint)
|
|
405
|
+
|
|
406
|
+
# Replace old format with new format
|
|
407
|
+
else:
|
|
408
|
+
constraints.append(f"uniqueness:{constraint}")
|
|
409
|
+
replaced = True
|
|
410
|
+
|
|
411
|
+
# If the constraint is not valid, we keep it as is
|
|
412
|
+
# to be caught by validation later
|
|
413
|
+
except ValidationError:
|
|
414
|
+
constraints.append(constraint)
|
|
415
|
+
|
|
416
|
+
cell.value = ",".join(constraints)
|
|
417
|
+
|
|
418
|
+
if replaced:
|
|
419
|
+
print(
|
|
420
|
+
(
|
|
421
|
+
"You are using a legacy container constraints format "
|
|
422
|
+
f"in the {sheet.title} sheet. Please update to the latest format."
|
|
423
|
+
),
|
|
424
|
+
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from cognite.neat.core._client.data_classes.schema import DMSSchema
|
|
2
|
-
from cognite.neat.core._data_model.models.conceptual._unverified import (
|
|
1
|
+
from cognite.neat.v0.core._client.data_classes.schema import DMSSchema
|
|
2
|
+
from cognite.neat.v0.core._data_model.models.conceptual._unverified import (
|
|
3
3
|
UnverifiedConceptualDataModel,
|
|
4
4
|
)
|
|
5
|
-
from cognite.neat.core._data_model.models.conceptual._verified import (
|
|
5
|
+
from cognite.neat.v0.core._data_model.models.conceptual._verified import (
|
|
6
6
|
ConceptualDataModel,
|
|
7
7
|
)
|
|
8
8
|
|
|
@@ -26,8 +26,8 @@ from pydantic.main import IncEx
|
|
|
26
26
|
from pydantic_core import core_schema
|
|
27
27
|
from rdflib import Namespace, URIRef
|
|
28
28
|
|
|
29
|
-
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
30
|
-
from cognite.neat.core._data_model.models._types import (
|
|
29
|
+
from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE
|
|
30
|
+
from cognite.neat.v0.core._data_model.models._types import (
|
|
31
31
|
ContainerEntityType,
|
|
32
32
|
DataModelExternalIdType,
|
|
33
33
|
PhysicalPropertyType,
|
|
@@ -37,13 +37,13 @@ from cognite.neat.core._data_model.models._types import (
|
|
|
37
37
|
VersionType,
|
|
38
38
|
ViewEntityType,
|
|
39
39
|
)
|
|
40
|
-
from cognite.neat.core._data_model.models.data_types import DataType
|
|
41
|
-
from cognite.neat.core._data_model.models.entities import (
|
|
40
|
+
from cognite.neat.v0.core._data_model.models.data_types import DataType
|
|
41
|
+
from cognite.neat.v0.core._data_model.models.entities import (
|
|
42
42
|
EdgeEntity,
|
|
43
43
|
ReverseConnectionEntity,
|
|
44
44
|
ViewEntity,
|
|
45
45
|
)
|
|
46
|
-
from cognite.neat.core._utils.rdf_ import uri_display_name
|
|
46
|
+
from cognite.neat.v0.core._utils.rdf_ import uri_display_name
|
|
47
47
|
|
|
48
48
|
if sys.version_info >= (3, 11):
|
|
49
49
|
from enum import StrEnum
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from collections.abc import Hashable, ItemsView, Iterator, KeysView, Mapping, ValuesView
|
|
2
|
+
from typing import TypeVar
|
|
3
|
+
|
|
4
|
+
from rdflib import URIRef
|
|
5
|
+
|
|
6
|
+
from cognite.neat.v0.core._utils.spreadsheet import SpreadsheetRead
|
|
7
|
+
|
|
8
|
+
T_Key = TypeVar("T_Key", bound=Hashable)
|
|
9
|
+
T_Value = TypeVar("T_Value")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ImportContext(dict, Mapping[T_Key, T_Value]):
|
|
13
|
+
def __init__(self, data: Mapping[T_Key, T_Value] | None = None) -> None:
|
|
14
|
+
super().__init__(data or {})
|
|
15
|
+
|
|
16
|
+
# The below methods are included to make better type hints in the IDE
|
|
17
|
+
def __getitem__(self, k: T_Key) -> T_Value:
|
|
18
|
+
return super().__getitem__(k)
|
|
19
|
+
|
|
20
|
+
def __setitem__(self, k: T_Key, v: T_Value) -> None:
|
|
21
|
+
super().__setitem__(k, v)
|
|
22
|
+
|
|
23
|
+
def __delitem__(self, k: T_Key) -> None:
|
|
24
|
+
super().__delitem__(k)
|
|
25
|
+
|
|
26
|
+
def __iter__(self) -> Iterator[T_Key]:
|
|
27
|
+
return super().__iter__()
|
|
28
|
+
|
|
29
|
+
def keys(self) -> KeysView[T_Key]: # type: ignore[override]
|
|
30
|
+
return super().keys()
|
|
31
|
+
|
|
32
|
+
def values(self) -> ValuesView[T_Value]: # type: ignore[override]
|
|
33
|
+
return super().values()
|
|
34
|
+
|
|
35
|
+
def items(self) -> ItemsView[T_Key, T_Value]: # type: ignore[override]
|
|
36
|
+
return super().items()
|
|
37
|
+
|
|
38
|
+
def get(self, __key: T_Key, __default: T_Value | None = None) -> T_Value: # type: ignore[override]
|
|
39
|
+
return super().get(__key, __default)
|
|
40
|
+
|
|
41
|
+
def pop(self, __key: T_Key, __default: T_Value | None = None) -> T_Value: # type: ignore[override]
|
|
42
|
+
return super().pop(__key, __default)
|
|
43
|
+
|
|
44
|
+
def popitem(self) -> tuple[T_Key, T_Value]:
|
|
45
|
+
return super().popitem()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class SpreadsheetContext(ImportContext[str, SpreadsheetRead]):
|
|
49
|
+
def __init__(self, data: dict[str, SpreadsheetRead] | None = None) -> None:
|
|
50
|
+
"""Initialize the SpreadsheetContext with a dictionary of SpreadsheetRead objects.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
data (dict[str, SpreadsheetRead]): A dictionary where keys are sheet names and values are
|
|
54
|
+
SpreadsheetRead objects containing the read data.
|
|
55
|
+
"""
|
|
56
|
+
super().__init__(data or {})
|
|
57
|
+
for k, v in self.items():
|
|
58
|
+
if not isinstance(k, str):
|
|
59
|
+
raise TypeError(f"Expected string key, got {type(k).__name__}")
|
|
60
|
+
if not isinstance(v, SpreadsheetRead):
|
|
61
|
+
raise TypeError(f"Expected SpreadsheetRead for key '{k}', got {type(v).__name__}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class GraphContext(ImportContext[str, Mapping[URIRef, int]]):
|
|
65
|
+
def __init__(self, data: dict[str, Mapping[URIRef, int]] | None = None) -> None:
|
|
66
|
+
"""Initialize the GraphContext with a dictionary of mappings from URIRef to int.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
data (dict[str, Mapping[URIRef, int]]): A dictionary where keys are graph names and values are
|
|
70
|
+
mappings of URIRef to integer identifiers.
|
|
71
|
+
"""
|
|
72
|
+
super().__init__(data or {})
|
|
73
|
+
for k, v in self.items():
|
|
74
|
+
if not isinstance(k, str):
|
|
75
|
+
raise TypeError(f"Expected string key, got {type(k).__name__}")
|
|
76
|
+
if not isinstance(v, Mapping):
|
|
77
|
+
raise TypeError(f"Expected Mapping[URIRef, int] for key '{k}', got {type(v).__name__}")
|
|
78
|
+
for uri, value in v.items():
|
|
79
|
+
if not isinstance(uri, URIRef):
|
|
80
|
+
raise TypeError(f"Expected URIRef key in mapping for '{k}', got {type(uri).__name__}")
|
|
81
|
+
if not isinstance(value, int):
|
|
82
|
+
raise TypeError(f"Expected int value in mapping for '{k}', got {type(value).__name__}")
|
|
@@ -14,21 +14,21 @@ from pydantic import (
|
|
|
14
14
|
)
|
|
15
15
|
from pydantic.functional_serializers import PlainSerializer
|
|
16
16
|
|
|
17
|
-
from cognite.neat.core._data_model._constants import (
|
|
17
|
+
from cognite.neat.v0.core._data_model._constants import (
|
|
18
18
|
DATA_MODEL_COMPLIANCE_REGEX,
|
|
19
19
|
PATTERNS,
|
|
20
20
|
PREFIX_COMPLIANCE_REGEX,
|
|
21
21
|
VERSION_COMPLIANCE_REGEX,
|
|
22
22
|
EntityTypes,
|
|
23
23
|
)
|
|
24
|
-
from cognite.neat.core._data_model.models.entities._multi_value import MultiValueTypeInfo
|
|
25
|
-
from cognite.neat.core._data_model.models.entities._single_value import (
|
|
24
|
+
from cognite.neat.v0.core._data_model.models.entities._multi_value import MultiValueTypeInfo
|
|
25
|
+
from cognite.neat.v0.core._data_model.models.entities._single_value import (
|
|
26
26
|
ConceptEntity,
|
|
27
27
|
ContainerEntity,
|
|
28
28
|
ViewEntity,
|
|
29
29
|
)
|
|
30
|
-
from cognite.neat.core._issues.errors import RegexViolationError
|
|
31
|
-
from cognite.neat.core._issues.warnings import RegexViolationWarning
|
|
30
|
+
from cognite.neat.v0.core._issues.errors import RegexViolationError
|
|
31
|
+
from cognite.neat.v0.core._issues.warnings import RegexViolationWarning
|
|
32
32
|
|
|
33
33
|
Entities: TypeAlias = ConceptEntity | ViewEntity | ContainerEntity
|
|
34
34
|
T_Entities = TypeVar("T_Entities", bound=Entities)
|
|
@@ -6,19 +6,19 @@ import pandas as pd
|
|
|
6
6
|
from cognite.client import data_modeling as dm
|
|
7
7
|
from rdflib import Namespace, URIRef
|
|
8
8
|
|
|
9
|
-
from cognite.neat.core._constants import DEFAULT_NAMESPACE
|
|
10
|
-
from cognite.neat.core._data_model.models._base_unverified import (
|
|
9
|
+
from cognite.neat.v0.core._constants import DEFAULT_NAMESPACE
|
|
10
|
+
from cognite.neat.v0.core._data_model.models._base_unverified import (
|
|
11
11
|
UnverifiedComponent,
|
|
12
12
|
UnverifiedDataModel,
|
|
13
13
|
)
|
|
14
|
-
from cognite.neat.core._data_model.models.data_types import DataType
|
|
15
|
-
from cognite.neat.core._data_model.models.entities import (
|
|
14
|
+
from cognite.neat.v0.core._data_model.models.data_types import DataType
|
|
15
|
+
from cognite.neat.v0.core._data_model.models.entities import (
|
|
16
16
|
ConceptEntity,
|
|
17
17
|
MultiValueTypeInfo,
|
|
18
18
|
UnknownEntity,
|
|
19
19
|
load_value_type,
|
|
20
20
|
)
|
|
21
|
-
from cognite.neat.core._utils.rdf_ import uri_display_name
|
|
21
|
+
from cognite.neat.v0.core._utils.rdf_ import uri_display_name
|
|
22
22
|
|
|
23
23
|
from ._verified import (
|
|
24
24
|
Concept,
|
|
@@ -78,7 +78,7 @@ class UnverifiedConceptualMetadata(UnverifiedComponent[ConceptualMetadata]):
|
|
|
78
78
|
|
|
79
79
|
@dataclass
|
|
80
80
|
class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
|
|
81
|
-
concept: ConceptEntity | str
|
|
81
|
+
concept: ConceptEntity | str | UnknownEntity
|
|
82
82
|
property_: str
|
|
83
83
|
value_type: DataType | ConceptEntity | MultiValueTypeInfo | UnknownEntity | str
|
|
84
84
|
name: str | None = None
|
|
@@ -100,8 +100,8 @@ class UnverifiedConceptualProperty(UnverifiedComponent[ConceptualProperty]):
|
|
|
100
100
|
|
|
101
101
|
def dump(self, default_prefix: str, **kwargs) -> dict[str, Any]: # type: ignore
|
|
102
102
|
output = super().dump()
|
|
103
|
-
output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix)
|
|
104
|
-
output["Value Type"] = load_value_type(self.value_type, default_prefix)
|
|
103
|
+
output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix, return_on_failure=True)
|
|
104
|
+
output["Value Type"] = load_value_type(self.value_type, default_prefix, return_on_failure=True)
|
|
105
105
|
return output
|
|
106
106
|
|
|
107
107
|
def copy(self, update: dict[str, Any], default_prefix: str) -> "UnverifiedConceptualProperty":
|
|
@@ -135,10 +135,16 @@ class UnverifiedConcept(UnverifiedComponent[Concept]):
|
|
|
135
135
|
parent: list[ConceptEntity] | None = None
|
|
136
136
|
if isinstance(self.implements, str):
|
|
137
137
|
self.implements = self.implements.strip()
|
|
138
|
-
parent = [
|
|
138
|
+
parent = [
|
|
139
|
+
ConceptEntity.load(parent_str, prefix=default_prefix, return_on_failure=True)
|
|
140
|
+
for parent_str in self.implements.split(",")
|
|
141
|
+
]
|
|
139
142
|
elif isinstance(self.implements, list):
|
|
140
|
-
parent = [
|
|
141
|
-
|
|
143
|
+
parent = [
|
|
144
|
+
ConceptEntity.load(parent_str, prefix=default_prefix, return_on_failure=True)
|
|
145
|
+
for parent_str in self.implements
|
|
146
|
+
]
|
|
147
|
+
output["Concept"] = ConceptEntity.load(self.concept, prefix=default_prefix, return_on_failure=True)
|
|
142
148
|
output["Implements"] = parent
|
|
143
149
|
return output
|
|
144
150
|
|
|
@@ -146,8 +152,8 @@ class UnverifiedConcept(UnverifiedComponent[Concept]):
|
|
|
146
152
|
@dataclass
|
|
147
153
|
class UnverifiedConceptualDataModel(UnverifiedDataModel[ConceptualDataModel]):
|
|
148
154
|
metadata: UnverifiedConceptualMetadata
|
|
149
|
-
properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
|
|
150
155
|
concepts: list[UnverifiedConcept] = field(default_factory=list)
|
|
156
|
+
properties: list[UnverifiedConceptualProperty] = field(default_factory=list)
|
|
151
157
|
prefixes: dict[str, Namespace] | None = None
|
|
152
158
|
|
|
153
159
|
@classmethod
|