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,220 @@
|
|
|
1
|
+
from collections import UserList
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from datetime import datetime, timezone
|
|
4
|
+
from typing import Any, cast
|
|
5
|
+
|
|
6
|
+
from cognite.neat._client.client import NeatClient
|
|
7
|
+
from cognite.neat._config import NeatConfig
|
|
8
|
+
from cognite.neat._data_model._shared import OnSuccess, OnSuccessIssuesChecker, OnSuccessResultProducer
|
|
9
|
+
from cognite.neat._data_model._snapshot import SchemaSnapshot
|
|
10
|
+
from cognite.neat._data_model.deployer.data_classes import DeploymentResult
|
|
11
|
+
from cognite.neat._data_model.deployer.deployer import SchemaDeployer
|
|
12
|
+
from cognite.neat._data_model.exporters import DMSExporter, DMSFileExporter
|
|
13
|
+
from cognite.neat._data_model.exporters._api_exporter import DMSAPIExporter
|
|
14
|
+
from cognite.neat._data_model.exporters._table_exporter.exporter import DMSTableExporter
|
|
15
|
+
from cognite.neat._data_model.importers import DMSImporter, DMSTableImporter
|
|
16
|
+
from cognite.neat._data_model.models.dms import RequestSchema as PhysicalDataModel
|
|
17
|
+
from cognite.neat._data_model.models.dms._limits import SchemaLimits
|
|
18
|
+
from cognite.neat._exceptions import DataModelImportException
|
|
19
|
+
from cognite.neat._issues import IssueList
|
|
20
|
+
from cognite.neat._state_machine._states import EmptyState, PhysicalState, State
|
|
21
|
+
from cognite.neat._utils.text import NEWLINE
|
|
22
|
+
|
|
23
|
+
from ._provenance import Change, Provenance
|
|
24
|
+
|
|
25
|
+
Agents = DMSExporter | DMSTableImporter | DMSImporter
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class NeatStore:
|
|
29
|
+
def __init__(self, config: NeatConfig, client: NeatClient) -> None:
|
|
30
|
+
self.physical_data_model = DataModelList()
|
|
31
|
+
self.provenance = Provenance()
|
|
32
|
+
self.state: State = EmptyState()
|
|
33
|
+
self._client = client
|
|
34
|
+
self._config = config
|
|
35
|
+
|
|
36
|
+
# Placeholder for CDF schema and limit snapshot
|
|
37
|
+
self._cdf_snapshot: SchemaSnapshot | None = None
|
|
38
|
+
self._cdf_limits: SchemaLimits | None = None
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def cdf_limits(self) -> SchemaLimits:
|
|
42
|
+
if not self._cdf_limits:
|
|
43
|
+
self._cdf_limits = SchemaLimits.from_api_response(self._client.statistics.project())
|
|
44
|
+
return self._cdf_limits
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def cdf_snapshot(self) -> SchemaSnapshot:
|
|
48
|
+
if not self._cdf_snapshot:
|
|
49
|
+
self._cdf_snapshot = SchemaSnapshot.fetch_entire_cdf(self._client)
|
|
50
|
+
return self._cdf_snapshot
|
|
51
|
+
|
|
52
|
+
def read_physical(self, reader: DMSImporter, on_success: OnSuccess | None = None) -> None:
|
|
53
|
+
"""Read object from the store"""
|
|
54
|
+
self._can_agent_do_activity(reader)
|
|
55
|
+
|
|
56
|
+
change, data_model = self._do_activity(reader.to_data_model, on_success)
|
|
57
|
+
|
|
58
|
+
if data_model:
|
|
59
|
+
change.target_entity = self.physical_data_model.generate_reference(cast(PhysicalDataModel, data_model))
|
|
60
|
+
self.physical_data_model.append(data_model)
|
|
61
|
+
self.state = self.state.transition(reader)
|
|
62
|
+
change.target_state = self.state
|
|
63
|
+
|
|
64
|
+
self.provenance.append(change)
|
|
65
|
+
|
|
66
|
+
def write_physical(self, writer: DMSExporter, on_success: OnSuccess | None = None, **kwargs: Any) -> None:
|
|
67
|
+
"""Write object into the store"""
|
|
68
|
+
self._can_agent_do_activity(writer)
|
|
69
|
+
|
|
70
|
+
activity: Callable
|
|
71
|
+
if isinstance(writer, DMSFileExporter):
|
|
72
|
+
activity = writer.export_to_file
|
|
73
|
+
if not kwargs.get("file_path"):
|
|
74
|
+
raise RuntimeError("file_path must be provided when using a DMSFileExporter")
|
|
75
|
+
else:
|
|
76
|
+
activity = writer.export
|
|
77
|
+
|
|
78
|
+
data_model = self._gather_data_model(writer)
|
|
79
|
+
|
|
80
|
+
change, _ = self._do_activity(activity, on_success, data_model=data_model, **kwargs)
|
|
81
|
+
|
|
82
|
+
if not change.issues:
|
|
83
|
+
change.target_entity = "ExternalEntity"
|
|
84
|
+
self.state = self.state.transition(writer)
|
|
85
|
+
change.target_state = self.state
|
|
86
|
+
|
|
87
|
+
self.provenance.append(change)
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
isinstance(writer, DMSAPIExporter)
|
|
91
|
+
and isinstance(on_success, SchemaDeployer)
|
|
92
|
+
and not on_success.options.dry_run
|
|
93
|
+
):
|
|
94
|
+
# Update CDF snapshot after successful deployment
|
|
95
|
+
self._cdf_snapshot = SchemaSnapshot.fetch_entire_cdf(self._client)
|
|
96
|
+
|
|
97
|
+
def _gather_data_model(self, writer: DMSExporter) -> PhysicalDataModel:
|
|
98
|
+
"""Gather the current physical data model from the store
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
writer (DMSExporter): The exporter that will be used to write the data model.
|
|
102
|
+
"""
|
|
103
|
+
# getting provenance of the last successful physical data model read
|
|
104
|
+
change = self.provenance.last_physical_data_model_read()
|
|
105
|
+
|
|
106
|
+
if not change:
|
|
107
|
+
raise RuntimeError("No successful physical data model read found in provenance.")
|
|
108
|
+
|
|
109
|
+
# We do not want to modify the data model for API representations
|
|
110
|
+
if not isinstance(writer, DMSTableExporter):
|
|
111
|
+
return self.physical_data_model[-1]
|
|
112
|
+
|
|
113
|
+
# This will handle data model that are partially and require to be converted to
|
|
114
|
+
# tabular representation to include all containers referenced by views.
|
|
115
|
+
copy = self.physical_data_model[-1].model_copy(deep=True)
|
|
116
|
+
container_refs = {container.as_reference() for container in copy.containers}
|
|
117
|
+
|
|
118
|
+
for view in copy.views:
|
|
119
|
+
for container in view.used_containers:
|
|
120
|
+
if container not in container_refs and (cdf_container := self.cdf_snapshot.containers.get(container)):
|
|
121
|
+
copy.containers.append(cdf_container)
|
|
122
|
+
container_refs.add(container)
|
|
123
|
+
|
|
124
|
+
return copy
|
|
125
|
+
|
|
126
|
+
def _can_agent_do_activity(self, agent: Agents) -> None:
|
|
127
|
+
"""Validate if activity can be performed in the current state and considering provenance"""
|
|
128
|
+
if not self.state.can_transition(agent):
|
|
129
|
+
# specific error messages for common mistakes
|
|
130
|
+
if isinstance(agent, DMSImporter) and isinstance(self.state, PhysicalState):
|
|
131
|
+
raise RuntimeError(
|
|
132
|
+
"⚠️ Cannot read data model, there is already a data model in the session!"
|
|
133
|
+
f"{NEWLINE}Start a new session to read a new data model."
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
if isinstance(agent, DMSExporter) and isinstance(self.state, EmptyState):
|
|
137
|
+
raise RuntimeError(
|
|
138
|
+
"⚠️ Cannot write data model, there is no data model in the session!"
|
|
139
|
+
f"{NEWLINE}Read a data model first!"
|
|
140
|
+
)
|
|
141
|
+
raise RuntimeError(f"Cannot run {type(agent).__name__} in state {self.state}")
|
|
142
|
+
|
|
143
|
+
if (
|
|
144
|
+
isinstance(agent, DMSExporter)
|
|
145
|
+
and self.provenance.last_change
|
|
146
|
+
and (error_count := self.provenance.last_change.error_count) > 0
|
|
147
|
+
):
|
|
148
|
+
raise RuntimeError(
|
|
149
|
+
f"⚠️ Cannot write data model, the model has {error_count} errors!"
|
|
150
|
+
f"{NEWLINE}Resolve issues before exporting the data model."
|
|
151
|
+
f"{NEWLINE}You can inspect issues using neat.issues"
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# need implementation of checking if required predecessor activities have been done
|
|
155
|
+
# this will be done by running self.provenance.can_agent_do_activity(agent)
|
|
156
|
+
|
|
157
|
+
def _do_activity(
|
|
158
|
+
self, activity: Callable, on_success: OnSuccess | None = None, **kwargs: Any
|
|
159
|
+
) -> tuple[Change, PhysicalDataModel | None]:
|
|
160
|
+
"""Execute activity and capture timing, results, and issues"""
|
|
161
|
+
start = datetime.now(timezone.utc)
|
|
162
|
+
created_data_model: PhysicalDataModel | None = None
|
|
163
|
+
issues = IssueList()
|
|
164
|
+
errors = IssueList()
|
|
165
|
+
deployment_result: DeploymentResult | None = None
|
|
166
|
+
|
|
167
|
+
try:
|
|
168
|
+
created_data_model = activity(**kwargs)
|
|
169
|
+
if created_data_model and on_success:
|
|
170
|
+
on_success.run(created_data_model)
|
|
171
|
+
if isinstance(on_success, OnSuccessIssuesChecker):
|
|
172
|
+
issues.extend(on_success.issues)
|
|
173
|
+
elif isinstance(on_success, OnSuccessResultProducer):
|
|
174
|
+
deployment_result = on_success.result
|
|
175
|
+
else:
|
|
176
|
+
raise RuntimeError(f"Unknown OnSuccess type {type(on_success).__name__}")
|
|
177
|
+
|
|
178
|
+
# we catch import exceptions to capture issues and errors in provenance
|
|
179
|
+
except DataModelImportException as e:
|
|
180
|
+
errors.extend(e.errors)
|
|
181
|
+
|
|
182
|
+
# these are all other errors, such as missing file, wrong format, etc.
|
|
183
|
+
except Exception as e:
|
|
184
|
+
raise e
|
|
185
|
+
|
|
186
|
+
end = datetime.now(timezone.utc)
|
|
187
|
+
|
|
188
|
+
return Change(
|
|
189
|
+
start=start,
|
|
190
|
+
end=end,
|
|
191
|
+
source_state=self.state,
|
|
192
|
+
agent=type(activity.__self__).__name__ if hasattr(activity, "__self__") else "UnknownAgent",
|
|
193
|
+
issues=issues,
|
|
194
|
+
errors=errors,
|
|
195
|
+
result=deployment_result,
|
|
196
|
+
activity=Change.standardize_activity_name(activity.__name__, start, end),
|
|
197
|
+
), created_data_model
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class DataModelList(UserList[PhysicalDataModel]):
|
|
201
|
+
def iteration(self, data_model: PhysicalDataModel) -> int:
|
|
202
|
+
"""Get iteration number for data model"""
|
|
203
|
+
for i, existing in enumerate(self):
|
|
204
|
+
if existing.data_model == data_model.data_model:
|
|
205
|
+
return i + 2
|
|
206
|
+
return 1
|
|
207
|
+
|
|
208
|
+
def generate_reference(self, data_model: PhysicalDataModel) -> str:
|
|
209
|
+
"""Generate reference string for data model based on iteration"""
|
|
210
|
+
space = data_model.data_model.space
|
|
211
|
+
external_id = data_model.data_model.external_id
|
|
212
|
+
version = data_model.data_model.version
|
|
213
|
+
iteration = self.iteration(data_model)
|
|
214
|
+
|
|
215
|
+
return f"physical/{space}/{external_id}/{version}/{iteration}"
|
|
216
|
+
|
|
217
|
+
def get_by_reference(self, reference: str) -> PhysicalDataModel | None:
|
|
218
|
+
"""Get data model by reference string"""
|
|
219
|
+
|
|
220
|
+
raise NotImplementedError("Not implemented yet")
|
|
File without changes
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from collections.abc import Iterable
|
|
4
|
+
from io import StringIO
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import IO, Any, TextIO
|
|
7
|
+
from urllib.parse import urlparse
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class NeatReader(ABC):
|
|
13
|
+
@classmethod
|
|
14
|
+
def create(cls, io: Any) -> "NeatReader":
|
|
15
|
+
if isinstance(io, str):
|
|
16
|
+
url = urlparse(io)
|
|
17
|
+
if url.scheme == "https" and url.netloc.endswith("github.com"):
|
|
18
|
+
return GitHubReader(io)
|
|
19
|
+
elif url.scheme == "https":
|
|
20
|
+
return HttpFileReader(io, url.path)
|
|
21
|
+
|
|
22
|
+
if isinstance(io, str):
|
|
23
|
+
return PathReader(Path(io))
|
|
24
|
+
if isinstance(io, Path):
|
|
25
|
+
return PathReader(io)
|
|
26
|
+
raise ValueError(f"Unsupported type: {type(io)}")
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def name(self) -> str:
|
|
30
|
+
return str(self)
|
|
31
|
+
|
|
32
|
+
@abstractmethod
|
|
33
|
+
def read_text(self) -> str:
|
|
34
|
+
"""Read the buffer as a string"""
|
|
35
|
+
raise NotImplementedError()
|
|
36
|
+
|
|
37
|
+
@abstractmethod
|
|
38
|
+
def read_bytes(self) -> bytes:
|
|
39
|
+
"""Read the buffer as bytes"""
|
|
40
|
+
raise NotImplementedError()
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def size(self) -> int:
|
|
44
|
+
"""Size of the buffer in bytes"""
|
|
45
|
+
raise NotImplementedError()
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def iterate(self, chunk_size: int) -> Iterable[str]:
|
|
49
|
+
"""Iterate over the buffer in chunks
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
chunk_size: Size of each chunk in bytes
|
|
53
|
+
"""
|
|
54
|
+
raise NotImplementedError()
|
|
55
|
+
|
|
56
|
+
@abstractmethod
|
|
57
|
+
def __enter__(self) -> IO:
|
|
58
|
+
raise NotImplementedError()
|
|
59
|
+
|
|
60
|
+
@abstractmethod
|
|
61
|
+
def __str__(self) -> str:
|
|
62
|
+
raise NotImplementedError()
|
|
63
|
+
|
|
64
|
+
@abstractmethod
|
|
65
|
+
def exists(self) -> bool:
|
|
66
|
+
raise NotImplementedError
|
|
67
|
+
|
|
68
|
+
@abstractmethod
|
|
69
|
+
def materialize_path(self) -> Path:
|
|
70
|
+
raise NotImplementedError
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class PathReader(NeatReader):
|
|
74
|
+
def __init__(self, path: Path):
|
|
75
|
+
self.path = path
|
|
76
|
+
self._io: TextIO | None = None
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def name(self) -> str:
|
|
80
|
+
return self.path.name
|
|
81
|
+
|
|
82
|
+
def read_text(self) -> str:
|
|
83
|
+
return self.path.read_text()
|
|
84
|
+
|
|
85
|
+
def read_bytes(self) -> bytes:
|
|
86
|
+
return self.path.read_bytes()
|
|
87
|
+
|
|
88
|
+
def size(self) -> int:
|
|
89
|
+
return self.path.stat().st_size
|
|
90
|
+
|
|
91
|
+
def iterate(self, chunk_size: int) -> Iterable[str]:
|
|
92
|
+
with self.path.open(mode="r") as f:
|
|
93
|
+
while chunk := f.read(chunk_size):
|
|
94
|
+
yield chunk
|
|
95
|
+
|
|
96
|
+
def __enter__(self) -> TextIO:
|
|
97
|
+
file = self.path.open(mode="r")
|
|
98
|
+
self._io = file
|
|
99
|
+
return file
|
|
100
|
+
|
|
101
|
+
def __exit__(self) -> None:
|
|
102
|
+
if self._io:
|
|
103
|
+
self._io.close()
|
|
104
|
+
|
|
105
|
+
def __str__(self) -> str:
|
|
106
|
+
return self.path.as_posix()
|
|
107
|
+
|
|
108
|
+
def exists(self) -> bool:
|
|
109
|
+
return self.path.exists()
|
|
110
|
+
|
|
111
|
+
def materialize_path(self) -> Path:
|
|
112
|
+
return self.path
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class HttpFileReader(NeatReader):
|
|
116
|
+
def __init__(self, url: str, path: str):
|
|
117
|
+
self._url = url
|
|
118
|
+
self.path = path
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def name(self) -> str:
|
|
122
|
+
if "/" in self.path:
|
|
123
|
+
return self.path.rsplit("/", maxsplit=1)[-1]
|
|
124
|
+
return self.path
|
|
125
|
+
|
|
126
|
+
def read_text(self) -> str:
|
|
127
|
+
response = requests.get(self._url)
|
|
128
|
+
response.raise_for_status()
|
|
129
|
+
return response.text
|
|
130
|
+
|
|
131
|
+
def read_bytes(self) -> bytes:
|
|
132
|
+
response = requests.get(self._url)
|
|
133
|
+
response.raise_for_status()
|
|
134
|
+
return response.content
|
|
135
|
+
|
|
136
|
+
def size(self) -> int:
|
|
137
|
+
response = requests.head(self._url)
|
|
138
|
+
response.raise_for_status()
|
|
139
|
+
return int(response.headers["Content-Length"])
|
|
140
|
+
|
|
141
|
+
def iterate(self, chunk_size: int) -> Iterable[str]:
|
|
142
|
+
with requests.get(self._url, stream=True) as response:
|
|
143
|
+
response.raise_for_status()
|
|
144
|
+
for chunk in response.iter_content(chunk_size):
|
|
145
|
+
yield chunk.decode("utf-8")
|
|
146
|
+
|
|
147
|
+
def __enter__(self) -> IO:
|
|
148
|
+
return StringIO(self.read_text())
|
|
149
|
+
|
|
150
|
+
def __str__(self) -> str:
|
|
151
|
+
return self._url
|
|
152
|
+
|
|
153
|
+
def exists(self) -> bool:
|
|
154
|
+
response = requests.head(self._url)
|
|
155
|
+
return 200 <= response.status_code < 400
|
|
156
|
+
|
|
157
|
+
def materialize_path(self) -> Path:
|
|
158
|
+
path = Path(tempfile.gettempdir()).resolve() / "neat" / self.name
|
|
159
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
160
|
+
path.write_bytes(self.read_bytes())
|
|
161
|
+
return path
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class GitHubReader(HttpFileReader):
|
|
165
|
+
raw_url = "https://raw.githubusercontent.com/"
|
|
166
|
+
|
|
167
|
+
def __init__(self, raw: str):
|
|
168
|
+
self.raw = raw
|
|
169
|
+
self.repo, path = self._parse_url(raw)
|
|
170
|
+
super().__init__(f"{self.raw_url}{self.repo}/main/{path}", path)
|
|
171
|
+
|
|
172
|
+
@staticmethod
|
|
173
|
+
def _parse_url(url: str) -> tuple[str, str]:
|
|
174
|
+
parsed = urlparse(url)
|
|
175
|
+
if parsed.scheme != "https":
|
|
176
|
+
raise ValueError(f"Unsupported scheme: {parsed.scheme}")
|
|
177
|
+
|
|
178
|
+
path = parsed.path.lstrip("/")
|
|
179
|
+
if parsed.netloc == "github.com":
|
|
180
|
+
repo, path = path.split("/blob/main/", maxsplit=1)
|
|
181
|
+
return repo, path
|
|
182
|
+
|
|
183
|
+
elif parsed.netloc == "api.github.com":
|
|
184
|
+
repo, path = path.removeprefix("repos/").split("/contents/", maxsplit=1)
|
|
185
|
+
return repo, path
|
|
186
|
+
|
|
187
|
+
elif parsed.netloc == "raw.githubusercontent.com":
|
|
188
|
+
repo, path = path.split("/main/", maxsplit=1)
|
|
189
|
+
return repo, path
|
|
190
|
+
|
|
191
|
+
raise ValueError(f"Unsupported netloc: {parsed.netloc}")
|
|
192
|
+
|
|
193
|
+
def __str__(self) -> str:
|
|
194
|
+
return self.raw
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import inspect
|
|
3
|
+
from abc import ABC
|
|
4
|
+
from types import ModuleType
|
|
5
|
+
from typing import TypeVar
|
|
6
|
+
|
|
7
|
+
from cognite.neat import _version
|
|
8
|
+
from cognite.neat._exceptions import NeatImportError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_current_neat_version() -> str:
|
|
12
|
+
return _version.__version__
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
T_Cls = TypeVar("T_Cls")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_concrete_subclasses(base_cls: type[T_Cls], exclude_direct_abc_inheritance: bool = True) -> list[type[T_Cls]]:
|
|
19
|
+
"""
|
|
20
|
+
Returns a list of all concrete subclasses of the given base class.
|
|
21
|
+
Args:
|
|
22
|
+
base_cls (type[T_Cls]): The base class to find subclasses for.
|
|
23
|
+
exclude_direct_abc_inheritance (bool): If True, excludes classes that directly inherit from `abc.ABC`.
|
|
24
|
+
This is used as a marker to filter out intermediate base classes. Defaults to True.
|
|
25
|
+
Returns:
|
|
26
|
+
list[type[T_Cls]]: A list of concrete subclasses of the base class.
|
|
27
|
+
"""
|
|
28
|
+
to_check = [base_cls]
|
|
29
|
+
subclasses: list[type[T_Cls]] = []
|
|
30
|
+
seen: set[type[T_Cls]] = {base_cls}
|
|
31
|
+
while to_check:
|
|
32
|
+
current_cls = to_check.pop()
|
|
33
|
+
for subclass in current_cls.__subclasses__():
|
|
34
|
+
if subclass in seen:
|
|
35
|
+
continue
|
|
36
|
+
if (not inspect.isabstract(subclass)) and (
|
|
37
|
+
not exclude_direct_abc_inheritance or ABC not in subclass.__bases__
|
|
38
|
+
):
|
|
39
|
+
subclasses.append(subclass)
|
|
40
|
+
seen.add(subclass)
|
|
41
|
+
to_check.append(subclass)
|
|
42
|
+
return subclasses
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def local_import(module: str, extra: str) -> ModuleType:
|
|
46
|
+
try:
|
|
47
|
+
return importlib.import_module(module)
|
|
48
|
+
except ImportError as e:
|
|
49
|
+
raise NeatImportError(module.split(".")[0], extra) from e
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from collections.abc import Iterator, Sequence
|
|
2
|
+
from typing import TypeVar
|
|
3
|
+
|
|
4
|
+
T_Sequence = TypeVar("T_Sequence", bound=Sequence)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def chunker_sequence(sequence: T_Sequence, size: int) -> Iterator[T_Sequence]:
|
|
8
|
+
"""Yield successive n-sized chunks from sequence."""
|
|
9
|
+
for i in range(0, len(sequence), size):
|
|
10
|
+
# MyPy does not expect sequence[i : i + size] to be of type T_Sequence
|
|
11
|
+
yield sequence[i : i + size] # type: ignore[misc]
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from ._client import HTTPClient
|
|
2
|
+
from ._data_classes import (
|
|
3
|
+
ErrorDetails,
|
|
4
|
+
FailedRequestItems,
|
|
5
|
+
FailedRequestMessage,
|
|
6
|
+
FailedResponse,
|
|
7
|
+
FailedResponseItems,
|
|
8
|
+
HTTPMessage,
|
|
9
|
+
ItemBody,
|
|
10
|
+
ItemIDBody,
|
|
11
|
+
ItemMessage,
|
|
12
|
+
ItemsRequest,
|
|
13
|
+
ParametersRequest,
|
|
14
|
+
RequestMessage,
|
|
15
|
+
ResponseMessage,
|
|
16
|
+
SimpleBodyRequest,
|
|
17
|
+
SuccessResponse,
|
|
18
|
+
SuccessResponseItems,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"ErrorDetails",
|
|
23
|
+
"FailedRequestItems",
|
|
24
|
+
"FailedRequestMessage",
|
|
25
|
+
"FailedResponse",
|
|
26
|
+
"FailedResponseItems",
|
|
27
|
+
"HTTPClient",
|
|
28
|
+
"HTTPMessage",
|
|
29
|
+
"ItemBody",
|
|
30
|
+
"ItemIDBody",
|
|
31
|
+
"ItemMessage",
|
|
32
|
+
"ItemsRequest",
|
|
33
|
+
"ParametersRequest",
|
|
34
|
+
"RequestMessage",
|
|
35
|
+
"ResponseMessage",
|
|
36
|
+
"SimpleBodyRequest",
|
|
37
|
+
"SuccessResponse",
|
|
38
|
+
"SuccessResponseItems",
|
|
39
|
+
]
|