cognite-neat 0.70.1__py3-none-any.whl → 0.127.19__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 -1
- 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/_data_model/_analysis.py +186 -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 +399 -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 +291 -0
- cognite/neat/_data_model/importers/_table_importer/importer.py +192 -0
- cognite/neat/_data_model/importers/_table_importer/reader.py +875 -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 +47 -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 +94 -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 +57 -0
- cognite/neat/_data_model/validation/dms/_ai_readiness.py +167 -0
- cognite/neat/_data_model/validation/dms/_base.py +304 -0
- cognite/neat/_data_model/validation/dms/_connections.py +627 -0
- cognite/neat/_data_model/validation/dms/_consistency.py +56 -0
- cognite/neat/_data_model/validation/dms/_containers.py +135 -0
- cognite/neat/_data_model/validation/dms/_limits.py +414 -0
- cognite/neat/_data_model/validation/dms/_orchestrator.py +202 -0
- cognite/neat/_data_model/validation/dms/_views.py +101 -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 +149 -0
- cognite/neat/_session/_html/static/issues.css +211 -0
- cognite/neat/_session/_html/static/issues.js +167 -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 +74 -0
- cognite/neat/_session/_html/templates/issues.html +44 -0
- cognite/neat/_session/_issues.py +76 -0
- cognite/neat/_session/_opt.py +35 -0
- cognite/neat/_session/_physical.py +240 -0
- cognite/neat/_session/_result.py +231 -0
- cognite/neat/_session/_session.py +69 -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 +71 -0
- cognite/neat/_store/_store.py +144 -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 +149 -0
- cognite/neat/_version.py +2 -1
- cognite/neat/v0/core/__init__.py +0 -0
- cognite/neat/v0/core/_client/__init__.py +4 -0
- cognite/neat/v0/core/_client/_api/__init__.py +0 -0
- cognite/neat/v0/core/_client/_api/data_modeling_loaders.py +1032 -0
- cognite/neat/v0/core/_client/_api/neat_instances.py +101 -0
- cognite/neat/v0/core/_client/_api/schema.py +158 -0
- cognite/neat/v0/core/_client/_api/statistics.py +91 -0
- cognite/neat/v0/core/_client/_api_client.py +21 -0
- cognite/neat/v0/core/_client/data_classes/__init__.py +0 -0
- cognite/neat/v0/core/_client/data_classes/data_modeling.py +198 -0
- cognite/neat/v0/core/_client/data_classes/neat_sequence.py +261 -0
- cognite/neat/v0/core/_client/data_classes/schema.py +540 -0
- cognite/neat/v0/core/_client/data_classes/statistics.py +125 -0
- cognite/neat/v0/core/_client/testing.py +39 -0
- cognite/neat/v0/core/_config.py +11 -0
- cognite/neat/v0/core/_constants.py +278 -0
- cognite/neat/v0/core/_data_model/__init__.py +0 -0
- cognite/neat/v0/core/_data_model/_constants.py +210 -0
- cognite/neat/v0/core/_data_model/_shared.py +59 -0
- cognite/neat/v0/core/_data_model/analysis/__init__.py +3 -0
- cognite/neat/v0/core/_data_model/analysis/_base.py +578 -0
- cognite/neat/v0/core/_data_model/catalog/__init__.py +8 -0
- cognite/neat/v0/core/_data_model/catalog/classic_model.xlsx +0 -0
- cognite/neat/v0/core/_data_model/catalog/conceptual-imf-data-model.xlsx +0 -0
- cognite/neat/v0/core/_data_model/catalog/hello_world_pump.xlsx +0 -0
- cognite/neat/v0/core/_data_model/exporters/__init__.py +38 -0
- cognite/neat/v0/core/_data_model/exporters/_base.py +67 -0
- cognite/neat/v0/core/_data_model/exporters/_data_model2dms.py +428 -0
- cognite/neat/v0/core/_data_model/exporters/_data_model2excel.py +612 -0
- cognite/neat/v0/core/_data_model/exporters/_data_model2instance_template.py +158 -0
- cognite/neat/v0/core/_data_model/exporters/_data_model2semantic_model.py +646 -0
- cognite/neat/v0/core/_data_model/exporters/_data_model2yaml.py +84 -0
- cognite/neat/v0/core/_data_model/importers/__init__.py +49 -0
- cognite/neat/v0/core/_data_model/importers/_base.py +64 -0
- cognite/neat/v0/core/_data_model/importers/_base_file_reader.py +56 -0
- cognite/neat/v0/core/_data_model/importers/_dict2data_model.py +131 -0
- cognite/neat/v0/core/_data_model/importers/_dms2data_model.py +705 -0
- 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/v0/core/_data_model/importers/_rdf/_base.py +161 -0
- cognite/neat/v0/core/_data_model/importers/_rdf/_inference2rdata_model.py +618 -0
- cognite/neat/v0/core/_data_model/importers/_rdf/_owl2data_model.py +124 -0
- cognite/neat/v0/core/_data_model/importers/_rdf/_shared.py +255 -0
- cognite/neat/v0/core/_data_model/importers/_spreadsheet2data_model.py +424 -0
- cognite/neat/v0/core/_data_model/models/__init__.py +38 -0
- cognite/neat/v0/core/_data_model/models/_base_unverified.py +181 -0
- cognite/neat/v0/core/_data_model/models/_base_verified.py +449 -0
- cognite/neat/v0/core/_data_model/models/_import_contexts.py +82 -0
- cognite/neat/v0/core/_data_model/models/_types.py +171 -0
- cognite/neat/v0/core/_data_model/models/conceptual/__init__.py +25 -0
- cognite/neat/v0/core/_data_model/models/conceptual/_unverified.py +193 -0
- cognite/neat/v0/core/_data_model/models/conceptual/_validation.py +308 -0
- cognite/neat/v0/core/_data_model/models/conceptual/_verified.py +327 -0
- cognite/neat/v0/core/_data_model/models/data_types.py +422 -0
- cognite/neat/v0/core/_data_model/models/entities/__init__.py +70 -0
- cognite/neat/v0/core/_data_model/models/entities/_constants.py +18 -0
- cognite/neat/v0/core/_data_model/models/entities/_loaders.py +155 -0
- cognite/neat/v0/core/_data_model/models/entities/_multi_value.py +83 -0
- cognite/neat/v0/core/_data_model/models/entities/_restrictions.py +230 -0
- cognite/neat/v0/core/_data_model/models/entities/_single_value.py +676 -0
- cognite/neat/v0/core/_data_model/models/entities/_types.py +103 -0
- cognite/neat/v0/core/_data_model/models/entities/_wrapped.py +217 -0
- cognite/neat/v0/core/_data_model/models/mapping/__init__.py +3 -0
- cognite/neat/v0/core/_data_model/models/mapping/_classic2core.py +39 -0
- cognite/neat/v0/core/_data_model/models/mapping/_classic2core.yaml +608 -0
- cognite/neat/v0/core/_data_model/models/physical/__init__.py +40 -0
- cognite/neat/v0/core/_data_model/models/physical/_exporter.py +658 -0
- cognite/neat/v0/core/_data_model/models/physical/_unverified.py +557 -0
- cognite/neat/v0/core/_data_model/models/physical/_validation.py +887 -0
- cognite/neat/v0/core/_data_model/models/physical/_verified.py +667 -0
- cognite/neat/v0/core/_data_model/transformers/__init__.py +70 -0
- cognite/neat/v0/core/_data_model/transformers/_base.py +79 -0
- cognite/neat/v0/core/_data_model/transformers/_converters.py +2485 -0
- cognite/neat/v0/core/_data_model/transformers/_mapping.py +390 -0
- cognite/neat/v0/core/_data_model/transformers/_union_conceptual.py +208 -0
- cognite/neat/v0/core/_data_model/transformers/_verification.py +120 -0
- cognite/neat/v0/core/_instances/__init__.py +0 -0
- cognite/neat/v0/core/_instances/_shared.py +37 -0
- cognite/neat/v0/core/_instances/_tracking/__init__.py +4 -0
- cognite/neat/v0/core/_instances/_tracking/base.py +30 -0
- cognite/neat/v0/core/_instances/_tracking/log.py +27 -0
- cognite/neat/v0/core/_instances/extractors/__init__.py +76 -0
- cognite/neat/v0/core/_instances/extractors/_base.py +58 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/__init__.py +0 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_assets.py +37 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_base.py +443 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_classic.py +479 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_data_sets.py +35 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_events.py +33 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_files.py +45 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_labels.py +54 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_relationships.py +122 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_sequences.py +280 -0
- cognite/neat/v0/core/_instances/extractors/_classic_cdf/_timeseries.py +48 -0
- cognite/neat/v0/core/_instances/extractors/_dict.py +105 -0
- cognite/neat/v0/core/_instances/extractors/_dms.py +315 -0
- cognite/neat/v0/core/_instances/extractors/_dms_graph.py +238 -0
- cognite/neat/v0/core/_instances/extractors/_mock_graph_generator.py +404 -0
- cognite/neat/v0/core/_instances/extractors/_raw.py +67 -0
- cognite/neat/v0/core/_instances/extractors/_rdf_file.py +80 -0
- cognite/neat/v0/core/_instances/loaders/__init__.py +24 -0
- cognite/neat/v0/core/_instances/loaders/_base.py +116 -0
- cognite/neat/v0/core/_instances/loaders/_rdf2dms.py +649 -0
- cognite/neat/v0/core/_instances/loaders/_rdf_to_instance_space.py +249 -0
- cognite/neat/v0/core/_instances/queries/__init__.py +3 -0
- cognite/neat/v0/core/_instances/queries/_base.py +16 -0
- cognite/neat/v0/core/_instances/queries/_queries.py +16 -0
- cognite/neat/v0/core/_instances/queries/_select.py +478 -0
- cognite/neat/v0/core/_instances/queries/_update.py +37 -0
- cognite/neat/v0/core/_instances/transformers/__init__.py +65 -0
- cognite/neat/v0/core/_instances/transformers/_base.py +133 -0
- cognite/neat/v0/core/_instances/transformers/_classic_cdf.py +589 -0
- cognite/neat/v0/core/_instances/transformers/_prune_graph.py +315 -0
- cognite/neat/v0/core/_instances/transformers/_rdfpath.py +84 -0
- cognite/neat/v0/core/_instances/transformers/_value_type.py +366 -0
- cognite/neat/v0/core/_issues/__init__.py +21 -0
- cognite/neat/v0/core/_issues/_base.py +348 -0
- cognite/neat/v0/core/_issues/_contextmanagers.py +50 -0
- cognite/neat/v0/core/_issues/_factory.py +69 -0
- cognite/neat/v0/core/_issues/errors/__init__.py +90 -0
- cognite/neat/v0/core/_issues/errors/_external.py +91 -0
- cognite/neat/v0/core/_issues/errors/_general.py +51 -0
- cognite/neat/v0/core/_issues/errors/_properties.py +80 -0
- cognite/neat/v0/core/_issues/errors/_resources.py +116 -0
- cognite/neat/v0/core/_issues/errors/_wrapper.py +93 -0
- cognite/neat/{rules/issues → v0/core/_issues}/formatters.py +12 -10
- cognite/neat/v0/core/_issues/warnings/__init__.py +99 -0
- cognite/neat/v0/core/_issues/warnings/_external.py +56 -0
- cognite/neat/v0/core/_issues/warnings/_general.py +46 -0
- cognite/neat/v0/core/_issues/warnings/_models.py +165 -0
- cognite/neat/v0/core/_issues/warnings/_properties.py +108 -0
- cognite/neat/v0/core/_issues/warnings/_resources.py +110 -0
- cognite/neat/v0/core/_issues/warnings/user_modeling.py +125 -0
- cognite/neat/v0/core/_shared.py +77 -0
- cognite/neat/v0/core/_store/__init__.py +4 -0
- cognite/neat/v0/core/_store/_data_model.py +487 -0
- cognite/neat/v0/core/_store/_instance.py +485 -0
- cognite/neat/v0/core/_store/_provenance.py +217 -0
- cognite/neat/v0/core/_store/exceptions.py +59 -0
- cognite/neat/v0/core/_utils/__init__.py +0 -0
- cognite/neat/v0/core/_utils/auth.py +364 -0
- cognite/neat/v0/core/_utils/auxiliary.py +169 -0
- cognite/neat/v0/core/_utils/collection_.py +66 -0
- cognite/neat/v0/core/_utils/graph_transformations_report.py +36 -0
- cognite/neat/v0/core/_utils/io_.py +11 -0
- cognite/neat/v0/core/_utils/rdf_.py +336 -0
- cognite/neat/v0/core/_utils/reader/__init__.py +3 -0
- cognite/neat/v0/core/_utils/reader/_base.py +194 -0
- cognite/neat/v0/core/_utils/spreadsheet.py +182 -0
- cognite/neat/v0/core/_utils/tarjan.py +44 -0
- cognite/neat/v0/core/_utils/text.py +277 -0
- cognite/neat/v0/core/_utils/time_.py +17 -0
- cognite/neat/v0/core/_utils/upload.py +134 -0
- cognite/neat/v0/core/_utils/xml_.py +52 -0
- 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/v0/plugins/_issues.py +35 -0
- cognite/neat/v0/plugins/_manager.py +94 -0
- cognite/neat/v0/session/__init__.py +3 -0
- cognite/neat/v0/session/_base.py +332 -0
- cognite/neat/v0/session/_collector.py +131 -0
- cognite/neat/v0/session/_diff.py +51 -0
- cognite/neat/v0/session/_drop.py +103 -0
- cognite/neat/v0/session/_experimental.py +26 -0
- cognite/neat/v0/session/_explore.py +39 -0
- cognite/neat/v0/session/_fix.py +28 -0
- cognite/neat/v0/session/_inspect.py +285 -0
- cognite/neat/v0/session/_mapping.py +71 -0
- cognite/neat/v0/session/_plugin.py +66 -0
- cognite/neat/v0/session/_prepare.py +286 -0
- cognite/neat/v0/session/_read.py +923 -0
- cognite/neat/v0/session/_set.py +101 -0
- cognite/neat/v0/session/_show.py +298 -0
- cognite/neat/v0/session/_state/README.md +23 -0
- cognite/neat/v0/session/_state.py +161 -0
- cognite/neat/v0/session/_subset.py +88 -0
- cognite/neat/v0/session/_template.py +208 -0
- cognite/neat/v0/session/_to.py +454 -0
- cognite/neat/v0/session/_wizard.py +44 -0
- cognite/neat/v0/session/engine/__init__.py +4 -0
- cognite/neat/v0/session/engine/_import.py +7 -0
- cognite/neat/v0/session/engine/_interface.py +25 -0
- cognite/neat/v0/session/engine/_load.py +131 -0
- cognite/neat/v0/session/exceptions.py +103 -0
- cognite/neat/v1.py +3 -0
- cognite_neat-0.127.19.dist-info/METADATA +145 -0
- cognite_neat-0.127.19.dist-info/RECORD +318 -0
- {cognite_neat-0.70.1.dist-info → cognite_neat-0.127.19.dist-info}/WHEEL +1 -1
- cognite/neat/app/api/asgi/metrics.py +0 -4
- cognite/neat/app/api/configuration.py +0 -110
- cognite/neat/app/api/context_manager/__init__.py +0 -3
- cognite/neat/app/api/context_manager/manager.py +0 -16
- cognite/neat/app/api/data_classes/configuration.py +0 -121
- cognite/neat/app/api/data_classes/rest.py +0 -78
- cognite/neat/app/api/explorer.py +0 -64
- cognite/neat/app/api/routers/configuration.py +0 -24
- cognite/neat/app/api/routers/core.py +0 -51
- cognite/neat/app/api/routers/crud.py +0 -112
- cognite/neat/app/api/routers/data_exploration.py +0 -334
- cognite/neat/app/api/routers/metrics.py +0 -10
- cognite/neat/app/api/routers/rules.py +0 -169
- cognite/neat/app/api/routers/workflows.py +0 -274
- cognite/neat/app/api/utils/data_mapping.py +0 -17
- cognite/neat/app/api/utils/logging.py +0 -26
- cognite/neat/app/api/utils/query_templates.py +0 -92
- cognite/neat/app/main.py +0 -17
- cognite/neat/app/monitoring/metrics.py +0 -69
- cognite/neat/app/ui/index.html +0 -1
- cognite/neat/app/ui/neat-app/.gitignore +0 -23
- cognite/neat/app/ui/neat-app/README.md +0 -70
- cognite/neat/app/ui/neat-app/build/asset-manifest.json +0 -14
- cognite/neat/app/ui/neat-app/build/favicon.ico +0 -0
- cognite/neat/app/ui/neat-app/build/index.html +0 -1
- cognite/neat/app/ui/neat-app/build/logo192.png +0 -0
- cognite/neat/app/ui/neat-app/build/manifest.json +0 -25
- cognite/neat/app/ui/neat-app/build/robots.txt +0 -3
- cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css +0 -2
- cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -1
- cognite/neat/app/ui/neat-app/build/static/js/main.ed960141.js +0 -3
- cognite/neat/app/ui/neat-app/build/static/js/main.ed960141.js.LICENSE.txt +0 -97
- cognite/neat/app/ui/neat-app/build/static/js/main.ed960141.js.map +0 -1
- cognite/neat/app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -1
- cognite/neat/config.py +0 -46
- cognite/neat/constants.py +0 -36
- cognite/neat/exceptions.py +0 -139
- cognite/neat/graph/__init__.py +0 -3
- cognite/neat/graph/exceptions.py +0 -91
- cognite/neat/graph/extractor/__init__.py +0 -6
- cognite/neat/graph/extractor/_base.py +0 -14
- cognite/neat/graph/extractor/_dexpi.py +0 -306
- cognite/neat/graph/extractor/_graph_capturing_sheet.py +0 -401
- cognite/neat/graph/extractor/_mock_graph_generator.py +0 -359
- cognite/neat/graph/extractors/_base.py +0 -14
- cognite/neat/graph/extractors/_mock_graph_generator.py +0 -359
- cognite/neat/graph/loader/__init__.py +0 -23
- cognite/neat/graph/loader/_asset_loader.py +0 -516
- cognite/neat/graph/loader/_base.py +0 -69
- cognite/neat/graph/loader/_exceptions.py +0 -87
- cognite/neat/graph/loader/core/labels.py +0 -58
- cognite/neat/graph/loader/core/models.py +0 -136
- cognite/neat/graph/loader/core/rdf_to_assets.py +0 -1047
- cognite/neat/graph/loader/core/rdf_to_relationships.py +0 -558
- cognite/neat/graph/loader/rdf_to_dms.py +0 -309
- cognite/neat/graph/loader/validator.py +0 -87
- cognite/neat/graph/models.py +0 -6
- cognite/neat/graph/stores/__init__.py +0 -13
- cognite/neat/graph/stores/_base.py +0 -384
- cognite/neat/graph/stores/_graphdb_store.py +0 -51
- cognite/neat/graph/stores/_memory_store.py +0 -43
- cognite/neat/graph/stores/_oxigraph_store.py +0 -145
- cognite/neat/graph/stores/_oxrdflib.py +0 -247
- cognite/neat/graph/stores/_rdf_to_graph.py +0 -40
- cognite/neat/graph/transformation/entity_matcher.py +0 -101
- cognite/neat/graph/transformation/query_generator/__init__.py +0 -3
- cognite/neat/graph/transformation/query_generator/sparql.py +0 -540
- cognite/neat/graph/transformation/transformer.py +0 -316
- cognite/neat/rules/_analysis/_base.py +0 -25
- cognite/neat/rules/_analysis/_information_rules.py +0 -414
- cognite/neat/rules/_shared.py +0 -5
- cognite/neat/rules/analysis.py +0 -231
- cognite/neat/rules/examples/Rules-Nordic44-to-TNT.xlsx +0 -0
- cognite/neat/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
- cognite/neat/rules/examples/__init__.py +0 -18
- cognite/neat/rules/examples/power-grid-containers.yaml +0 -113
- cognite/neat/rules/examples/power-grid-example.xlsx +0 -0
- cognite/neat/rules/examples/power-grid-model.yaml +0 -213
- cognite/neat/rules/examples/rules-template.xlsx +0 -0
- cognite/neat/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
- cognite/neat/rules/examples/skos-rules.xlsx +0 -0
- cognite/neat/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
- cognite/neat/rules/examples/wind-energy.owl +0 -1511
- cognite/neat/rules/exceptions.py +0 -2972
- cognite/neat/rules/exporter/__init__.py +0 -20
- cognite/neat/rules/exporter/_base.py +0 -45
- cognite/neat/rules/exporter/_core/__init__.py +0 -5
- cognite/neat/rules/exporter/_core/rules2labels.py +0 -24
- cognite/neat/rules/exporter/_rules2dms.py +0 -888
- cognite/neat/rules/exporter/_rules2excel.py +0 -212
- cognite/neat/rules/exporter/_rules2graphql.py +0 -183
- cognite/neat/rules/exporter/_rules2ontology.py +0 -523
- cognite/neat/rules/exporter/_rules2pydantic_models.py +0 -748
- cognite/neat/rules/exporter/_rules2rules.py +0 -104
- cognite/neat/rules/exporter/_rules2triples.py +0 -37
- cognite/neat/rules/exporter/_validation.py +0 -150
- cognite/neat/rules/exporters/__init__.py +0 -15
- cognite/neat/rules/exporters/_base.py +0 -42
- cognite/neat/rules/exporters/_models.py +0 -58
- cognite/neat/rules/exporters/_rules2dms.py +0 -259
- cognite/neat/rules/exporters/_rules2excel.py +0 -196
- cognite/neat/rules/exporters/_rules2ontology.py +0 -561
- cognite/neat/rules/exporters/_rules2yaml.py +0 -78
- cognite/neat/rules/exporters/_validation.py +0 -107
- cognite/neat/rules/importer/__init__.py +0 -22
- cognite/neat/rules/importer/_base.py +0 -70
- cognite/neat/rules/importer/_dict2rules.py +0 -158
- cognite/neat/rules/importer/_dms2rules.py +0 -196
- cognite/neat/rules/importer/_graph2rules.py +0 -304
- cognite/neat/rules/importer/_json2rules.py +0 -39
- cognite/neat/rules/importer/_owl2rules/__init__.py +0 -3
- cognite/neat/rules/importer/_owl2rules/_owl2classes.py +0 -239
- cognite/neat/rules/importer/_owl2rules/_owl2metadata.py +0 -255
- cognite/neat/rules/importer/_owl2rules/_owl2properties.py +0 -217
- cognite/neat/rules/importer/_owl2rules/_owl2rules.py +0 -290
- cognite/neat/rules/importer/_spreadsheet2rules.py +0 -45
- cognite/neat/rules/importer/_xsd2rules.py +0 -20
- cognite/neat/rules/importer/_yaml2rules.py +0 -39
- cognite/neat/rules/importers/__init__.py +0 -16
- cognite/neat/rules/importers/_base.py +0 -124
- cognite/neat/rules/importers/_dms2rules.py +0 -191
- cognite/neat/rules/importers/_dtdl2rules/__init__.py +0 -3
- cognite/neat/rules/importers/_dtdl2rules/_unit_lookup.py +0 -224
- cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +0 -318
- cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +0 -164
- cognite/neat/rules/importers/_dtdl2rules/spec.py +0 -359
- cognite/neat/rules/importers/_owl2rules/__init__.py +0 -3
- cognite/neat/rules/importers/_owl2rules/_owl2classes.py +0 -219
- cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +0 -217
- cognite/neat/rules/importers/_owl2rules/_owl2properties.py +0 -203
- cognite/neat/rules/importers/_owl2rules/_owl2rules.py +0 -148
- cognite/neat/rules/importers/_spreadsheet2rules.py +0 -266
- cognite/neat/rules/importers/_yaml2rules.py +0 -110
- cognite/neat/rules/issues/__init__.py +0 -27
- cognite/neat/rules/issues/base.py +0 -190
- cognite/neat/rules/issues/dms.py +0 -331
- cognite/neat/rules/issues/fileread.py +0 -156
- cognite/neat/rules/issues/importing.py +0 -220
- cognite/neat/rules/issues/spreadsheet.py +0 -381
- cognite/neat/rules/issues/spreadsheet_file.py +0 -151
- cognite/neat/rules/models/__init__.py +0 -5
- cognite/neat/rules/models/_base.py +0 -151
- cognite/neat/rules/models/_rules/__init__.py +0 -14
- cognite/neat/rules/models/_rules/_types/__init__.py +0 -66
- cognite/neat/rules/models/_rules/_types/_base.py +0 -450
- cognite/neat/rules/models/_rules/_types/_field.py +0 -339
- cognite/neat/rules/models/_rules/_types/_value.py +0 -156
- cognite/neat/rules/models/_rules/base.py +0 -320
- cognite/neat/rules/models/_rules/dms_architect_rules.py +0 -1034
- cognite/neat/rules/models/_rules/dms_schema.py +0 -641
- cognite/neat/rules/models/_rules/domain_rules.py +0 -55
- cognite/neat/rules/models/_rules/information_rules.py +0 -525
- cognite/neat/rules/models/raw_rules.py +0 -304
- cognite/neat/rules/models/rdfpath.py +0 -238
- cognite/neat/rules/models/rules.py +0 -1269
- cognite/neat/rules/models/tables.py +0 -9
- cognite/neat/rules/models/value_types.py +0 -117
- cognite/neat/utils/__init__.py +0 -3
- cognite/neat/utils/auxiliary.py +0 -11
- cognite/neat/utils/cdf.py +0 -24
- cognite/neat/utils/cdf_loaders/__init__.py +0 -25
- cognite/neat/utils/cdf_loaders/_base.py +0 -62
- cognite/neat/utils/cdf_loaders/_data_modeling.py +0 -275
- cognite/neat/utils/cdf_loaders/_ingestion.py +0 -152
- cognite/neat/utils/cdf_loaders/data_classes.py +0 -121
- cognite/neat/utils/exceptions.py +0 -41
- cognite/neat/utils/spreadsheet.py +0 -84
- cognite/neat/utils/text.py +0 -104
- cognite/neat/utils/utils.py +0 -354
- cognite/neat/utils/xml.py +0 -37
- cognite/neat/workflows/__init__.py +0 -12
- cognite/neat/workflows/_exceptions.py +0 -41
- cognite/neat/workflows/base.py +0 -574
- cognite/neat/workflows/cdf_store.py +0 -393
- cognite/neat/workflows/examples/Export DMS/workflow.yaml +0 -89
- cognite/neat/workflows/examples/Export Rules to Ontology/workflow.yaml +0 -152
- cognite/neat/workflows/examples/Extract DEXPI Graph and Export Rules/workflow.yaml +0 -139
- cognite/neat/workflows/examples/Extract RDF Graph and Generate Assets/workflow.yaml +0 -270
- cognite/neat/workflows/examples/Import DMS/workflow.yaml +0 -65
- cognite/neat/workflows/examples/Ontology to Data Model/workflow.yaml +0 -116
- cognite/neat/workflows/examples/Validate Rules/workflow.yaml +0 -67
- cognite/neat/workflows/examples/Validate Solution Model/workflow.yaml +0 -64
- cognite/neat/workflows/examples/Visualize Data Model Using Mock Graph/workflow.yaml +0 -95
- cognite/neat/workflows/examples/Visualize Semantic Data Model/workflow.yaml +0 -111
- cognite/neat/workflows/manager.py +0 -309
- cognite/neat/workflows/migration/steps.py +0 -93
- cognite/neat/workflows/migration/wf_manifests.py +0 -33
- cognite/neat/workflows/model.py +0 -202
- cognite/neat/workflows/steps/data_contracts.py +0 -140
- cognite/neat/workflows/steps/lib/__init__.py +0 -7
- cognite/neat/workflows/steps/lib/graph_extractor.py +0 -123
- cognite/neat/workflows/steps/lib/graph_loader.py +0 -68
- cognite/neat/workflows/steps/lib/graph_store.py +0 -139
- cognite/neat/workflows/steps/lib/io_steps.py +0 -393
- cognite/neat/workflows/steps/lib/rules_exporter.py +0 -453
- cognite/neat/workflows/steps/lib/rules_importer.py +0 -171
- cognite/neat/workflows/steps/lib/rules_validator.py +0 -102
- cognite/neat/workflows/steps/lib/v1/__init__.py +0 -7
- cognite/neat/workflows/steps/lib/v1/graph_contextualization.py +0 -82
- cognite/neat/workflows/steps/lib/v1/graph_extractor.py +0 -644
- cognite/neat/workflows/steps/lib/v1/graph_loader.py +0 -606
- cognite/neat/workflows/steps/lib/v1/graph_store.py +0 -278
- cognite/neat/workflows/steps/lib/v1/graph_transformer.py +0 -58
- cognite/neat/workflows/steps/lib/v1/rules_exporter.py +0 -513
- cognite/neat/workflows/steps/lib/v1/rules_importer.py +0 -612
- cognite/neat/workflows/steps/step_model.py +0 -83
- cognite/neat/workflows/steps_registry.py +0 -212
- cognite/neat/workflows/tasks.py +0 -18
- cognite/neat/workflows/triggers.py +0 -169
- cognite/neat/workflows/utils.py +0 -19
- cognite_neat-0.70.1.dist-info/METADATA +0 -212
- cognite_neat-0.70.1.dist-info/RECORD +0 -234
- cognite_neat-0.70.1.dist-info/entry_points.txt +0 -3
- /cognite/neat/{app/api → _data_model}/__init__.py +0 -0
- /cognite/neat/{app/api/data_classes → _data_model/deployer}/__init__.py +0 -0
- /cognite/neat/{app/api/utils → _data_model/exporters/_table_exporter}/__init__.py +0 -0
- /cognite/neat/{app/monitoring → _data_model/importers/_table_importer}/__init__.py +0 -0
- /cognite/neat/{graph/extractors → _data_model/models}/__init__.py +0 -0
- /cognite/neat/{graph/loader/core → _data_model/models/conceptual}/__init__.py +0 -0
- /cognite/neat/{graph/transformation → _data_model/validation}/__init__.py +0 -0
- /cognite/neat/{rules → _session/_html}/__init__.py +0 -0
- /cognite/neat/{rules/_analysis → _session/_usage_analytics}/__init__.py +0 -0
- /cognite/neat/{workflows/migration → _utils}/__init__.py +0 -0
- /cognite/neat/{workflows/steps → v0}/__init__.py +0 -0
- /cognite/neat/{graph → v0/core/_instances}/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/{graph → v0/core/_instances}/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/{graph → v0/core/_instances}/examples/__init__.py +0 -0
- /cognite/neat/{graph → v0/core/_instances}/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- {cognite_neat-0.70.1.dist-info → cognite_neat-0.127.19.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from cognite.neat.v0.core._data_model.models.mapping import load_classic_to_core_mapping
|
|
2
|
+
from cognite.neat.v0.core._data_model.transformers import (
|
|
3
|
+
AsParentPropertyId,
|
|
4
|
+
ChangeViewPrefix,
|
|
5
|
+
IncludeReferenced,
|
|
6
|
+
PhysicalDataModelMapper,
|
|
7
|
+
VerifiedDataModelTransformer,
|
|
8
|
+
)
|
|
9
|
+
from cognite.neat.v0.core._issues import IssueList
|
|
10
|
+
|
|
11
|
+
from ._state import SessionState
|
|
12
|
+
from .exceptions import NeatSessionError, session_class_wrapper
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@session_class_wrapper
|
|
16
|
+
class MappingAPI:
|
|
17
|
+
def __init__(self, state: SessionState):
|
|
18
|
+
self.data_model = DataModelMappingAPI(state)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@session_class_wrapper
|
|
22
|
+
class DataModelMappingAPI:
|
|
23
|
+
def __init__(self, state: SessionState):
|
|
24
|
+
self._state = state
|
|
25
|
+
|
|
26
|
+
def classic_to_core(self, company_prefix: str | None = None, use_parent_property_name: bool = True) -> IssueList:
|
|
27
|
+
"""Map classic types to core types.
|
|
28
|
+
|
|
29
|
+
Note this automatically creates an extended CogniteCore model.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
company_prefix: Prefix used for all extended CogniteCore types.
|
|
33
|
+
use_parent_property_name: Whether to use the parent property name in the extended CogniteCore model.
|
|
34
|
+
See below for more information.
|
|
35
|
+
|
|
36
|
+
If you extend CogniteAsset, with for example, ClassicAsset. You will map the property `parentId` to `parent`.
|
|
37
|
+
If you set `user_parent_property_name` to True, the `parentId` will be renamed to `parent` after the
|
|
38
|
+
mapping is done. If you set it to False, the property will remain `parentId`.
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
```python
|
|
42
|
+
neat.mapping.classic_to_core(company_prefix="WindFarmX", use_parent_property_name=True)
|
|
43
|
+
```
|
|
44
|
+
"""
|
|
45
|
+
if self._state.data_model_store.empty:
|
|
46
|
+
raise NeatSessionError("No data model to map")
|
|
47
|
+
last_entity = self._state.data_model_store.provenance[-1].target_entity
|
|
48
|
+
if last_entity.physical is None:
|
|
49
|
+
raise NeatSessionError("Data model not converted to DMS. Try running `neat.convert('dms')` first.")
|
|
50
|
+
data_model = last_entity.physical
|
|
51
|
+
if self._state.client is None:
|
|
52
|
+
raise NeatSessionError("Client is required to map classic to core")
|
|
53
|
+
|
|
54
|
+
transformers: list[VerifiedDataModelTransformer] = []
|
|
55
|
+
if company_prefix:
|
|
56
|
+
transformers.append(ChangeViewPrefix("Classic", company_prefix))
|
|
57
|
+
transformers.extend(
|
|
58
|
+
[
|
|
59
|
+
PhysicalDataModelMapper(
|
|
60
|
+
load_classic_to_core_mapping(
|
|
61
|
+
company_prefix,
|
|
62
|
+
data_model.metadata.space,
|
|
63
|
+
data_model.metadata.version,
|
|
64
|
+
)
|
|
65
|
+
),
|
|
66
|
+
IncludeReferenced(self._state.client),
|
|
67
|
+
]
|
|
68
|
+
)
|
|
69
|
+
if use_parent_property_name:
|
|
70
|
+
transformers.append(AsParentPropertyId(self._state.client))
|
|
71
|
+
return self._state.data_model_transform(*transformers)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from cognite.neat.v0.core._issues._base import IssueList
|
|
6
|
+
from cognite.neat.v0.core._utils.reader._base import NeatReader
|
|
7
|
+
from cognite.neat.v0.plugins import DataModelImporterPlugin, get_plugin_manager
|
|
8
|
+
from cognite.neat.v0.session._experimental import ExperimentalFlags
|
|
9
|
+
|
|
10
|
+
from ._state import SessionState
|
|
11
|
+
from .exceptions import session_class_wrapper
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@session_class_wrapper
|
|
15
|
+
class PluginAPI:
|
|
16
|
+
"""Read from a data source into NeatSession graph store."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, state: SessionState) -> None:
|
|
19
|
+
self._state = state
|
|
20
|
+
|
|
21
|
+
self.data_model = DataModelPlugins(self._state)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@session_class_wrapper
|
|
25
|
+
class DataModelPlugins:
|
|
26
|
+
"""Read from a data source into NeatSession graph store."""
|
|
27
|
+
|
|
28
|
+
def __init__(self, state: SessionState) -> None:
|
|
29
|
+
self._state = state
|
|
30
|
+
|
|
31
|
+
def read(self, name: str, io: str | Path | None = None, **kwargs: Any) -> IssueList:
|
|
32
|
+
"""Provides access to the external plugins for data model importing.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
name (str): The name of format (e.g. Excel) plugin is handling.
|
|
36
|
+
io (str | Path | None): The input/output interface for the plugin.
|
|
37
|
+
**kwargs (Any): Additional keyword arguments for the plugin.
|
|
38
|
+
|
|
39
|
+
!!! note "kwargs"
|
|
40
|
+
Users must consult the documentation of the plugin to understand
|
|
41
|
+
what keyword arguments are supported.
|
|
42
|
+
"""
|
|
43
|
+
warnings.filterwarnings("default")
|
|
44
|
+
ExperimentalFlags.plugin.warn()
|
|
45
|
+
|
|
46
|
+
# Some plugins may not support the io argument
|
|
47
|
+
if io:
|
|
48
|
+
reader = NeatReader.create(io)
|
|
49
|
+
path = reader.materialize_path()
|
|
50
|
+
else:
|
|
51
|
+
path = None
|
|
52
|
+
|
|
53
|
+
self._state._raise_exception_if_condition_not_met(
|
|
54
|
+
"Data Model Read",
|
|
55
|
+
empty_data_model_store_required=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
plugin_manager = get_plugin_manager()
|
|
59
|
+
plugin = plugin_manager.get(name, DataModelImporterPlugin)
|
|
60
|
+
|
|
61
|
+
print(
|
|
62
|
+
f"You are using an external plugin {plugin.__name__}, which is not developed by the NEAT team."
|
|
63
|
+
"\nUse it at your own risk."
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
return self._state.data_model_import(plugin().configure(io=path, **kwargs))
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
from collections.abc import Callable
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from rdflib import URIRef
|
|
6
|
+
|
|
7
|
+
from cognite.neat.v0.core._data_model.transformers import PrefixEntities, StandardizeNaming
|
|
8
|
+
from cognite.neat.v0.core._data_model.transformers._converters import StandardizeSpaceAndVersion
|
|
9
|
+
from cognite.neat.v0.core._instances.transformers import (
|
|
10
|
+
ConnectionToLiteral,
|
|
11
|
+
ConvertLiteral,
|
|
12
|
+
LiteralToEntity,
|
|
13
|
+
RelationshipAsEdgeTransformer,
|
|
14
|
+
)
|
|
15
|
+
from cognite.neat.v0.core._instances.transformers._rdfpath import MakeConnectionOnExactMatch
|
|
16
|
+
from cognite.neat.v0.core._issues import IssueList
|
|
17
|
+
from cognite.neat.v0.core._issues.errors import NeatValueError
|
|
18
|
+
from cognite.neat.v0.core._utils.text import humanize_collection
|
|
19
|
+
from cognite.neat.v0.session._experimental import ExperimentalFlags
|
|
20
|
+
|
|
21
|
+
from ._state import SessionState
|
|
22
|
+
from .exceptions import NeatSessionError, session_class_wrapper
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@session_class_wrapper
|
|
26
|
+
class PrepareAPI:
|
|
27
|
+
"""Apply various operations on the knowledge graph as a necessary preprocessing step before for instance
|
|
28
|
+
inferring a data model or exporting the knowledge graph to a desired destination.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, state: SessionState, verbose: bool) -> None:
|
|
32
|
+
self._state = state
|
|
33
|
+
self._verbose = verbose
|
|
34
|
+
self.data_model = DataModelPrepareAPI(state, verbose)
|
|
35
|
+
self.instances = InstancePrepareAPI(state, verbose)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@session_class_wrapper
|
|
39
|
+
class InstancePrepareAPI:
|
|
40
|
+
"""Operations to perform on instances of data in the knowledge graph."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, state: SessionState, verbose: bool) -> None:
|
|
43
|
+
self._state = state
|
|
44
|
+
self._verbose = verbose
|
|
45
|
+
|
|
46
|
+
def make_connection_on_exact_match(
|
|
47
|
+
self,
|
|
48
|
+
source: tuple[str, str],
|
|
49
|
+
target: tuple[str, str],
|
|
50
|
+
connection: str | None = None,
|
|
51
|
+
limit: int | None = 100,
|
|
52
|
+
) -> None:
|
|
53
|
+
"""Make connection on exact match.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
source: The source of the connection. A tuple of (type, property) where
|
|
57
|
+
where property is the property that should be matched on the source
|
|
58
|
+
to make the connection with the target.
|
|
59
|
+
target: The target of the connection. A tuple of (type, property) where
|
|
60
|
+
where property is the property that should be matched on the target
|
|
61
|
+
to make the connection with the source.
|
|
62
|
+
|
|
63
|
+
connection: new property to use for the connection. If None, the connection
|
|
64
|
+
will be made by lowercasing the target type.
|
|
65
|
+
limit: The maximum number of connections to make. If None, all connections
|
|
66
|
+
|
|
67
|
+
!!! note "Make Connection on Exact Match"
|
|
68
|
+
This method will make a connection between the source and target based on the exact match:
|
|
69
|
+
(SourceType)-[sourceProperty]->(sourceValue) == (TargetType)-[targetProperty]->(targetValue)
|
|
70
|
+
|
|
71
|
+
The connection will be made by creating a new property on the source type that will contain the
|
|
72
|
+
target value, as follows:
|
|
73
|
+
(SourceType)-[connection]->(TargetType)
|
|
74
|
+
|
|
75
|
+
Example:
|
|
76
|
+
Make connection on exact match:
|
|
77
|
+
```python
|
|
78
|
+
# From an active NeatSession
|
|
79
|
+
neat.read.csv("workitem.Table.csv",
|
|
80
|
+
type = "Activity",
|
|
81
|
+
primary_key="sourceId")
|
|
82
|
+
|
|
83
|
+
neat.read.csv("assets.Table.csv",
|
|
84
|
+
type="Asset",
|
|
85
|
+
primary_key="WMT_TAG_GLOBALID")
|
|
86
|
+
|
|
87
|
+
# Here we specify what column from the source table we should use when we link it with a column in the
|
|
88
|
+
# target table. In this case, it is the "workorderItemname" column in the source table
|
|
89
|
+
source = ("Activity", "workorderItemname")
|
|
90
|
+
|
|
91
|
+
# Here we give a name to the new property that is created when a match between the source and target is
|
|
92
|
+
# found
|
|
93
|
+
connection = "asset"
|
|
94
|
+
|
|
95
|
+
# Here we specify what column from the target table we should use when searching for a match.
|
|
96
|
+
# In this case, it is the "wmtTagName" column in the target table
|
|
97
|
+
target = ("Asset", "wmtTagName")
|
|
98
|
+
|
|
99
|
+
neat.prepare.instances.make_connection_on_exact_match(source, target, connection)
|
|
100
|
+
```
|
|
101
|
+
"""
|
|
102
|
+
try:
|
|
103
|
+
subject_type, subject_predicate = self._get_type_and_property_uris(*source)
|
|
104
|
+
object_type, object_predicate = self._get_type_and_property_uris(*target)
|
|
105
|
+
except NeatValueError as e:
|
|
106
|
+
raise NeatSessionError(f"Cannot make connection: {e}") from None
|
|
107
|
+
|
|
108
|
+
transformer = MakeConnectionOnExactMatch(
|
|
109
|
+
subject_type,
|
|
110
|
+
subject_predicate,
|
|
111
|
+
object_type,
|
|
112
|
+
object_predicate,
|
|
113
|
+
connection,
|
|
114
|
+
limit,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
self._state.instances.store.transform(transformer)
|
|
118
|
+
|
|
119
|
+
def _get_type_and_property_uris(self, type_: str, property_: str) -> tuple[URIRef, URIRef]:
|
|
120
|
+
type_uri = self._state.instances.store.queries.select.type_uri(type_)
|
|
121
|
+
property_uri = self._state.instances.store.queries.select.property_uri(property_)
|
|
122
|
+
|
|
123
|
+
if not type_uri:
|
|
124
|
+
raise NeatValueError(f"Type {type_} does not exist in the graph.")
|
|
125
|
+
elif len(type_uri) > 1:
|
|
126
|
+
raise NeatValueError(f"{type_} has multiple ids found in the graph: {humanize_collection(type_uri)}.")
|
|
127
|
+
|
|
128
|
+
if not property_uri:
|
|
129
|
+
raise NeatValueError(f"Property {property_} does not exist in the graph.")
|
|
130
|
+
elif len(type_uri) > 1:
|
|
131
|
+
raise NeatValueError(
|
|
132
|
+
f"{property_} has multiple ids found in the graph: {humanize_collection(property_uri)}."
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
if not self._state.instances.store.queries.select.type_with_property(type_uri[0], property_uri[0]):
|
|
136
|
+
raise NeatValueError(f"Property {property_} is not defined for type {type_}.")
|
|
137
|
+
return type_uri[0], property_uri[0]
|
|
138
|
+
|
|
139
|
+
def relationships_as_edges(self, min_relationship_types: int = 1, limit_per_type: int | None = None) -> None:
|
|
140
|
+
"""This assumes that you have read a classic CDF knowledge graph including relationships.
|
|
141
|
+
|
|
142
|
+
This method converts relationships into edges in the graph. This is useful as the
|
|
143
|
+
edges will be picked up as part of the schema connected to Assets, Events, Files, Sequences,
|
|
144
|
+
and TimeSeries in the InferenceImporter.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
min_relationship_types: The minimum number of relationship types that must exists to convert those
|
|
148
|
+
relationships to edges. For example, if there is only 5 relationships between Assets and TimeSeries,
|
|
149
|
+
and limit is 10, those relationships will not be converted to edges.
|
|
150
|
+
limit_per_type: The number of conversions to perform per relationship type. For example, if there are 10
|
|
151
|
+
relationships between Assets and TimeSeries, and limit_per_type is 1, only 1 of those relationships
|
|
152
|
+
will be converted to an edge. If None, all relationships will be converted.
|
|
153
|
+
|
|
154
|
+
"""
|
|
155
|
+
transformer = RelationshipAsEdgeTransformer(min_relationship_types, limit_per_type)
|
|
156
|
+
self._state.instances.store.transform(transformer)
|
|
157
|
+
|
|
158
|
+
def convert_data_type(self, source: tuple[str, str], *, convert: Callable[[Any], Any] | None = None) -> None:
|
|
159
|
+
"""Convert the data type of the given property.
|
|
160
|
+
|
|
161
|
+
This is, for example, useful when you have a boolean property that you want to convert to an enum.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
source: The source of the conversion. A tuple of (type, property)
|
|
165
|
+
where property is the property that should be converted.
|
|
166
|
+
convert: The function to use for the conversion. The function should take the value of the property
|
|
167
|
+
as input and return the converted value. Default to assume you have a string that should be
|
|
168
|
+
converted to int, float, bool, or datetime.
|
|
169
|
+
|
|
170
|
+
Example:
|
|
171
|
+
Convert a boolean property to a string:
|
|
172
|
+
```python
|
|
173
|
+
neat.prepare.instances.convert_data_type(
|
|
174
|
+
("TimeSeries", "isString"),
|
|
175
|
+
convert=lambda is_string: "string" if is_string else "numeric"
|
|
176
|
+
)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
"""
|
|
180
|
+
try:
|
|
181
|
+
subject_type, subject_predicate = self._get_type_and_property_uris(*source)
|
|
182
|
+
except NeatValueError as e:
|
|
183
|
+
raise NeatSessionError(f"Cannot convert data type: {e}") from None
|
|
184
|
+
|
|
185
|
+
transformer = ConvertLiteral(subject_type, subject_predicate, convert)
|
|
186
|
+
self._state.instances.store.transform(transformer)
|
|
187
|
+
|
|
188
|
+
def property_to_type(self, source: tuple[str | None, str], type: str, new_property: str | None = None) -> None:
|
|
189
|
+
"""Convert a property to a new type.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
source: The source of the conversion. A tuple of (type, property)
|
|
193
|
+
where property is the property that should be converted.
|
|
194
|
+
You can pass (None, property) to covert all properties with the given name.
|
|
195
|
+
type: The new type of the property.
|
|
196
|
+
new_property: Add the identifier as a new property. If None, the new entity will not have a property.
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
Convert the property 'source' to SourceSystem
|
|
200
|
+
```python
|
|
201
|
+
neat.prepare.instances.property_to_type(
|
|
202
|
+
(None, "source"), "SourceSystem"
|
|
203
|
+
)
|
|
204
|
+
```
|
|
205
|
+
"""
|
|
206
|
+
subject_type: URIRef | None = None
|
|
207
|
+
if source[0] is not None:
|
|
208
|
+
try:
|
|
209
|
+
subject_type, subject_predicate = self._get_type_and_property_uris(*source) # type: ignore[arg-type, assignment]
|
|
210
|
+
except NeatValueError as e:
|
|
211
|
+
raise NeatSessionError(f"Cannot convert to type: {e}") from None
|
|
212
|
+
else:
|
|
213
|
+
subject_predicate = self._state.instances.store.queries.select.property_uri(source[1])[0]
|
|
214
|
+
|
|
215
|
+
transformer = LiteralToEntity(subject_type, subject_predicate, type, new_property)
|
|
216
|
+
self._state.instances.store.transform(transformer)
|
|
217
|
+
|
|
218
|
+
def connection_to_data_type(self, source: tuple[str | None, str]) -> None:
|
|
219
|
+
"""Converts a connection to a data type.
|
|
220
|
+
|
|
221
|
+
Args:
|
|
222
|
+
source: The source of the conversion. A tuple of (type, property)
|
|
223
|
+
where property is the property that should be converted.
|
|
224
|
+
You can pass (None, property) to covert all properties with the given name.
|
|
225
|
+
|
|
226
|
+
Example:
|
|
227
|
+
|
|
228
|
+
Convert all properties 'labels' from a connection to a string:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
neat.prepare.instances.connection_to_data_type(
|
|
232
|
+
(None, "labels")
|
|
233
|
+
)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
"""
|
|
237
|
+
subject_type: URIRef | None = None
|
|
238
|
+
if source[0] is not None:
|
|
239
|
+
try:
|
|
240
|
+
subject_type, subject_predicate = self._get_type_and_property_uris(*source) # type: ignore[arg-type, assignment]
|
|
241
|
+
except NeatValueError as e:
|
|
242
|
+
raise NeatSessionError(f"Cannot convert to data type: {e}") from None
|
|
243
|
+
else:
|
|
244
|
+
subject_predicate = self._state.instances.store.queries.select.property_uri(source[1])[0]
|
|
245
|
+
transformer = ConnectionToLiteral(subject_type, subject_predicate)
|
|
246
|
+
self._state.instances.store.transform(transformer)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@session_class_wrapper
|
|
250
|
+
class DataModelPrepareAPI:
|
|
251
|
+
"""Operations to perform on a data model as part of a workflow before writing the data model
|
|
252
|
+
to a desired destination.
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
def __init__(self, state: SessionState, verbose: bool) -> None:
|
|
256
|
+
self._state = state
|
|
257
|
+
self._verbose = verbose
|
|
258
|
+
|
|
259
|
+
def prefix(self, prefix: str) -> IssueList:
|
|
260
|
+
"""Prefix all views in the data model with the given prefix.
|
|
261
|
+
|
|
262
|
+
Args:
|
|
263
|
+
prefix: The prefix to add to the views in the data model.
|
|
264
|
+
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
return self._state.data_model_transform(PrefixEntities(prefix)) # type: ignore[arg-type]
|
|
268
|
+
|
|
269
|
+
def standardize_naming(self) -> IssueList:
|
|
270
|
+
"""Standardize the naming of all views/classes/properties in the data model.
|
|
271
|
+
|
|
272
|
+
For classes/views/containers, the naming will be standardized to PascalCase.
|
|
273
|
+
For properties, the naming will be standardized to camelCase.
|
|
274
|
+
"""
|
|
275
|
+
warnings.filterwarnings("default")
|
|
276
|
+
ExperimentalFlags.standardize_naming.warn()
|
|
277
|
+
return self._state.data_model_transform(StandardizeNaming())
|
|
278
|
+
|
|
279
|
+
def standardize_space_and_version(self) -> IssueList:
|
|
280
|
+
"""Standardize space and version in the data model.
|
|
281
|
+
|
|
282
|
+
This method will standardize the space and version in the data model to the Cognite standard.
|
|
283
|
+
"""
|
|
284
|
+
warnings.filterwarnings("default")
|
|
285
|
+
ExperimentalFlags.standardize_space_and_version.warn()
|
|
286
|
+
return self._state.data_model_transform(StandardizeSpaceAndVersion())
|