cognite-neat 0.75.8__py3-none-any.whl → 0.76.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.

Files changed (99) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/app/api/configuration.py +4 -9
  3. cognite/neat/app/api/routers/configuration.py +2 -1
  4. cognite/neat/app/api/routers/crud.py +5 -5
  5. cognite/neat/app/api/routers/data_exploration.py +3 -1
  6. cognite/neat/app/api/routers/rules.py +3 -3
  7. cognite/neat/app/api/routers/workflows.py +3 -3
  8. cognite/neat/app/ui/neat-app/build/asset-manifest.json +3 -3
  9. cognite/neat/app/ui/neat-app/build/index.html +1 -1
  10. cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js → main.ec7f72e2.js} +3 -3
  11. cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js.map → main.ec7f72e2.js.map} +1 -1
  12. cognite/neat/config.py +147 -12
  13. cognite/neat/constants.py +1 -0
  14. cognite/neat/graph/exceptions.py +1 -2
  15. cognite/neat/legacy/graph/exceptions.py +1 -2
  16. cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +1 -2
  17. cognite/neat/legacy/graph/loaders/_asset_loader.py +8 -13
  18. cognite/neat/legacy/graph/loaders/_base.py +2 -4
  19. cognite/neat/legacy/graph/loaders/_exceptions.py +1 -3
  20. cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +4 -8
  21. cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +2 -4
  22. cognite/neat/legacy/graph/loaders/rdf_to_dms.py +2 -4
  23. cognite/neat/legacy/graph/loaders/validator.py +1 -1
  24. cognite/neat/legacy/graph/transformations/transformer.py +1 -2
  25. cognite/neat/legacy/rules/exporters/_rules2dms.py +1 -2
  26. cognite/neat/legacy/rules/exporters/_validation.py +4 -8
  27. cognite/neat/legacy/rules/importers/_base.py +0 -4
  28. cognite/neat/legacy/rules/importers/_dms2rules.py +0 -2
  29. cognite/neat/legacy/rules/models/rdfpath.py +1 -2
  30. cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +89 -0
  31. cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +152 -0
  32. cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +139 -0
  33. cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +270 -0
  34. cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +65 -0
  35. cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +116 -0
  36. cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +67 -0
  37. cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +64 -0
  38. cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +95 -0
  39. cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +111 -0
  40. cognite/neat/rules/exporters/_models.py +3 -0
  41. cognite/neat/rules/exporters/_rules2dms.py +46 -4
  42. cognite/neat/rules/exporters/_rules2excel.py +2 -11
  43. cognite/neat/rules/exporters/_validation.py +6 -8
  44. cognite/neat/rules/importers/_base.py +8 -4
  45. cognite/neat/rules/importers/_dms2rules.py +321 -129
  46. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +2 -4
  47. cognite/neat/rules/importers/_dtdl2rules/spec.py +2 -4
  48. cognite/neat/rules/importers/_owl2rules/_owl2rules.py +2 -4
  49. cognite/neat/rules/importers/_spreadsheet2rules.py +18 -16
  50. cognite/neat/rules/importers/_yaml2rules.py +2 -4
  51. cognite/neat/rules/issues/base.py +3 -0
  52. cognite/neat/rules/issues/dms.py +144 -58
  53. cognite/neat/rules/issues/fileread.py +41 -0
  54. cognite/neat/rules/issues/formatters.py +3 -1
  55. cognite/neat/rules/issues/importing.py +155 -0
  56. cognite/neat/rules/issues/spreadsheet.py +12 -9
  57. cognite/neat/rules/models/entities.py +30 -8
  58. cognite/neat/rules/models/rdfpath.py +1 -2
  59. cognite/neat/rules/models/rules/_base.py +5 -6
  60. cognite/neat/rules/models/rules/_dms_architect_rules.py +494 -333
  61. cognite/neat/rules/models/rules/_dms_rules_write.py +43 -52
  62. cognite/neat/rules/models/rules/_dms_schema.py +112 -22
  63. cognite/neat/rules/models/rules/_domain_rules.py +5 -0
  64. cognite/neat/rules/models/rules/_information_rules.py +13 -6
  65. cognite/neat/rules/models/wrapped_entities.py +166 -0
  66. cognite/neat/utils/cdf_loaders/_data_modeling.py +3 -1
  67. cognite/neat/utils/cdf_loaders/_ingestion.py +2 -4
  68. cognite/neat/utils/spreadsheet.py +2 -4
  69. cognite/neat/utils/utils.py +2 -4
  70. cognite/neat/workflows/base.py +5 -5
  71. cognite/neat/workflows/manager.py +32 -22
  72. cognite/neat/workflows/model.py +3 -3
  73. cognite/neat/workflows/steps/lib/__init__.py +0 -7
  74. cognite/neat/workflows/steps/lib/current/__init__.py +6 -0
  75. cognite/neat/workflows/steps/lib/{rules_exporter.py → current/rules_exporter.py} +8 -8
  76. cognite/neat/workflows/steps/lib/{rules_importer.py → current/rules_importer.py} +4 -4
  77. cognite/neat/workflows/steps/lib/io/__init__.py +1 -0
  78. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_contextualization.py +2 -2
  79. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_extractor.py +9 -9
  80. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_loader.py +9 -9
  81. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_store.py +4 -4
  82. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_transformer.py +2 -2
  83. cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_exporter.py +15 -17
  84. cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_importer.py +7 -7
  85. cognite/neat/workflows/steps/step_model.py +5 -9
  86. cognite/neat/workflows/steps_registry.py +20 -11
  87. {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/METADATA +1 -1
  88. {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/RECORD +98 -86
  89. cognite/neat/app/api/data_classes/configuration.py +0 -121
  90. /cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js.LICENSE.txt → main.ec7f72e2.js.LICENSE.txt} +0 -0
  91. /cognite/neat/workflows/steps/lib/{graph_extractor.py → current/graph_extractor.py} +0 -0
  92. /cognite/neat/workflows/steps/lib/{graph_loader.py → current/graph_loader.py} +0 -0
  93. /cognite/neat/workflows/steps/lib/{graph_store.py → current/graph_store.py} +0 -0
  94. /cognite/neat/workflows/steps/lib/{rules_validator.py → current/rules_validator.py} +0 -0
  95. /cognite/neat/workflows/steps/lib/{io_steps.py → io/io_steps.py} +0 -0
  96. /cognite/neat/workflows/steps/lib/{v1 → legacy}/__init__.py +0 -0
  97. {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/LICENSE +0 -0
  98. {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/WHEEL +0 -0
  99. {cognite_neat-0.75.8.dist-info → cognite_neat-0.76.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,116 @@
1
+ configs: []
2
+ description: null
3
+ implementation_module: null
4
+ name: Ontology to Data Model
5
+ steps:
6
+ - complex_configs: {}
7
+ configs: {}
8
+ description: null
9
+ enabled: true
10
+ id: step_trigger
11
+ label: Trigger
12
+ max_retries: 0
13
+ method: null
14
+ params: {}
15
+ retry_delay: 3
16
+ stype: http_trigger
17
+ system_component_id: null
18
+ transition_to:
19
+ - step_128344
20
+ - dowload_ontology
21
+ trigger: true
22
+ ui_config:
23
+ pos_x: 524
24
+ pos_y: 259
25
+ - complex_configs: {}
26
+ configs:
27
+ excel_file_path: rules/LIS-14-rules.xlsx
28
+ make_compliant: "True"
29
+ ontology_file_path: staging/LIS-14.ttl
30
+ description: null
31
+ enabled: true
32
+ id: onotology2rules
33
+ label: Import Ontology to Rules
34
+ max_retries: 0
35
+ method: ImportOntologyToRules
36
+ params: {}
37
+ retry_delay: 3
38
+ stype: stdstep
39
+ system_component_id: null
40
+ transition_to:
41
+ - load_generated_rules
42
+ - import_generated_rules
43
+ trigger: false
44
+ ui_config:
45
+ pos_x: 524
46
+ pos_y: 403
47
+ - complex_configs: {}
48
+ configs:
49
+ file_name: LIS-14-rules.xlsx
50
+ validation_report_file: rules_validation_report.txt
51
+ validation_report_storage_dir: rules_validation_report
52
+ version: ""
53
+ description: null
54
+ enabled: true
55
+ id: import_generated_rules
56
+ label: Import Generated Rules
57
+ max_retries: 0
58
+ method: ImportExcelToRules
59
+ params: {}
60
+ retry_delay: 3
61
+ stype: stdstep
62
+ system_component_id: null
63
+ transition_to:
64
+ - step_59017
65
+ - step_829062
66
+ - export_rules_to_graphql_schema
67
+ trigger: false
68
+ ui_config:
69
+ pos_x: 524
70
+ pos_y: 490
71
+ - complex_configs: {}
72
+ configs:
73
+ api_url: https://rds.posccaesar.org/ontology/lis14/ont/core/2.0/LIS-14.ttl
74
+ auth_mode: none
75
+ http_method: GET
76
+ output_file_path: staging/LIS-14.ttl
77
+ password: ""
78
+ response_destination: file
79
+ token: ""
80
+ username: ""
81
+ description: null
82
+ enabled: true
83
+ id: dowload_ontology
84
+ label: Download Ontology
85
+ max_retries: 0
86
+ method: DownloadDataFromRestApiToFile
87
+ params: {}
88
+ retry_delay: 3
89
+ stype: stdstep
90
+ system_component_id: null
91
+ transition_to:
92
+ - onotology2rules
93
+ trigger: false
94
+ ui_config:
95
+ pos_x: 524
96
+ pos_y: 333
97
+ - complex_configs: {}
98
+ configs:
99
+ file_name: ""
100
+ storage_dir: staging
101
+ description: null
102
+ enabled: true
103
+ id: export_rules_to_graphql_schema
104
+ label: Export Rules to GraphQL Schema
105
+ max_retries: 0
106
+ method: ExportRulesToGraphQLSchema
107
+ params: {}
108
+ retry_delay: 3
109
+ stype: stdstep
110
+ system_component_id: null
111
+ transition_to: []
112
+ trigger: false
113
+ ui_config:
114
+ pos_x: 525
115
+ pos_y: 577
116
+ system_components: []
@@ -0,0 +1,67 @@
1
+ configs: []
2
+ description: null
3
+ implementation_module: null
4
+ name: Validate Rules
5
+ steps:
6
+ - complex_configs: {}
7
+ configs:
8
+ File name: ''
9
+ Report formatter: BasicHTML
10
+ Role: infer
11
+ description: null
12
+ enabled: true
13
+ id: step_validate_rules
14
+ label: Validate Rules
15
+ max_retries: 0
16
+ method: ExcelToRules
17
+ params: {}
18
+ retry_delay: 3
19
+ stype: stdstep
20
+ system_component_id: null
21
+ transition_to:
22
+ - step_942973
23
+ - step_715590
24
+ trigger: false
25
+ ui_config:
26
+ pos_x: 558
27
+ pos_y: 97
28
+ - complex_configs: {}
29
+ configs: {}
30
+ description: null
31
+ enabled: true
32
+ id: step_upload_rules
33
+ label: Upload Rules Spreadsheets
34
+ max_retries: 0
35
+ method: null
36
+ params:
37
+ file_type: rules
38
+ retry_delay: 3
39
+ stype: file_uploader
40
+ system_component_id: null
41
+ transition_to:
42
+ - step_31642
43
+ - step_validate_rules
44
+ trigger: true
45
+ ui_config:
46
+ pos_x: 558
47
+ pos_y: -14
48
+ - complex_configs: {}
49
+ configs:
50
+ Output role format: input
51
+ Styling: default
52
+ description: null
53
+ enabled: true
54
+ id: step_715590
55
+ label: Convert Rules
56
+ max_retries: 0
57
+ method: RulesToExcel
58
+ params: {}
59
+ retry_delay: 3
60
+ stype: stdstep
61
+ system_component_id: null
62
+ transition_to: []
63
+ trigger: false
64
+ ui_config:
65
+ pos_x: 558
66
+ pos_y: 217
67
+ system_components: []
@@ -0,0 +1,64 @@
1
+ configs: []
2
+ description: null
3
+ implementation_module: null
4
+ name: Validate Solution Model
5
+ steps:
6
+ - complex_configs: {}
7
+ configs: {}
8
+ description: null
9
+ enabled: true
10
+ id: step_769298
11
+ label: Upload File
12
+ max_retries: 0
13
+ method: null
14
+ params:
15
+ file_type: rules
16
+ retry_delay: 3
17
+ stype: file_uploader
18
+ system_component_id: null
19
+ transition_to:
20
+ - step_399494
21
+ trigger: true
22
+ ui_config:
23
+ pos_x: 627
24
+ pos_y: -19
25
+ - complex_configs: {}
26
+ configs:
27
+ File name: ''
28
+ Report formatter: BasicHTML
29
+ Role: infer
30
+ description: null
31
+ enabled: true
32
+ id: step_399494
33
+ label: Import Excel
34
+ max_retries: 0
35
+ method: ExcelToRules
36
+ params: {}
37
+ retry_delay: 3
38
+ stype: stdstep
39
+ system_component_id: null
40
+ transition_to:
41
+ - step_273233
42
+ trigger: false
43
+ ui_config:
44
+ pos_x: 627
45
+ pos_y: 66
46
+ - complex_configs: {}
47
+ configs:
48
+ Report Formatter: BasicHTML
49
+ description: null
50
+ enabled: true
51
+ id: step_273233
52
+ label: Validate Against CDF
53
+ max_retries: 0
54
+ method: ValidateRulesAgainstCDF
55
+ params: {}
56
+ retry_delay: 3
57
+ stype: stdstep
58
+ system_component_id: null
59
+ transition_to: []
60
+ trigger: false
61
+ ui_config:
62
+ pos_x: 627
63
+ pos_y: 154
64
+ system_components: []
@@ -0,0 +1,95 @@
1
+ configs: []
2
+ description: null
3
+ implementation_module: null
4
+ name: Visualize Data Model Using Mock Graph
5
+ steps:
6
+ - complex_configs: {}
7
+ configs:
8
+ File name: information-architect-david.xlsx
9
+ Report formatter: BasicHTML
10
+ Role: infer
11
+ description: null
12
+ enabled: true
13
+ id: step_verify_rules
14
+ label: Verify Rules
15
+ max_retries: 0
16
+ method: ExcelToRules
17
+ params: {}
18
+ retry_delay: 3
19
+ stype: stdstep
20
+ system_component_id: null
21
+ transition_to:
22
+ - step_configure_graph_store
23
+ trigger: false
24
+ ui_config:
25
+ pos_x: 507
26
+ pos_y: 250
27
+ - complex_configs: {}
28
+ configs:
29
+ Disk storage directory: mock-graph-store
30
+ Graph: source
31
+ Graph store type: oxigraph
32
+ GraphDB API root URL: ""
33
+ Init procedure: reset
34
+ Query URL: ""
35
+ Update URL: ""
36
+ description: null
37
+ enabled: true
38
+ id: step_configure_graph_store
39
+ label: Configure Graph Store
40
+ max_retries: 0
41
+ method: GraphStoreConfiguration
42
+ params: {}
43
+ retry_delay: 3
44
+ stype: stdstep
45
+ system_component_id: null
46
+ transition_to:
47
+ - step_166101
48
+ - step_mock_graph_generation
49
+ trigger: false
50
+ ui_config:
51
+ pos_x: 506
52
+ pos_y: 314
53
+ - complex_configs: {}
54
+ configs:
55
+ Class count:
56
+ '{"WindTurbine" : 1, "WindFarm" : 1, "OffshoreSubstation" : 1,
57
+ "DistributionSubstation" : 1, "OnshoreSubstation" : 1, "ArrayCable" :
58
+ 1, "ExportCable" : 1, "Transmission" : 1, "DistributionLine" : 1, "Meter"
59
+ : 1, "ElectricCarCharger" : 1}'
60
+ Graph: source
61
+ description: null
62
+ enabled: true
63
+ id: step_mock_graph_generation
64
+ label: Generate Mock Graph
65
+ max_retries: 0
66
+ method: GraphFromMockData
67
+ params: {}
68
+ retry_delay: 3
69
+ stype: stdstep
70
+ system_component_id: null
71
+ transition_to: []
72
+ trigger: false
73
+ ui_config:
74
+ pos_x: 506
75
+ pos_y: 390
76
+ - complex_configs: {}
77
+ configs: {}
78
+ description: null
79
+ enabled: true
80
+ id: step_upload_rules
81
+ label: Upload Rules
82
+ max_retries: 0
83
+ method: null
84
+ params:
85
+ file_type: rules
86
+ retry_delay: 3
87
+ stype: file_uploader
88
+ system_component_id: null
89
+ transition_to:
90
+ - step_verify_rules
91
+ trigger: true
92
+ ui_config:
93
+ pos_x: 507
94
+ pos_y: 177
95
+ system_components: []
@@ -0,0 +1,111 @@
1
+ configs: []
2
+ description: null
3
+ implementation_module: null
4
+ name: Visualize Semantic Data Model
5
+ steps:
6
+ - complex_configs: {}
7
+ configs: {}
8
+ description: null
9
+ enabled: true
10
+ id: step_upload_excel_rules
11
+ label: Upload Excel Rules
12
+ max_retries: 0
13
+ method: null
14
+ params:
15
+ file_type: rules
16
+ retry_delay: 3
17
+ stype: file_uploader
18
+ system_component_id: null
19
+ transition_to:
20
+ - step_421523
21
+ - step_excel_to_rules
22
+ trigger: true
23
+ ui_config:
24
+ pos_x: 498
25
+ pos_y: 149
26
+ - complex_configs: {}
27
+ configs:
28
+ File name: ''
29
+ Report formatter: BasicHTML
30
+ Role: infer
31
+ description: null
32
+ enabled: true
33
+ id: step_excel_to_rules
34
+ label: Import and Validate Rules
35
+ max_retries: 0
36
+ method: ExcelToRules
37
+ params: {}
38
+ retry_delay: 3
39
+ stype: stdstep
40
+ system_component_id: null
41
+ transition_to:
42
+ - step_rules_to_ontology
43
+ trigger: false
44
+ ui_config:
45
+ pos_x: 497
46
+ pos_y: 234
47
+ - complex_configs: {}
48
+ configs:
49
+ File path: staging/semantic-data-model.ttl
50
+ description: null
51
+ enabled: true
52
+ id: step_rules_to_ontology
53
+ label: Rules to Ontology
54
+ max_retries: 0
55
+ method: RulesToSemanticDataModel
56
+ params: {}
57
+ retry_delay: 3
58
+ stype: stdstep
59
+ system_component_id: null
60
+ transition_to:
61
+ - step_configure_graph_store
62
+ trigger: false
63
+ ui_config:
64
+ pos_x: 497
65
+ pos_y: 323
66
+ - complex_configs: {}
67
+ configs:
68
+ Disk storage directory: semantic-data-model
69
+ Graph: source
70
+ Graph store type: oxigraph
71
+ GraphDB API root URL: ''
72
+ Init procedure: reset
73
+ Query URL: ''
74
+ Update URL: ''
75
+ description: null
76
+ enabled: true
77
+ id: step_configure_graph_store
78
+ label: Configure Graph Store
79
+ max_retries: 0
80
+ method: GraphStoreConfiguration
81
+ params: {}
82
+ retry_delay: 3
83
+ stype: stdstep
84
+ system_component_id: null
85
+ transition_to:
86
+ - step_load_semantic_data_model
87
+ trigger: false
88
+ ui_config:
89
+ pos_x: 495
90
+ pos_y: 399
91
+ - complex_configs: {}
92
+ configs:
93
+ Add base URI: 'False'
94
+ File path: staging/semantic-data-model.ttl
95
+ MIME type: text/turtle
96
+ description: null
97
+ enabled: true
98
+ id: step_load_semantic_data_model
99
+ label: Load Semantic Data Model
100
+ max_retries: 0
101
+ method: GraphFromRdfFile
102
+ params: {}
103
+ retry_delay: 3
104
+ stype: stdstep
105
+ system_component_id: null
106
+ transition_to: []
107
+ trigger: false
108
+ ui_config:
109
+ pos_x: 495
110
+ pos_y: 476
111
+ system_components: []
@@ -2,6 +2,8 @@ from abc import ABC
2
2
  from dataclasses import dataclass, field
3
3
  from functools import total_ordering
4
4
 
5
+ from cognite.neat.rules.issues import IssueList
6
+
5
7
 
6
8
  @total_ordering
7
9
  @dataclass
@@ -32,6 +34,7 @@ class UploadResult(UploadResultCore):
32
34
  failed_changed: int = 0
33
35
  failed_deleted: int = 0
34
36
  error_messages: list[str] = field(default_factory=list)
37
+ issues: IssueList = field(default_factory=IssueList)
35
38
 
36
39
  @property
37
40
  def total(self) -> int:
@@ -4,10 +4,13 @@ from pathlib import Path
4
4
  from typing import Literal, TypeAlias, cast
5
5
 
6
6
  from cognite.client import CogniteClient
7
- from cognite.client.data_classes._base import CogniteResourceList
7
+ from cognite.client.data_classes._base import CogniteResource, CogniteResourceList
8
+ from cognite.client.data_classes.data_modeling import DataModelApply, DataModelId
8
9
  from cognite.client.exceptions import CogniteAPIError
9
10
 
11
+ from cognite.neat.rules import issues
10
12
  from cognite.neat.rules._shared import Rules
13
+ from cognite.neat.rules.issues import IssueList
11
14
  from cognite.neat.rules.models.rules import InformationRules
12
15
  from cognite.neat.rules.models.rules._base import ExtensionCategory, SheetList
13
16
  from cognite.neat.rules.models.rules._dms_architect_rules import DMSContainer, DMSRules
@@ -43,6 +46,8 @@ class DMSExporter(CDFExporter[DMSSchema]):
43
46
  export_pipeline (bool, optional): Whether to export the pipeline. Defaults to False. This means setting
44
47
  up transformations, RAW databases and tables to populate the data model.
45
48
  instance_space (str, optional): The space to use for the instance. Defaults to None.
49
+ suppress_warnings (bool, optional): Suppress warnings. Defaults to False.
50
+
46
51
  ... note::
47
52
 
48
53
  - "fail": If any component already exists, the export will fail.
@@ -59,12 +64,14 @@ class DMSExporter(CDFExporter[DMSSchema]):
59
64
  existing_handling: Literal["fail", "skip", "update", "force"] = "update",
60
65
  export_pipeline: bool = False,
61
66
  instance_space: str | None = None,
67
+ suppress_warnings: bool = False,
62
68
  ):
63
69
  self.export_components = {export_components} if isinstance(export_components, str) else set(export_components)
64
70
  self.include_space = include_space
65
71
  self.existing_handling = existing_handling
66
72
  self.export_pipeline = export_pipeline
67
73
  self.instance_space = instance_space
74
+ self.suppress_warnings = suppress_warnings
68
75
  self._schema: DMSSchema | None = None
69
76
 
70
77
  def export_to_file(self, rules: Rules, filepath: Path) -> None:
@@ -115,11 +122,11 @@ class DMSExporter(CDFExporter[DMSSchema]):
115
122
  )
116
123
  is_new_model = dms_rules.reference is None
117
124
  if is_new_model or is_solution_model:
118
- return dms_rules.as_schema(self.export_pipeline, self.instance_space)
125
+ return dms_rules.as_schema(False, self.export_pipeline, self.instance_space)
119
126
 
120
127
  # This is an extension of an existing model.
121
128
  reference_rules = cast(DMSRules, dms_rules.reference).model_copy(deep=True)
122
- reference_schema = reference_rules.as_schema(self.export_pipeline)
129
+ reference_schema = reference_rules.as_schema(include_ref=False, include_pipeline=self.export_pipeline)
123
130
 
124
131
  # Todo Move this to an appropriate location
125
132
  # Merging Reference with User Rules
@@ -142,7 +149,7 @@ class DMSExporter(CDFExporter[DMSSchema]):
142
149
  property_.reference = None
143
150
  combined_rules.properties.append(property_)
144
151
 
145
- schema = combined_rules.as_schema(self.export_pipeline, self.instance_space)
152
+ schema = combined_rules.as_schema(True, self.export_pipeline, self.instance_space)
146
153
 
147
154
  if dms_rules.metadata.extension in (ExtensionCategory.addition, ExtensionCategory.reshape):
148
155
  # We do not freeze views as they might be changed, even for addition,
@@ -206,6 +213,7 @@ class DMSExporter(CDFExporter[DMSSchema]):
206
213
  redeploy_data_model = False
207
214
 
208
215
  for all_items, loader in to_export:
216
+ issue_list = IssueList()
209
217
  all_item_ids = loader.get_ids(all_items)
210
218
  skipped = sum(1 for item_id in all_item_ids if item_id in schema.frozen_ids)
211
219
  item_ids = [item_id for item_id in all_item_ids if item_id not in schema.frozen_ids]
@@ -249,6 +257,9 @@ class DMSExporter(CDFExporter[DMSSchema]):
249
257
  else:
250
258
  raise ValueError(f"Unsupported existing_handling {self.existing_handling}")
251
259
 
260
+ warning_list = self._validate(loader, items)
261
+ issue_list.extend(warning_list)
262
+
252
263
  error_messages: list[str] = []
253
264
  if not dry_run:
254
265
  if to_delete:
@@ -284,6 +295,7 @@ class DMSExporter(CDFExporter[DMSSchema]):
284
295
  failed_created=failed_created,
285
296
  failed_changed=failed_changed,
286
297
  error_messages=error_messages,
298
+ issues=issue_list,
287
299
  )
