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,48 @@
|
|
|
1
|
+
SPACE_FORMAT_PATTERN = r"^[a-zA-Z][a-zA-Z0-9_-]{0,41}[a-zA-Z0-9]?$"
|
|
2
|
+
DM_EXTERNAL_ID_PATTERN = r"^[a-zA-Z]([a-zA-Z0-9_]{0,253}[a-zA-Z0-9])?$"
|
|
3
|
+
CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN = r"^[a-zA-Z0-9][a-zA-Z0-9_-]{0,253}[a-zA-Z0-9]?$"
|
|
4
|
+
INSTANCE_ID_PATTERN = r"^[^\x00]{1,256}$"
|
|
5
|
+
ENUM_VALUE_IDENTIFIER_PATTERN = r"^[_A-Za-z][_0-9A-Za-z]{0,127}$"
|
|
6
|
+
DM_VERSION_PATTERN = r"^[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?$"
|
|
7
|
+
DATA_MODEL_DESCRIPTION_MAX_LENGTH = 1024
|
|
8
|
+
FORBIDDEN_ENUM_VALUES = frozenset({"true", "false", "null"})
|
|
9
|
+
FORBIDDEN_SPACES = frozenset(["space", "cdf", "dms", "pg3", "shared", "system", "node", "edge"])
|
|
10
|
+
FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS = frozenset(
|
|
11
|
+
[
|
|
12
|
+
"Query",
|
|
13
|
+
"Mutation",
|
|
14
|
+
"Subscription",
|
|
15
|
+
"String",
|
|
16
|
+
"Int32",
|
|
17
|
+
"Int64",
|
|
18
|
+
"Int",
|
|
19
|
+
"Float32",
|
|
20
|
+
"Float64",
|
|
21
|
+
"Float",
|
|
22
|
+
"Timestamp",
|
|
23
|
+
"JSONObject",
|
|
24
|
+
"Date",
|
|
25
|
+
"Numeric",
|
|
26
|
+
"Boolean",
|
|
27
|
+
"PageInfo",
|
|
28
|
+
"File",
|
|
29
|
+
"Sequence",
|
|
30
|
+
"TimeSeries",
|
|
31
|
+
]
|
|
32
|
+
)
|
|
33
|
+
FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER = frozenset(
|
|
34
|
+
[
|
|
35
|
+
"space",
|
|
36
|
+
"externalId",
|
|
37
|
+
"createdTime",
|
|
38
|
+
"lastUpdatedTime",
|
|
39
|
+
"deletedTime",
|
|
40
|
+
"edge_id",
|
|
41
|
+
"node_id",
|
|
42
|
+
"project_id",
|
|
43
|
+
"property_group",
|
|
44
|
+
"seq",
|
|
45
|
+
"tg_table_name",
|
|
46
|
+
"extensions",
|
|
47
|
+
]
|
|
48
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from typing import Annotated, Any, Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, TypeAdapter, field_serializer
|
|
5
|
+
from pydantic_core.core_schema import FieldSerializationInfo
|
|
6
|
+
|
|
7
|
+
from cognite.neat._utils.useful_types import BaseModelObject
|
|
8
|
+
|
|
9
|
+
from ._references import ContainerReference
|
|
10
|
+
from ._types import Bool
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ConstraintDefinition(BaseModelObject, ABC):
|
|
14
|
+
constraint_type: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class UniquenessConstraintDefinition(ConstraintDefinition):
|
|
18
|
+
constraint_type: Literal["uniqueness"] = "uniqueness"
|
|
19
|
+
properties: list[str] = Field(
|
|
20
|
+
description="List of properties included in the constraint.", min_length=1, max_length=10
|
|
21
|
+
)
|
|
22
|
+
by_space: Bool | None = Field(default=None, description="Whether to make the constraint space-specific.")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class RequiresConstraintDefinition(ConstraintDefinition):
|
|
26
|
+
constraint_type: Literal["requires"] = "requires"
|
|
27
|
+
require: ContainerReference = Field(description="Reference to an existing container.")
|
|
28
|
+
|
|
29
|
+
@field_serializer("require", mode="plain")
|
|
30
|
+
@classmethod
|
|
31
|
+
def serialize_require(cls, require: ContainerReference, info: FieldSerializationInfo) -> dict[str, Any]:
|
|
32
|
+
output = require.model_dump(**vars(info))
|
|
33
|
+
output["type"] = "container"
|
|
34
|
+
return output
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Constraint = Annotated[
|
|
38
|
+
UniquenessConstraintDefinition | RequiresConstraintDefinition,
|
|
39
|
+
Field(discriminator="constraint_type"),
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
ConstraintAdapter: TypeAdapter[Constraint] = TypeAdapter(Constraint)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from abc import ABC
|
|
3
|
+
from typing import Any, Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import Field, field_validator
|
|
6
|
+
from pydantic_core.core_schema import ValidationInfo
|
|
7
|
+
|
|
8
|
+
from cognite.neat._utils.text import humanize_collection
|
|
9
|
+
from cognite.neat._utils.useful_types import BaseModelObject
|
|
10
|
+
|
|
11
|
+
from ._base import APIResource, Resource, WriteableResource
|
|
12
|
+
from ._constants import (
|
|
13
|
+
CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN,
|
|
14
|
+
DM_EXTERNAL_ID_PATTERN,
|
|
15
|
+
FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS,
|
|
16
|
+
FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER,
|
|
17
|
+
SPACE_FORMAT_PATTERN,
|
|
18
|
+
)
|
|
19
|
+
from ._constraints import Constraint
|
|
20
|
+
from ._data_types import DataType
|
|
21
|
+
from ._indexes import Index
|
|
22
|
+
from ._references import ContainerReference
|
|
23
|
+
|
|
24
|
+
KEY_PATTERN = re.compile(CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ContainerPropertyDefinition(BaseModelObject):
|
|
28
|
+
immutable: bool | None = Field(
|
|
29
|
+
default=None,
|
|
30
|
+
description="Should updates to this property be rejected after the initial population?",
|
|
31
|
+
)
|
|
32
|
+
nullable: bool | None = Field(
|
|
33
|
+
default=None,
|
|
34
|
+
description="Does this property need to be set to a value, or not?",
|
|
35
|
+
)
|
|
36
|
+
auto_increment: bool | None = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="Increment the property based on its highest current value (max value).",
|
|
39
|
+
)
|
|
40
|
+
default_value: str | int | float | bool | dict[str, Any] | None = Field(
|
|
41
|
+
default=None,
|
|
42
|
+
description="Default value to use when you do not specify a value for the property.",
|
|
43
|
+
)
|
|
44
|
+
description: str | None = Field(
|
|
45
|
+
default=None,
|
|
46
|
+
description="Description of the content and suggested use for this property.",
|
|
47
|
+
max_length=1024,
|
|
48
|
+
)
|
|
49
|
+
name: str | None = Field(
|
|
50
|
+
default=None,
|
|
51
|
+
description="Readable property name.",
|
|
52
|
+
max_length=255,
|
|
53
|
+
)
|
|
54
|
+
type: DataType = Field(description="The type of data you can store in this property.")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Container(Resource, APIResource[ContainerReference], ABC):
|
|
58
|
+
space: str = Field(
|
|
59
|
+
description="The workspace for the container, a unique identifier for the space.",
|
|
60
|
+
min_length=1,
|
|
61
|
+
max_length=43,
|
|
62
|
+
pattern=SPACE_FORMAT_PATTERN,
|
|
63
|
+
)
|
|
64
|
+
external_id: str = Field(
|
|
65
|
+
description="External-id of the container.",
|
|
66
|
+
min_length=1,
|
|
67
|
+
max_length=255,
|
|
68
|
+
pattern=DM_EXTERNAL_ID_PATTERN,
|
|
69
|
+
)
|
|
70
|
+
name: str | None = Field(
|
|
71
|
+
default=None,
|
|
72
|
+
description="name for the container.",
|
|
73
|
+
max_length=255,
|
|
74
|
+
)
|
|
75
|
+
description: str | None = Field(
|
|
76
|
+
default=None,
|
|
77
|
+
description="Description of the container.",
|
|
78
|
+
max_length=1024,
|
|
79
|
+
)
|
|
80
|
+
used_for: Literal["node", "edge", "all"] | None = Field(
|
|
81
|
+
default=None,
|
|
82
|
+
description="Should this operation apply to nodes, edges or both.",
|
|
83
|
+
)
|
|
84
|
+
properties: dict[str, ContainerPropertyDefinition] = Field(
|
|
85
|
+
description="Set of properties to apply to the container.",
|
|
86
|
+
)
|
|
87
|
+
constraints: dict[str, Constraint] | None = Field(
|
|
88
|
+
default=None,
|
|
89
|
+
description="Set of constraints to apply to the container.",
|
|
90
|
+
max_length=10,
|
|
91
|
+
)
|
|
92
|
+
indexes: dict[str, Index] | None = Field(
|
|
93
|
+
default=None,
|
|
94
|
+
description="Set of indexes to apply to the container.",
|
|
95
|
+
max_length=10,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
@field_validator("indexes", "constraints", mode="after")
|
|
99
|
+
def validate_key_length(cls, val: dict[str, Any] | None, info: ValidationInfo) -> dict[str, Any] | None:
|
|
100
|
+
"""Validate keys"""
|
|
101
|
+
if not isinstance(val, dict):
|
|
102
|
+
return val
|
|
103
|
+
invalid_keys = {key for key in val.keys() if not (1 <= len(key) <= 43)}
|
|
104
|
+
if invalid_keys:
|
|
105
|
+
raise ValueError(
|
|
106
|
+
f"{info.field_name} keys must be between 1 and 43 characters long. Invalid keys: "
|
|
107
|
+
f"{humanize_collection(invalid_keys)}"
|
|
108
|
+
)
|
|
109
|
+
return val
|
|
110
|
+
|
|
111
|
+
@field_validator("properties", mode="after")
|
|
112
|
+
def validate_property_keys(cls, val: dict[str, Any]) -> dict[str, Any]:
|
|
113
|
+
"""Validate property keys"""
|
|
114
|
+
if invalid_keys := {key for key in val if not KEY_PATTERN.match(key)}:
|
|
115
|
+
raise ValueError(
|
|
116
|
+
f"Property keys must match pattern '{CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER_PATTERN}'. "
|
|
117
|
+
f"Invalid keys: {humanize_collection(invalid_keys)}"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
if forbidden_keys := set(val.keys()).intersection(FORBIDDEN_CONTAINER_AND_VIEW_PROPERTIES_IDENTIFIER):
|
|
121
|
+
raise ValueError(
|
|
122
|
+
f"Property keys cannot be any of the following reserved values: {humanize_collection(forbidden_keys)}"
|
|
123
|
+
)
|
|
124
|
+
return val
|
|
125
|
+
|
|
126
|
+
@field_validator("external_id")
|
|
127
|
+
def check_forbidden_external_id_value(cls, val: str) -> str:
|
|
128
|
+
"""Check the external_id not present in forbidden set"""
|
|
129
|
+
if val in FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS:
|
|
130
|
+
raise ValueError(
|
|
131
|
+
f"{val!r} is a reserved container External ID. Reserved External IDs are: "
|
|
132
|
+
f"{humanize_collection(FORBIDDEN_CONTAINER_AND_VIEW_EXTERNAL_IDS)}"
|
|
133
|
+
)
|
|
134
|
+
return val
|
|
135
|
+
|
|
136
|
+
def as_reference(self) -> ContainerReference:
|
|
137
|
+
return ContainerReference(
|
|
138
|
+
space=self.space,
|
|
139
|
+
external_id=self.external_id,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class ContainerRequest(Container): ...
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class ContainerResponse(Container, WriteableResource[ContainerRequest]):
|
|
147
|
+
created_time: int = Field(
|
|
148
|
+
description="When the container was created. The number of milliseconds since 00:00:00 "
|
|
149
|
+
"Thursday, 1 January 1970, "
|
|
150
|
+
"Coordinated Universal Time (UTC), minus leap seconds."
|
|
151
|
+
)
|
|
152
|
+
last_updated_time: int = Field(
|
|
153
|
+
description="When the container was last updated. The number of milliseconds since 00:00:00 Thursday, "
|
|
154
|
+
"1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
|
|
155
|
+
)
|
|
156
|
+
is_global: bool = Field(description="Whether the container is a global container.")
|
|
157
|
+
|
|
158
|
+
def as_request(self) -> "ContainerRequest":
|
|
159
|
+
return ContainerRequest.model_validate(self.model_dump(by_alias=True))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, field_serializer
|
|
5
|
+
from pydantic_core.core_schema import FieldSerializationInfo
|
|
6
|
+
|
|
7
|
+
from ._base import APIResource, Resource, WriteableResource
|
|
8
|
+
from ._constants import (
|
|
9
|
+
DATA_MODEL_DESCRIPTION_MAX_LENGTH,
|
|
10
|
+
DM_EXTERNAL_ID_PATTERN,
|
|
11
|
+
DM_VERSION_PATTERN,
|
|
12
|
+
SPACE_FORMAT_PATTERN,
|
|
13
|
+
)
|
|
14
|
+
from ._references import DataModelReference, ViewReference
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DataModel(Resource, APIResource[DataModelReference], ABC):
|
|
18
|
+
"""Cognite Data Model resource.
|
|
19
|
+
|
|
20
|
+
Data models group and structure views into reusable collections.
|
|
21
|
+
A data model contains a set of views where the node types can
|
|
22
|
+
refer to each other with direct relations and edges.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
space: str = Field(
|
|
26
|
+
description="The workspace for the data model, a unique identifier for the space.",
|
|
27
|
+
min_length=1,
|
|
28
|
+
max_length=43,
|
|
29
|
+
pattern=SPACE_FORMAT_PATTERN,
|
|
30
|
+
)
|
|
31
|
+
external_id: str = Field(
|
|
32
|
+
description="External-id of the data model.",
|
|
33
|
+
min_length=1,
|
|
34
|
+
max_length=255,
|
|
35
|
+
pattern=DM_EXTERNAL_ID_PATTERN,
|
|
36
|
+
)
|
|
37
|
+
version: str = Field(
|
|
38
|
+
description="Version of the data model.",
|
|
39
|
+
max_length=43,
|
|
40
|
+
pattern=DM_VERSION_PATTERN,
|
|
41
|
+
)
|
|
42
|
+
name: str | None = Field(
|
|
43
|
+
default=None,
|
|
44
|
+
description="Human readable name for the data model.",
|
|
45
|
+
max_length=255,
|
|
46
|
+
)
|
|
47
|
+
description: str | None = Field(
|
|
48
|
+
default=None,
|
|
49
|
+
description="Description of the data model.",
|
|
50
|
+
max_length=DATA_MODEL_DESCRIPTION_MAX_LENGTH,
|
|
51
|
+
)
|
|
52
|
+
# The API supports View here, but in Neat we will only use ViewReference
|
|
53
|
+
views: list[ViewReference] | None = Field(
|
|
54
|
+
description="List of views included in this data model.",
|
|
55
|
+
default=None,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def as_reference(self) -> DataModelReference:
|
|
59
|
+
return DataModelReference(
|
|
60
|
+
space=self.space,
|
|
61
|
+
external_id=self.external_id,
|
|
62
|
+
version=self.version,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
@field_serializer("views", mode="plain")
|
|
66
|
+
@classmethod
|
|
67
|
+
def serialize_views(
|
|
68
|
+
cls, views: list[ViewReference] | None, info: FieldSerializationInfo
|
|
69
|
+
) -> list[dict[str, Any]] | None:
|
|
70
|
+
if views is None:
|
|
71
|
+
return None
|
|
72
|
+
output: list[dict[str, Any]] = []
|
|
73
|
+
for view in views:
|
|
74
|
+
dumped = view.model_dump(**vars(info))
|
|
75
|
+
dumped["type"] = "view"
|
|
76
|
+
output.append(dumped)
|
|
77
|
+
return output
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class DataModelRequest(DataModel): ...
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class DataModelResponse(DataModel, WriteableResource[DataModelRequest]):
|
|
84
|
+
created_time: int = Field(
|
|
85
|
+
description="When the data model was created. The number of milliseconds since 00:00:00 Thursday, "
|
|
86
|
+
"1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
|
|
87
|
+
)
|
|
88
|
+
last_updated_time: int = Field(
|
|
89
|
+
description="When the data model was last updated. The number of milliseconds since 00:00:00 Thursday, "
|
|
90
|
+
"1 January 1970, Coordinated Universal Time (UTC), minus leap seconds."
|
|
91
|
+
)
|
|
92
|
+
is_global: bool = Field(description="Is this a global data model.")
|
|
93
|
+
|
|
94
|
+
def as_request(self) -> DataModelRequest:
|
|
95
|
+
return DataModelRequest.model_validate(self.model_dump(by_alias=True))
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from abc import ABC
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Annotated, Literal
|
|
5
|
+
|
|
6
|
+
from pydantic import Field, TypeAdapter, field_validator
|
|
7
|
+
|
|
8
|
+
from cognite.neat._utils.auxiliary import get_concrete_subclasses
|
|
9
|
+
from cognite.neat._utils.useful_types import BaseModelObject
|
|
10
|
+
|
|
11
|
+
from ._constants import ENUM_VALUE_IDENTIFIER_PATTERN, FORBIDDEN_ENUM_VALUES, INSTANCE_ID_PATTERN
|
|
12
|
+
from ._references import ContainerReference, ViewReference
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PropertyTypeDefinition(BaseModelObject, ABC):
|
|
16
|
+
type: str
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ListablePropertyTypeDefinition(PropertyTypeDefinition, ABC):
|
|
20
|
+
list: bool | None = Field(
|
|
21
|
+
default=None,
|
|
22
|
+
description="Specifies that the data type is a list of values.",
|
|
23
|
+
)
|
|
24
|
+
max_list_size: int | None = Field(
|
|
25
|
+
default=None,
|
|
26
|
+
description="Specifies the maximum number of values in the list",
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TextProperty(ListablePropertyTypeDefinition):
|
|
31
|
+
type: Literal["text"] = "text"
|
|
32
|
+
max_text_size: int | None = Field(
|
|
33
|
+
default=None,
|
|
34
|
+
description="Specifies the maximum size in bytes of the text property, when encoded with utf-8.",
|
|
35
|
+
)
|
|
36
|
+
collation: str | None = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="he set of language specific rules - used when sorting text fields.",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Unit(BaseModelObject):
|
|
43
|
+
external_id: str = Field(
|
|
44
|
+
description="The external ID of the unit. Must match the unit in the Cognite Unit catalog.",
|
|
45
|
+
min_length=1,
|
|
46
|
+
max_length=256,
|
|
47
|
+
pattern=INSTANCE_ID_PATTERN,
|
|
48
|
+
)
|
|
49
|
+
source_unit: str | None = Field(
|
|
50
|
+
default=None,
|
|
51
|
+
description="The unit in the source system.",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class FloatProperty(ListablePropertyTypeDefinition, ABC):
|
|
56
|
+
unit: Unit | None = Field(default=None, description="The unit of the data stored in this property", exclude=False)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class Float32Property(FloatProperty):
|
|
60
|
+
type: Literal["float32"] = "float32"
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class Float64Property(FloatProperty):
|
|
64
|
+
type: Literal["float64"] = "float64"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class BooleanProperty(ListablePropertyTypeDefinition):
|
|
68
|
+
type: Literal["boolean"] = "boolean"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class Int32Property(ListablePropertyTypeDefinition):
|
|
72
|
+
type: Literal["int32"] = "int32"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Int64Property(ListablePropertyTypeDefinition):
|
|
76
|
+
type: Literal["int64"] = "int64"
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class TimestampProperty(ListablePropertyTypeDefinition):
|
|
80
|
+
type: Literal["timestamp"] = "timestamp"
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class DateProperty(ListablePropertyTypeDefinition):
|
|
84
|
+
type: Literal["date"] = "date"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class JSONProperty(ListablePropertyTypeDefinition):
|
|
88
|
+
type: Literal["json"] = "json"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class TimeseriesCDFExternalIdReference(ListablePropertyTypeDefinition):
|
|
92
|
+
type: Literal["timeseries"] = "timeseries"
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class FileCDFExternalIdReference(ListablePropertyTypeDefinition):
|
|
96
|
+
type: Literal["file"] = "file"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class SequenceCDFExternalIdReference(ListablePropertyTypeDefinition):
|
|
100
|
+
type: Literal["sequence"] = "sequence"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class DirectNodeRelation(ListablePropertyTypeDefinition):
|
|
104
|
+
type: Literal["direct"] = "direct"
|
|
105
|
+
container: ContainerReference | None = Field(
|
|
106
|
+
default=None,
|
|
107
|
+
description="The (optional) required type for the node the direct relation points to. If specified, "
|
|
108
|
+
"the node must exist before the direct relation is referenced and of the specified type. "
|
|
109
|
+
"If no container specification is used, the node will be auto created with the built-in node "
|
|
110
|
+
"container type, and it does not explicitly have to be created before the node that references it.",
|
|
111
|
+
)
|
|
112
|
+
# This property is only available in the response object. It will be ignored in the request object.
|
|
113
|
+
# In the request object, use ViewCoreProperty.source instead.
|
|
114
|
+
source: ViewReference | None = Field(
|
|
115
|
+
None, description="The hint showing the view what the direct relation points to.", exclude=True
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class EnumValue(BaseModelObject):
|
|
120
|
+
name: str | None = Field(
|
|
121
|
+
None,
|
|
122
|
+
max_length=255,
|
|
123
|
+
description="The name of the enum value.",
|
|
124
|
+
)
|
|
125
|
+
description: str | None = Field(
|
|
126
|
+
default=None,
|
|
127
|
+
max_length=1024,
|
|
128
|
+
description="Description of the enum value.",
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
_ENUM_KEY = re.compile(ENUM_VALUE_IDENTIFIER_PATTERN)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class EnumProperty(PropertyTypeDefinition):
|
|
136
|
+
type: Literal["enum"] = "enum"
|
|
137
|
+
unknown_value: str | None = Field(
|
|
138
|
+
default=None,
|
|
139
|
+
description="TThe value to use when the enum value is unknown. This can optionally be used to "
|
|
140
|
+
"provide forward-compatibility, Specifying what value to use if the client does not "
|
|
141
|
+
"recognize the returned value. It is not possible to ingest the unknown value, "
|
|
142
|
+
"but it must be part of the allowed values.",
|
|
143
|
+
min_length=1,
|
|
144
|
+
max_length=128,
|
|
145
|
+
pattern=ENUM_VALUE_IDENTIFIER_PATTERN,
|
|
146
|
+
)
|
|
147
|
+
values: dict[str, EnumValue] = Field(
|
|
148
|
+
description="A set of all possible values for the enum property.",
|
|
149
|
+
min_length=1,
|
|
150
|
+
max_length=32,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
@field_validator("values", mode="after")
|
|
154
|
+
def _valid_enum_value(cls, val: dict[str, EnumValue]) -> dict[str, EnumValue]:
|
|
155
|
+
errors: list[str] = []
|
|
156
|
+
for key in val.keys():
|
|
157
|
+
if not _ENUM_KEY.match(key):
|
|
158
|
+
errors.append(
|
|
159
|
+
f"Enum value {key!r} is not valid. Enum values must match "
|
|
160
|
+
f"the pattern: {ENUM_VALUE_IDENTIFIER_PATTERN}"
|
|
161
|
+
)
|
|
162
|
+
if len(key) > 128 or len(key) < 1:
|
|
163
|
+
errors.append(f"Enum value {key!r} must be between 1 and 128 characters long.")
|
|
164
|
+
if key.lower() in FORBIDDEN_ENUM_VALUES:
|
|
165
|
+
errors.append(
|
|
166
|
+
f"Enum value {key!r} cannot be any of the following reserved values: {FORBIDDEN_ENUM_VALUES}"
|
|
167
|
+
)
|
|
168
|
+
if errors:
|
|
169
|
+
raise ValueError(";".join(errors))
|
|
170
|
+
return val
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
DataType = Annotated[
|
|
174
|
+
TextProperty
|
|
175
|
+
| Float32Property
|
|
176
|
+
| Float64Property
|
|
177
|
+
| BooleanProperty
|
|
178
|
+
| Int32Property
|
|
179
|
+
| Int64Property
|
|
180
|
+
| TimestampProperty
|
|
181
|
+
| DateProperty
|
|
182
|
+
| JSONProperty
|
|
183
|
+
| TimeseriesCDFExternalIdReference
|
|
184
|
+
| FileCDFExternalIdReference
|
|
185
|
+
| SequenceCDFExternalIdReference
|
|
186
|
+
| EnumProperty
|
|
187
|
+
| DirectNodeRelation,
|
|
188
|
+
Field(discriminator="type"),
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
DataTypeAdapter: TypeAdapter[DataType] = TypeAdapter(DataType)
|
|
192
|
+
|
|
193
|
+
DMS_DATA_TYPES: Mapping[str, type[PropertyTypeDefinition]] = {
|
|
194
|
+
cls_.model_fields["type"].default: cls_ for cls_ in get_concrete_subclasses(PropertyTypeDefinition)
|
|
195
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from typing import TypeAlias, TypeVar
|
|
2
|
+
|
|
3
|
+
from cognite.neat._utils.http_client import ItemBody
|
|
4
|
+
from cognite.neat._utils.useful_types import ReferenceObject
|
|
5
|
+
|
|
6
|
+
from ._container import ContainerRequest
|
|
7
|
+
from ._data_model import DataModelRequest
|
|
8
|
+
from ._references import (
|
|
9
|
+
ContainerReference,
|
|
10
|
+
DataModelReference,
|
|
11
|
+
SpaceReference,
|
|
12
|
+
ViewReference,
|
|
13
|
+
)
|
|
14
|
+
from ._space import SpaceRequest
|
|
15
|
+
from ._views import ViewRequest
|
|
16
|
+
|
|
17
|
+
DataModelResource: TypeAlias = SpaceRequest | DataModelRequest | ViewRequest | ContainerRequest
|
|
18
|
+
|
|
19
|
+
T_DataModelResource = TypeVar("T_DataModelResource", bound=DataModelResource)
|
|
20
|
+
|
|
21
|
+
ResourceId: TypeAlias = SpaceReference | DataModelReference | ViewReference | ContainerReference
|
|
22
|
+
|
|
23
|
+
T_ResourceId = TypeVar("T_ResourceId", bound=ResourceId)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DataModelBody(ItemBody[ReferenceObject, DataModelResource]):
|
|
27
|
+
def as_ids(self) -> list[ReferenceObject]:
|
|
28
|
+
return [item.as_reference() for item in self.items]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from abc import ABC
|
|
2
|
+
from typing import Annotated, Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, TypeAdapter
|
|
5
|
+
|
|
6
|
+
from cognite.neat._utils.useful_types import BaseModelObject
|
|
7
|
+
|
|
8
|
+
from ._types import Bool
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IndexDefinition(BaseModelObject, ABC):
|
|
12
|
+
index_type: str
|
|
13
|
+
properties: list[str] = Field(description="List of properties to define the index across.")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BtreeIndex(IndexDefinition):
|
|
17
|
+
index_type: Literal["btree"] = "btree"
|
|
18
|
+
by_space: Bool | None = Field(default=None, description="Whether to make the index space-specific.")
|
|
19
|
+
cursorable: Bool | None = Field(
|
|
20
|
+
default=None, description="Whether the index can be used for cursor-based pagination."
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class InvertedIndex(IndexDefinition):
|
|
25
|
+
index_type: Literal["inverted"] = "inverted"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Index = Annotated[BtreeIndex | InvertedIndex, Field(discriminator="index_type")]
|
|
29
|
+
|
|
30
|
+
IndexAdapter: TypeAdapter[Index] = TypeAdapter(Index)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from pydantic import BaseModel, Field
|
|
2
|
+
|
|
3
|
+
from cognite.neat._client.statistics_api import StatisticsResponse
|
|
4
|
+
|
|
5
|
+
from ._data_types import DataType, DirectNodeRelation, Int32Property, Int64Property
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SpaceLimit(BaseModel):
|
|
9
|
+
"""Limits for spaces."""
|
|
10
|
+
|
|
11
|
+
limit: int = 100
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ListablePropertyLimits(BaseModel):
|
|
15
|
+
"""Limits for list properties."""
|
|
16
|
+
|
|
17
|
+
limit: int = Field(2_000, description="Max limit for types other than int32/64 with b-tree index.")
|
|
18
|
+
int32_with_btree_limit: int = Field(600, description="Max limit for Int32 properties with B-tree index.")
|
|
19
|
+
int64_with_btree_limit: int = Field(300, description="Max limit for Int64 properties with B-tree index.")
|
|
20
|
+
# defaults
|
|
21
|
+
direct_default: int = Field(100, description="Default limit for direct relations.")
|
|
22
|
+
other_default: int = Field(1_000, description="Default limit for types other than direct.")
|
|
23
|
+
|
|
24
|
+
def __call__(self, data_type: DataType, has_btree_index: bool = False) -> int:
|
|
25
|
+
"""Get the limit for a specific data type."""
|
|
26
|
+
if isinstance(data_type, Int32Property) and has_btree_index:
|
|
27
|
+
return self.int32_with_btree_limit
|
|
28
|
+
if isinstance(data_type, Int64Property) and has_btree_index:
|
|
29
|
+
return self.int64_with_btree_limit
|
|
30
|
+
return self.limit
|
|
31
|
+
|
|
32
|
+
def default(self, data_type: DataType) -> int:
|
|
33
|
+
"""Get the default limit for a specific data type."""
|
|
34
|
+
if isinstance(data_type, DirectNodeRelation):
|
|
35
|
+
return self.direct_default
|
|
36
|
+
return self.other_default
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ContainerPropertyLimits(BaseModel):
|
|
40
|
+
limit: int = Field(100, description="Limit of properties per container.")
|
|
41
|
+
enums: int = Field(32, description="Limit of enums per property.")
|
|
42
|
+
total: int = Field(25_000, description="Total limit of properties.")
|
|
43
|
+
|
|
44
|
+
listable: ListablePropertyLimits = Field(default_factory=ListablePropertyLimits)
|
|
45
|
+
|
|
46
|
+
def __call__(self) -> int:
|
|
47
|
+
return self.limit
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ContainerLimits(BaseModel):
|
|
51
|
+
"""Limits for containers."""
|
|
52
|
+
|
|
53
|
+
limit: int = 1_000
|
|
54
|
+
properties: ContainerPropertyLimits = Field(default_factory=ContainerPropertyLimits)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class ViewLimits(BaseModel):
|
|
58
|
+
"""Limits for views."""
|
|
59
|
+
|
|
60
|
+
limit: int = 2_000
|
|
61
|
+
versions: int = 100
|
|
62
|
+
properties: int = 300
|
|
63
|
+
implements: int = 10
|
|
64
|
+
containers: int = 10
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class DataModelLimits(BaseModel):
|
|
68
|
+
"""Limits for data models."""
|
|
69
|
+
|
|
70
|
+
limit: int = 500
|
|
71
|
+
versions: int = Field(100, description="Limit of versions per data model.")
|
|
72
|
+
views: int = Field(100, description="Limit of views per data model.")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class SchemaLimits(BaseModel):
|
|
76
|
+
"""CDF Data Modeling resource limits."""
|
|
77
|
+
|
|
78
|
+
spaces: SpaceLimit = Field(default_factory=SpaceLimit)
|
|
79
|
+
containers: ContainerLimits = Field(default_factory=ContainerLimits)
|
|
80
|
+
views: ViewLimits = Field(default_factory=ViewLimits)
|
|
81
|
+
data_models: DataModelLimits = Field(default_factory=DataModelLimits)
|
|
82
|
+
|
|
83
|
+
@classmethod
|
|
84
|
+
def from_api_response(cls, response: StatisticsResponse) -> "SchemaLimits":
|
|
85
|
+
"""Populate limits from API response."""
|
|
86
|
+
# Implementation to parse and set limits from response can be added here
|
|
87
|
+
|
|
88
|
+
container = ContainerLimits(**response.containers.model_dump())
|
|
89
|
+
container.properties.limit = response.container_properties.limit
|
|
90
|
+
|
|
91
|
+
return cls(
|
|
92
|
+
spaces=SpaceLimit(**response.spaces.model_dump()),
|
|
93
|
+
containers=container,
|
|
94
|
+
views=ViewLimits(**response.views.model_dump()),
|
|
95
|
+
data_models=DataModelLimits(**response.data_models.model_dump()),
|
|
96
|
+
)
|