cognite-neat 0.75.7__py3-none-any.whl → 0.75.9__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 (103) 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/graph/extractors/_mock_graph_generator.py +6 -5
  16. cognite/neat/legacy/graph/exceptions.py +1 -2
  17. cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +1 -2
  18. cognite/neat/legacy/graph/loaders/_asset_loader.py +8 -13
  19. cognite/neat/legacy/graph/loaders/_base.py +2 -4
  20. cognite/neat/legacy/graph/loaders/_exceptions.py +1 -3
  21. cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +4 -8
  22. cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +2 -4
  23. cognite/neat/legacy/graph/loaders/rdf_to_dms.py +2 -4
  24. cognite/neat/legacy/graph/loaders/validator.py +1 -1
  25. cognite/neat/legacy/graph/transformations/transformer.py +1 -2
  26. cognite/neat/legacy/rules/exporters/_rules2dms.py +1 -2
  27. cognite/neat/legacy/rules/exporters/_validation.py +4 -8
  28. cognite/neat/legacy/rules/importers/_base.py +0 -4
  29. cognite/neat/legacy/rules/importers/_dms2rules.py +0 -2
  30. cognite/neat/legacy/rules/models/rdfpath.py +1 -2
  31. cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +89 -0
  32. cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +152 -0
  33. cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +139 -0
  34. cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +270 -0
  35. cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +65 -0
  36. cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +116 -0
  37. cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +67 -0
  38. cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +64 -0
  39. cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +95 -0
  40. cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +111 -0
  41. cognite/neat/rules/analysis/_base.py +1 -1
  42. cognite/neat/rules/analysis/_information_rules.py +4 -4
  43. cognite/neat/rules/exporters/_rules2excel.py +2 -2
  44. cognite/neat/rules/exporters/_rules2ontology.py +20 -17
  45. cognite/neat/rules/exporters/_validation.py +8 -10
  46. cognite/neat/rules/importers/_base.py +2 -4
  47. cognite/neat/rules/importers/_dms2rules.py +16 -19
  48. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +21 -19
  49. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +2 -4
  50. cognite/neat/rules/importers/_dtdl2rules/spec.py +3 -5
  51. cognite/neat/rules/importers/_owl2rules/_owl2rules.py +4 -6
  52. cognite/neat/rules/importers/_spreadsheet2rules.py +10 -9
  53. cognite/neat/rules/importers/_yaml2rules.py +10 -6
  54. cognite/neat/rules/issues/dms.py +3 -5
  55. cognite/neat/rules/issues/formatters.py +3 -1
  56. cognite/neat/rules/models/data_types.py +54 -31
  57. cognite/neat/rules/models/entities.py +184 -42
  58. cognite/neat/rules/models/rdfpath.py +112 -13
  59. cognite/neat/rules/models/rules/_base.py +2 -2
  60. cognite/neat/rules/models/rules/_dms_architect_rules.py +119 -189
  61. cognite/neat/rules/models/rules/_dms_rules_write.py +344 -0
  62. cognite/neat/rules/models/rules/_dms_schema.py +3 -3
  63. cognite/neat/rules/models/rules/_domain_rules.py +6 -3
  64. cognite/neat/rules/models/rules/_information_rules.py +68 -61
  65. cognite/neat/rules/models/rules/_types/__init__.py +0 -47
  66. cognite/neat/rules/models/rules/_types/_base.py +1 -309
  67. cognite/neat/rules/models/rules/_types/_field.py +0 -225
  68. cognite/neat/utils/cdf_loaders/_data_modeling.py +3 -1
  69. cognite/neat/utils/cdf_loaders/_ingestion.py +2 -4
  70. cognite/neat/utils/spreadsheet.py +2 -4
  71. cognite/neat/utils/utils.py +2 -4
  72. cognite/neat/workflows/base.py +5 -5
  73. cognite/neat/workflows/manager.py +32 -22
  74. cognite/neat/workflows/model.py +3 -3
  75. cognite/neat/workflows/steps/lib/__init__.py +0 -7
  76. cognite/neat/workflows/steps/lib/current/__init__.py +6 -0
  77. cognite/neat/workflows/steps/lib/{rules_exporter.py → current/rules_exporter.py} +8 -8
  78. cognite/neat/workflows/steps/lib/{rules_importer.py → current/rules_importer.py} +7 -7
  79. cognite/neat/workflows/steps/lib/io/__init__.py +1 -0
  80. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_contextualization.py +2 -2
  81. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_extractor.py +9 -9
  82. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_loader.py +9 -9
  83. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_store.py +4 -4
  84. cognite/neat/workflows/steps/lib/{v1 → legacy}/graph_transformer.py +2 -2
  85. cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_exporter.py +15 -17
  86. cognite/neat/workflows/steps/lib/{v1 → legacy}/rules_importer.py +7 -7
  87. cognite/neat/workflows/steps/step_model.py +5 -9
  88. cognite/neat/workflows/steps_registry.py +20 -11
  89. {cognite_neat-0.75.7.dist-info → cognite_neat-0.75.9.dist-info}/METADATA +1 -1
  90. {cognite_neat-0.75.7.dist-info → cognite_neat-0.75.9.dist-info}/RECORD +100 -90
  91. cognite/neat/app/api/data_classes/configuration.py +0 -121
  92. cognite/neat/rules/models/_entity.py +0 -142
  93. cognite/neat/rules/models/rules/_types/_value.py +0 -159
  94. /cognite/neat/app/ui/neat-app/build/static/js/{main.4345d42f.js.LICENSE.txt → main.ec7f72e2.js.LICENSE.txt} +0 -0
  95. /cognite/neat/workflows/steps/lib/{graph_extractor.py → current/graph_extractor.py} +0 -0
  96. /cognite/neat/workflows/steps/lib/{graph_loader.py → current/graph_loader.py} +0 -0
  97. /cognite/neat/workflows/steps/lib/{graph_store.py → current/graph_store.py} +0 -0
  98. /cognite/neat/workflows/steps/lib/{rules_validator.py → current/rules_validator.py} +0 -0
  99. /cognite/neat/workflows/steps/lib/{io_steps.py → io/io_steps.py} +0 -0
  100. /cognite/neat/workflows/steps/lib/{v1 → legacy}/__init__.py +0 -0
  101. {cognite_neat-0.75.7.dist-info → cognite_neat-0.75.9.dist-info}/LICENSE +0 -0
  102. {cognite_neat-0.75.7.dist-info → cognite_neat-0.75.9.dist-info}/WHEEL +0 -0
  103. {cognite_neat-0.75.7.dist-info → cognite_neat-0.75.9.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: []
@@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
3
3
  from typing import Generic, TypeVar
4
4
 
5
5
  from cognite.neat.rules._shared import Rules
6
- from cognite.neat.rules.models.rules._types import ClassEntity
6
+ from cognite.neat.rules.models.entities import ClassEntity
7
7
 
8
8
  if sys.version_info >= (3, 11):
9
9
  from enum import StrEnum
@@ -7,10 +7,10 @@ from typing import Any, cast
7
7
  import pandas as pd
8
8
  from pydantic import ValidationError
9
9
 
10
+ from cognite.neat.rules.models.entities import ClassEntity, EntityTypes, ParentClassEntity, ReferenceEntity
10
11
  from cognite.neat.rules.models.rdfpath import TransformationRuleType
11
12
  from cognite.neat.rules.models.rules._base import SchemaCompleteness
12
13
  from cognite.neat.rules.models.rules._information_rules import InformationClass, InformationProperty, InformationRules
13
- from cognite.neat.rules.models.rules._types._base import ClassEntity, EntityTypes, ParentClassEntity, ReferenceEntity
14
14
  from cognite.neat.utils.utils import get_inheritance_path
15
15
 
16
16
  from ._base import BaseAnalysis, DataModelingScenario
@@ -126,7 +126,7 @@ class InformationArchitectRulesAnalysis(BaseAnalysis):
126
126
  return class_property_pairs
127
127
 
128
128
  def class_inheritance_path(self, class_: ClassEntity | str, use_reference: bool = False) -> list[ClassEntity]:
129
- class_ = class_ if isinstance(class_, ClassEntity) else ClassEntity.from_raw(class_)
129
+ class_ = class_ if isinstance(class_, ClassEntity) else ClassEntity.load(class_)
130
130
  class_parent_pairs = self.class_parent_pairs(use_reference)
131
131
  return get_inheritance_path(class_, class_parent_pairs)
132
132
 
@@ -328,7 +328,7 @@ class InformationArchitectRulesAnalysis(BaseAnalysis):
328
328
  """This is to simplify access to classes through dict."""
329
329
  class_dict: dict[str, InformationClass] = {}
330
330
  for definition in self.rules.classes:
331
- class_dict[definition.class_.suffix] = definition
331
+ class_dict[str(definition.class_.suffix)] = definition
332
332
  return class_dict
333
333
 
334
334
  def subset_rules(self, desired_classes: set[ClassEntity], use_reference: bool = False) -> InformationRules:
@@ -398,7 +398,7 @@ class InformationArchitectRulesAnalysis(BaseAnalysis):
398
398
 
399
399
  logging.info(f"Reducing data model to only include the following classes: {possible_classes}")
400
400
  for class_ in possible_classes:
401
- reduced_data_model["classes"].append(class_as_dict[class_.suffix])
401
+ reduced_data_model["classes"].append(class_as_dict[str(class_.suffix)])
402
402
 
403
403
  class_property_pairs = self.classes_with_properties(consider_inheritance=False)
404
404
 
@@ -205,8 +205,8 @@ class ExcelExporter(BaseExporter[Workbook]):
205
205
 
206
206
  @classmethod
207
207
  def _adjust_column_widths(cls, workbook: Workbook) -> None:
208
- for sheet in workbook:
209
- sheet = cast(Worksheet, sheet)
208
+ for sheet_ in workbook:
209
+ sheet = cast(Worksheet, sheet_)
210
210
  for column_cells in sheet.columns:
211
211
  try:
212
212
  max_length = max(len(str(cell.value)) for cell in column_cells if cell.value is not None)
@@ -11,6 +11,8 @@ from rdflib.collection import Collection as GraphCollection
11
11
  from cognite.neat.constants import DEFAULT_NAMESPACE as NEAT_NAMESPACE
12
12
  from cognite.neat.rules import exceptions
13
13
  from cognite.neat.rules.analysis import InformationArchitectRulesAnalysis
14
+ from cognite.neat.rules.models.data_types import DataType
15
+ from cognite.neat.rules.models.entities import ClassEntity, EntityTypes
14
16
  from cognite.neat.rules.models.rules import DMSRules
15
17
  from cognite.neat.rules.models.rules._information_rules import (
16
18
  InformationClass,
@@ -18,7 +20,6 @@ from cognite.neat.rules.models.rules._information_rules import (
18
20
  InformationProperty,
19
21
  InformationRules,
20
22
  )
21
- from cognite.neat.rules.models.rules._types import XSD_VALUE_TYPE_MAPPINGS, EntityTypes
22
23
  from cognite.neat.utils.utils import generate_exception_report, remove_namespace
23
24
 
24
25
  from ._base import BaseExporter
@@ -114,7 +115,7 @@ class Ontology(OntologyModel):
114
115
  ],
115
116
  shapes=[
116
117
  SHACLNodeShape.from_rules(
117
- class_dict[class_.suffix],
118
+ class_dict[str(class_.suffix)],
118
119
  list(properties.values()),
119
120
  rules.metadata.namespace,
120
121
  )
@@ -249,15 +250,15 @@ class OWLClass(OntologyModel):
249
250
  sub_class_of = []
250
251
  for parent_class in definition.parent:
251
252
  try:
252
- sub_class_of.append(prefixes[parent_class.prefix][parent_class.suffix])
253
+ sub_class_of.append(prefixes[str(parent_class.prefix)][str(parent_class.suffix)])
253
254
  except KeyError:
254
- sub_class_of.append(namespace[parent_class.suffix])
255
+ sub_class_of.append(namespace[str(parent_class.suffix)])
255
256
  else:
256
257
  sub_class_of = None
257
258
 
258
259
  return cls(
259
- id_=namespace[definition.class_.suffix],
260
- label=definition.name or definition.class_.suffix,
260
+ id_=namespace[str(definition.class_.suffix)],
261
+ label=definition.name or str(definition.class_.suffix),
261
262
  comment=definition.description,
262
263
  sub_class_of=sub_class_of,
263
264
  namespace=namespace,
@@ -324,12 +325,14 @@ class OWLProperty(OntologyModel):
324
325
  )
325
326
  for definition in definitions:
326
327
  owl_property.type_.add(OWL[definition.type_])
327
- owl_property.range_.add(
328
- XSD[definition.value_type.suffix]
329
- if definition.value_type.suffix in XSD_VALUE_TYPE_MAPPINGS
330
- else namespace[definition.value_type.suffix]
331
- )
332
- owl_property.domain.add(namespace[definition.class_.suffix])
328
+
329
+ if isinstance(definition.value_type, DataType):
330
+ owl_property.range_.add(XSD[definition.value_type.xsd])
331
+ elif isinstance(definition.value_type, ClassEntity):
332
+ owl_property.range_.add(namespace[str(definition.value_type.suffix)])
333
+ else:
334
+ raise ValueError(f"Value type {definition.value_type} is not supported")
335
+ owl_property.domain.add(namespace[str(definition.class_.suffix)])
333
336
  owl_property.label.add(definition.name or definition.property_)
334
337
  if definition.description:
335
338
  owl_property.comment.add(definition.description)
@@ -493,12 +496,12 @@ class SHACLNodeShape(OntologyModel):
493
496
  cls, class_definition: InformationClass, property_definitions: list[InformationProperty], namespace: Namespace
494
497
  ) -> "SHACLNodeShape":
495
498
  if class_definition.parent:
496
- parent = [namespace[parent.suffix + "Shape"] for parent in class_definition.parent]
499
+ parent = [namespace[str(parent.suffix) + "Shape"] for parent in class_definition.parent]
497
500
  else:
498
501
  parent = None
499
502
  return cls(
500
- id_=namespace[f"{class_definition.class_.suffix}Shape"],
501
- target_class=namespace[class_definition.class_.suffix],
503
+ id_=namespace[f"{class_definition.class_.suffix!s}Shape"],
504
+ target_class=namespace[str(class_definition.class_.suffix)],
502
505
  parent=parent,
503
506
  property_shapes=[SHACLPropertyShape.from_property(prop, namespace) for prop in property_definitions],
504
507
  namespace=namespace,
@@ -552,8 +555,8 @@ class SHACLPropertyShape(OntologyModel):
552
555
  node_kind=SHACL.IRI if definition.type_ == EntityTypes.object_property else SHACL.Literal,
553
556
  expected_value_type=(
554
557
  namespace[f"{definition.value_type.suffix}Shape"]
555
- if definition.type_ == EntityTypes.object_property
556
- else XSD[definition.value_type.suffix]
558
+ if isinstance(definition.value_type, ClassEntity)
559
+ else XSD[definition.value_type.xsd]
557
560
  ),
558
561
  min_count=definition.min_count,
559
562
  max_count=(
@@ -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(
@@ -26,7 +26,7 @@ def are_entity_names_dms_compliant(
26
26
  flag: bool = True
27
27
  with warnings.catch_warnings(record=True) as validation_warnings:
28
28
  for class_ in rules.classes:
29
- if not re.match(VIEW_ID_COMPLIANCE_REGEX, class_.class_.suffix):
29
+ if not re.match(VIEW_ID_COMPLIANCE_REGEX, str(class_.class_.suffix)):
30
30
  warnings.warn(
31
31
  exceptions.EntityIDNotDMSCompliant(
32
32
  "Class", class_.class_.versioned_id, f"[Classes/Class/{class_.class_.versioned_id}]"
@@ -38,7 +38,7 @@ def are_entity_names_dms_compliant(
38
38
 
39
39
  for row, property_ in enumerate(rules.properties):
40
40
  # check class id which would resolve as view/container id
41
- if not re.match(VIEW_ID_COMPLIANCE_REGEX, property_.class_.suffix):
41
+ if not re.match(VIEW_ID_COMPLIANCE_REGEX, str(property_.class_.suffix)):
42
42
  warnings.warn(
43
43
  exceptions.EntityIDNotDMSCompliant(
44
44
  "Class", property_.class_.versioned_id, f"[Properties/Class/{row}]"
@@ -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(