288
300
 
289
301
  if loader.resource_name == "views" and (created or changed) and not redeploy_data_model:
@@ -307,3 +319,33 @@ class DMSExporter(CDFExporter[DMSSchema]):
307
319
  to_export.append((schema.raw_tables, RawTableLoader(client)))
308
320
  to_export.append((schema.transformations, TransformationLoader(client)))
309
321
  return schema, to_export
322
+
323
+ def _validate(self, loader: ResourceLoader, items: list[CogniteResource]) -> IssueList:
324
+ issue_list = IssueList()
325
+ if isinstance(loader, DataModelLoader):
326
+ models = cast(list[DataModelApply], items)
327
+ if other_models := self._exist_other_data_models(loader, models):
328
+ warning = issues.dms.OtherDataModelsInSpaceWarning(models[0].space, other_models)
329
+ if not self.suppress_warnings:
330
+ warnings.warn(warning, stacklevel=2)
331
+ issue_list.append(warning)
332
+
333
+ return issue_list
334
+
335
+ @classmethod
336
+ def _exist_other_data_models(cls, loader: DataModelLoader, models: list[DataModelApply]) -> list[DataModelId]:
337
+ if not models:
338
+ return []
339
+ space = models[0].space
340
+ external_id = models[0].external_id
341
+ try:
342
+ data_models = loader.client.data_modeling.data_models.list(space=space, limit=25, all_versions=False)
343
+ except CogniteAPIError as e:
344
+ warnings.warn(issues.importing.APIWarning(str(e)), stacklevel=2)
345
+ return []
346
+ else:
347
+ return [
348
+ data_model.as_id()
349
+ for data_model in data_models
350
+ if (data_model.space, data_model.external_id) != (space, external_id)
351
+ ]
@@ -120,13 +120,6 @@ class ExcelExporter(BaseExporter[Workbook]):
120
120
  else:
