cognite-neat 0.73.4__py3-none-any.whl → 0.75.1__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 (160) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/app/api/routers/core.py +1 -2
  3. cognite/neat/app/api/routers/data_exploration.py +1 -1
  4. cognite/neat/app/api/routers/rules.py +71 -37
  5. cognite/neat/app/ui/neat-app/build/asset-manifest.json +3 -3
  6. cognite/neat/app/ui/neat-app/build/img/architect-icon.svg +116 -0
  7. cognite/neat/app/ui/neat-app/build/img/developer-icon.svg +112 -0
  8. cognite/neat/app/ui/neat-app/build/img/sme-icon.svg +34 -0
  9. cognite/neat/app/ui/neat-app/build/index.html +1 -1
  10. cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js → main.25d27396.js} +3 -3
  11. cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js.map → main.25d27396.js.map} +1 -1
  12. cognite/neat/constants.py +2 -2
  13. cognite/neat/graph/extractors/_mock_graph_generator.py +4 -4
  14. cognite/neat/graph/stores/_base.py +2 -23
  15. cognite/neat/legacy/graph/__init__.py +3 -0
  16. cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +20182 -0
  17. cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +20163 -0
  18. cognite/neat/legacy/graph/examples/__init__.py +7 -0
  19. cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
  20. cognite/neat/legacy/graph/exceptions.py +91 -0
  21. cognite/neat/{graph/extractor → legacy/graph/extractors}/_base.py +1 -1
  22. cognite/neat/{graph/extractor → legacy/graph/extractors}/_dexpi.py +2 -2
  23. cognite/neat/{graph/extractor → legacy/graph/extractors}/_graph_capturing_sheet.py +6 -6
  24. cognite/neat/{graph/extractor → legacy/graph/extractors}/_mock_graph_generator.py +6 -5
  25. cognite/neat/{graph/loader → legacy/graph/loaders}/__init__.py +1 -1
  26. cognite/neat/{graph/loader → legacy/graph/loaders}/_asset_loader.py +3 -3
  27. cognite/neat/{graph/loader → legacy/graph/loaders}/_base.py +4 -4
  28. cognite/neat/{graph/loader → legacy/graph/loaders}/core/labels.py +2 -2
  29. cognite/neat/{graph/loader → legacy/graph/loaders}/core/models.py +1 -1
  30. cognite/neat/{graph/loader → legacy/graph/loaders}/core/rdf_to_assets.py +3 -3
  31. cognite/neat/{graph/loader → legacy/graph/loaders}/core/rdf_to_relationships.py +5 -5
  32. cognite/neat/{graph/loader → legacy/graph/loaders}/rdf_to_dms.py +5 -5
  33. cognite/neat/legacy/graph/models.py +6 -0
  34. cognite/neat/legacy/graph/stores/__init__.py +13 -0
  35. cognite/neat/legacy/graph/stores/_base.py +384 -0
  36. cognite/neat/legacy/graph/stores/_graphdb_store.py +51 -0
  37. cognite/neat/legacy/graph/stores/_memory_store.py +43 -0
  38. cognite/neat/legacy/graph/stores/_oxigraph_store.py +147 -0
  39. cognite/neat/legacy/graph/stores/_oxrdflib.py +247 -0
  40. cognite/neat/legacy/graph/stores/_rdf_to_graph.py +40 -0
  41. cognite/neat/{graph/transformation → legacy/graph/transformations}/entity_matcher.py +1 -1
  42. cognite/neat/{graph/transformation → legacy/graph/transformations}/query_generator/sparql.py +9 -7
  43. cognite/neat/{graph/transformation → legacy/graph/transformations}/transformer.py +12 -5
  44. cognite/neat/legacy/rules/__init__.py +0 -0
  45. cognite/neat/{rules → legacy/rules}/analysis.py +2 -2
  46. cognite/neat/legacy/rules/examples/__init__.py +18 -0
  47. cognite/neat/legacy/rules/examples/wind-energy.owl +1511 -0
  48. cognite/neat/legacy/rules/exceptions.py +2972 -0
  49. cognite/neat/{rules/exporter → legacy/rules/exporters}/_base.py +2 -2
  50. cognite/neat/{rules/exporter → legacy/rules/exporters}/_core/rules2labels.py +1 -1
  51. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2dms.py +6 -6
  52. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2excel.py +1 -1
  53. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2graphql.py +5 -5
  54. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2ontology.py +6 -6
  55. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2pydantic_models.py +8 -8
  56. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2rules.py +3 -2
  57. cognite/neat/{rules/exporter → legacy/rules/exporters}/_rules2triples.py +3 -2
  58. cognite/neat/{rules/exporter → legacy/rules/exporters}/_validation.py +2 -2
  59. cognite/neat/{rules/importer → legacy/rules/importers}/_base.py +2 -2
  60. cognite/neat/{rules/importer → legacy/rules/importers}/_dict2rules.py +1 -1
  61. cognite/neat/{rules/importer → legacy/rules/importers}/_dms2rules.py +2 -2
  62. cognite/neat/{rules/importer → legacy/rules/importers}/_graph2rules.py +5 -4
  63. cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2metadata.py +11 -7
  64. cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2rules.py +5 -5
  65. cognite/neat/{rules/importer → legacy/rules/importers}/_spreadsheet2rules.py +2 -2
  66. cognite/neat/{rules/importer → legacy/rules/importers}/_xsd2rules.py +1 -1
  67. cognite/neat/{rules/importer → legacy/rules/importers}/_yaml2rules.py +1 -1
  68. cognite/neat/{rules → legacy/rules}/models/raw_rules.py +4 -4
  69. cognite/neat/legacy/rules/models/rdfpath.py +238 -0
  70. cognite/neat/{rules → legacy/rules}/models/rules.py +4 -4
  71. cognite/neat/{rules → legacy/rules}/models/value_types.py +1 -1
  72. cognite/neat/rules/_shared.py +1 -1
  73. cognite/neat/rules/analysis/__init__.py +3 -0
  74. cognite/neat/rules/{_analysis → analysis}/_base.py +1 -1
  75. cognite/neat/rules/{_analysis → analysis}/_information_rules.py +3 -3
  76. cognite/neat/rules/examples/__init__.py +0 -9
  77. cognite/neat/rules/exporters/_base.py +1 -1
  78. cognite/neat/rules/exporters/_rules2dms.py +4 -4
  79. cognite/neat/rules/exporters/_rules2excel.py +2 -2
  80. cognite/neat/rules/exporters/_rules2ontology.py +4 -4
  81. cognite/neat/rules/exporters/_rules2yaml.py +1 -1
  82. cognite/neat/rules/exporters/_validation.py +2 -2
  83. cognite/neat/rules/importers/_base.py +1 -1
  84. cognite/neat/rules/importers/_dms2rules.py +10 -10
  85. cognite/neat/rules/importers/_dtdl2rules/dtdl_converter.py +2 -2
  86. cognite/neat/rules/importers/_dtdl2rules/dtdl_importer.py +3 -3
  87. cognite/neat/rules/importers/_dtdl2rules/spec.py +1 -1
  88. cognite/neat/rules/importers/_owl2rules/_owl2classes.py +1 -1
  89. cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +6 -6
  90. cognite/neat/rules/importers/_owl2rules/_owl2properties.py +1 -1
  91. cognite/neat/rules/importers/_owl2rules/_owl2rules.py +2 -2
  92. cognite/neat/rules/importers/_spreadsheet2rules.py +2 -2
  93. cognite/neat/rules/importers/_yaml2rules.py +1 -1
  94. cognite/neat/rules/models/_entity.py +142 -0
  95. cognite/neat/rules/models/rdfpath.py +6 -8
  96. cognite/neat/rules/models/{_rules → rules}/__init__.py +5 -5
  97. cognite/neat/rules/models/{_rules/base.py → rules/_base.py} +1 -1
  98. cognite/neat/rules/models/{_rules/dms_architect_rules.py → rules/_dms_architect_rules.py} +5 -5
  99. cognite/neat/rules/models/{_rules/dms_schema.py → rules/_dms_schema.py} +1 -1
  100. cognite/neat/rules/models/{_rules/domain_rules.py → rules/_domain_rules.py} +2 -2
  101. cognite/neat/rules/models/{_rules/information_rules.py → rules/_information_rules.py} +18 -15
  102. cognite/neat/rules/models/{_rules → rules}/_types/_base.py +18 -134
  103. cognite/neat/workflows/steps/data_contracts.py +4 -4
  104. cognite/neat/workflows/steps/lib/graph_store.py +1 -1
  105. cognite/neat/workflows/steps/lib/rules_exporter.py +18 -5
  106. cognite/neat/workflows/steps/lib/rules_importer.py +2 -2
  107. cognite/neat/workflows/steps/lib/rules_validator.py +2 -2
  108. cognite/neat/workflows/steps/lib/v1/graph_contextualization.py +1 -1
  109. cognite/neat/workflows/steps/lib/v1/graph_extractor.py +5 -5
  110. cognite/neat/workflows/steps/lib/v1/graph_loader.py +7 -7
  111. cognite/neat/workflows/steps/lib/v1/graph_store.py +7 -1
  112. cognite/neat/workflows/steps/lib/v1/graph_transformer.py +2 -2
  113. cognite/neat/workflows/steps/lib/v1/rules_exporter.py +7 -7
  114. cognite/neat/workflows/steps/lib/v1/rules_importer.py +13 -13
  115. {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/METADATA +1 -1
  116. cognite_neat-0.75.1.dist-info/RECORD +258 -0
  117. cognite_neat-0.73.4.dist-info/RECORD +0 -234
  118. /cognite/neat/app/ui/neat-app/build/static/js/{main.2efd96b2.js.LICENSE.txt → main.25d27396.js.LICENSE.txt} +0 -0
  119. /cognite/neat/{graph/loader/core → legacy}/__init__.py +0 -0
  120. /cognite/neat/{graph/extractor → legacy/graph/extractors}/__init__.py +0 -0
  121. /cognite/neat/{graph/loader → legacy/graph/loaders}/_exceptions.py +0 -0
  122. /cognite/neat/{graph/transformation → legacy/graph/loaders/core}/__init__.py +0 -0
  123. /cognite/neat/{graph/loader → legacy/graph/loaders}/validator.py +0 -0
  124. /cognite/neat/{rules/_analysis → legacy/graph/transformations}/__init__.py +0 -0
  125. /cognite/neat/{graph/transformation → legacy/graph/transformations}/query_generator/__init__.py +0 -0
  126. /cognite/neat/{rules → legacy/rules}/examples/Rules-Nordic44-to-TNT.xlsx +0 -0
  127. /cognite/neat/{rules → legacy/rules}/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
  128. /cognite/neat/{rules → legacy/rules}/examples/power-grid-containers.yaml +0 -0
  129. /cognite/neat/{rules → legacy/rules}/examples/power-grid-example.xlsx +0 -0
  130. /cognite/neat/{rules → legacy/rules}/examples/power-grid-model.yaml +0 -0
  131. /cognite/neat/{rules → legacy/rules}/examples/rules-template.xlsx +0 -0
  132. /cognite/neat/{rules → legacy/rules}/examples/sheet2cdf-transformation-rules.xlsx +0 -0
  133. /cognite/neat/{rules → legacy/rules}/examples/skos-rules.xlsx +0 -0
  134. /cognite/neat/{rules → legacy/rules}/examples/source-to-solution-mapping-rules.xlsx +0 -0
  135. /cognite/neat/{rules/exporter → legacy/rules/exporters}/__init__.py +0 -0
  136. /cognite/neat/{rules/exporter → legacy/rules/exporters}/_core/__init__.py +0 -0
  137. /cognite/neat/{rules/importer → legacy/rules/importers}/__init__.py +0 -0
  138. /cognite/neat/{rules/importer → legacy/rules/importers}/_json2rules.py +0 -0
  139. /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/__init__.py +0 -0
  140. /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2classes.py +0 -0
  141. /cognite/neat/{rules/importer → legacy/rules/importers}/_owl2rules/_owl2properties.py +0 -0
  142. /cognite/neat/{rules → legacy/rules}/models/__init__.py +0 -0
  143. /cognite/neat/{rules → legacy/rules}/models/_base.py +0 -0
  144. /cognite/neat/{rules → legacy/rules}/models/tables.py +0 -0
  145. /cognite/neat/rules/models/{_rules → rules}/_types/__init__.py +0 -0
  146. /cognite/neat/rules/models/{_rules → rules}/_types/_field.py +0 -0
  147. /cognite/neat/rules/models/{_rules → rules}/_types/_value.py +0 -0
  148. /cognite/neat/workflows/examples/{Export DMS → Export_DMS}/workflow.yaml +0 -0
  149. /cognite/neat/workflows/examples/{Export Rules to Ontology → Export_Rules_to_Ontology}/workflow.yaml +0 -0
  150. /cognite/neat/workflows/examples/{Extract DEXPI Graph and Export Rules → Extract_DEXPI_Graph_and_Export_Rules}/workflow.yaml +0 -0
  151. /cognite/neat/workflows/examples/{Extract RDF Graph and Generate Assets → Extract_RDF_Graph_and_Generate_Assets}/workflow.yaml +0 -0
  152. /cognite/neat/workflows/examples/{Import DMS → Import_DMS}/workflow.yaml +0 -0
  153. /cognite/neat/workflows/examples/{Ontology to Data Model → Ontology_to_Data_Model}/workflow.yaml +0 -0
  154. /cognite/neat/workflows/examples/{Validate Rules → Validate_Rules}/workflow.yaml +0 -0
  155. /cognite/neat/workflows/examples/{Validate Solution Model → Validate_Solution_Model}/workflow.yaml +0 -0
  156. /cognite/neat/workflows/examples/{Visualize Data Model Using Mock Graph → Visualize_Data_Model_Using_Mock_Graph}/workflow.yaml +0 -0
  157. /cognite/neat/workflows/examples/{Visualize Semantic Data Model → Visualize_Semantic_Data_Model}/workflow.yaml +0 -0
  158. {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/LICENSE +0 -0
  159. {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/WHEEL +0 -0
  160. {cognite_neat-0.73.4.dist-info → cognite_neat-0.75.1.dist-info}/entry_points.txt +0 -0
@@ -6,7 +6,7 @@ from typing import Generic, TypeVar
6
6
  from cognite.client import CogniteClient
7
7
 
8
8
  from cognite.neat.rules._shared import Rules
9
- from cognite.neat.rules.models._rules import DMSRules, InformationRules, RoleTypes
9
+ from cognite.neat.rules.models.rules import DMSRules, InformationRules, RoleTypes
10
10
 
11
11
  from ._models import UploadResult
12
12
 
@@ -8,10 +8,10 @@ from cognite.client.data_classes._base import CogniteResourceList
8
8
  from cognite.client.exceptions import CogniteAPIError
9
9
 
10
10
  from cognite.neat.rules._shared import Rules
11
- from cognite.neat.rules.models._rules import InformationRules
12
- from cognite.neat.rules.models._rules.base import ExtensionCategory, SheetList
13
- from cognite.neat.rules.models._rules.dms_architect_rules import DMSContainer, DMSRules
14
- from cognite.neat.rules.models._rules.dms_schema import DMSSchema, PipelineSchema
11
+ from cognite.neat.rules.models.rules import InformationRules
12
+ from cognite.neat.rules.models.rules._base import ExtensionCategory, SheetList
13
+ from cognite.neat.rules.models.rules._dms_architect_rules import DMSContainer, DMSRules
14
+ from cognite.neat.rules.models.rules._dms_schema import DMSSchema, PipelineSchema
15
15
  from cognite.neat.utils.cdf_loaders import (
16
16
  ContainerLoader,
17
17
  DataModelingLoader,
@@ -12,8 +12,8 @@ from openpyxl.styles import Alignment, Border, Font, PatternFill, Side
12
12
  from openpyxl.worksheet.worksheet import Worksheet
13
13
 
14
14
  from cognite.neat.rules._shared import Rules
15
- from cognite.neat.rules.models._rules import DMSRules, DomainRules, InformationRules
16
- from cognite.neat.rules.models._rules.base import RoleTypes, SchemaCompleteness, SheetEntity
15
+ from cognite.neat.rules.models.rules import DMSRules, DomainRules, InformationRules
16
+ from cognite.neat.rules.models.rules._base import RoleTypes, SchemaCompleteness, SheetEntity
17
17
 
18
18
  from ._base import BaseExporter
19
19
 
@@ -10,15 +10,15 @@ from rdflib.collection import Collection as GraphCollection
10
10
 
11
11
  from cognite.neat.constants import DEFAULT_NAMESPACE as NEAT_NAMESPACE
12
12
  from cognite.neat.rules import exceptions
13
- from cognite.neat.rules._analysis._information_rules import InformationArchitectRulesAnalysis
14
- from cognite.neat.rules.models._rules import DMSRules
15
- from cognite.neat.rules.models._rules._types import XSD_VALUE_TYPE_MAPPINGS, EntityTypes
16
- from cognite.neat.rules.models._rules.information_rules import (
13
+ from cognite.neat.rules.analysis import InformationArchitectRulesAnalysis
14
+ from cognite.neat.rules.models.rules import DMSRules
15
+ from cognite.neat.rules.models.rules._information_rules import (
17
16
  InformationClass,
18
17
  InformationMetadata,
19
18
  InformationProperty,
20
19
  InformationRules,
21
20
  )
21
+ from cognite.neat.rules.models.rules._types import XSD_VALUE_TYPE_MAPPINGS, EntityTypes
22
22
  from cognite.neat.utils.utils import generate_exception_report, remove_namespace
23
23
 
24
24
  from ._base import BaseExporter
@@ -6,7 +6,7 @@ from typing import Literal, get_args
6
6
  import yaml
7
7
 
8
8
  from cognite.neat.rules._shared import Rules
9
- from cognite.neat.rules.models._rules.base import RoleTypes
9
+ from cognite.neat.rules.models.rules._base import RoleTypes
10
10
 
11
11
  from ._base import BaseExporter
12
12
 
@@ -4,8 +4,8 @@ from typing import Literal, overload
4
4
 
5
5
  from cognite.neat.exceptions import wrangle_warnings
6
6
  from cognite.neat.rules import exceptions
7
- from cognite.neat.rules.models._rules import InformationRules
8
- from cognite.neat.rules.models._rules._types._base import DMS_PROPERTY_ID_COMPLIANCE_REGEX, VIEW_ID_COMPLIANCE_REGEX
7
+ from cognite.neat.rules.models.rules import InformationRules
8
+ from cognite.neat.rules.models.rules._types._base import DMS_PROPERTY_ID_COMPLIANCE_REGEX, VIEW_ID_COMPLIANCE_REGEX
9
9
 
10
10
 
11
11
  @overload
@@ -11,7 +11,7 @@ from rdflib import Namespace
11
11
 
12
12
  from cognite.neat.rules._shared import Rules
13
13
  from cognite.neat.rules.issues.base import IssueList, NeatValidationError, ValidationWarning
14
- from cognite.neat.rules.models._rules import DMSRules, InformationRules, RoleTypes
14
+ from cognite.neat.rules.models.rules import DMSRules, InformationRules, RoleTypes
15
15
 
16
16
 
17
17
  class BaseImporter(ABC):
@@ -10,8 +10,16 @@ from cognite.client.utils import ms_to_datetime
10
10
  from cognite.neat.rules import issues
11
11
  from cognite.neat.rules.importers._base import BaseImporter, Rules
12
12
  from cognite.neat.rules.issues import IssueList
13
- from cognite.neat.rules.models._rules import DMSRules, DMSSchema, RoleTypes
14
- from cognite.neat.rules.models._rules._types import (
13
+ from cognite.neat.rules.models.rules import DMSRules, DMSSchema, RoleTypes
14
+ from cognite.neat.rules.models.rules._base import ExtensionCategory, SchemaCompleteness
15
+ from cognite.neat.rules.models.rules._dms_architect_rules import (
16
+ DMSContainer,
17
+ DMSMetadata,
18
+ DMSProperty,
19
+ DMSView,
20
+ SheetList,
21
+ )
22
+ from cognite.neat.rules.models.rules._types import (
15
23
  ClassEntity,
16
24
  ContainerEntity,
17
25
  DMSValueType,
@@ -20,14 +28,6 @@ from cognite.neat.rules.models._rules._types import (
20
28
  ViewEntity,
21
29
  ViewPropEntity,
22
30
  )
23
- from cognite.neat.rules.models._rules.base import ExtensionCategory, SchemaCompleteness
24
- from cognite.neat.rules.models._rules.dms_architect_rules import (
25
- DMSContainer,
26
- DMSMetadata,
27
- DMSProperty,
28
- DMSView,
29
- SheetList,
30
- )
31
31
 
32
32
 
33
33
  class DMSImporter(BaseImporter):
@@ -20,13 +20,13 @@ from cognite.neat.rules.importers._dtdl2rules.spec import (
20
20
  TelemetryV2,
21
21
  )
22
22
  from cognite.neat.rules.issues import IssueList, ValidationIssue
23
- from cognite.neat.rules.models._rules._types import (
23
+ from cognite.neat.rules.models.rules._information_rules import InformationClass, InformationProperty
24
+ from cognite.neat.rules.models.rules._types import (
24
25
  XSD_VALUE_TYPE_MAPPINGS,
25
26
  ClassEntity,
26
27
  ParentClassEntity,
27
28
  XSDValueType,
28
29
  )
29
- from cognite.neat.rules.models._rules.information_rules import InformationClass, InformationProperty
30
30
 
31
31
 
32
32
  class _DTDLConverter:
@@ -12,9 +12,9 @@ from cognite.neat.rules.importers._base import BaseImporter, _handle_issues
12
12
  from cognite.neat.rules.importers._dtdl2rules.dtdl_converter import _DTDLConverter
13
13
  from cognite.neat.rules.importers._dtdl2rules.spec import DTDL_CLS_BY_TYPE_BY_SPEC, DTDLBase, Interface
14
14
  from cognite.neat.rules.issues import IssueList, ValidationIssue
15
- from cognite.neat.rules.models._rules import InformationRules, RoleTypes
16
- from cognite.neat.rules.models._rules.base import SchemaCompleteness, SheetList
17
- from cognite.neat.rules.models._rules.information_rules import InformationClass, InformationProperty
15
+ from cognite.neat.rules.models.rules import InformationRules, RoleTypes
16
+ from cognite.neat.rules.models.rules._base import SchemaCompleteness, SheetList
17
+ from cognite.neat.rules.models.rules._information_rules import InformationClass, InformationProperty
18
18
  from cognite.neat.utils.text import to_pascal
19
19
 
20
20
 
@@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any, ClassVar, Literal, TypeAlias
14
14
 
15
15
  from pydantic import BaseModel, Field, field_validator, model_serializer, model_validator
16
16
 
17
- from cognite.neat.rules.models._rules._types import ClassEntity
17
+ from cognite.neat.rules.models.rules._types import ClassEntity
18
18
 
19
19
  if TYPE_CHECKING:
20
20
  from pydantic.type_adapter import IncEx
@@ -4,7 +4,7 @@ import numpy as np
4
4
  import pandas as pd
5
5
  from rdflib import OWL, Graph
6
6
 
7
- from cognite.neat.rules.models._rules.base import MatchType
7
+ from cognite.neat.rules.models.rules._base import MatchType
8
8
  from cognite.neat.utils.utils import remove_namespace
9
9
 
10
10
 
@@ -4,10 +4,10 @@ import re
4
4
  from rdflib import Graph, Namespace
5
5
 
6
6
  from cognite.neat.constants import DEFAULT_NAMESPACE
7
- from cognite.neat.rules.models._rules.base import RoleTypes, SchemaCompleteness
8
- from cognite.neat.rules.models.rules import (
9
- prefix_compliance_regex,
10
- version_compliance_regex,
7
+ from cognite.neat.rules.models.rules._base import RoleTypes, SchemaCompleteness
8
+ from cognite.neat.rules.models.rules._types._base import (
9
+ PREFIX_COMPLIANCE_REGEX,
10
+ VERSION_COMPLIANCE_REGEX,
11
11
  )
12
12
  from cognite.neat.utils.utils import convert_rdflib_content, remove_none_elements_from_set
13
13
 
@@ -148,7 +148,7 @@ def fix_description(metadata: dict, default: str = "This model has been inferred
148
148
 
149
149
  def fix_prefix(metadata: dict, default: str = "neat") -> dict:
150
150
  if prefix := metadata.get("prefix", None):
151
- if not isinstance(prefix, str) or not re.match(prefix_compliance_regex, prefix):
151
+ if not isinstance(prefix, str) or not re.match(PREFIX_COMPLIANCE_REGEX, prefix):
152
152
  metadata["prefix"] = default
153
153
  else:
154
154
  metadata["prefix"] = default
@@ -193,7 +193,7 @@ def fix_date(
193
193
 
194
194
  def fix_version(metadata: dict, default: str = "1.0.0") -> dict:
195
195
  if version := metadata.get("version", None):
196
- if not re.match(version_compliance_regex, version):
196
+ if not re.match(VERSION_COMPLIANCE_REGEX, version):
197
197
  metadata["version"] = default
198
198
  else:
199
199
  metadata["version"] = default
@@ -4,7 +4,7 @@ import numpy as np
4
4
  import pandas as pd
5
5
  from rdflib import Graph
6
6
 
7
- from cognite.neat.rules.models._rules.base import MatchType
7
+ from cognite.neat.rules.models.rules._base import MatchType
8
8
  from cognite.neat.utils.utils import remove_namespace
9
9
 
10
10
  from ._owl2classes import _data_type_property_class, _object_property_class, _thing_class
@@ -10,8 +10,8 @@ from rdflib import DC, DCTERMS, OWL, RDF, RDFS, SKOS, Graph
10
10
 
11
11
  from cognite.neat.rules.importers._base import BaseImporter, Rules
12
12
  from cognite.neat.rules.issues import IssueList
13
- from cognite.neat.rules.models._rules import InformationRules, RoleTypes
14
- from cognite.neat.rules.models._rules._types import XSD_VALUE_TYPE_MAPPINGS
13
+ from cognite.neat.rules.models.rules import InformationRules, RoleTypes
14
+ from cognite.neat.rules.models.rules._types import XSD_VALUE_TYPE_MAPPINGS
15
15
 
16
16
  from ._owl2classes import parse_owl_classes
17
17
  from ._owl2metadata import parse_owl_metadata
@@ -13,8 +13,8 @@ from pandas import ExcelFile
13
13
 
14
14
  from cognite.neat.rules import issues
15
15
  from cognite.neat.rules.issues import IssueList
16
- from cognite.neat.rules.models._rules import RULES_PER_ROLE, DMSRules, DomainRules, InformationRules
17
- from cognite.neat.rules.models._rules.base import RoleTypes, SchemaCompleteness
16
+ from cognite.neat.rules.models.rules import RULES_PER_ROLE, DMSRules, DomainRules, InformationRules
17
+ from cognite.neat.rules.models.rules._base import RoleTypes, SchemaCompleteness
18
18
  from cognite.neat.utils.auxiliary import local_import
19
19
  from cognite.neat.utils.spreadsheet import SpreadsheetRead, read_individual_sheet
20
20
 
@@ -5,7 +5,7 @@ import yaml
5
5
 
6
6
  from cognite.neat.rules import issues
7
7
  from cognite.neat.rules.issues import IssueList, NeatValidationError, ValidationIssue
8
- from cognite.neat.rules.models._rules import RULES_PER_ROLE, RoleTypes
8
+ from cognite.neat.rules.models.rules import RULES_PER_ROLE, RoleTypes
9
9
 
10
10
  from ._base import BaseImporter, Rules, _handle_issues
11
11
 
@@ -0,0 +1,142 @@
1
+ import re
2
+ import sys
3
+ from functools import total_ordering
4
+ from typing import ClassVar
5
+
6
+ from pydantic import BaseModel
7
+
8
+ if sys.version_info >= (3, 11):
9
+ from enum import StrEnum
10
+ from typing import Self
11
+ else:
12
+ from backports.strenum import StrEnum
13
+ from typing_extensions import Self
14
+
15
+
16
+ class EntityTypes(StrEnum):
17
+ subject = "subject"
18
+ predicate = "predicate"
19
+ object = "object"
20
+ class_ = "class"
21
+ parent_class = "parent_class"
22
+ property_ = "property"
23
+ object_property = "ObjectProperty"
24
+ data_property = "DatatypeProperty"
25
+ annotation_property = "AnnotationProperty"
26
+ object_value_type = "object_value_type"
27
+ data_value_type = "data_value_type" # these are strings, floats, ...
28
+ xsd_value_type = "xsd_value_type"
29
+ dms_value_type = "dms_value_type"
30
+ view = "view"
31
+ view_prop = "view_prop"
32
+ reference_entity = "reference_entity"
33
+ container = "container"
34
+ datamodel = "datamodel"
35
+ undefined = "undefined"
36
+
37
+
38
+ # ALLOWED
39
+ ALLOWED_PATTERN = r"[^a-zA-Z0-9-_.]"
40
+
41
+ # FOR PARSING STRINGS:
42
+ PREFIX_REGEX = r"[a-zA-Z]+[a-zA-Z0-9-_.]*[a-zA-Z0-9]+"
43
+ SUFFIX_REGEX = r"[a-zA-Z0-9-_.]+[a-zA-Z0-9]|[-_.]*[a-zA-Z0-9]+"
44
+ VERSION_REGEX = r"[a-zA-Z0-9]([.a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?"
45
+ PROPERTY_REGEX = r"[a-zA-Z0-9][a-zA-Z0-9_-]*[a-zA-Z0-9]?"
46
+ ENTITY_ID_REGEX = rf"{PREFIX_REGEX}:({SUFFIX_REGEX})"
47
+ ENTITY_ID_REGEX_COMPILED = re.compile(rf"^(?P<prefix>{PREFIX_REGEX}):(?P<suffix>{SUFFIX_REGEX})$")
48
+ VERSIONED_ENTITY_REGEX_COMPILED = re.compile(
49
+ rf"^(?P<prefix>{PREFIX_REGEX}):(?P<suffix>{SUFFIX_REGEX})\(version=(?P<version>{VERSION_REGEX})\)$"
50
+ )
51
+ CLASS_ID_REGEX = rf"(?P<{EntityTypes.class_}>{ENTITY_ID_REGEX})"
52
+ CLASS_ID_REGEX_COMPILED = re.compile(rf"^{CLASS_ID_REGEX}$")
53
+ PROPERTY_ID_REGEX = rf"\((?P<{EntityTypes.property_}>{ENTITY_ID_REGEX})\)"
54
+
55
+ Undefined = type(object())
56
+ Unknown = type(object())
57
+
58
+
59
+ # mypy does not like the sentinel value, and it is not possible to ignore only the line with it below.
60
+ # so we ignore all errors beyond this point.
61
+ # mypy: ignore-errors
62
+ @total_ordering
63
+ class Entity(BaseModel, arbitrary_types_allowed=True):
64
+ """Entity is a class or property in OWL/RDF sense."""
65
+
66
+ type_: ClassVar[EntityTypes] = EntityTypes.undefined
67
+ prefix: str | Undefined = Undefined
68
+ suffix: str | Unknown
69
+ version: str | None = None
70
+ name: str | None = None
71
+ description: str | None = None
72
+
73
+ def __lt__(self, other: object) -> bool:
74
+ if type(self) is not type(other) or not isinstance(other, Entity):
75
+ return NotImplemented
76
+ return self.versioned_id < other.versioned_id
77
+
78
+ def __eq__(self, other: object) -> bool:
79
+ if type(self) is not type(other) or not isinstance(other, Entity):
80
+ return NotImplemented
81
+ return self.versioned_id == other.versioned_id
82
+
83
+ def __hash__(self) -> int:
84
+ return hash(self.versioned_id)
85
+
86
+ def as_non_versioned_entity(self) -> Self:
87
+ return self.from_string(f"{self.prefix}:{self.suffix}")
88
+
89
+ @property
90
+ def id(self) -> str:
91
+ if self.suffix is Unknown:
92
+ return "#N/A"
93
+ elif self.prefix is Undefined:
94
+ return self.suffix
95
+ else:
96
+ return f"{self.prefix}:{self.suffix}"
97
+
98
+ @property
99
+ def versioned_id(self) -> str:
100
+ if self.version is None:
101
+ return self.id
102
+ else:
103
+ return f"{self.id}(version={self.version})"
104
+
105
+ @property
106
+ def space(self) -> str:
107
+ """Returns entity space in CDF."""
108
+ return self.prefix
109
+
110
+ @property
111
+ def external_id(self) -> str:
112
+ """Returns entity external id in CDF."""
113
+ return self.suffix
114
+
115
+ def __repr__(self):
116
+ return self.versioned_id
117
+
118
+ def __str__(self):
119
+ return self.versioned_id
120
+
121
+ @classmethod
122
+ def from_string(cls, entity_string: str, base_prefix: str | None = None) -> Self:
123
+ if entity_string == "#N/A":
124
+ return cls(prefix=Undefined, suffix=Unknown)
125
+ elif result := VERSIONED_ENTITY_REGEX_COMPILED.match(entity_string):
126
+ return cls(
127
+ prefix=result.group("prefix"),
128
+ suffix=result.group("suffix"),
129
+ version=result.group("version"),
130
+ )
131
+ elif result := ENTITY_ID_REGEX_COMPILED.match(entity_string):
132
+ return cls(prefix=result.group("prefix"), suffix=result.group("suffix"))
133
+ elif base_prefix and re.match(SUFFIX_REGEX, entity_string) and re.match(PREFIX_REGEX, base_prefix):
134
+ return cls(prefix=base_prefix, suffix=entity_string)
135
+ else:
136
+ raise ValueError(f"{cls.__name__} is expected to be prefix:suffix, got {entity_string}")
137
+
138
+ @classmethod
139
+ def from_list(cls, entity_strings: list[str], base_prefix: str | None = None) -> list[Self]:
140
+ return [
141
+ cls.from_string(entity_string=entity_string, base_prefix=base_prefix) for entity_string in entity_strings
142
+ ]
@@ -10,7 +10,7 @@ from pydantic import BaseModel, field_validator
10
10
 
11
11
  from cognite.neat.rules import exceptions
12
12
 
13
- from ._base import (
13
+ from ._entity import (
14
14
  CLASS_ID_REGEX,
15
15
  CLASS_ID_REGEX_COMPILED,
16
16
  ENTITY_ID_REGEX,
@@ -83,8 +83,8 @@ class Step(BaseModel):
83
83
  def from_string(cls, raw: str, **kwargs) -> Self:
84
84
  if result := STEP_CLASS_AND_PROPERTY_REGEX_COMPILED.match(raw):
85
85
  return cls(
86
- class_=Entity.from_string(result.group(EntityTypes.class_), type_="class"),
87
- property=Entity.from_string(result.group(EntityTypes.property_), type_="property"),
86
+ class_=Entity.from_string(result.group(EntityTypes.class_)),
87
+ property=Entity.from_string(result.group(EntityTypes.property_)),
88
88
  direction=_direction_by_symbol[result.group("direction")],
89
89
  **kwargs,
90
90
  )
@@ -107,21 +107,19 @@ class SingleProperty(Traversal):
107
107
 
108
108
  @classmethod
109
109
  def from_string(cls, class_: str, property_: str) -> Self:
110
- return cls(
111
- class_=Entity.from_string(class_, type_="class"), property=Entity.from_string(property_, type_="property")
112
- )
110
+ return cls(class_=Entity.from_string(class_), property=Entity.from_string(property_))
113
111
 
114
112
 
115
113
  class AllReferences(Traversal):
116
114
  @classmethod
117
115
  def from_string(cls, class_: str) -> Self:
118
- return cls(class_=Entity.from_string(class_, type_="class"))
116
+ return cls(class_=Entity.from_string(class_))
119
117
 
120
118
 
121
119
  class AllProperties(Traversal):
122
120
  @classmethod
123
121
  def from_string(cls, class_: str) -> Self:
124
- return cls(class_=Entity.from_string(class_, type_="class"))
122
+ return cls(class_=Entity.from_string(class_))
125
123
 
126
124
 
127
125
  class Origin(BaseModel):
@@ -1,8 +1,8 @@
1
- from .base import RoleTypes
2
- from .dms_architect_rules import DMSRules
3
- from .dms_schema import DMSSchema
4
- from .domain_rules import DomainRules
5
- from .information_rules import InformationRules
1
+ from ._base import RoleTypes
2
+ from ._dms_architect_rules import DMSRules
3
+ from ._dms_schema import DMSSchema
4
+ from ._domain_rules import DomainRules
5
+ from ._information_rules import InformationRules
6
6
 
7
7
  RULES_PER_ROLE: dict[RoleTypes, type[DomainRules] | type[InformationRules] | type[DMSRules]] = {
8
8
  RoleTypes.domain_expert: DomainRules,
@@ -27,7 +27,7 @@ from pydantic import (
27
27
  )
28
28
  from pydantic.fields import FieldInfo
29
29
 
30
- from cognite.neat.rules.models._rules._types import ClassType
30
+ from cognite.neat.rules.models.rules._types import ClassType
31
31
 
32
32
  if sys.version_info >= (3, 11):
33
33
  from enum import StrEnum
@@ -17,8 +17,10 @@ from rdflib import Namespace
17
17
 
18
18
  import cognite.neat.rules.issues.spreadsheet
19
19
  from cognite.neat.rules import issues
20
- from cognite.neat.rules.models._rules.domain_rules import DomainRules
20
+ from cognite.neat.rules.models.rules._domain_rules import DomainRules
21
21
 
22
+ from ._base import BaseMetadata, BaseRules, ExtensionCategory, RoleTypes, SchemaCompleteness, SheetEntity, SheetList
23
+ from ._dms_schema import DMSSchema, PipelineSchema
22
24
  from ._types import (
23
25
  CdfValueType,
24
26
  ClassEntity,
@@ -40,11 +42,9 @@ from ._types import (
40
42
  ViewType,
41
43
  XSDValueType,
42
44
  )
43
- from .base import BaseMetadata, BaseRules, ExtensionCategory, RoleTypes, SchemaCompleteness, SheetEntity, SheetList
44
- from .dms_schema import DMSSchema, PipelineSchema
45
45
 
46
46
  if TYPE_CHECKING:
47
- from .information_rules import InformationRules
47
+ from ._information_rules import InformationRules
48
48
 
49
49
  if sys.version_info >= (3, 11):
50
50
  from typing import Self
@@ -1063,7 +1063,7 @@ class _DMSRulesConverter:
1063
1063
  name: str | None = None,
1064
1064
  namespace: Namespace | None = None,
1065
1065
  ) -> "InformationRules":
1066
- from .information_rules import InformationClass, InformationMetadata, InformationProperty, InformationRules
1066
+ from ._information_rules import InformationClass, InformationMetadata, InformationProperty, InformationRules
1067
1067
 
1068
1068
  dms = self.dms.metadata
1069
1069
  prefix = dms.space
@@ -27,7 +27,7 @@ from cognite.neat.rules.issues.dms import (
27
27
  MissingSpaceError,
28
28
  MissingViewError,
29
29
  )
30
- from cognite.neat.rules.models._rules._types._value import DMS_VALUE_TYPE_MAPPINGS
30
+ from cognite.neat.rules.models.rules._types._value import DMS_VALUE_TYPE_MAPPINGS
31
31
  from cognite.neat.utils.cdf_loaders import ViewLoader
32
32
  from cognite.neat.utils.cdf_loaders.data_classes import RawTableWrite, RawTableWriteList
33
33
  from cognite.neat.utils.text import to_camel
@@ -4,14 +4,14 @@ from typing import Any, ClassVar
4
4
  from pydantic import Field, field_serializer, field_validator, model_serializer
5
5
  from pydantic_core.core_schema import SerializationInfo
6
6
 
7
- from ._types import ParentClassType, PropertyType, SemanticValueType, StrOrListType
8
- from .base import (
7
+ from ._base import (
9
8
  BaseMetadata,
10
9
  RoleTypes,
11
10
  RuleModel,
12
11
  SheetEntity,
13
12
  SheetList,
14
13
  )
14
+ from ._types import ParentClassType, PropertyType, SemanticValueType, StrOrListType
15
15
 
16
16
 
17
17
  class DomainMetadata(BaseMetadata):
@@ -24,6 +24,18 @@ from cognite.neat.rules.models.rdfpath import (
24
24
  parse_rule,
25
25
  )
26
26
 
27
+ from ._base import (
28
+ BaseMetadata,
29
+ ExtensionCategory,
30
+ ExtensionCategoryType,
31
+ MatchType,
32
+ RoleTypes,
33
+ RuleModel,
34
+ SchemaCompleteness,
35
+ SheetEntity,
36
+ SheetList,
37
+ )
38
+ from ._domain_rules import DomainRules
27
39
  from ._types import (
28
40
  ClassEntity,
29
41
  ContainerEntity,
@@ -45,21 +57,9 @@ from ._types import (
45
57
  XSDValueType,
46
58
  )
47
59
  from ._types._base import Unknown
48
- from .base import (
49
- BaseMetadata,
50
- ExtensionCategory,
51
- ExtensionCategoryType,
52
- MatchType,
53
- RoleTypes,
54
- RuleModel,
55
- SchemaCompleteness,
56
- SheetEntity,
57
- SheetList,
58
- )
59
- from .domain_rules import DomainRules
60
60
 
61
61
  if TYPE_CHECKING:
62
- from .dms_architect_rules import DMSProperty, DMSRules
62
+ from ._dms_architect_rules import DMSProperty, DMSRules
63
63
 
64
64
 
65
65
  if sys.version_info >= (3, 11):
@@ -380,7 +380,7 @@ class _InformationRulesConverter:
380
380
  raise NotImplementedError("DomainRules not implemented yet")
381
381
 
382
382
  def as_dms_architect_rules(self, created: datetime | None = None, updated: datetime | None = None) -> "DMSRules":
383
- from .dms_architect_rules import DMSContainer, DMSMetadata, DMSProperty, DMSRules, DMSView
383
+ from ._dms_architect_rules import DMSContainer, DMSMetadata, DMSProperty, DMSRules, DMSView
384
384
 
385
385
  info_metadata = self.information.metadata
386
386
 
@@ -404,6 +404,7 @@ class _InformationRulesConverter:
404
404
  views: list[DMSView] = [
405
405
  DMSView(
406
406
  class_=cls_.class_,
407
+ name=cls_.name,
407
408
  view=ViewPropEntity(prefix=cls_.class_.prefix, suffix=cls_.class_.suffix, version=cls_.class_.version),
408
409
  description=cls_.description,
409
410
  reference=cls_.reference,
@@ -427,6 +428,7 @@ class _InformationRulesConverter:
427
428
  containers.append(
428
429
  DMSContainer(
429
430
  class_=class_.class_,
431
+ name=class_.name,
430
432
  container=ContainerEntity(prefix=class_.class_.prefix, suffix=class_.class_.suffix),
431
433
  description=class_.description,
432
434
  constraint=[
@@ -456,7 +458,7 @@ class _InformationRulesConverter:
456
458
  def _as_dms_property(cls, prop: InformationProperty) -> "DMSProperty":
457
459
  """This creates the first"""
458
460
 
459
- from .dms_architect_rules import DMSProperty
461
+ from ._dms_architect_rules import DMSProperty
460
462
 
461
463
  # returns property type, which can be ObjectProperty or DatatypeProperty
462
464
  if isinstance(prop.value_type, XSDValueType):
@@ -487,6 +489,7 @@ class _InformationRulesConverter:
487
489
 
488
490
  return DMSProperty(
489
491
  class_=prop.class_,
492
+ name=prop.name,
490
493
  property_=prop.property_,
491
494
  value_type=value_type,
492
495
  nullable=nullable,