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,83 @@
|
|
|
1
|
+
from typing import Any, ClassVar
|
|
2
|
+
|
|
3
|
+
from pydantic import (
|
|
4
|
+
BaseModel,
|
|
5
|
+
model_serializer,
|
|
6
|
+
model_validator,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from cognite.neat.v0.core._data_model._constants import EntityTypes
|
|
10
|
+
from cognite.neat.v0.core._data_model.models.data_types import DataType
|
|
11
|
+
|
|
12
|
+
from ._constants import _PARSE, Undefined
|
|
13
|
+
from ._single_value import ConceptEntity, UnknownEntity
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MultiValueTypeInfo(BaseModel):
|
|
17
|
+
type_: ClassVar[EntityTypes] = EntityTypes.multi_value_type
|
|
18
|
+
types: list[DataType | ConceptEntity]
|
|
19
|
+
|
|
20
|
+
def __str__(self) -> str:
|
|
21
|
+
return ", ".join([str(t) for t in self.types])
|
|
22
|
+
|
|
23
|
+
@model_serializer(when_used="unless-none", return_type=str)
|
|
24
|
+
def as_str(self) -> str:
|
|
25
|
+
return str(self)
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def load(cls, data: Any) -> "MultiValueTypeInfo":
|
|
29
|
+
# already instance of MultiValueTypeInfo
|
|
30
|
+
if isinstance(data, cls):
|
|
31
|
+
return data
|
|
32
|
+
|
|
33
|
+
# it is a raw string that needs to be parsed
|
|
34
|
+
elif isinstance(data, str):
|
|
35
|
+
return cls.model_validate({_PARSE: data})
|
|
36
|
+
|
|
37
|
+
# it is dict that needs to be parsed
|
|
38
|
+
else:
|
|
39
|
+
return cls.model_validate(data)
|
|
40
|
+
|
|
41
|
+
@model_validator(mode="before")
|
|
42
|
+
def _load(cls, data: Any) -> "dict | MultiValueTypeInfo":
|
|
43
|
+
if isinstance(data, dict) and _PARSE in data:
|
|
44
|
+
data = data[_PARSE]
|
|
45
|
+
elif isinstance(data, dict):
|
|
46
|
+
return data
|
|
47
|
+
else:
|
|
48
|
+
raise ValueError(f"Cannot load {cls.__name__} from {data}")
|
|
49
|
+
|
|
50
|
+
result = cls._parse(data)
|
|
51
|
+
return result
|
|
52
|
+
|
|
53
|
+
@classmethod
|
|
54
|
+
def _parse(cls, raw: str) -> dict:
|
|
55
|
+
if not (types := [type_.strip() for type_ in raw.split(",")]):
|
|
56
|
+
return {"types": [UnknownEntity()]}
|
|
57
|
+
else:
|
|
58
|
+
return {
|
|
59
|
+
"types": [
|
|
60
|
+
(DataType.load(type_) if DataType.is_data_type(type_) else ConceptEntity.load(type_))
|
|
61
|
+
for type_ in types
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
def set_default_prefix(self, prefix: str) -> None:
|
|
66
|
+
for type_ in self.types:
|
|
67
|
+
if isinstance(type_, ConceptEntity) and type_.prefix is Undefined:
|
|
68
|
+
type_.prefix = prefix
|
|
69
|
+
|
|
70
|
+
def is_multi_object_type(self) -> bool:
|
|
71
|
+
"""Will signalize to DMS converter to create connection to unknown Node type"""
|
|
72
|
+
return all(isinstance(t, ConceptEntity) for t in self.types)
|
|
73
|
+
|
|
74
|
+
def is_multi_data_type(self) -> bool:
|
|
75
|
+
"""Will signalize to DMS converter to attempt to find the best data type for value"""
|
|
76
|
+
return all(isinstance(t, DataType) for t in self.types)
|
|
77
|
+
|
|
78
|
+
def is_mixed_type(self) -> bool:
|
|
79
|
+
"""Will signalize to DMS converter to fall back to string"""
|
|
80
|
+
return not self.is_multi_object_type() and not self.is_multi_data_type()
|
|
81
|
+
|
|
82
|
+
def __hash__(self) -> int:
|
|
83
|
+
return hash(str(self))
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
from abc import ABC
|
|
4
|
+
from typing import Any, ClassVar, Final, Literal, TypeVar, cast, get_args
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
|
7
|
+
from rdflib import Literal as RDFLiteral
|
|
8
|
+
from rdflib import URIRef
|
|
9
|
+
|
|
10
|
+
from cognite.neat.v0.core._data_model._constants import EntityTypes
|
|
11
|
+
from cognite.neat.v0.core._data_model.models.data_types import _XSD_TYPES, DataType
|
|
12
|
+
from cognite.neat.v0.core._data_model.models.entities._constants import _PARSE
|
|
13
|
+
from cognite.neat.v0.core._data_model.models.entities._single_value import ConceptEntity, ConceptualEntity
|
|
14
|
+
from cognite.neat.v0.core._issues.errors._general import NeatValueError
|
|
15
|
+
from cognite.neat.v0.core._utils.rdf_ import remove_namespace_from_uri
|
|
16
|
+
|
|
17
|
+
if sys.version_info <= (3, 11):
|
|
18
|
+
from typing_extensions import Self
|
|
19
|
+
else:
|
|
20
|
+
from typing import Self
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
ValueConstraints = Literal["allValuesFrom", "someValuesFrom", "hasValue"]
|
|
24
|
+
CardinalityConstraints = Literal["minCardinality", "maxCardinality", "cardinality", "qualifiedCardinality"]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# Constants for regex patterns - more maintainable
|
|
28
|
+
PROPERTY_PATTERN: Final[str] = r"[a-zA-Z0-9._~?@!$&'*+,;=%-]+"
|
|
29
|
+
VALUE_PATTERN: Final[str] = r".+"
|
|
30
|
+
CARDINALITY_VALUE_PATTERN: Final[str] = r"\d+"
|
|
31
|
+
ON_PATTERN: Final[str] = r"[^(]*"
|
|
32
|
+
|
|
33
|
+
VALUE_CONSTRAINT_REGEX = re.compile(
|
|
34
|
+
rf"^{EntityTypes.value_constraint}:(?P<property>{PROPERTY_PATTERN})\((?P<constraint>{'|'.join(get_args(ValueConstraints))}),(?P<value>{VALUE_PATTERN})\)$"
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
CARDINALITY_CONSTRAINT_REGEX = re.compile(
|
|
38
|
+
rf"^{EntityTypes.cardinality_constraint}:(?P<property>{PROPERTY_PATTERN})\((?P<constraint>{'|'.join(get_args(CardinalityConstraints))}),(?P<value>{CARDINALITY_VALUE_PATTERN})(?:,(?P<on>{ON_PATTERN}))?\)$"
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class NamedIndividualEntity(ConceptualEntity):
|
|
43
|
+
type_: ClassVar[EntityTypes] = EntityTypes.named_individual
|
|
44
|
+
|
|
45
|
+
@model_validator(mode="after")
|
|
46
|
+
def reset_prefix(self) -> Self:
|
|
47
|
+
self.prefix = "ni"
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ConceptPropertyRestriction(ABC, BaseModel):
|
|
52
|
+
model_config: ClassVar[ConfigDict] = ConfigDict(
|
|
53
|
+
str_strip_whitespace=True,
|
|
54
|
+
arbitrary_types_allowed=True,
|
|
55
|
+
strict=False,
|
|
56
|
+
extra="ignore",
|
|
57
|
+
)
|
|
58
|
+
type_: ClassVar[EntityTypes] = EntityTypes.concept_restriction
|
|
59
|
+
property_: str
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def load(cls: "type[T_ConceptPropertyRestriction]", data: Any, **defaults: Any) -> "T_ConceptPropertyRestriction":
|
|
63
|
+
if isinstance(data, cls):
|
|
64
|
+
return data
|
|
65
|
+
elif not isinstance(data, str):
|
|
66
|
+
raise ValueError(f"Cannot load {cls.__name__} from {data}")
|
|
67
|
+
|
|
68
|
+
return cls.model_validate({_PARSE: data, "defaults": defaults})
|
|
69
|
+
|
|
70
|
+
@model_validator(mode="before")
|
|
71
|
+
def _load(cls, data: Any) -> dict:
|
|
72
|
+
defaults = {}
|
|
73
|
+
if isinstance(data, dict) and _PARSE in data:
|
|
74
|
+
defaults = data.get("defaults", {})
|
|
75
|
+
data = data[_PARSE]
|
|
76
|
+
if isinstance(data, dict):
|
|
77
|
+
data.update(defaults)
|
|
78
|
+
return data
|
|
79
|
+
|
|
80
|
+
if not isinstance(data, str):
|
|
81
|
+
raise ValueError(f"Cannot load {cls.__name__} from {data}")
|
|
82
|
+
|
|
83
|
+
return cls._parse(data, defaults)
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def _parse(cls, data: str, defaults: dict) -> dict:
|
|
87
|
+
raise NotImplementedError(f"{cls.__name__} must implement _parse method")
|
|
88
|
+
|
|
89
|
+
def dump(self) -> str:
|
|
90
|
+
return self.__str__()
|
|
91
|
+
|
|
92
|
+
def as_tuple(self) -> tuple[str, ...]:
|
|
93
|
+
# We haver overwritten the serialization to str, so we need to do it manually
|
|
94
|
+
extra: tuple[str, ...] = tuple(
|
|
95
|
+
[
|
|
96
|
+
str(v or "")
|
|
97
|
+
for field_name in self.model_fields.keys()
|
|
98
|
+
if (v := getattr(self, field_name)) and field_name not in {"property_"}
|
|
99
|
+
]
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
return self.property_, *extra
|
|
103
|
+
|
|
104
|
+
def __lt__(self, other: object) -> bool:
|
|
105
|
+
if not isinstance(other, ConceptPropertyRestriction):
|
|
106
|
+
return NotImplemented
|
|
107
|
+
return self.as_tuple() < other.as_tuple()
|
|
108
|
+
|
|
109
|
+
def __eq__(self, other: object) -> bool:
|
|
110
|
+
if not isinstance(other, ConceptPropertyRestriction):
|
|
111
|
+
return NotImplemented
|
|
112
|
+
return self.as_tuple() == other.as_tuple()
|
|
113
|
+
|
|
114
|
+
def __hash__(self) -> int:
|
|
115
|
+
return hash(str(self))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
T_ConceptPropertyRestriction = TypeVar("T_ConceptPropertyRestriction", bound="ConceptPropertyRestriction")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class ConceptPropertyValueConstraint(ConceptPropertyRestriction):
|
|
122
|
+
type_: ClassVar[EntityTypes] = EntityTypes.value_constraint
|
|
123
|
+
constraint: ValueConstraints
|
|
124
|
+
value: RDFLiteral | ConceptEntity | NamedIndividualEntity
|
|
125
|
+
|
|
126
|
+
@field_validator("value")
|
|
127
|
+
def validate_value(cls, value: Any) -> Any:
|
|
128
|
+
if isinstance(value, RDFLiteral) and value.datatype is None:
|
|
129
|
+
raise NeatValueError("RDFLiteral must have a datatype set, which must be one of the XSD types.")
|
|
130
|
+
return value
|
|
131
|
+
|
|
132
|
+
def __str__(self) -> str:
|
|
133
|
+
value_str = (
|
|
134
|
+
f"{self.value.value}^^{remove_namespace_from_uri(cast(URIRef, self.value.datatype))}"
|
|
135
|
+
if isinstance(self.value, RDFLiteral)
|
|
136
|
+
else str(self.value)
|
|
137
|
+
)
|
|
138
|
+
return f"{self.type_}:{self.property_}({self.constraint},{value_str})"
|
|
139
|
+
|
|
140
|
+
@classmethod
|
|
141
|
+
def _parse(cls, data: str, defaults: dict) -> dict:
|
|
142
|
+
if not (result := VALUE_CONSTRAINT_REGEX.match(data)):
|
|
143
|
+
raise NeatValueError(f"Invalid value constraint format: {data}")
|
|
144
|
+
|
|
145
|
+
property_ = result.group("property")
|
|
146
|
+
constraint = result.group("constraint")
|
|
147
|
+
raw_value = result.group("value")
|
|
148
|
+
|
|
149
|
+
value: NamedIndividualEntity | RDFLiteral | ConceptEntity
|
|
150
|
+
# scenario 1: NamedIndividual as value restriction
|
|
151
|
+
if raw_value.startswith("ni:"):
|
|
152
|
+
value = NamedIndividualEntity.load(raw_value)
|
|
153
|
+
# scenario 2: Datatype as value restriction
|
|
154
|
+
elif "^^" in raw_value:
|
|
155
|
+
if len(value_components := raw_value.split("^^")) == 2 and value_components[1] in _XSD_TYPES:
|
|
156
|
+
value = RDFLiteral(value_components[0], datatype=DataType.load(value_components[1]).as_xml_uri_ref())
|
|
157
|
+
else:
|
|
158
|
+
raise NeatValueError(f"Invalid value format for datatype: {raw_value}")
|
|
159
|
+
|
|
160
|
+
# scenario 3: ConceptEntity as value restriction
|
|
161
|
+
else:
|
|
162
|
+
value = ConceptEntity.load(raw_value, **defaults)
|
|
163
|
+
|
|
164
|
+
return dict(property_=property_, constraint=constraint, value=value)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
class ConceptPropertyCardinalityConstraint(ConceptPropertyRestriction):
|
|
168
|
+
type_: ClassVar[EntityTypes] = EntityTypes.cardinality_constraint
|
|
169
|
+
constraint: CardinalityConstraints
|
|
170
|
+
value: int = Field(ge=0)
|
|
171
|
+
on: DataType | ConceptEntity | None = None
|
|
172
|
+
|
|
173
|
+
def __str__(self) -> str:
|
|
174
|
+
on_str = f",{self.on}" if self.on else ""
|
|
175
|
+
return f"{self.type_}:{self.property_}({self.constraint},{self.value}{on_str})"
|
|
176
|
+
|
|
177
|
+
@classmethod
|
|
178
|
+
def _parse(cls, data: str, defaults: dict) -> dict:
|
|
179
|
+
if not (result := CARDINALITY_CONSTRAINT_REGEX.match(data)):
|
|
180
|
+
raise NeatValueError(f"Invalid cardinality constraint format: {data}")
|
|
181
|
+
|
|
182
|
+
property_ = result.group("property")
|
|
183
|
+
constraint = result.group("constraint")
|
|
184
|
+
value = result.group("value")
|
|
185
|
+
on = result.group("on")
|
|
186
|
+
if on:
|
|
187
|
+
if on in _XSD_TYPES:
|
|
188
|
+
on = DataType.load(on)
|
|
189
|
+
else:
|
|
190
|
+
on = cast(ConceptEntity, ConceptEntity.load(on, **defaults))
|
|
191
|
+
|
|
192
|
+
return dict(property_=property_, constraint=constraint, value=value, on=on)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def parse_restriction(data: str, **defaults: Any) -> ConceptPropertyRestriction:
|
|
196
|
+
"""Parse a string to create either a value or cardinality restriction.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
data: String representation of the restriction
|
|
200
|
+
**defaults: Default values to use when parsing
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Either a ConceptPropertyValueConstraint or ConceptPropertyCardinalityConstraint
|
|
204
|
+
|
|
205
|
+
Raises:
|
|
206
|
+
NeatValueError: If the string cannot be parsed as either restriction type
|
|
207
|
+
"""
|
|
208
|
+
# Check for value constraint pattern first (more specific)
|
|
209
|
+
if VALUE_CONSTRAINT_REGEX.match(data):
|
|
210
|
+
try:
|
|
211
|
+
return ConceptPropertyValueConstraint.load(data, **defaults)
|
|
212
|
+
except Exception as e:
|
|
213
|
+
raise NeatValueError(f"Failed to parse value constraint: {data}") from e
|
|
214
|
+
|
|
215
|
+
# Check for cardinality constraint pattern
|
|
216
|
+
if CARDINALITY_CONSTRAINT_REGEX.match(data):
|
|
217
|
+
try:
|
|
218
|
+
return ConceptPropertyCardinalityConstraint.load(data, **defaults)
|
|
219
|
+
except Exception as e:
|
|
220
|
+
raise NeatValueError(f"Failed to parse cardinality constraint: {data}") from e
|
|
221
|
+
|
|
222
|
+
# If neither pattern matches, provide a clear error
|
|
223
|
+
raise NeatValueError(
|
|
224
|
+
f"Invalid restriction format: {data}. "
|
|
225
|
+
f"Expected format: '{EntityTypes.value_constraint}:property(constraint,value)' "
|
|
226
|
+
f"or '{EntityTypes.cardinality_constraint}:property(constraint,value[,on])'"
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
T_ConceptRestriction = TypeVar("T_ConceptRestriction", bound=ConceptPropertyRestriction)
|