121
121
  sheet = workbook.create_sheet(sheet_name)
122
122
 
123
- # Reorder such that the first column is class + the first field of the subclass
124
- # of sheet entity. This is to make the properties/classes/views/containers sheet more readable.
125
- # For example, for the properties these that means class, property, name, description
126
- # instead of class, name, description, property
127
- move = len(SheetEntity.model_fields) - 1 # -1 is for the class field
128
- headers = headers[:1] + headers[move : move + 1] + headers[1:move] + headers[move + 1 :]
129
-
130
123
  main_header = self._main_header_by_sheet_name[sheet_name]
131
124
  sheet.append([main_header] + [""] * (len(headers) - 1))
132
125
  sheet.merge_cells(start_row=1, start_column=1, end_row=1, end_column=len(headers))
@@ -150,8 +143,6 @@ class ExcelExporter(BaseExporter[Workbook]):
150
143
  cell.border = Border(left=side, right=side, top=side, bottom=side)
151
144
  fill_color = next(fill_colors)
152
145
 
153
- # Need to do the same reordering as for the headers above
154
- row = row[:1] + row[move : move + 1] + row[1:move] + row[move + 1 :]
155
146
  sheet.append(row)
156
147
  if self._styling_level > 2 and is_properties:
157
148
  for cell in sheet[sheet.max_row]:
