cognite-neat 0.123.26__py3-none-any.whl → 1.0.22__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cognite/neat/__init__.py +4 -3
- cognite/neat/_client/__init__.py +5 -0
- cognite/neat/_client/api.py +8 -0
- cognite/neat/_client/client.py +21 -0
- cognite/neat/_client/config.py +40 -0
- cognite/neat/_client/containers_api.py +138 -0
- cognite/neat/_client/data_classes.py +44 -0
- cognite/neat/_client/data_model_api.py +115 -0
- cognite/neat/_client/init/credentials.py +70 -0
- cognite/neat/_client/init/env_vars.py +131 -0
- cognite/neat/_client/init/main.py +51 -0
- cognite/neat/_client/spaces_api.py +115 -0
- cognite/neat/_client/statistics_api.py +24 -0
- cognite/neat/_client/views_api.py +144 -0
- cognite/neat/_config.py +266 -0
- cognite/neat/_data_model/_analysis.py +571 -0
- cognite/neat/_data_model/_constants.py +74 -0
- cognite/neat/_data_model/_identifiers.py +61 -0
- cognite/neat/_data_model/_shared.py +41 -0
- cognite/neat/_data_model/_snapshot.py +134 -0
- cognite/neat/_data_model/deployer/_differ.py +140 -0
- cognite/neat/_data_model/deployer/_differ_container.py +360 -0
- cognite/neat/_data_model/deployer/_differ_data_model.py +54 -0
- cognite/neat/_data_model/deployer/_differ_space.py +9 -0
- cognite/neat/_data_model/deployer/_differ_view.py +299 -0
- cognite/neat/_data_model/deployer/data_classes.py +644 -0
- cognite/neat/_data_model/deployer/deployer.py +431 -0
- cognite/neat/_data_model/exporters/__init__.py +15 -0
- cognite/neat/_data_model/exporters/_api_exporter.py +37 -0
- cognite/neat/_data_model/exporters/_base.py +24 -0
- cognite/neat/_data_model/exporters/_table_exporter/exporter.py +128 -0
- cognite/neat/_data_model/exporters/_table_exporter/workbook.py +409 -0
- cognite/neat/_data_model/exporters/_table_exporter/writer.py +480 -0
- cognite/neat/_data_model/importers/__init__.py +5 -0
- cognite/neat/_data_model/importers/_api_importer.py +166 -0
- cognite/neat/_data_model/importers/_base.py +16 -0
- cognite/neat/_data_model/importers/_table_importer/data_classes.py +344 -0
- cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
- cognite/neat/_data_model/importers/_table_importer/reader.py +1102 -0
- cognite/neat/_data_model/importers/_table_importer/source.py +94 -0
- cognite/neat/_data_model/models/conceptual/_base.py +18 -0
- cognite/neat/_data_model/models/conceptual/_concept.py +67 -0
- cognite/neat/_data_model/models/conceptual/_data_model.py +51 -0
- cognite/neat/_data_model/models/conceptual/_properties.py +104 -0
- cognite/neat/_data_model/models/conceptual/_property.py +105 -0
- cognite/neat/_data_model/models/dms/__init__.py +206 -0
- cognite/neat/_data_model/models/dms/_base.py +31 -0
- cognite/neat/_data_model/models/dms/_constants.py +48 -0
- cognite/neat/_data_model/models/dms/_constraints.py +42 -0
- cognite/neat/_data_model/models/dms/_container.py +159 -0
- cognite/neat/_data_model/models/dms/_data_model.py +95 -0
- cognite/neat/_data_model/models/dms/_data_types.py +195 -0
- cognite/neat/_data_model/models/dms/_http.py +28 -0
- cognite/neat/_data_model/models/dms/_indexes.py +30 -0
- cognite/neat/_data_model/models/dms/_limits.py +96 -0
- cognite/neat/_data_model/models/dms/_references.py +141 -0
- cognite/neat/_data_model/models/dms/_schema.py +18 -0
- cognite/neat/_data_model/models/dms/_space.py +48 -0
- cognite/neat/_data_model/models/dms/_types.py +17 -0
- cognite/neat/_data_model/models/dms/_view_filter.py +310 -0
- cognite/neat/_data_model/models/dms/_view_property.py +235 -0
- cognite/neat/_data_model/models/dms/_views.py +216 -0
- cognite/neat/_data_model/models/entities/__init__.py +50 -0
- cognite/neat/_data_model/models/entities/_base.py +101 -0
- cognite/neat/_data_model/models/entities/_constants.py +22 -0
- cognite/neat/_data_model/models/entities/_data_types.py +144 -0
- cognite/neat/_data_model/models/entities/_identifiers.py +61 -0
- cognite/neat/_data_model/models/entities/_parser.py +226 -0
- cognite/neat/_data_model/validation/dms/__init__.py +75 -0
- cognite/neat/_data_model/validation/dms/_ai_readiness.py +381 -0
- cognite/neat/_data_model/validation/dms/_base.py +25 -0
- cognite/neat/_data_model/validation/dms/_connections.py +681 -0
- cognite/neat/_data_model/validation/dms/_consistency.py +58 -0
- cognite/neat/_data_model/validation/dms/_containers.py +199 -0
- cognite/neat/_data_model/validation/dms/_limits.py +368 -0
- cognite/neat/_data_model/validation/dms/_orchestrator.py +70 -0
- cognite/neat/_data_model/validation/dms/_views.py +164 -0
- cognite/neat/_exceptions.py +68 -0
- cognite/neat/_issues.py +68 -0
- cognite/neat/_session/__init__.py +3 -0
- cognite/neat/_session/_html/_render.py +30 -0
- cognite/neat/_session/_html/static/__init__.py +8 -0
- cognite/neat/_session/_html/static/deployment.css +476 -0
- cognite/neat/_session/_html/static/deployment.js +181 -0
- cognite/neat/_session/_html/static/issues.css +211 -0
- cognite/neat/_session/_html/static/issues.js +168 -0
- cognite/neat/_session/_html/static/shared.css +186 -0
- cognite/neat/_session/_html/templates/__init__.py +4 -0
- cognite/neat/_session/_html/templates/deployment.html +80 -0
- cognite/neat/_session/_html/templates/issues.html +45 -0
- cognite/neat/_session/_issues.py +81 -0
- cognite/neat/_session/_physical.py +294 -0
- cognite/neat/_session/_result/__init__.py +3 -0
- cognite/neat/_session/_result/_deployment/__init__.py +0 -0
- cognite/neat/_session/_result/_deployment/_physical/__init__.py +0 -0
- cognite/neat/_session/_result/_deployment/_physical/_changes.py +196 -0
- cognite/neat/_session/_result/_deployment/_physical/_statistics.py +180 -0
- cognite/neat/_session/_result/_deployment/_physical/serializer.py +35 -0
- cognite/neat/_session/_result/_result.py +31 -0
- cognite/neat/_session/_session.py +81 -0
- cognite/neat/_session/_usage_analytics/__init__.py +0 -0
- cognite/neat/_session/_usage_analytics/_collector.py +131 -0
- cognite/neat/_session/_usage_analytics/_constants.py +23 -0
- cognite/neat/_session/_usage_analytics/_storage.py +240 -0
- cognite/neat/_session/_wrappers.py +101 -0
- cognite/neat/_state_machine/__init__.py +10 -0
- cognite/neat/_state_machine/_base.py +37 -0
- cognite/neat/_state_machine/_states.py +52 -0
- cognite/neat/_store/__init__.py +3 -0
- cognite/neat/_store/_provenance.py +88 -0
- cognite/neat/_store/_store.py +220 -0
- cognite/neat/_utils/__init__.py +0 -0
- cognite/neat/_utils/_reader.py +194 -0
- cognite/neat/_utils/auxiliary.py +49 -0
- cognite/neat/_utils/collection.py +11 -0
- cognite/neat/_utils/http_client/__init__.py +39 -0
- cognite/neat/_utils/http_client/_client.py +245 -0
- cognite/neat/_utils/http_client/_config.py +19 -0
- cognite/neat/_utils/http_client/_data_classes.py +294 -0
- cognite/neat/_utils/http_client/_tracker.py +31 -0
- cognite/neat/_utils/repo.py +19 -0
- cognite/neat/_utils/text.py +71 -0
- cognite/neat/_utils/useful_types.py +37 -0
- cognite/neat/_utils/validation.py +154 -0
- cognite/neat/_v0/__init__.py +0 -0
- cognite/neat/_v0/core/__init__.py +0 -0
- cognite/neat/_v0/core/_client/_api/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_client/_api/data_modeling_loaders.py +8 -7
- cognite/neat/{core → _v0/core}/_client/_api/neat_instances.py +5 -5
- cognite/neat/{core → _v0/core}/_client/_api/schema.py +5 -5
- cognite/neat/{core → _v0/core}/_client/_api/statistics.py +3 -3
- cognite/neat/{core → _v0/core}/_client/_api_client.py +1 -1
- cognite/neat/_v0/core/_client/data_classes/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_client/data_classes/schema.py +4 -4
- cognite/neat/{core → _v0/core}/_client/testing.py +1 -1
- cognite/neat/{core → _v0/core}/_constants.py +5 -3
- cognite/neat/_v0/core/_data_model/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_data_model/_constants.py +7 -0
- cognite/neat/{core → _v0/core}/_data_model/_shared.py +4 -4
- cognite/neat/{core → _v0/core}/_data_model/analysis/_base.py +8 -8
- cognite/neat/{core → _v0/core}/_data_model/exporters/__init__.py +1 -2
- cognite/neat/{core → _v0/core}/_data_model/exporters/_base.py +7 -7
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2dms.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2excel.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2instance_template.py +4 -4
- cognite/neat/{core/_data_model/exporters/_data_model2ontology.py → _v0/core/_data_model/exporters/_data_model2semantic_model.py} +126 -116
- cognite/neat/{core → _v0/core}/_data_model/exporters/_data_model2yaml.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/importers/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/importers/_base_file_reader.py +2 -2
- cognite/neat/{core → _v0/core}/_data_model/importers/_dict2data_model.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/importers/_dms2data_model.py +18 -15
- cognite/neat/{core → _v0/core}/_data_model/importers/_graph2data_model.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_base.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_inference2rdata_model.py +14 -14
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_owl2data_model.py +41 -21
- cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/_shared.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/importers/_spreadsheet2data_model.py +92 -12
- cognite/neat/{core → _v0/core}/_data_model/models/__init__.py +3 -3
- cognite/neat/{core → _v0/core}/_data_model/models/_base_verified.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/_import_contexts.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/models/_types.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_unverified.py +16 -10
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_validation.py +12 -12
- cognite/neat/{core → _v0/core}/_data_model/models/conceptual/_verified.py +9 -9
- cognite/neat/{core → _v0/core}/_data_model/models/data_types.py +14 -4
- cognite/neat/{core → _v0/core}/_data_model/models/entities/__init__.py +6 -0
- cognite/neat/_v0/core/_data_model/models/entities/_loaders.py +155 -0
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_multi_value.py +2 -2
- cognite/neat/_v0/core/_data_model/models/entities/_restrictions.py +230 -0
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_single_value.py +121 -16
- cognite/neat/{core → _v0/core}/_data_model/models/entities/_types.py +10 -0
- cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/models/physical/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_exporter.py +26 -19
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_unverified.py +133 -37
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_validation.py +24 -20
- cognite/neat/{core → _v0/core}/_data_model/models/physical/_verified.py +95 -24
- cognite/neat/{core → _v0/core}/_data_model/transformers/_base.py +4 -4
- cognite/neat/{core → _v0/core}/_data_model/transformers/_converters.py +35 -28
- cognite/neat/{core → _v0/core}/_data_model/transformers/_mapping.py +7 -7
- cognite/neat/{core → _v0/core}/_data_model/transformers/_union_conceptual.py +5 -5
- cognite/neat/{core → _v0/core}/_data_model/transformers/_verification.py +7 -7
- cognite/neat/_v0/core/_instances/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_instances/_tracking/base.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/_tracking/log.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/extractors/__init__.py +3 -2
- cognite/neat/{core → _v0/core}/_instances/extractors/_base.py +6 -6
- cognite/neat/_v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_base.py +7 -7
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_classic.py +12 -12
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_relationships.py +3 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_sequences.py +2 -2
- cognite/neat/{core → _v0/core}/_instances/extractors/_dict.py +6 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_dms.py +6 -6
- cognite/neat/{core → _v0/core}/_instances/extractors/_dms_graph.py +11 -11
- cognite/neat/{core → _v0/core}/_instances/extractors/_mock_graph_generator.py +10 -10
- cognite/neat/{core → _v0/core}/_instances/extractors/_raw.py +3 -3
- cognite/neat/{core → _v0/core}/_instances/extractors/_rdf_file.py +7 -7
- cognite/neat/{core → _v0/core}/_instances/loaders/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_instances/loaders/_rdf2dms.py +17 -17
- cognite/neat/{core → _v0/core}/_instances/loaders/_rdf_to_instance_space.py +11 -11
- cognite/neat/{core → _v0/core}/_instances/queries/_select.py +29 -3
- cognite/neat/{core → _v0/core}/_instances/queries/_update.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/transformers/_base.py +4 -4
- cognite/neat/{core → _v0/core}/_instances/transformers/_classic_cdf.py +6 -6
- cognite/neat/{core → _v0/core}/_instances/transformers/_prune_graph.py +4 -4
- cognite/neat/{core → _v0/core}/_instances/transformers/_rdfpath.py +1 -1
- cognite/neat/{core → _v0/core}/_instances/transformers/_value_type.py +4 -4
- cognite/neat/{core → _v0/core}/_issues/_base.py +5 -5
- cognite/neat/{core → _v0/core}/_issues/_contextmanagers.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/_factory.py +3 -3
- cognite/neat/{core → _v0/core}/_issues/errors/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_external.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_general.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_properties.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/errors/_resources.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/errors/_wrapper.py +7 -3
- cognite/neat/{core → _v0/core}/_issues/warnings/__init__.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_external.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_general.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/_models.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/warnings/_properties.py +2 -2
- cognite/neat/{core → _v0/core}/_issues/warnings/_resources.py +1 -1
- cognite/neat/{core → _v0/core}/_issues/warnings/user_modeling.py +1 -1
- cognite/neat/{core → _v0/core}/_store/_data_model.py +12 -12
- cognite/neat/{core → _v0/core}/_store/_instance.py +43 -10
- cognite/neat/{core → _v0/core}/_store/_provenance.py +3 -3
- cognite/neat/{core → _v0/core}/_store/exceptions.py +4 -4
- cognite/neat/_v0/core/_utils/__init__.py +0 -0
- cognite/neat/{core → _v0/core}/_utils/auth.py +22 -12
- cognite/neat/{core → _v0/core}/_utils/auxiliary.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/collection_.py +2 -2
- cognite/neat/{core → _v0/core}/_utils/graph_transformations_report.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/rdf_.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/reader/_base.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/spreadsheet.py +18 -4
- cognite/neat/{core → _v0/core}/_utils/text.py +1 -1
- cognite/neat/{core → _v0/core}/_utils/upload.py +3 -3
- cognite/neat/{session → _v0}/engine/_load.py +1 -1
- cognite/neat/_v0/plugins/__init__.py +4 -0
- cognite/neat/_v0/plugins/_base.py +9 -0
- cognite/neat/_v0/plugins/_data_model.py +48 -0
- cognite/neat/{plugins → _v0/plugins}/_issues.py +1 -1
- cognite/neat/{plugins → _v0/plugins}/_manager.py +7 -16
- cognite/neat/{session → _v0/session}/_base.py +13 -15
- cognite/neat/{session → _v0/session}/_collector.py +1 -1
- cognite/neat/_v0/session/_diff.py +51 -0
- cognite/neat/{session → _v0/session}/_drop.py +3 -3
- cognite/neat/{session → _v0/session}/_explore.py +2 -2
- cognite/neat/{session → _v0/session}/_fix.py +2 -2
- cognite/neat/{session → _v0/session}/_inspect.py +3 -3
- cognite/neat/{session → _v0/session}/_mapping.py +3 -3
- cognite/neat/{session → _v0/session}/_plugin.py +4 -5
- cognite/neat/{session → _v0/session}/_prepare.py +8 -8
- cognite/neat/{session → _v0/session}/_read.py +34 -21
- cognite/neat/{session → _v0/session}/_set.py +8 -8
- cognite/neat/{session → _v0/session}/_show.py +5 -5
- cognite/neat/{session → _v0/session}/_state.py +10 -10
- cognite/neat/{session → _v0/session}/_subset.py +4 -4
- cognite/neat/{session → _v0/session}/_template.py +11 -11
- cognite/neat/{session → _v0/session}/_to.py +12 -12
- cognite/neat/{session → _v0/session}/_wizard.py +1 -1
- cognite/neat/{session → _v0/session}/exceptions.py +5 -5
- cognite/neat/_version.py +1 -1
- cognite/neat/legacy.py +6 -0
- cognite_neat-1.0.22.dist-info/METADATA +123 -0
- cognite_neat-1.0.22.dist-info/RECORD +329 -0
- cognite_neat-1.0.22.dist-info/WHEEL +4 -0
- cognite/neat/core/_data_model/models/entities/_loaders.py +0 -75
- cognite/neat/plugins/__init__.py +0 -3
- cognite/neat/plugins/data_model/importers/__init__.py +0 -5
- cognite/neat/plugins/data_model/importers/_base.py +0 -28
- cognite/neat/session/_session/_data_model/__init__.py +0 -3
- cognite/neat/session/_session/_data_model/_read.py +0 -193
- cognite/neat/session/_session/_data_model/_routes.py +0 -45
- cognite/neat/session/_session/_data_model/_show.py +0 -147
- cognite/neat/session/_session/_data_model/_write.py +0 -335
- cognite_neat-0.123.26.dist-info/METADATA +0 -144
- cognite_neat-0.123.26.dist-info/RECORD +0 -201
- cognite_neat-0.123.26.dist-info/WHEEL +0 -4
- cognite_neat-0.123.26.dist-info/licenses/LICENSE +0 -201
- /cognite/neat/{core → _client/init}/__init__.py +0 -0
- /cognite/neat/{core/_client/_api → _data_model}/__init__.py +0 -0
- /cognite/neat/{core/_client/data_classes → _data_model/deployer}/__init__.py +0 -0
- /cognite/neat/{core/_data_model → _data_model/exporters/_table_exporter}/__init__.py +0 -0
- /cognite/neat/{core/_instances → _data_model/importers/_table_importer}/__init__.py +0 -0
- /cognite/neat/{core/_instances/extractors/_classic_cdf → _data_model/models}/__init__.py +0 -0
- /cognite/neat/{core/_utils → _data_model/models/conceptual}/__init__.py +0 -0
- /cognite/neat/{plugins/data_model → _data_model/validation}/__init__.py +0 -0
- /cognite/neat/{session/_session → _session/_html}/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/data_modeling.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/neat_sequence.py +0 -0
- /cognite/neat/{core → _v0/core}/_client/data_classes/statistics.py +0 -0
- /cognite/neat/{core → _v0/core}/_config.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/analysis/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/classic_model.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/catalog/hello_world_pump.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/importers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/importers/_rdf/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/_base_unverified.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/conceptual/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/entities/_constants.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/entities/_wrapped.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/mapping/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/models/mapping/_classic2core.yaml +0 -0
- /cognite/neat/{core → _v0/core}/_data_model/transformers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/_shared.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/_tracking/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_assets.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_data_sets.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_events.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_files.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_labels.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/extractors/_classic_cdf/_timeseries.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/loaders/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/_base.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/queries/_queries.py +0 -0
- /cognite/neat/{core → _v0/core}/_instances/transformers/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_issues/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_issues/formatters.py +0 -0
- /cognite/neat/{core → _v0/core}/_shared.py +0 -0
- /cognite/neat/{core → _v0/core}/_store/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/io_.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/reader/__init__.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/tarjan.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/time_.py +0 -0
- /cognite/neat/{core → _v0/core}/_utils/xml_.py +0 -0
- /cognite/neat/{session → _v0}/engine/__init__.py +0 -0
- /cognite/neat/{session → _v0}/engine/_import.py +0 -0
- /cognite/neat/{session → _v0}/engine/_interface.py +0 -0
- /cognite/neat/{session → _v0/session}/__init__.py +0 -0
- /cognite/neat/{session → _v0/session}/_experimental.py +0 -0
- /cognite/neat/{session → _v0/session}/_state/README.md +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
from collections.abc import Mapping
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
|
|
4
|
+
from .data_classes import DMS_API_MAPPING
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass
|
|
8
|
+
class SpreadsheetReadContext:
|
|
9
|
+
"""This class is used to store information about the source spreadsheet.
|
|
10
|
+
|
|
11
|
+
It is used to adjust row numbers to account for header rows and empty rows
|
|
12
|
+
such that the error/warning messages are accurate.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
header_row: int = 0
|
|
16
|
+
empty_rows: list[int] = field(default_factory=list)
|
|
17
|
+
|
|
18
|
+
def __post_init__(self) -> None:
|
|
19
|
+
self.empty_rows.sort()
|
|
20
|
+
|
|
21
|
+
def adjusted_row_number(self, row_no: int) -> int:
|
|
22
|
+
"""Adjusts the given row number to account for header rows and empty rows.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
row_no (int): The original row number (0-based).
|
|
26
|
+
|
|
27
|
+
!!! note "Row Numbering"
|
|
28
|
+
Input rows are zero-indexed, while output rows are one-indexed as they appear in Excel.
|
|
29
|
+
Therefore, we are adding 1 to offset header and 1 to offset row no
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
output = (row_no + 1) + (self.header_row + 1)
|
|
33
|
+
counter = 0
|
|
34
|
+
for empty_row in self.empty_rows:
|
|
35
|
+
if empty_row < self.header_row:
|
|
36
|
+
continue
|
|
37
|
+
if empty_row <= output:
|
|
38
|
+
counter += 1
|
|
39
|
+
output += 1
|
|
40
|
+
else:
|
|
41
|
+
break
|
|
42
|
+
|
|
43
|
+
return output
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@dataclass
|
|
47
|
+
class TableSource:
|
|
48
|
+
source: str
|
|
49
|
+
table_read: dict[str, SpreadsheetReadContext] = field(default_factory=dict)
|
|
50
|
+
|
|
51
|
+
def location(self, path: tuple[int | str, ...]) -> str:
|
|
52
|
+
table_id: str | None = None
|
|
53
|
+
row_no: int | None = None
|
|
54
|
+
column: str | None = None
|
|
55
|
+
if len(path) >= 1 and isinstance(path[0], str):
|
|
56
|
+
table_id = path[0]
|
|
57
|
+
if len(path) >= 2 and isinstance(path[1], int):
|
|
58
|
+
row_no = path[1]
|
|
59
|
+
if len(path) >= 3 and isinstance(path[2], str):
|
|
60
|
+
column = path[2]
|
|
61
|
+
column = self.field_to_column(table_id, column)
|
|
62
|
+
if isinstance(row_no, int):
|
|
63
|
+
row_no = self.adjust_row_number(table_id, row_no)
|
|
64
|
+
location_parts = []
|
|
65
|
+
if table_id is not None:
|
|
66
|
+
location_parts.append(f"table {table_id!r}")
|
|
67
|
+
if row_no is not None:
|
|
68
|
+
location_parts.append(f"row {row_no}")
|
|
69
|
+
if column is not None:
|
|
70
|
+
location_parts.append(f"column {column!r}")
|
|
71
|
+
if len(path) >= 4:
|
|
72
|
+
location_parts.append("-> " + ".".join(str(p) for p in path[3:]))
|
|
73
|
+
|
|
74
|
+
return " ".join(location_parts)
|
|
75
|
+
|
|
76
|
+
def adjust_row_number(self, table_id: str | None, row_no: int) -> int:
|
|
77
|
+
table_read = table_id and self.table_read.get(table_id)
|
|
78
|
+
if table_read:
|
|
79
|
+
return table_read.adjusted_row_number(row_no)
|
|
80
|
+
return row_no + 1 # Convert to 1-indexed if no table read info is available
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def field_to_column(cls, table_id: str | None, field_: str) -> str:
|
|
84
|
+
"""Maps the field name used in the DMS API to the column named used by Neat."""
|
|
85
|
+
mapping = cls.field_mapping(table_id)
|
|
86
|
+
if mapping is not None:
|
|
87
|
+
return mapping.get(field_, field_)
|
|
88
|
+
return field_
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def field_mapping(cls, table_id: str | int | None) -> Mapping[str, str] | None:
|
|
92
|
+
if not isinstance(table_id, str):
|
|
93
|
+
return None
|
|
94
|
+
return DMS_API_MAPPING.get(table_id)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
from pydantic.alias_generators import to_camel
|
|
3
|
+
|
|
4
|
+
from cognite.neat._data_model._identifiers import URI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BaseModelObject(BaseModel, alias_generator=to_camel, extra="ignore", populate_by_name=True):
|
|
8
|
+
"""Base class for all object. This includes resources and nested objects."""
|
|
9
|
+
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ResourceMetadata(BaseModelObject):
|
|
14
|
+
name: str | None = Field(
|
|
15
|
+
None, description="Human readable / display name of resource being described.", max_length=1024
|
|
16
|
+
)
|
|
17
|
+
description: str | None = Field(None, description="The description of the resource.", max_length=255)
|
|
18
|
+
uri: URI | None = Field(None, description="The URI of the resource being described.")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from collections import Counter
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, ValidationInfo, field_validator
|
|
4
|
+
from pyparsing import cast
|
|
5
|
+
|
|
6
|
+
from cognite.neat._data_model.models.entities import ConceptEntity
|
|
7
|
+
from cognite.neat._data_model.models.entities._constants import PREFIX_PATTERN, SUFFIX_PATTERN, VERSION_PATTERN
|
|
8
|
+
from cognite.neat._utils.text import humanize_collection
|
|
9
|
+
|
|
10
|
+
from ._base import ResourceMetadata
|
|
11
|
+
from ._property import Property
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Concept(ResourceMetadata):
|
|
15
|
+
space: str = Field(
|
|
16
|
+
description="Id of the space that the concept belongs to.",
|
|
17
|
+
min_length=1,
|
|
18
|
+
max_length=43,
|
|
19
|
+
pattern=PREFIX_PATTERN,
|
|
20
|
+
alias="prefix",
|
|
21
|
+
)
|
|
22
|
+
external_id: str = Field(
|
|
23
|
+
description="External-id of the concept.",
|
|
24
|
+
min_length=1,
|
|
25
|
+
max_length=255,
|
|
26
|
+
pattern=SUFFIX_PATTERN,
|
|
27
|
+
alias="suffix",
|
|
28
|
+
)
|
|
29
|
+
version: str | None = Field(
|
|
30
|
+
default=None,
|
|
31
|
+
description="Version of the concept.",
|
|
32
|
+
max_length=43,
|
|
33
|
+
pattern=VERSION_PATTERN,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
implements: list[ConceptEntity] | None = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="References to the concepts from where this concept will inherit properties.",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
properties: dict[str, Property] | None = Field(default=None, description="Properties associated with the concept.")
|
|
42
|
+
|
|
43
|
+
@field_validator("implements", mode="after")
|
|
44
|
+
def cannot_implement_itself(cls, value: list[ConceptEntity], info: ValidationInfo) -> list[ConceptEntity]:
|
|
45
|
+
if not value:
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
this_concept = ConceptEntity(
|
|
49
|
+
prefix=info.data["space"],
|
|
50
|
+
suffix=info.data["external_id"],
|
|
51
|
+
version=cast(str, info.data.get("version")),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
if this_concept in value:
|
|
55
|
+
raise ValueError("A concept cannot implement itself.")
|
|
56
|
+
|
|
57
|
+
return value
|
|
58
|
+
|
|
59
|
+
@field_validator("implements", mode="after")
|
|
60
|
+
def cannot_have_duplicates(cls, value: list[ConceptEntity], info: ValidationInfo) -> list[ConceptEntity]:
|
|
61
|
+
counts = Counter(value)
|
|
62
|
+
duplicates = {concept for concept, count in counts.items() if count > 1}
|
|
63
|
+
|
|
64
|
+
if duplicates:
|
|
65
|
+
raise ValueError(f"Duplicate concepts found: {humanize_collection(duplicates)}")
|
|
66
|
+
|
|
67
|
+
return value
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from collections import Counter
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, ValidationInfo, field_validator
|
|
4
|
+
|
|
5
|
+
from cognite.neat._data_model.models.entities import ConceptEntity
|
|
6
|
+
from cognite.neat._data_model.models.entities._constants import PREFIX_PATTERN, SUFFIX_PATTERN, VERSION_PATTERN
|
|
7
|
+
from cognite.neat._utils.text import humanize_collection
|
|
8
|
+
|
|
9
|
+
from ._base import ResourceMetadata
|
|
10
|
+
from ._concept import Concept
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DataModel(ResourceMetadata):
|
|
14
|
+
space: str = Field(
|
|
15
|
+
description="Id of the space that the concept belongs to.",
|
|
16
|
+
min_length=1,
|
|
17
|
+
max_length=43,
|
|
18
|
+
pattern=PREFIX_PATTERN,
|
|
19
|
+
alias="prefix",
|
|
20
|
+
)
|
|
21
|
+
external_id: str = Field(
|
|
22
|
+
description="External-id of the concept.",
|
|
23
|
+
min_length=1,
|
|
24
|
+
max_length=255,
|
|
25
|
+
pattern=SUFFIX_PATTERN,
|
|
26
|
+
alias="suffix",
|
|
27
|
+
)
|
|
28
|
+
version: str = Field(
|
|
29
|
+
description="Version of the concept.",
|
|
30
|
+
max_length=43,
|
|
31
|
+
pattern=VERSION_PATTERN,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
concepts: list[Concept] = Field(
|
|
35
|
+
description="References to the concepts from where this concept will inherit properties.",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@field_validator("concepts", mode="after")
|
|
39
|
+
def cannot_have_duplicates(cls, value: list[Concept], info: ValidationInfo) -> list[Concept]:
|
|
40
|
+
concept_ids = [
|
|
41
|
+
ConceptEntity(prefix=concept.space, suffix=concept.external_id, version=concept.version)
|
|
42
|
+
for concept in value
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
counts = Counter(concept_ids)
|
|
46
|
+
duplicates = {concept for concept, count in counts.items() if count > 1}
|
|
47
|
+
|
|
48
|
+
if duplicates:
|
|
49
|
+
raise ValueError(f"Duplicate concepts found: {humanize_collection(duplicates)}")
|
|
50
|
+
|
|
51
|
+
return value
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, ValidationInfo, field_validator, model_validator
|
|
4
|
+
|
|
5
|
+
from cognite.neat._data_model.models.entities import URI, ConceptEntity, DataType, UnknownEntity
|
|
6
|
+
|
|
7
|
+
from ._base import ResourceMetadata
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Property(ResourceMetadata):
|
|
11
|
+
value_type: DataType | ConceptEntity | UnknownEntity = Field(
|
|
12
|
+
union_mode="left_to_right",
|
|
13
|
+
description="Value type that the property can hold. It takes either subset of XSD type or a class defined.",
|
|
14
|
+
)
|
|
15
|
+
min_count: int | None = Field(
|
|
16
|
+
default=None,
|
|
17
|
+
ge=0,
|
|
18
|
+
description="Minimum number of values that the property can hold. "
|
|
19
|
+
"If no value is provided, the default value is None meaning `0`, "
|
|
20
|
+
"which means that the property is optional.",
|
|
21
|
+
)
|
|
22
|
+
max_count: int | None = Field(
|
|
23
|
+
default=None,
|
|
24
|
+
ge=0,
|
|
25
|
+
description="Maximum number of values that the property can hold. "
|
|
26
|
+
"If no value is provided, the default value is None meaning `inf`, "
|
|
27
|
+
"which means that the property can hold any number of values (listable).",
|
|
28
|
+
)
|
|
29
|
+
default: Any | None = Field(alias="Default", default=None, description="Default value of the property.")
|
|
30
|
+
instance_reference: list[URI] | None = Field(
|
|
31
|
+
default=None,
|
|
32
|
+
description="The URI(s) in the graph to get the value of the property.",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
@model_validator(mode="after")
|
|
36
|
+
def check_min_max_count(self) -> "Property":
|
|
37
|
+
if self.min_count is not None and self.max_count is not None:
|
|
38
|
+
if self.min_count > self.max_count:
|
|
39
|
+
raise ValueError("min_count must be less than or equal to max_count")
|
|
40
|
+
return self
|
|
41
|
+
|
|
42
|
+
@field_validator("default", mode="after")
|
|
43
|
+
def check_default_value_primitive_type(cls, value: Any, info: ValidationInfo) -> Any:
|
|
44
|
+
if not value:
|
|
45
|
+
return value
|
|
46
|
+
|
|
47
|
+
value_type = info.data.get("value_type")
|
|
48
|
+
if not isinstance(value_type, DataType):
|
|
49
|
+
raise ValueError("Setting default value is only supported for primitive value types.")
|
|
50
|
+
return value
|
|
51
|
+
|
|
52
|
+
@field_validator("default", mode="after")
|
|
53
|
+
def check_default_value_python_type_exists(cls, value: Any, info: ValidationInfo) -> Any:
|
|
54
|
+
if not value:
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
value_type = info.data.get("value_type")
|
|
58
|
+
|
|
59
|
+
if isinstance(value_type, DataType) and not hasattr(value_type, "python"):
|
|
60
|
+
raise ValueError(
|
|
61
|
+
f"DataType {value_type} does not have a python type defined."
|
|
62
|
+
" Setting default value for property is not possible."
|
|
63
|
+
)
|
|
64
|
+
return value
|
|
65
|
+
|
|
66
|
+
@field_validator("default", mode="after")
|
|
67
|
+
def check_default_value_not_list(cls, value: Any, info: ValidationInfo) -> Any:
|
|
68
|
+
if not value:
|
|
69
|
+
return value
|
|
70
|
+
|
|
71
|
+
if isinstance(value, list):
|
|
72
|
+
raise ValueError("Setting list as default value is not supported.")
|
|
73
|
+
return value
|
|
74
|
+
|
|
75
|
+
@field_validator("default", mode="after")
|
|
76
|
+
def check_default_value_single_valued(cls, value: Any, info: ValidationInfo) -> Any:
|
|
77
|
+
if not value:
|
|
78
|
+
return value
|
|
79
|
+
|
|
80
|
+
max_count = info.data.get("max_count")
|
|
81
|
+
|
|
82
|
+
if max_count is None or max_count > 1:
|
|
83
|
+
raise ValueError(
|
|
84
|
+
"Setting default value is only supported for single-valued properties."
|
|
85
|
+
f" Property has max_count={max_count or 'Inf'}."
|
|
86
|
+
)
|
|
87
|
+
return value
|
|
88
|
+
|
|
89
|
+
@field_validator("default", mode="after")
|
|
90
|
+
def check_default_value_type_match(cls, value: Any, info: ValidationInfo) -> Any:
|
|
91
|
+
if not value:
|
|
92
|
+
return value
|
|
93
|
+
|
|
94
|
+
value_type = info.data.get("value_type")
|
|
95
|
+
|
|
96
|
+
if (
|
|
97
|
+
isinstance(value_type, DataType)
|
|
98
|
+
and hasattr(value_type, "python")
|
|
99
|
+
and not isinstance(value, value_type.python)
|
|
100
|
+
):
|
|
101
|
+
raise ValueError(
|
|
102
|
+
f"Default value type is {type(value)}, which does not match expected value type {value_type.python}."
|
|
103
|
+
)
|
|
104
|
+
return value
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import Field, ValidationInfo, field_validator, model_validator
|
|
4
|
+
|
|
5
|
+
from cognite.neat._data_model.models.entities import URI, ConceptEntity, DataType, UnknownEntity
|
|
6
|
+
|
|
7
|
+
from ._base import ResourceMetadata
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Property(ResourceMetadata):
|
|
11
|
+
value_type: DataType | ConceptEntity | UnknownEntity = Field(
|
|
12
|
+
union_mode="left_to_right",
|
|
13
|
+
description="Value type that the property can hold. It takes either subset of XSD type or a class defined.",
|
|
14
|
+
)
|
|
15
|
+
min_count: int | None = Field(
|
|
16
|
+
default=None,
|
|
17
|
+
ge=0,
|
|
18
|
+
description="Minimum number of values that the property can hold. "
|
|
19
|
+
"If no value is provided, the default value is None meaning `0`, "
|
|
20
|
+
"which means that the property is optional.",
|
|
21
|
+
)
|
|
22
|
+
max_count: int | None = Field(
|
|
23
|
+
default=None,
|
|
24
|
+
ge=0,
|
|
25
|
+
description="Maximum number of values that the property can hold. "
|
|
26
|
+
"If no value is provided, the default value is None meaning `inf`, "
|
|
27
|
+
"which means that the property can hold any number of values (listable).",
|
|
28
|
+
)
|
|
29
|
+
default: Any | None = Field(alias="Default", default=None, description="Default value of the property.")
|
|
30
|
+
instance_reference: list[URI] | None = Field(
|
|
31
|
+
default=None,
|
|
32
|
+
description="The URI(s) in the graph to get the value of the property.",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
@model_validator(mode="after")
|
|
36
|
+
def check_min_max_count(self) -> "Property":
|
|
37
|
+
if self.min_count is not None and self.max_count is not None:
|
|
38
|
+
if self.min_count > self.max_count:
|
|
39
|
+
raise ValueError("min_count must be less than or equal to max_count")
|
|
40
|
+
return self
|
|
41
|
+
|
|
42
|
+
@field_validator("default", mode="after")
|
|
43
|
+
def check_default_value_primitive_type(cls, value: Any, info: ValidationInfo) -> Any:
|
|
44
|
+
if not value:
|
|
45
|
+
return value
|
|
46
|
+
|
|
47
|
+
value_type = info.data.get("value_type")
|
|
48
|
+
if not isinstance(value_type, DataType):
|
|
49
|
+
raise ValueError("Setting default value is only supported for primitive value types.")
|
|
50
|
+
return value
|
|
51
|
+
|
|
52
|
+
@field_validator("default", mode="after")
|
|
53
|
+
def check_default_value_python_type_exists(cls, value: Any, info: ValidationInfo) -> Any:
|
|
54
|
+
if not value:
|
|
55
|
+
return value
|
|
56
|
+
|
|
57
|
+
value_type = info.data.get("value_type")
|
|
58
|
+
|
|
59
|
+
if isinstance(value_type, DataType) and not hasattr(value_type, "python"):
|
|
60
|
+
raise ValueError(
|
|
61
|
+
f"DataType {value_type} does not have a python type defined."
|
|
62
|
+
" Setting default value for property is not possible."
|
|
63
|
+
)
|
|
64
|
+
return value
|
|
65
|
+
|
|
66
|
+
@field_validator("default", mode="after")
|
|
67
|
+
def check_default_value_not_list(cls, value: Any, info: ValidationInfo) -> Any:
|
|
68
|
+
if not value:
|
|
69
|
+
return value
|
|
70
|
+
|
|
71
|
+
if isinstance(value, list):
|
|
72
|
+
raise ValueError("Setting list as default value is not supported.")
|
|
73
|
+
return value
|
|
74
|
+
|
|
75
|
+
@field_validator("default", mode="after")
|
|
76
|
+
def check_default_value_single_valued(cls, value: Any, info: ValidationInfo) -> Any:
|
|
77
|
+
if not value:
|
|
78
|
+
return value
|
|
79
|
+
|
|
80
|
+
max_count = info.data.get("max_count")
|
|
81
|
+
min_count = info.data.get("min_count")
|
|
82
|
+
|
|
83
|
+
if max_count is None or max_count > 1 or (min_count and min_count > 1):
|
|
84
|
+
raise ValueError(
|
|
85
|
+
"Setting default value is only supported for single-valued properties."
|
|
86
|
+
f" Property has min_count={info.data.get('min_count')} and max_count={info.data.get('max_count')}."
|
|
87
|
+
)
|
|
88
|
+
return value
|
|
89
|
+
|
|
90
|
+
@field_validator("default", mode="after")
|
|
91
|
+
def check_default_value_type_match(cls, value: Any, info: ValidationInfo) -> Any:
|
|
92
|
+
if not value:
|
|
93
|
+
return value
|
|
94
|
+
|
|
95
|
+
value_type = info.data.get("value_type")
|
|
96
|
+
|
|
97
|
+
if (
|
|
98
|
+
isinstance(value_type, DataType)
|
|
99
|
+
and hasattr(value_type, "python")
|
|
100
|
+
and not isinstance(value, value_type.python)
|
|
101
|
+
):
|
|
102
|
+
raise ValueError(
|
|
103
|
+
f"Default value type is {type(value)}, which does not match expected value type {value_type.python}."
|
|
104
|
+
)
|
|
105
|
+
return value
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
from cognite.neat._data_model.models.dms._base import (
|
|
2
|
+
APIResource,
|
|
3
|
+
BaseModelObject,
|
|
4
|
+
Resource,
|
|
5
|
+
T_Resource,
|
|
6
|
+
WriteableResource,
|
|
7
|
+
)
|
|
8
|
+
from cognite.neat._data_model.models.dms._constraints import (
|
|
9
|
+
Constraint,
|
|
10
|
+
ConstraintAdapter,
|
|
11
|
+
ConstraintDefinition,
|
|
12
|
+
RequiresConstraintDefinition,
|
|
13
|
+
UniquenessConstraintDefinition,
|
|
14
|
+
)
|
|
15
|
+
from cognite.neat._data_model.models.dms._container import (
|
|
16
|
+
Container,
|
|
17
|
+
ContainerPropertyDefinition,
|
|
18
|
+
ContainerRequest,
|
|
19
|
+
ContainerResponse,
|
|
20
|
+
)
|
|
21
|
+
from cognite.neat._data_model.models.dms._data_types import (
|
|
22
|
+
DMS_DATA_TYPES,
|
|
23
|
+
BooleanProperty,
|
|
24
|
+
DataType,
|
|
25
|
+
DataTypeAdapter,
|
|
26
|
+
DateProperty,
|
|
27
|
+
DirectNodeRelation,
|
|
28
|
+
EnumProperty,
|
|
29
|
+
EnumValue,
|
|
30
|
+
FileCDFExternalIdReference,
|
|
31
|
+
Float32Property,
|
|
32
|
+
Float64Property,
|
|
33
|
+
FloatProperty,
|
|
34
|
+
Int32Property,
|
|
35
|
+
Int64Property,
|
|
36
|
+
JSONProperty,
|
|
37
|
+
ListablePropertyTypeDefinition,
|
|
38
|
+
PropertyTypeDefinition,
|
|
39
|
+
SequenceCDFExternalIdReference,
|
|
40
|
+
TextProperty,
|
|
41
|
+
TimeseriesCDFExternalIdReference,
|
|
42
|
+
TimestampProperty,
|
|
43
|
+
)
|
|
44
|
+
from cognite.neat._data_model.models.dms._indexes import BtreeIndex, Index, IndexAdapter, IndexDefinition, InvertedIndex
|
|
45
|
+
from cognite.neat._data_model.models.dms._space import Space, SpaceRequest, SpaceResponse
|
|
46
|
+
|
|
47
|
+
from ._data_model import DataModelRequest, DataModelResponse
|
|
48
|
+
from ._http import DataModelBody, DataModelResource, ResourceId, T_DataModelResource, T_ResourceId
|
|
49
|
+
from ._references import (
|
|
50
|
+
ContainerConstraintReference,
|
|
51
|
+
ContainerDirectReference,
|
|
52
|
+
ContainerIndexReference,
|
|
53
|
+
ContainerReference,
|
|
54
|
+
DataModelReference,
|
|
55
|
+
NodeReference,
|
|
56
|
+
SpaceReference,
|
|
57
|
+
ViewDirectReference,
|
|
58
|
+
ViewReference,
|
|
59
|
+
)
|
|
60
|
+
from ._schema import RequestSchema
|
|
61
|
+
from ._view_filter import (
|
|
62
|
+
AVAILABLE_FILTERS,
|
|
63
|
+
AndFilter,
|
|
64
|
+
ContainsAllFilterData,
|
|
65
|
+
ContainsAnyFilterData,
|
|
66
|
+
EqualsFilterData,
|
|
67
|
+
ExistsFilterData,
|
|
68
|
+
Filter,
|
|
69
|
+
FilterAdapter,
|
|
70
|
+
FilterDataDefinition,
|
|
71
|
+
HasDataFilter,
|
|
72
|
+
InFilterData,
|
|
73
|
+
InstanceReferencesFilterData,
|
|
74
|
+
MatchAllFilterData,
|
|
75
|
+
NestedFilterData,
|
|
76
|
+
NotFilter,
|
|
77
|
+
OrFilter,
|
|
78
|
+
OverlapsFilterData,
|
|
79
|
+
PrefixFilterData,
|
|
80
|
+
RangeFilterData,
|
|
81
|
+
)
|
|
82
|
+
from ._view_property import (
|
|
83
|
+
ConnectionPropertyDefinition,
|
|
84
|
+
ConstraintOrIndexState,
|
|
85
|
+
MultiEdgeProperty,
|
|
86
|
+
MultiReverseDirectRelationPropertyRequest,
|
|
87
|
+
MultiReverseDirectRelationPropertyResponse,
|
|
88
|
+
SingleEdgeProperty,
|
|
89
|
+
SingleReverseDirectRelationPropertyRequest,
|
|
90
|
+
SingleReverseDirectRelationPropertyResponse,
|
|
91
|
+
ViewCorePropertyRequest,
|
|
92
|
+
ViewCorePropertyResponse,
|
|
93
|
+
ViewPropertyDefinition,
|
|
94
|
+
ViewRequestProperty,
|
|
95
|
+
ViewRequestPropertyAdapter,
|
|
96
|
+
ViewResponseProperty,
|
|
97
|
+
)
|
|
98
|
+
from ._views import (
|
|
99
|
+
View,
|
|
100
|
+
ViewRequest,
|
|
101
|
+
ViewResponse,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
__all__ = [
|
|
105
|
+
"AVAILABLE_FILTERS",
|
|
106
|
+
"DMS_DATA_TYPES",
|
|
107
|
+
"APIResource",
|
|
108
|
+
"AndFilter",
|
|
109
|
+
"BaseModelObject",
|
|
110
|
+
"BooleanProperty",
|
|
111
|
+
"BtreeIndex",
|
|
112
|
+
"ConnectionPropertyDefinition",
|
|
113
|
+
"Constraint",
|
|
114
|
+
"ConstraintAdapter",
|
|
115
|
+
"ConstraintDefinition",
|
|
116
|
+
"ConstraintOrIndexState",
|
|
117
|
+
"Container",
|
|
118
|
+
"ContainerConstraintReference",
|
|
119
|
+
"ContainerDirectReference",
|
|
120
|
+
"ContainerIndexReference",
|
|
121
|
+
"ContainerPropertyDefinition",
|
|
122
|
+
"ContainerReference",
|
|
123
|
+
"ContainerRequest",
|
|
124
|
+
"ContainerResponse",
|
|
125
|
+
"ContainsAllFilterData",
|
|
126
|
+
"ContainsAnyFilterData",
|
|
127
|
+
"DataModelBody",
|
|
128
|
+
"DataModelReference",
|
|
129
|
+
"DataModelRequest",
|
|
130
|
+
"DataModelResource",
|
|
131
|
+
"DataModelResponse",
|
|
132
|
+
"DataType",
|
|
133
|
+
"DataTypeAdapter",
|
|
134
|
+
"DateProperty",
|
|
135
|
+
"DirectNodeRelation",
|
|
136
|
+
"EnumProperty",
|
|
137
|
+
"EnumValue",
|
|
138
|
+
"EqualsFilterData",
|
|
139
|
+
"ExistsFilterData",
|
|
140
|
+
"FileCDFExternalIdReference",
|
|
141
|
+
"Filter",
|
|
142
|
+
"FilterAdapter",
|
|
143
|
+
"FilterDataDefinition",
|
|
144
|
+
"Float32Property",
|
|
145
|
+
"Float64Property",
|
|
146
|
+
"FloatProperty",
|
|
147
|
+
"HasDataFilter",
|
|
148
|
+
"InFilterData",
|
|
149
|
+
"Index",
|
|
150
|
+
"IndexAdapter",
|
|
151
|
+
"IndexDefinition",
|
|
152
|
+
"InstanceReferencesFilterData",
|
|
153
|
+
"Int32Property",
|
|
154
|
+
"Int64Property",
|
|
155
|
+
"InvertedIndex",
|
|
156
|
+
"JSONProperty",
|
|
157
|
+
"ListablePropertyTypeDefinition",
|
|
158
|
+
"MatchAllFilterData",
|
|
159
|
+
"MultiEdgeProperty",
|
|
160
|
+
"MultiReverseDirectRelationPropertyRequest",
|
|
161
|
+
"MultiReverseDirectRelationPropertyResponse",
|
|
162
|
+
"NestedFilterData",
|
|
163
|
+
"NodeReference",
|
|
164
|
+
"NotFilter",
|
|
165
|
+
"OrFilter",
|
|
166
|
+
"OverlapsFilterData",
|
|
167
|
+
"PrefixFilterData",
|
|
168
|
+
"PropertyTypeDefinition",
|
|
169
|
+
"RangeFilterData",
|
|
170
|
+
"RequestSchema",
|
|
171
|
+
"RequiresConstraintDefinition",
|
|
172
|
+
"Resource",
|
|
173
|
+
"ResourceId",
|
|
174
|
+
"SequenceCDFExternalIdReference",
|
|
175
|
+
"SequenceCDFExternalIdReference",
|
|
176
|
+
"SingleEdgeProperty",
|
|
177
|
+
"SingleReverseDirectRelationPropertyRequest",
|
|
178
|
+
"SingleReverseDirectRelationPropertyResponse",
|
|
179
|
+
"Space",
|
|
180
|
+
"SpaceReference",
|
|
181
|
+
"SpaceRequest",
|
|
182
|
+
"SpaceResponse",
|
|
183
|
+
"T_DataModelResource",
|
|
184
|
+
"T_Resource",
|
|
185
|
+
"T_ResourceId",
|
|
186
|
+
"TextProperty",
|
|
187
|
+
"TextProperty",
|
|
188
|
+
"TimeseriesCDFExternalIdReference",
|
|
189
|
+
"TimeseriesCDFExternalIdReference",
|
|
190
|
+
"TimestampProperty",
|
|
191
|
+
"TimestampProperty",
|
|
192
|
+
"UniquenessConstraintDefinition",
|
|
193
|
+
"UniquenessConstraintDefinition",
|
|
194
|
+
"View",
|
|
195
|
+
"ViewCorePropertyRequest",
|
|
196
|
+
"ViewCorePropertyResponse",
|
|
197
|
+
"ViewDirectReference",
|
|
198
|
+
"ViewPropertyDefinition",
|
|
199
|
+
"ViewReference",
|
|
200
|
+
"ViewRequest",
|
|
201
|
+
"ViewRequestProperty",
|
|
202
|
+
"ViewRequestPropertyAdapter",
|
|
203
|
+
"ViewResponse",
|
|
204
|
+
"ViewResponseProperty",
|
|
205
|
+
"WriteableResource",
|
|
206
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from abc import ABC, abstractmethod
|
|
2
|
+
from typing import Generic, TypeVar
|
|
3
|
+
|
|
4
|
+
from cognite.neat._utils.useful_types import BaseModelObject, T_Reference
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Resource(BaseModelObject):
|
|
8
|
+
"""Base class for all data modeling resources."""
|
|
9
|
+
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
T_Resource = TypeVar("T_Resource", bound=Resource)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class WriteableResource(Resource, Generic[T_Resource], ABC):
|
|
17
|
+
"""Base class for all writeable data modeling resources."""
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def as_request(self) -> T_Resource:
|
|
21
|
+
"""Convert the response model to a request model by removing read-only fields."""
|
|
22
|
+
raise NotImplementedError()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class APIResource(Generic[T_Reference], ABC):
|
|
26
|
+
"""Base class for all API data modeling resources."""
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
def as_reference(self) -> T_Reference:
|
|
30
|
+
"""Convert the resource to a reference object (identifier)."""
|
|
31
|
+
raise NotImplementedError()
|