cognite-neat 0.92.3__py3-none-any.whl → 0.93.0__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.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- cognite/neat/__init__.py +3 -2
- cognite/neat/{app → _app}/api/configuration.py +9 -7
- cognite/neat/_app/api/context_manager/__init__.py +3 -0
- cognite/neat/{app → _app}/api/context_manager/manager.py +1 -1
- cognite/neat/{app → _app}/api/explorer.py +5 -5
- cognite/neat/{app → _app}/api/routers/configuration.py +2 -2
- cognite/neat/{app → _app}/api/routers/crud.py +4 -4
- cognite/neat/{app → _app}/api/routers/workflows.py +7 -7
- cognite/neat/{app → _app}/main.py +1 -1
- cognite/neat/_app/ui/neat-app/package-lock.json +18306 -0
- cognite/neat/_app/ui/neat-app/package.json +62 -0
- cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
- cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +116 -0
- cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +112 -0
- cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +34 -0
- cognite/neat/_app/ui/neat-app/public/index.html +43 -0
- cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
- cognite/neat/_app/ui/neat-app/public/manifest.json +25 -0
- cognite/neat/_app/ui/neat-app/public/robots.txt +3 -0
- cognite/neat/_app/ui/neat-app/src/App.css +38 -0
- cognite/neat/_app/ui/neat-app/src/App.js +17 -0
- cognite/neat/_app/ui/neat-app/src/App.test.js +8 -0
- cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +70 -0
- cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +43 -0
- cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +124 -0
- cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +63 -0
- cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +511 -0
- cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +36 -0
- cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +56 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +60 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +112 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +67 -0
- cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +79 -0
- cognite/neat/_app/ui/neat-app/src/index.css +13 -0
- cognite/neat/_app/ui/neat-app/src/index.js +13 -0
- cognite/neat/_app/ui/neat-app/src/logo.svg +1 -0
- cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +13 -0
- cognite/neat/_app/ui/neat-app/src/setupTests.js +5 -0
- cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +388 -0
- cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +61 -0
- cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +184 -0
- cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +180 -0
- cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +570 -0
- cognite/neat/_app/ui/neat-app/tsconfig.json +27 -0
- cognite/neat/{config.py → _config.py} +3 -3
- cognite/neat/{constants.py → _constants.py} +13 -5
- cognite/neat/_graph/_shared.py +34 -0
- cognite/neat/{graph → _graph}/_tracking/base.py +1 -1
- cognite/neat/{graph → _graph}/_tracking/log.py +1 -1
- cognite/neat/{graph → _graph}/extractors/__init__.py +5 -0
- cognite/neat/{graph → _graph}/extractors/_base.py +2 -2
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_assets.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_base.py +4 -4
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_classic.py +5 -5
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_data_sets.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_events.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_files.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_labels.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_relationships.py +2 -2
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_sequences.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_classic_cdf/_timeseries.py +1 -1
- cognite/neat/{graph → _graph}/extractors/_dexpi.py +5 -5
- cognite/neat/{graph → _graph}/extractors/_dms.py +3 -3
- cognite/neat/_graph/extractors/_iodd.py +402 -0
- cognite/neat/{graph → _graph}/extractors/_mock_graph_generator.py +9 -8
- cognite/neat/_graph/extractors/_rdf_file.py +49 -0
- cognite/neat/{graph → _graph}/loaders/_base.py +5 -5
- cognite/neat/{graph → _graph}/loaders/_rdf2asset.py +11 -10
- cognite/neat/{graph → _graph}/loaders/_rdf2dms.py +10 -10
- cognite/neat/{graph → _graph}/queries/_base.py +91 -19
- cognite/neat/{graph → _graph}/queries/_construct.py +5 -5
- cognite/neat/{graph → _graph}/queries/_shared.py +3 -3
- cognite/neat/{graph → _graph}/transformers/__init__.py +6 -0
- cognite/neat/{graph → _graph}/transformers/_classic_cdf.py +135 -3
- cognite/neat/_graph/transformers/_iodd.py +25 -0
- cognite/neat/_graph/transformers/_prune_graph.py +126 -0
- cognite/neat/{graph → _graph}/transformers/_rdfpath.py +3 -3
- cognite/neat/_graph/transformers/_value_type.py +66 -0
- cognite/neat/{issues → _issues}/_base.py +32 -17
- cognite/neat/{issues → _issues}/errors/__init__.py +1 -1
- cognite/neat/{issues → _issues}/errors/_external.py +8 -8
- cognite/neat/{issues → _issues}/errors/_general.py +5 -5
- cognite/neat/{issues → _issues}/errors/_properties.py +7 -7
- cognite/neat/{issues → _issues}/errors/_resources.py +11 -11
- cognite/neat/{issues → _issues}/errors/_workflow.py +5 -5
- cognite/neat/{issues → _issues}/warnings/__init__.py +1 -1
- cognite/neat/{issues → _issues}/warnings/_external.py +5 -5
- cognite/neat/{issues → _issues}/warnings/_general.py +4 -4
- cognite/neat/{issues → _issues}/warnings/_models.py +10 -10
- cognite/neat/{issues → _issues}/warnings/_properties.py +6 -6
- cognite/neat/{issues → _issues}/warnings/_resources.py +5 -5
- cognite/neat/{issues → _issues}/warnings/user_modeling.py +9 -9
- cognite/neat/_rules/_constants.py +190 -0
- cognite/neat/{rules → _rules}/_shared.py +5 -5
- cognite/neat/_rules/analysis/__init__.py +5 -0
- cognite/neat/{rules → _rules}/analysis/_asset.py +5 -5
- cognite/neat/{rules → _rules}/analysis/_base.py +5 -5
- cognite/neat/_rules/analysis/_dms.py +43 -0
- cognite/neat/{rules → _rules}/analysis/_information.py +12 -6
- cognite/neat/_rules/catalog/__init__.py +6 -0
- cognite/neat/_rules/catalog/info-rules-imf.xlsx +0 -0
- cognite/neat/{rules → _rules}/exporters/__init__.py +2 -0
- cognite/neat/{rules → _rules}/exporters/_base.py +3 -3
- cognite/neat/{rules → _rules}/exporters/_rules2dms.py +5 -5
- cognite/neat/{rules → _rules}/exporters/_rules2excel.py +12 -8
- cognite/neat/_rules/exporters/_rules2instance_template.py +152 -0
- cognite/neat/{rules → _rules}/exporters/_rules2ontology.py +10 -9
- cognite/neat/{rules → _rules}/exporters/_rules2yaml.py +1 -3
- cognite/neat/{rules → _rules}/exporters/_validation.py +2 -2
- cognite/neat/{rules → _rules}/importers/_base.py +3 -3
- cognite/neat/{rules → _rules}/importers/_dms2rules.py +9 -9
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/dtdl_converter.py +7 -7
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/dtdl_importer.py +9 -9
- cognite/neat/{rules → _rules}/importers/_dtdl2rules/spec.py +1 -1
- cognite/neat/_rules/importers/_rdf/_base.py +144 -0
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2classes.py +1 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2metadata.py +4 -4
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2properties.py +2 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/_imf2rules.py +8 -39
- cognite/neat/{rules → _rules}/importers/_rdf/_inference2rules.py +33 -106
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2classes.py +1 -1
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2metadata.py +5 -5
- cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/_owl2properties.py +1 -1
- cognite/neat/_rules/importers/_rdf/_owl2rules/_owl2rules.py +39 -0
- cognite/neat/{rules → _rules}/importers/_rdf/_shared.py +4 -4
- cognite/neat/{rules → _rules}/importers/_spreadsheet2rules.py +7 -7
- cognite/neat/{rules → _rules}/importers/_yaml2rules.py +5 -5
- cognite/neat/{rules → _rules}/models/__init__.py +5 -5
- cognite/neat/{rules → _rules}/models/_base_input.py +15 -6
- cognite/neat/{rules → _rules}/models/_base_rules.py +14 -2
- cognite/neat/{rules → _rules}/models/_rdfpath.py +1 -1
- cognite/neat/_rules/models/_types.py +151 -0
- cognite/neat/{rules → _rules}/models/asset/_rules.py +4 -4
- cognite/neat/{rules → _rules}/models/asset/_rules_input.py +4 -4
- cognite/neat/{rules → _rules}/models/asset/_validation.py +7 -7
- cognite/neat/{rules → _rules}/models/data_types.py +15 -12
- cognite/neat/{rules → _rules}/models/dms/_exporter.py +60 -12
- cognite/neat/{rules → _rules}/models/dms/_rules.py +26 -23
- cognite/neat/{rules → _rules}/models/dms/_rules_input.py +4 -4
- cognite/neat/{rules → _rules}/models/dms/_schema.py +15 -14
- cognite/neat/{rules → _rules}/models/dms/_validation.py +8 -8
- cognite/neat/{rules → _rules}/models/domain.py +6 -6
- cognite/neat/{rules → _rules}/models/entities/__init__.py +1 -2
- cognite/neat/_rules/models/entities/_constants.py +15 -0
- cognite/neat/{rules → _rules}/models/entities/_loaders.py +2 -2
- cognite/neat/{rules → _rules}/models/entities/_multi_value.py +15 -2
- cognite/neat/{rules → _rules}/models/entities/_single_value.py +7 -4
- cognite/neat/{rules → _rules}/models/information/_rules.py +34 -22
- cognite/neat/{rules → _rules}/models/information/_rules_input.py +3 -3
- cognite/neat/{rules → _rules}/models/information/_validation.py +6 -5
- cognite/neat/_rules/models/mapping/__init__.py +4 -0
- cognite/neat/_rules/models/mapping/_base.py +131 -0
- cognite/neat/_rules/models/mapping/_classic2core.py +150 -0
- cognite/neat/{rules → _rules}/transformers/__init__.py +15 -2
- cognite/neat/{rules → _rules}/transformers/_base.py +3 -3
- cognite/neat/{rules → _rules}/transformers/_converters.py +289 -20
- cognite/neat/{rules/transformers/_map_onto.py → _rules/transformers/_mapping.py} +46 -4
- cognite/neat/{rules → _rules}/transformers/_pipelines.py +4 -4
- cognite/neat/{rules → _rules}/transformers/_verification.py +10 -4
- cognite/neat/_session/__init__.py +3 -0
- cognite/neat/_session/_base.py +86 -0
- cognite/neat/_session/_prepare.py +61 -0
- cognite/neat/_session/_read.py +118 -0
- cognite/neat/_session/_show.py +96 -0
- cognite/neat/_session/_state.py +69 -0
- cognite/neat/_session/_to.py +70 -0
- cognite/neat/_session/_wizard.py +39 -0
- cognite/neat/_session/exceptions.py +42 -0
- cognite/neat/{store → _store}/_base.py +63 -32
- cognite/neat/{store → _store}/_provenance.py +11 -1
- cognite/neat/{utils → _utils}/auth.py +14 -3
- cognite/neat/{utils → _utils}/auxiliary.py +1 -1
- cognite/neat/{utils → _utils}/cdf/loaders/_data_modeling.py +8 -2
- cognite/neat/{utils → _utils}/cdf/loaders/_ingestion.py +1 -1
- cognite/neat/{utils → _utils}/upload.py +1 -1
- cognite/neat/_version.py +1 -1
- cognite/neat/_workflows/__init__.py +17 -0
- cognite/neat/{workflows → _workflows}/base.py +10 -10
- cognite/neat/{workflows → _workflows}/cdf_store.py +3 -3
- cognite/neat/{workflows → _workflows}/examples/Export_DMS/workflow.yaml +89 -89
- cognite/neat/{workflows → _workflows}/manager.py +6 -6
- cognite/neat/{workflows → _workflows}/steps/data_contracts.py +3 -3
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_extractor.py +8 -31
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_loader.py +4 -4
- cognite/neat/{workflows → _workflows}/steps/lib/current/graph_store.py +4 -4
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_exporter.py +8 -8
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_importer.py +13 -13
- cognite/neat/{workflows → _workflows}/steps/lib/current/rules_validator.py +8 -8
- cognite/neat/{workflows → _workflows}/steps/lib/io/io_steps.py +3 -3
- cognite/neat/{workflows → _workflows}/steps/step_model.py +3 -3
- cognite/neat/{workflows → _workflows}/steps_registry.py +9 -9
- cognite/neat/{workflows → _workflows}/tasks.py +1 -1
- cognite/neat/{workflows → _workflows}/triggers.py +2 -2
- {cognite_neat-0.92.3.dist-info → cognite_neat-0.93.0.dist-info}/METADATA +6 -2
- cognite_neat-0.93.0.dist-info/RECORD +276 -0
- {cognite_neat-0.92.3.dist-info → cognite_neat-0.93.0.dist-info}/WHEEL +1 -1
- cognite_neat-0.93.0.dist-info/entry_points.txt +3 -0
- cognite/neat/app/api/context_manager/__init__.py +0 -3
- cognite/neat/graph/_shared.py +0 -5
- cognite/neat/graph/extractors/_iodd.py +0 -160
- cognite/neat/graph/extractors/_rdf_file.py +0 -26
- cognite/neat/rules/analysis/__init__.py +0 -6
- cognite/neat/rules/examples/__init__.py +0 -10
- cognite/neat/rules/examples/info-rules-imf.xlsx +0 -0
- cognite/neat/rules/examples/wind-energy.owl +0 -1511
- cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py +0 -65
- cognite/neat/rules/models/_types.py +0 -96
- cognite/neat/rules/models/entities/_constants.py +0 -73
- cognite/neat/utils/regex_patterns.py +0 -58
- cognite/neat/workflows/__init__.py +0 -12
- cognite_neat-0.92.3.dist-info/RECORD +0 -224
- cognite_neat-0.92.3.dist-info/entry_points.txt +0 -3
- /cognite/neat/{app → _app}/api/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/asgi/metrics.py +0 -0
- /cognite/neat/{app → _app}/api/data_classes/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/data_classes/rest.py +0 -0
- /cognite/neat/{app → _app}/api/routers/metrics.py +0 -0
- /cognite/neat/{app → _app}/api/utils/__init__.py +0 -0
- /cognite/neat/{app → _app}/api/utils/data_mapping.py +0 -0
- /cognite/neat/{app → _app}/api/utils/logging.py +0 -0
- /cognite/neat/{app → _app}/api/utils/query_templates.py +0 -0
- /cognite/neat/{app → _app}/monitoring/__init__.py +0 -0
- /cognite/neat/{app → _app}/monitoring/metrics.py +0 -0
- /cognite/neat/{app → _app}/ui/index.html +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/.gitignore +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/README.md +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/asset-manifest.json +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/favicon.ico +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/architect-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/developer-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/img/sme-icon.svg +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/index.html +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/logo192.png +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/manifest.json +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/robots.txt +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/css/main.72e3d92e.css +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -0
- /cognite/neat/{app → _app}/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -0
- /cognite/neat/{graph → _graph}/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/_tracking/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -0
- /cognite/neat/{graph → _graph}/examples/Knowledge-Graph-Nordic44.xml +0 -0
- /cognite/neat/{graph → _graph}/examples/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
- /cognite/neat/{graph → _graph}/extractors/_classic_cdf/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/loaders/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/models.py +0 -0
- /cognite/neat/{graph → _graph}/queries/__init__.py +0 -0
- /cognite/neat/{graph → _graph}/transformers/_base.py +0 -0
- /cognite/neat/{issues → _issues}/__init__.py +0 -0
- /cognite/neat/{issues → _issues}/formatters.py +0 -0
- /cognite/neat/{rules → _rules}/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_dtdl2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_dtdl2rules/_unit_lookup.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/_imf2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/importers/_rdf/_owl2rules/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/asset/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/dms/__init__.py +0 -0
- /cognite/neat/{rules → _rules}/models/entities/_types.py +0 -0
- /cognite/neat/{rules → _rules}/models/entities/_wrapped.py +0 -0
- /cognite/neat/{rules → _rules}/models/information/__init__.py +0 -0
- /cognite/neat/{store → _store}/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/data_classes.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/loaders/__init__.py +0 -0
- /cognite/neat/{utils → _utils}/cdf/loaders/_base.py +0 -0
- /cognite/neat/{utils → _utils}/collection_.py +0 -0
- /cognite/neat/{utils → _utils}/rdf_.py +0 -0
- /cognite/neat/{utils → _utils}/spreadsheet.py +0 -0
- /cognite/neat/{utils → _utils}/text.py +0 -0
- /cognite/neat/{utils → _utils}/time_.py +0 -0
- /cognite/neat/{utils → _utils}/xml_.py +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Export_Semantic_Data_Model/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Import_DMS/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Validate_Rules/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/examples/Validate_Solution_Model/workflow.yaml +0 -0
- /cognite/neat/{workflows → _workflows}/model.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/current/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/steps/lib/io/__init__.py +0 -0
- /cognite/neat/{workflows → _workflows}/utils.py +0 -0
- {cognite_neat-0.92.3.dist-info → cognite_neat-0.93.0.dist-info}/LICENSE +0 -0
|
@@ -4,15 +4,15 @@ from typing import Any, ClassVar, cast
|
|
|
4
4
|
from pydantic import Field, field_validator, model_validator
|
|
5
5
|
from rdflib import Namespace
|
|
6
6
|
|
|
7
|
-
from cognite.neat.
|
|
8
|
-
from cognite.neat.
|
|
9
|
-
from cognite.neat.
|
|
7
|
+
from cognite.neat._constants import get_default_prefixes
|
|
8
|
+
from cognite.neat._rules.models._base_rules import BaseRules, RoleTypes, SheetList
|
|
9
|
+
from cognite.neat._rules.models.entities import (
|
|
10
10
|
CdfResourceEntityList,
|
|
11
11
|
ClassEntity,
|
|
12
12
|
MultiValueTypeInfo,
|
|
13
13
|
Undefined,
|
|
14
14
|
)
|
|
15
|
-
from cognite.neat.
|
|
15
|
+
from cognite.neat._rules.models.information import (
|
|
16
16
|
InformationClass,
|
|
17
17
|
InformationMetadata,
|
|
18
18
|
InformationProperty,
|
|
@@ -3,15 +3,15 @@ from typing import Any
|
|
|
3
3
|
|
|
4
4
|
from rdflib import Namespace
|
|
5
5
|
|
|
6
|
-
from cognite.neat.
|
|
7
|
-
from cognite.neat.
|
|
8
|
-
from cognite.neat.
|
|
6
|
+
from cognite.neat._rules.models._base_input import InputComponent, InputRules
|
|
7
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
8
|
+
from cognite.neat._rules.models.entities import (
|
|
9
9
|
ClassEntity,
|
|
10
10
|
MultiValueTypeInfo,
|
|
11
11
|
UnknownEntity,
|
|
12
12
|
load_value_type,
|
|
13
13
|
)
|
|
14
|
-
from cognite.neat.
|
|
14
|
+
from cognite.neat._rules.models.information._rules_input import InformationInputClass, InformationInputMetadata
|
|
15
15
|
|
|
16
16
|
from ._rules import AssetClass, AssetMetadata, AssetProperty, AssetRules
|
|
17
17
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from graphlib import CycleError
|
|
2
2
|
from typing import cast
|
|
3
3
|
|
|
4
|
-
from cognite.neat.
|
|
5
|
-
from cognite.neat.
|
|
6
|
-
from cognite.neat.
|
|
7
|
-
from cognite.neat.
|
|
8
|
-
from cognite.neat.
|
|
9
|
-
from cognite.neat.
|
|
4
|
+
from cognite.neat._issues import IssueList
|
|
5
|
+
from cognite.neat._issues.errors import NeatValueError, PropertyDefinitionError
|
|
6
|
+
from cognite.neat._rules.models._base_rules import SheetList
|
|
7
|
+
from cognite.neat._rules.models.asset._rules import AssetProperty, AssetRules
|
|
8
|
+
from cognite.neat._rules.models.entities import AssetEntity, AssetFields, ClassEntity
|
|
9
|
+
from cognite.neat._rules.models.information._validation import InformationPostValidation
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class AssetPostValidation(InformationPostValidation):
|
|
@@ -35,7 +35,7 @@ class AssetPostValidation(InformationPostValidation):
|
|
|
35
35
|
)
|
|
36
36
|
|
|
37
37
|
def _circular_dependency(self) -> None:
|
|
38
|
-
from cognite.neat.
|
|
38
|
+
from cognite.neat._rules.analysis import AssetAnalysis
|
|
39
39
|
|
|
40
40
|
try:
|
|
41
41
|
_ = AssetAnalysis(cast(AssetRules, self.rules)).class_topological_sort()
|
|
@@ -9,8 +9,8 @@ from cognite.client.data_classes.data_modeling.data_types import Enum as DMSEnum
|
|
|
9
9
|
from pydantic import BaseModel, Field, model_serializer, model_validator
|
|
10
10
|
from pydantic.functional_validators import ModelWrapValidatorHandler
|
|
11
11
|
|
|
12
|
-
from cognite.neat.
|
|
13
|
-
from cognite.neat.
|
|
12
|
+
from cognite.neat._rules._constants import SPLIT_ON_COMMA_PATTERN, SPLIT_ON_EQUAL_PATTERN
|
|
13
|
+
from cognite.neat._rules.models.entities._single_value import ClassEntity, UnitEntity
|
|
14
14
|
|
|
15
15
|
if sys.version_info >= (3, 11):
|
|
16
16
|
from typing import Self
|
|
@@ -28,13 +28,13 @@ class DataType(BaseModel):
|
|
|
28
28
|
graphql: ClassVar[str]
|
|
29
29
|
xsd: ClassVar[str]
|
|
30
30
|
sql: ClassVar[str]
|
|
31
|
-
_dms_loaded: bool = False
|
|
32
31
|
# Repeat all here, just to make mypy happy
|
|
33
32
|
name: typing.Literal[
|
|
34
33
|
"boolean",
|
|
35
34
|
"token",
|
|
36
35
|
"float",
|
|
37
36
|
"double",
|
|
37
|
+
"decimal",
|
|
38
38
|
"integer",
|
|
39
39
|
"nonPositiveInteger",
|
|
40
40
|
"nonNegativeInteger",
|
|
@@ -75,10 +75,8 @@ class DataType(BaseModel):
|
|
|
75
75
|
cls_: type[DataType]
|
|
76
76
|
if name in _DATA_TYPE_BY_DMS_TYPE:
|
|
77
77
|
cls_ = _DATA_TYPE_BY_DMS_TYPE[name]
|
|
78
|
-
dms_loaded = True
|
|
79
78
|
elif name in _DATA_TYPE_BY_NAME:
|
|
80
79
|
cls_ = _DATA_TYPE_BY_NAME[name]
|
|
81
|
-
dms_loaded = False
|
|
82
80
|
else:
|
|
83
81
|
raise ValueError(f"Unknown data type: {value}") from None
|
|
84
82
|
extra_args: dict[str, Any] = {}
|
|
@@ -89,8 +87,6 @@ class DataType(BaseModel):
|
|
|
89
87
|
# Todo? Raise warning if extra_args contains keys that are not in the model fields
|
|
90
88
|
instance = cls_(**extra_args)
|
|
91
89
|
created = handler(instance)
|
|
92
|
-
# Private attributes are not validated or set. We need to set it manually
|
|
93
|
-
created._dms_loaded = dms_loaded
|
|
94
90
|
return created
|
|
95
91
|
raise ValueError(f"Cannot load {cls.__name__} from {value}")
|
|
96
92
|
|
|
@@ -99,11 +95,7 @@ class DataType(BaseModel):
|
|
|
99
95
|
return str(self)
|
|
100
96
|
|
|
101
97
|
def __str__(self) -> str:
|
|
102
|
-
|
|
103
|
-
base = self.dms._type
|
|
104
|
-
else:
|
|
105
|
-
base = self.model_fields["name"].default
|
|
106
|
-
return self._suffix_extra_args(base)
|
|
98
|
+
return self._suffix_extra_args(self.model_fields["name"].default)
|
|
107
99
|
|
|
108
100
|
def _suffix_extra_args(self, base: str) -> str:
|
|
109
101
|
extra_fields: dict[str, str] = {}
|
|
@@ -164,6 +156,17 @@ class Double(DataType):
|
|
|
164
156
|
unit: UnitEntity | None = None
|
|
165
157
|
|
|
166
158
|
|
|
159
|
+
class Decimal(DataType):
|
|
160
|
+
python = float
|
|
161
|
+
dms = dms.Float64
|
|
162
|
+
graphql = "Float"
|
|
163
|
+
xsd = "decimal"
|
|
164
|
+
sql = "FLOAT"
|
|
165
|
+
|
|
166
|
+
name: typing.Literal["decimal"] = "decimal"
|
|
167
|
+
unit: UnitEntity | None = None
|
|
168
|
+
|
|
169
|
+
|
|
167
170
|
class Integer(DataType):
|
|
168
171
|
python = int
|
|
169
172
|
dms = dms.Int32
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from collections import defaultdict
|
|
3
|
-
from collections.abc import Collection, Sequence
|
|
3
|
+
from collections.abc import Collection, Hashable, Sequence
|
|
4
4
|
from typing import Any, cast
|
|
5
5
|
|
|
6
6
|
from cognite.client.data_classes import data_modeling as dm
|
|
@@ -13,17 +13,17 @@ from cognite.client.data_classes.data_modeling.views import (
|
|
|
13
13
|
ViewPropertyApply,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
from cognite.neat.
|
|
17
|
-
from cognite.neat.
|
|
18
|
-
from cognite.neat.
|
|
16
|
+
from cognite.neat._issues.errors import NeatTypeError, ResourceNotFoundError
|
|
17
|
+
from cognite.neat._issues.warnings import NotSupportedWarning, PropertyNotFoundWarning
|
|
18
|
+
from cognite.neat._issues.warnings.user_modeling import (
|
|
19
19
|
EmptyContainerWarning,
|
|
20
20
|
HasDataFilterOnNoPropertiesViewWarning,
|
|
21
21
|
HasDataFilterOnViewWithReferencesWarning,
|
|
22
22
|
NodeTypeFilterOnParentViewWarning,
|
|
23
23
|
)
|
|
24
|
-
from cognite.neat.
|
|
25
|
-
from cognite.neat.
|
|
26
|
-
from cognite.neat.
|
|
24
|
+
from cognite.neat._rules.models._base_rules import DataModelType, ExtensionCategory, SchemaCompleteness
|
|
25
|
+
from cognite.neat._rules.models.data_types import DataType, Double, Enum, Float
|
|
26
|
+
from cognite.neat._rules.models.entities import (
|
|
27
27
|
ClassEntity,
|
|
28
28
|
ContainerEntity,
|
|
29
29
|
DMSFilter,
|
|
@@ -37,7 +37,7 @@ from cognite.neat.rules.models.entities import (
|
|
|
37
37
|
UnitEntity,
|
|
38
38
|
ViewEntity,
|
|
39
39
|
)
|
|
40
|
-
from cognite.neat.
|
|
40
|
+
from cognite.neat._utils.cdf.data_classes import ContainerApplyDict, NodeApplyDict, SpaceApplyDict, ViewApplyDict
|
|
41
41
|
|
|
42
42
|
from ._rules import DMSEnum, DMSMetadata, DMSProperty, DMSRules, DMSView
|
|
43
43
|
from ._schema import DMSSchema, PipelineSchema
|
|
@@ -120,7 +120,13 @@ class _DMSExporter:
|
|
|
120
120
|
|
|
121
121
|
containers = self._create_containers(container_properties_by_id, rules.enum) # type: ignore[arg-type]
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
view_properties_with_ancestors_by_id = self._gather_properties_with_ancestors(
|
|
124
|
+
view_properties_by_id, rules.views
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
views, view_node_type_filters = self._create_views_with_node_types(
|
|
128
|
+
view_properties_by_id, view_properties_with_ancestors_by_id
|
|
129
|
+
)
|
|
124
130
|
if rules.nodes:
|
|
125
131
|
node_types = NodeApplyDict(
|
|
126
132
|
[node.as_node() for node in rules.nodes]
|
|
@@ -198,6 +204,7 @@ class _DMSExporter:
|
|
|
198
204
|
def _create_views_with_node_types(
|
|
199
205
|
self,
|
|
200
206
|
view_properties_by_id: dict[dm.ViewId, list[DMSProperty]],
|
|
207
|
+
view_properties_with_ancestors_by_id: dict[dm.ViewId, list[DMSProperty]],
|
|
201
208
|
) -> tuple[ViewApplyDict, set[dm.NodeId]]:
|
|
202
209
|
input_views = list(self.rules.views)
|
|
203
210
|
if self.rules.last:
|
|
@@ -217,7 +224,7 @@ class _DMSExporter:
|
|
|
217
224
|
if not (view_properties := view_properties_by_id.get(view_id)):
|
|
218
225
|
continue
|
|
219
226
|
for prop in view_properties:
|
|
220
|
-
view_property = self._create_view_property(prop,
|
|
227
|
+
view_property = self._create_view_property(prop, view_properties_with_ancestors_by_id)
|
|
221
228
|
if view_property is not None:
|
|
222
229
|
view.properties[prop.view_property] = view_property
|
|
223
230
|
|
|
@@ -395,6 +402,43 @@ class _DMSExporter:
|
|
|
395
402
|
|
|
396
403
|
return container_properties_by_id, view_properties_by_id
|
|
397
404
|
|
|
405
|
+
@staticmethod
|
|
406
|
+
def _gather_properties_with_ancestors(
|
|
407
|
+
view_properties_by_id: dict[dm.ViewId, list[DMSProperty]],
|
|
408
|
+
views: Sequence[DMSView],
|
|
409
|
+
) -> dict[dm.ViewId, list[DMSProperty]]:
|
|
410
|
+
view_properties_with_parents_by_id: dict[dm.ViewId, list[DMSProperty]] = defaultdict(list)
|
|
411
|
+
view_by_view_id = {view.view.as_id(): view for view in views}
|
|
412
|
+
for view in views:
|
|
413
|
+
view_id = view.view.as_id()
|
|
414
|
+
seen: set[Hashable] = set()
|
|
415
|
+
if view_properties := view_properties_by_id.get(view_id):
|
|
416
|
+
view_properties_with_parents_by_id[view_id].extend(view_properties)
|
|
417
|
+
seen.update(prop._identifier() for prop in view_properties)
|
|
418
|
+
if not view.implements:
|
|
419
|
+
continue
|
|
420
|
+
parents = view.implements.copy()
|
|
421
|
+
seen_parents = set(parents)
|
|
422
|
+
while parents:
|
|
423
|
+
parent = parents.pop()
|
|
424
|
+
parent_view_id = parent.as_id()
|
|
425
|
+
if parent_view := view_by_view_id.get(parent_view_id):
|
|
426
|
+
for grandparent in parent_view.implements or []:
|
|
427
|
+
if grandparent not in seen_parents:
|
|
428
|
+
parents.append(grandparent)
|
|
429
|
+
seen_parents.add(grandparent)
|
|
430
|
+
|
|
431
|
+
if not (parent_view_properties := view_properties_by_id.get(parent_view_id)):
|
|
432
|
+
continue
|
|
433
|
+
for prop in parent_view_properties:
|
|
434
|
+
new_prop = prop.model_copy(update={"view": view.view})
|
|
435
|
+
|
|
436
|
+
if new_prop._identifier() not in seen:
|
|
437
|
+
view_properties_with_parents_by_id[view_id].append(new_prop)
|
|
438
|
+
seen.add(new_prop._identifier())
|
|
439
|
+
|
|
440
|
+
return view_properties_with_parents_by_id
|
|
441
|
+
|
|
398
442
|
@classmethod
|
|
399
443
|
def _update_with_properties(
|
|
400
444
|
cls,
|
|
@@ -472,7 +516,7 @@ class _DMSExporter:
|
|
|
472
516
|
|
|
473
517
|
@classmethod
|
|
474
518
|
def _create_view_property(
|
|
475
|
-
cls, prop: DMSProperty,
|
|
519
|
+
cls, prop: DMSProperty, view_properties_with_ancestors_by_id: dict[dm.ViewId, list[DMSProperty]]
|
|
476
520
|
) -> ViewPropertyApply | None:
|
|
477
521
|
if prop.container and prop.container_property:
|
|
478
522
|
container_prop_identifier = prop.container_property
|
|
@@ -538,7 +582,11 @@ class _DMSExporter:
|
|
|
538
582
|
)
|
|
539
583
|
edge_source = None
|
|
540
584
|
reverse_prop = next(
|
|
541
|
-
(
|
|
585
|
+
(
|
|
586
|
+
prop
|
|
587
|
+
for prop in view_properties_with_ancestors_by_id.get(source_view_id, [])
|
|
588
|
+
if prop.property_ == reverse_prop_id
|
|
589
|
+
),
|
|
542
590
|
None,
|
|
543
591
|
)
|
|
544
592
|
if (
|
|
@@ -9,12 +9,12 @@ from cognite.client import data_modeling as dm
|
|
|
9
9
|
from pydantic import Field, field_serializer, field_validator, model_validator
|
|
10
10
|
from pydantic_core.core_schema import SerializationInfo, ValidationInfo
|
|
11
11
|
|
|
12
|
-
from cognite.neat.
|
|
13
|
-
from cognite.neat.
|
|
12
|
+
from cognite.neat._issues import MultiValueError
|
|
13
|
+
from cognite.neat._issues.warnings import (
|
|
14
14
|
PrincipleMatchingSpaceAndVersionWarning,
|
|
15
15
|
PrincipleSolutionBuildsOnEnterpriseWarning,
|
|
16
16
|
)
|
|
17
|
-
from cognite.neat.
|
|
17
|
+
from cognite.neat._rules.models._base_rules import (
|
|
18
18
|
BaseMetadata,
|
|
19
19
|
BaseRules,
|
|
20
20
|
DataModelType,
|
|
@@ -24,16 +24,19 @@ from cognite.neat.rules.models._base_rules import (
|
|
|
24
24
|
SheetList,
|
|
25
25
|
SheetRow,
|
|
26
26
|
)
|
|
27
|
-
from cognite.neat.
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
from cognite.neat._rules.models._types import (
|
|
28
|
+
ClassEntityType,
|
|
29
|
+
ContainerEntityType,
|
|
30
|
+
DataModelExternalIdType,
|
|
31
|
+
DmsPropertyType,
|
|
32
|
+
InformationPropertyType,
|
|
33
|
+
SpaceType,
|
|
30
34
|
StrListType,
|
|
31
35
|
VersionType,
|
|
36
|
+
ViewEntityType,
|
|
32
37
|
)
|
|
33
|
-
from cognite.neat.
|
|
34
|
-
from cognite.neat.
|
|
35
|
-
ClassEntity,
|
|
36
|
-
ContainerEntity,
|
|
38
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
39
|
+
from cognite.neat._rules.models.entities import (
|
|
37
40
|
ContainerEntityList,
|
|
38
41
|
DMSEntity,
|
|
39
42
|
DMSNodeEntity,
|
|
@@ -68,7 +71,7 @@ class DMSMetadata(BaseMetadata):
|
|
|
68
71
|
data_model_type: DataModelType = Field(DataModelType.enterprise, alias="dataModelType")
|
|
69
72
|
schema_: SchemaCompleteness = Field(alias="schema")
|
|
70
73
|
extension: ExtensionCategory = ExtensionCategory.addition
|
|
71
|
-
space:
|
|
74
|
+
space: SpaceType
|
|
72
75
|
name: str | None = Field(
|
|
73
76
|
None,
|
|
74
77
|
description="Human readable name of the data model",
|
|
@@ -76,7 +79,7 @@ class DMSMetadata(BaseMetadata):
|
|
|
76
79
|
max_length=255,
|
|
77
80
|
)
|
|
78
81
|
description: str | None = Field(None, min_length=1, max_length=1024)
|
|
79
|
-
external_id:
|
|
82
|
+
external_id: DataModelExternalIdType = Field(alias="externalId")
|
|
80
83
|
version: VersionType
|
|
81
84
|
creator: StrListType
|
|
82
85
|
created: datetime = Field(
|
|
@@ -152,8 +155,8 @@ def _metadata(context: Any) -> DMSMetadata | None:
|
|
|
152
155
|
|
|
153
156
|
|
|
154
157
|
class DMSProperty(SheetRow):
|
|
155
|
-
view:
|
|
156
|
-
view_property:
|
|
158
|
+
view: ViewEntityType = Field(alias="View")
|
|
159
|
+
view_property: DmsPropertyType = Field(alias="View Property")
|
|
157
160
|
name: str | None = Field(alias="Name", default=None)
|
|
158
161
|
description: str | None = Field(alias="Description", default=None)
|
|
159
162
|
connection: Literal["direct"] | ReverseConnectionEntity | EdgeEntity | None = Field(None, alias="Connection")
|
|
@@ -163,12 +166,12 @@ class DMSProperty(SheetRow):
|
|
|
163
166
|
is_list: bool | None = Field(default=None, alias="Is List")
|
|
164
167
|
default: str | int | dict | None = Field(None, alias="Default")
|
|
165
168
|
reference: URLEntity | ReferenceEntity | None = Field(default=None, alias="Reference", union_mode="left_to_right")
|
|
166
|
-
container:
|
|
167
|
-
container_property:
|
|
169
|
+
container: ContainerEntityType | None = Field(None, alias="Container")
|
|
170
|
+
container_property: DmsPropertyType | None = Field(None, alias="Container Property")
|
|
168
171
|
index: StrListType | None = Field(None, alias="Index")
|
|
169
172
|
constraint: StrListType | None = Field(None, alias="Constraint")
|
|
170
|
-
class_:
|
|
171
|
-
property_:
|
|
173
|
+
class_: ClassEntityType = Field(alias="Class (linage)")
|
|
174
|
+
property_: InformationPropertyType = Field(alias="Property (linage)")
|
|
172
175
|
|
|
173
176
|
def _identifier(self) -> tuple[Hashable, ...]:
|
|
174
177
|
return self.view, self.view_property
|
|
@@ -233,13 +236,13 @@ class DMSProperty(SheetRow):
|
|
|
233
236
|
|
|
234
237
|
|
|
235
238
|
class DMSContainer(SheetRow):
|
|
236
|
-
container:
|
|
239
|
+
container: ContainerEntityType = Field(alias="Container")
|
|
237
240
|
name: str | None = Field(alias="Name", default=None)
|
|
238
241
|
description: str | None = Field(alias="Description", default=None)
|
|
239
242
|
reference: URLEntity | ReferenceEntity | None = Field(alias="Reference", default=None, union_mode="left_to_right")
|
|
240
243
|
constraint: ContainerEntityList | None = Field(None, alias="Constraint")
|
|
241
244
|
used_for: Literal["node", "edge", "all"] | None = Field("all", alias="Used For")
|
|
242
|
-
class_:
|
|
245
|
+
class_: ClassEntityType = Field(alias="Class (linage)")
|
|
243
246
|
|
|
244
247
|
def _identifier(self) -> tuple[Hashable, ...]:
|
|
245
248
|
return (self.container,)
|
|
@@ -289,14 +292,14 @@ class DMSContainer(SheetRow):
|
|
|
289
292
|
|
|
290
293
|
|
|
291
294
|
class DMSView(SheetRow):
|
|
292
|
-
view:
|
|
295
|
+
view: ViewEntityType = Field(alias="View")
|
|
293
296
|
name: str | None = Field(alias="Name", default=None)
|
|
294
297
|
description: str | None = Field(alias="Description", default=None)
|
|
295
298
|
implements: ViewEntityList | None = Field(None, alias="Implements")
|
|
296
299
|
reference: URLEntity | ReferenceEntity | None = Field(alias="Reference", default=None, union_mode="left_to_right")
|
|
297
300
|
filter_: HasDataFilter | NodeTypeFilter | RawFilter | None = Field(None, alias="Filter")
|
|
298
301
|
in_model: bool = Field(True, alias="In Model")
|
|
299
|
-
class_:
|
|
302
|
+
class_: ClassEntityType = Field(alias="Class (linage)")
|
|
300
303
|
|
|
301
304
|
def _identifier(self) -> tuple[Hashable, ...]:
|
|
302
305
|
return (self.view,)
|
|
@@ -369,7 +372,7 @@ class DMSNode(SheetRow):
|
|
|
369
372
|
|
|
370
373
|
|
|
371
374
|
class DMSEnum(SheetRow):
|
|
372
|
-
collection:
|
|
375
|
+
collection: ClassEntityType = Field(alias="Collection")
|
|
373
376
|
value: str = Field(alias="Value")
|
|
374
377
|
name: str | None = Field(alias="Name", default=None)
|
|
375
378
|
description: str | None = Field(alias="Description", default=None)
|
|
@@ -5,9 +5,9 @@ from typing import Any, Literal
|
|
|
5
5
|
|
|
6
6
|
from cognite.client import data_modeling as dm
|
|
7
7
|
|
|
8
|
-
from cognite.neat.
|
|
9
|
-
from cognite.neat.
|
|
10
|
-
from cognite.neat.
|
|
8
|
+
from cognite.neat._rules.models._base_input import InputComponent, InputRules
|
|
9
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
10
|
+
from cognite.neat._rules.models.entities import (
|
|
11
11
|
ClassEntity,
|
|
12
12
|
ContainerEntity,
|
|
13
13
|
DMSNodeEntity,
|
|
@@ -267,7 +267,7 @@ class DMSInputRules(InputRules[DMSRules]):
|
|
|
267
267
|
|
|
268
268
|
def dump(self) -> dict[str, Any]:
|
|
269
269
|
default_space = self.metadata.space
|
|
270
|
-
default_version = self.metadata.version
|
|
270
|
+
default_version = str(self.metadata.version)
|
|
271
271
|
reference: dict[str, Any] | None = None
|
|
272
272
|
if isinstance(self.reference, DMSInputRules):
|
|
273
273
|
reference = self.reference.dump()
|
|
@@ -25,23 +25,23 @@ from cognite.client.data_classes.data_modeling.views import (
|
|
|
25
25
|
)
|
|
26
26
|
from cognite.client.data_classes.transformations.common import Edges, EdgeType, Nodes, ViewInfo
|
|
27
27
|
|
|
28
|
-
from cognite.neat.
|
|
29
|
-
from cognite.neat.
|
|
28
|
+
from cognite.neat._issues import NeatError
|
|
29
|
+
from cognite.neat._issues.errors import (
|
|
30
30
|
NeatYamlError,
|
|
31
31
|
PropertyMappingDuplicatedError,
|
|
32
32
|
PropertyNotFoundError,
|
|
33
33
|
ResourceDuplicatedError,
|
|
34
34
|
ResourceNotFoundError,
|
|
35
35
|
)
|
|
36
|
-
from cognite.neat.
|
|
36
|
+
from cognite.neat._issues.warnings import (
|
|
37
37
|
FileTypeUnexpectedWarning,
|
|
38
38
|
ResourceNotFoundWarning,
|
|
39
39
|
ResourceRetrievalWarning,
|
|
40
40
|
ResourcesDuplicatedWarning,
|
|
41
41
|
)
|
|
42
|
-
from cognite.neat.
|
|
43
|
-
from cognite.neat.
|
|
44
|
-
from cognite.neat.
|
|
42
|
+
from cognite.neat._issues.warnings.user_modeling import DirectRelationMissingSourceWarning
|
|
43
|
+
from cognite.neat._rules.models.data_types import _DATA_TYPE_BY_DMS_TYPE
|
|
44
|
+
from cognite.neat._utils.cdf.data_classes import (
|
|
45
45
|
CogniteResourceDict,
|
|
46
46
|
ContainerApplyDict,
|
|
47
47
|
NodeApplyDict,
|
|
@@ -50,9 +50,9 @@ from cognite.neat.utils.cdf.data_classes import (
|
|
|
50
50
|
SpaceApplyDict,
|
|
51
51
|
ViewApplyDict,
|
|
52
52
|
)
|
|
53
|
-
from cognite.neat.
|
|
54
|
-
from cognite.neat.
|
|
55
|
-
from cognite.neat.
|
|
53
|
+
from cognite.neat._utils.cdf.loaders import ViewLoader
|
|
54
|
+
from cognite.neat._utils.rdf_ import get_inheritance_path
|
|
55
|
+
from cognite.neat._utils.text import to_camel
|
|
56
56
|
|
|
57
57
|
if sys.version_info >= (3, 11):
|
|
58
58
|
from typing import Self
|
|
@@ -461,7 +461,7 @@ class DMSSchema:
|
|
|
461
461
|
)
|
|
462
462
|
else:
|
|
463
463
|
try:
|
|
464
|
-
loaded[attr.name] = attr.type.load(items)
|
|
464
|
+
loaded[attr.name] = attr.type.load(items) # type: ignore[union-attr]
|
|
465
465
|
except Exception as e:
|
|
466
466
|
loaded[attr.name] = cls._load_individual_resources(
|
|
467
467
|
items, attr, str(e), context.get(attr.name, [])
|
|
@@ -470,14 +470,15 @@ class DMSSchema:
|
|
|
470
470
|
|
|
471
471
|
@classmethod
|
|
472
472
|
def _load_individual_resources(cls, items: list, attr: Field, trigger_error: str, resource_context) -> list[Any]:
|
|
473
|
-
|
|
474
|
-
|
|
473
|
+
type_ = cast(type, attr.type)
|
|
474
|
+
resources = type_([])
|
|
475
|
+
if not hasattr(type_, "_RESOURCE"):
|
|
475
476
|
warnings.warn(
|
|
476
|
-
FileTypeUnexpectedWarning(Path("UNKNOWN"), frozenset([
|
|
477
|
+
FileTypeUnexpectedWarning(Path("UNKNOWN"), frozenset([type_.__name__]), trigger_error), stacklevel=2
|
|
477
478
|
)
|
|
478
479
|
return resources
|
|
479
480
|
# Fallback to load individual resources.
|
|
480
|
-
single_cls =
|
|
481
|
+
single_cls = type_._RESOURCE
|
|
481
482
|
for no, item in enumerate(items):
|
|
482
483
|
try:
|
|
483
484
|
loaded_instance = single_cls.load(item)
|
|
@@ -3,24 +3,24 @@ from typing import Any, ClassVar
|
|
|
3
3
|
|
|
4
4
|
from cognite.client import data_modeling as dm
|
|
5
5
|
|
|
6
|
-
from cognite.neat.
|
|
7
|
-
from cognite.neat.
|
|
8
|
-
from cognite.neat.
|
|
6
|
+
from cognite.neat._constants import DMS_CONTAINER_PROPERTY_SIZE_LIMIT
|
|
7
|
+
from cognite.neat._issues import IssueList, NeatError, NeatIssue, NeatIssueList
|
|
8
|
+
from cognite.neat._issues.errors import (
|
|
9
9
|
PropertyDefinitionDuplicatedError,
|
|
10
10
|
ResourceChangedError,
|
|
11
11
|
ResourceNotDefinedError,
|
|
12
12
|
)
|
|
13
|
-
from cognite.neat.
|
|
13
|
+
from cognite.neat._issues.warnings import (
|
|
14
14
|
NotSupportedHasDataFilterLimitWarning,
|
|
15
15
|
NotSupportedViewContainerLimitWarning,
|
|
16
16
|
)
|
|
17
|
-
from cognite.neat.
|
|
17
|
+
from cognite.neat._issues.warnings.user_modeling import (
|
|
18
18
|
NotNeatSupportedFilterWarning,
|
|
19
19
|
ViewPropertyLimitWarning,
|
|
20
20
|
)
|
|
21
|
-
from cognite.neat.
|
|
22
|
-
from cognite.neat.
|
|
23
|
-
from cognite.neat.
|
|
21
|
+
from cognite.neat._rules.models._base_rules import DataModelType, ExtensionCategory, SchemaCompleteness
|
|
22
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
23
|
+
from cognite.neat._rules.models.entities import ContainerEntity, RawFilter
|
|
24
24
|
|
|
25
25
|
from ._rules import DMSProperty, DMSRules
|
|
26
26
|
from ._schema import DMSSchema
|
|
@@ -5,8 +5,8 @@ from typing import ClassVar
|
|
|
5
5
|
|
|
6
6
|
from pydantic import Field, field_serializer, field_validator
|
|
7
7
|
|
|
8
|
-
from cognite.neat.
|
|
9
|
-
from cognite.neat.
|
|
8
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
9
|
+
from cognite.neat._rules.models.entities import ClassEntity, ClassEntityList
|
|
10
10
|
|
|
11
11
|
from ._base_input import InputComponent, InputRules
|
|
12
12
|
from ._base_rules import (
|
|
@@ -16,7 +16,7 @@ from ._base_rules import (
|
|
|
16
16
|
SheetList,
|
|
17
17
|
SheetRow,
|
|
18
18
|
)
|
|
19
|
-
from ._types import
|
|
19
|
+
from ._types import ClassEntityType, InformationPropertyType, StrOrListType
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class DomainMetadata(BaseMetadata):
|
|
@@ -31,8 +31,8 @@ class DomainMetadata(BaseMetadata):
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
class DomainProperty(SheetRow):
|
|
34
|
-
class_:
|
|
35
|
-
property_:
|
|
34
|
+
class_: ClassEntityType = Field(alias="Class")
|
|
35
|
+
property_: InformationPropertyType = Field(alias="Property")
|
|
36
36
|
name: str | None = Field(alias="Name", default=None)
|
|
37
37
|
description: str | None = Field(alias="Description", default=None)
|
|
38
38
|
value_type: DataType | ClassEntity = Field(alias="Value Type")
|
|
@@ -56,7 +56,7 @@ class DomainProperty(SheetRow):
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
class DomainClass(SheetRow):
|
|
59
|
-
class_:
|
|
59
|
+
class_: ClassEntityType = Field(alias="Class")
|
|
60
60
|
name: str | None = Field(alias="Name", default=None)
|
|
61
61
|
description: str | None = Field(None, alias="Description")
|
|
62
62
|
parent: ClassEntityList | None = Field(alias="Parent Class")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ._constants import
|
|
1
|
+
from ._constants import Undefined, Unknown
|
|
2
2
|
from ._loaders import load_connection, load_dms_value_type, load_value_type
|
|
3
3
|
from ._multi_value import MultiValueTypeInfo
|
|
4
4
|
from ._single_value import (
|
|
@@ -34,7 +34,6 @@ __all__ = [
|
|
|
34
34
|
"ClassEntity",
|
|
35
35
|
"ViewEntityList",
|
|
36
36
|
"UnknownEntity",
|
|
37
|
-
"EntityTypes",
|
|
38
37
|
"Unknown",
|
|
39
38
|
"Undefined",
|
|
40
39
|
"T_Entity",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class _UndefinedType(BaseModel): ...
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _UnknownType(BaseModel):
|
|
8
|
+
def __str__(self) -> str:
|
|
9
|
+
return "#N/A"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# This is a trick to make Undefined and Unknown singletons
|
|
13
|
+
Undefined = _UndefinedType()
|
|
14
|
+
Unknown = _UnknownType()
|
|
15
|
+
_PARSE = object()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Literal
|
|
2
2
|
|
|
3
|
-
from cognite.neat.
|
|
4
|
-
from cognite.neat.
|
|
3
|
+
from cognite.neat._issues.errors import NeatTypeError
|
|
4
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
5
5
|
|
|
6
6
|
from ._multi_value import MultiValueTypeInfo
|
|
7
7
|
from ._single_value import (
|
|
@@ -6,9 +6,10 @@ from pydantic import (
|
|
|
6
6
|
model_validator,
|
|
7
7
|
)
|
|
8
8
|
|
|
9
|
-
from cognite.neat.
|
|
9
|
+
from cognite.neat._rules._constants import EntityTypes
|
|
10
|
+
from cognite.neat._rules.models.data_types import DataType
|
|
10
11
|
|
|
11
|
-
from ._constants import _PARSE,
|
|
12
|
+
from ._constants import _PARSE, Undefined
|
|
12
13
|
from ._single_value import ClassEntity, UnknownEntity
|
|
13
14
|
|
|
14
15
|
|
|
@@ -65,3 +66,15 @@ class MultiValueTypeInfo(BaseModel):
|
|
|
65
66
|
for type_ in self.types:
|
|
66
67
|
if isinstance(type_, ClassEntity) and type_.prefix is Undefined:
|
|
67
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, ClassEntity) 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()
|