@@ -205,8 +196,8 @@ class ExcelExporter(BaseExporter[Workbook]):
205
196
 
206
197
  @classmethod
207
198
  def _adjust_column_widths(cls, workbook: Workbook) -> None:
208
- for sheet in workbook:
209
- sheet = cast(Worksheet, sheet)
199
+ for sheet_ in workbook:
200
+ sheet = cast(Worksheet, sheet_)
210
201
  for column_cells in sheet.columns:
211
202
  try:
212
203
  max_length = max(len(str(cell.value)) for cell in column_cells if cell.value is not None)
@@ -9,13 +9,13 @@ from cognite.neat.rules.models.rules._types._base import DMS_PROPERTY_ID_COMPLIA
9
9
 
10
10
 
11
11
  @overload
12
- def are_entity_names_dms_compliant(rules: InformationRules, return_report: Literal[True]) -> tuple[bool, list[dict]]:
13
- ...
12
+ def are_entity_names_dms_compliant(
13
+ rules: InformationRules, return_report: Literal[True]
14
+ ) -> tuple[bool, list[dict]]: ...
14
15
 
15
16
 
16
17
  @overload
17
- def are_entity_names_dms_compliant(rules: InformationRules, return_report: Literal[False] = False) -> bool:
18
- ...
18
+ def are_entity_names_dms_compliant(rules: InformationRules, return_report: Literal[False] = False) -> bool: ...
19
19
 
20
20
 
21
21
  def are_entity_names_dms_compliant(
@@ -66,13 +66,11 @@ def are_entity_names_dms_compliant(
66
66
 
67
67
 
68
68
  @overload
69
- def are_properties_redefined(rules: InformationRules, return_report: Literal[True]) -> tuple[bool, list[dict]]:
70
- ...
69
+ def are_properties_redefined(rules: InformationRules, return_report: Literal[True]) -> tuple[bool, list[dict]]: ...
71
70
 
72
71
 
73
72
  @overload
74
- def are_properties_redefined(rules: InformationRules, return_report: Literal[False] = False) -> bool:
75
- ...
73
+ def are_properties_redefined(rules: InformationRules, return_report: Literal[False] = False) -> bool: ...
76
74
 
77
75
 
78
76
  def are_properties_redefined(rules: InformationRules, return_report: bool = False) -> bool | tuple[bool, list[dict]]:
@@ -20,14 +20,12 @@ class BaseImporter(ABC):
20
20
  """
21
21
 
22
22
  @overload
23
- def to_rules(self, errors: Literal["raise"], role: RoleTypes | None = None) -> Rules:
24
- ...
23
+ def to_rules(self, errors: Literal["raise"], role: RoleTypes | None = None) -> Rules: ...
25
24
 
26
25
  @overload
27
26
  def to_rules(
28
27
  self, errors: Literal["continue"] = "continue", role: RoleTypes | None = None
29
- ) -> tuple[Rules | None, IssueList]:
30
- ...
28
+ ) -> tuple[Rules | None, IssueList]: ...
31
29
 
32
30
  @abstractmethod
33
31
  def to_rules(
@@ -62,6 +60,12 @@ class BaseImporter(ABC):
62
60
  else:
63
61
  return output, issues
64
62
 
63
+ @classmethod
64
+ def _return_or_raise(cls, issue_list: IssueList, errors: Literal["raise", "continue"]) -> tuple[None, IssueList]:
65
+ if errors == "raise":
66
+ raise issue_list.as_errors()
67
+ return None, issue_list
68
+
65
69
  def _default_metadata(self):
66
70
  return {
67
71
  "prefix": "neat",