cognite-neat 0.87.6__py3-none-any.whl → 0.88.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 (171) hide show
  1. cognite/neat/_version.py +1 -1
  2. cognite/neat/app/api/data_classes/rest.py +0 -19
  3. cognite/neat/app/api/explorer.py +6 -4
  4. cognite/neat/app/api/routers/configuration.py +1 -1
  5. cognite/neat/app/api/routers/crud.py +11 -21
  6. cognite/neat/app/api/routers/workflows.py +24 -94
  7. cognite/neat/app/ui/neat-app/build/asset-manifest.json +7 -7
  8. cognite/neat/app/ui/neat-app/build/index.html +1 -1
  9. cognite/neat/app/ui/neat-app/build/static/css/{main.38a62222.css → main.72e3d92e.css} +2 -2
  10. cognite/neat/app/ui/neat-app/build/static/css/main.72e3d92e.css.map +1 -0
  11. cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js +3 -0
  12. cognite/neat/app/ui/neat-app/build/static/js/{main.ec7f72e2.js.LICENSE.txt → main.5a52cf09.js.LICENSE.txt} +0 -9
  13. cognite/neat/app/ui/neat-app/build/static/js/main.5a52cf09.js.map +1 -0
  14. cognite/neat/config.py +44 -27
  15. cognite/neat/exceptions.py +6 -0
  16. cognite/neat/graph/extractors/_classic_cdf/_assets.py +21 -73
  17. cognite/neat/graph/extractors/_classic_cdf/_base.py +102 -0
  18. cognite/neat/graph/extractors/_classic_cdf/_events.py +46 -42
  19. cognite/neat/graph/extractors/_classic_cdf/_files.py +41 -45
  20. cognite/neat/graph/extractors/_classic_cdf/_labels.py +75 -52
  21. cognite/neat/graph/extractors/_classic_cdf/_relationships.py +49 -27
  22. cognite/neat/graph/extractors/_classic_cdf/_sequences.py +47 -50
  23. cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +47 -49
  24. cognite/neat/graph/queries/_base.py +22 -29
  25. cognite/neat/graph/queries/_shared.py +1 -1
  26. cognite/neat/graph/stores/_base.py +24 -11
  27. cognite/neat/graph/transformers/_rdfpath.py +3 -2
  28. cognite/neat/issues.py +8 -0
  29. cognite/neat/rules/exporters/_rules2ontology.py +28 -20
  30. cognite/neat/rules/exporters/_validation.py +15 -21
  31. cognite/neat/rules/importers/_inference2rules.py +31 -35
  32. cognite/neat/rules/importers/_owl2rules/_owl2metadata.py +3 -7
  33. cognite/neat/rules/importers/_spreadsheet2rules.py +30 -27
  34. cognite/neat/rules/issues/dms.py +20 -0
  35. cognite/neat/rules/issues/importing.py +15 -0
  36. cognite/neat/rules/issues/ontology.py +298 -0
  37. cognite/neat/rules/issues/spreadsheet.py +48 -0
  38. cognite/neat/rules/issues/tables.py +72 -0
  39. cognite/neat/rules/models/_rdfpath.py +4 -4
  40. cognite/neat/rules/models/_types/_field.py +9 -19
  41. cognite/neat/rules/models/information/_rules.py +5 -4
  42. cognite/neat/utils/rdf_.py +17 -9
  43. cognite/neat/utils/regex_patterns.py +52 -0
  44. cognite/neat/workflows/steps/data_contracts.py +17 -43
  45. cognite/neat/workflows/steps/lib/current/graph_extractor.py +28 -24
  46. cognite/neat/workflows/steps/lib/current/graph_loader.py +4 -21
  47. cognite/neat/workflows/steps/lib/current/graph_store.py +18 -134
  48. cognite/neat/workflows/steps_registry.py +5 -7
  49. {cognite_neat-0.87.6.dist-info → cognite_neat-0.88.1.dist-info}/METADATA +2 -6
  50. cognite_neat-0.88.1.dist-info/RECORD +209 -0
  51. cognite/neat/app/api/routers/core.py +0 -91
  52. cognite/neat/app/api/routers/data_exploration.py +0 -336
  53. cognite/neat/app/api/routers/rules.py +0 -203
  54. cognite/neat/app/ui/neat-app/build/static/css/main.38a62222.css.map +0 -1
  55. cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js +0 -3
  56. cognite/neat/app/ui/neat-app/build/static/js/main.ec7f72e2.js.map +0 -1
  57. cognite/neat/graph/stores/_oxrdflib.py +0 -247
  58. cognite/neat/legacy/__init__.py +0 -0
  59. cognite/neat/legacy/graph/__init__.py +0 -3
  60. cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44-dirty.xml +0 -20182
  61. cognite/neat/legacy/graph/examples/Knowledge-Graph-Nordic44.xml +0 -20163
  62. cognite/neat/legacy/graph/examples/__init__.py +0 -10
  63. cognite/neat/legacy/graph/examples/skos-capturing-sheet-wind-topics.xlsx +0 -0
  64. cognite/neat/legacy/graph/exceptions.py +0 -90
  65. cognite/neat/legacy/graph/extractors/__init__.py +0 -6
  66. cognite/neat/legacy/graph/extractors/_base.py +0 -14
  67. cognite/neat/legacy/graph/extractors/_dexpi.py +0 -44
  68. cognite/neat/legacy/graph/extractors/_graph_capturing_sheet.py +0 -403
  69. cognite/neat/legacy/graph/extractors/_mock_graph_generator.py +0 -361
  70. cognite/neat/legacy/graph/loaders/__init__.py +0 -23
  71. cognite/neat/legacy/graph/loaders/_asset_loader.py +0 -511
  72. cognite/neat/legacy/graph/loaders/_base.py +0 -67
  73. cognite/neat/legacy/graph/loaders/_exceptions.py +0 -85
  74. cognite/neat/legacy/graph/loaders/core/__init__.py +0 -0
  75. cognite/neat/legacy/graph/loaders/core/labels.py +0 -58
  76. cognite/neat/legacy/graph/loaders/core/models.py +0 -136
  77. cognite/neat/legacy/graph/loaders/core/rdf_to_assets.py +0 -1046
  78. cognite/neat/legacy/graph/loaders/core/rdf_to_relationships.py +0 -559
  79. cognite/neat/legacy/graph/loaders/rdf_to_dms.py +0 -309
  80. cognite/neat/legacy/graph/loaders/validator.py +0 -87
  81. cognite/neat/legacy/graph/models.py +0 -6
  82. cognite/neat/legacy/graph/stores/__init__.py +0 -13
  83. cognite/neat/legacy/graph/stores/_base.py +0 -400
  84. cognite/neat/legacy/graph/stores/_graphdb_store.py +0 -52
  85. cognite/neat/legacy/graph/stores/_memory_store.py +0 -43
  86. cognite/neat/legacy/graph/stores/_oxigraph_store.py +0 -151
  87. cognite/neat/legacy/graph/stores/_oxrdflib.py +0 -247
  88. cognite/neat/legacy/graph/stores/_rdf_to_graph.py +0 -42
  89. cognite/neat/legacy/graph/transformations/__init__.py +0 -0
  90. cognite/neat/legacy/graph/transformations/entity_matcher.py +0 -101
  91. cognite/neat/legacy/graph/transformations/query_generator/__init__.py +0 -3
  92. cognite/neat/legacy/graph/transformations/query_generator/sparql.py +0 -575
  93. cognite/neat/legacy/graph/transformations/transformer.py +0 -322
  94. cognite/neat/legacy/rules/__init__.py +0 -0
  95. cognite/neat/legacy/rules/analysis.py +0 -231
  96. cognite/neat/legacy/rules/examples/Rules-Nordic44-to-graphql.xlsx +0 -0
  97. cognite/neat/legacy/rules/examples/Rules-Nordic44.xlsx +0 -0
  98. cognite/neat/legacy/rules/examples/__init__.py +0 -18
  99. cognite/neat/legacy/rules/examples/power-grid-containers.yaml +0 -124
  100. cognite/neat/legacy/rules/examples/power-grid-example.xlsx +0 -0
  101. cognite/neat/legacy/rules/examples/power-grid-model.yaml +0 -224
  102. cognite/neat/legacy/rules/examples/rules-template.xlsx +0 -0
  103. cognite/neat/legacy/rules/examples/sheet2cdf-transformation-rules.xlsx +0 -0
  104. cognite/neat/legacy/rules/examples/skos-rules.xlsx +0 -0
  105. cognite/neat/legacy/rules/examples/source-to-solution-mapping-rules.xlsx +0 -0
  106. cognite/neat/legacy/rules/examples/wind-energy.owl +0 -1511
  107. cognite/neat/legacy/rules/exceptions.py +0 -2972
  108. cognite/neat/legacy/rules/exporters/__init__.py +0 -20
  109. cognite/neat/legacy/rules/exporters/_base.py +0 -45
  110. cognite/neat/legacy/rules/exporters/_core/__init__.py +0 -5
  111. cognite/neat/legacy/rules/exporters/_core/rules2labels.py +0 -24
  112. cognite/neat/legacy/rules/exporters/_rules2dms.py +0 -885
  113. cognite/neat/legacy/rules/exporters/_rules2excel.py +0 -213
  114. cognite/neat/legacy/rules/exporters/_rules2graphql.py +0 -183
  115. cognite/neat/legacy/rules/exporters/_rules2ontology.py +0 -524
  116. cognite/neat/legacy/rules/exporters/_rules2pydantic_models.py +0 -748
  117. cognite/neat/legacy/rules/exporters/_rules2rules.py +0 -105
  118. cognite/neat/legacy/rules/exporters/_rules2triples.py +0 -38
  119. cognite/neat/legacy/rules/exporters/_validation.py +0 -146
  120. cognite/neat/legacy/rules/importers/__init__.py +0 -22
  121. cognite/neat/legacy/rules/importers/_base.py +0 -66
  122. cognite/neat/legacy/rules/importers/_dict2rules.py +0 -158
  123. cognite/neat/legacy/rules/importers/_dms2rules.py +0 -194
  124. cognite/neat/legacy/rules/importers/_graph2rules.py +0 -308
  125. cognite/neat/legacy/rules/importers/_json2rules.py +0 -39
  126. cognite/neat/legacy/rules/importers/_owl2rules/__init__.py +0 -3
  127. cognite/neat/legacy/rules/importers/_owl2rules/_owl2classes.py +0 -239
  128. cognite/neat/legacy/rules/importers/_owl2rules/_owl2metadata.py +0 -260
  129. cognite/neat/legacy/rules/importers/_owl2rules/_owl2properties.py +0 -217
  130. cognite/neat/legacy/rules/importers/_owl2rules/_owl2rules.py +0 -290
  131. cognite/neat/legacy/rules/importers/_spreadsheet2rules.py +0 -45
  132. cognite/neat/legacy/rules/importers/_xsd2rules.py +0 -20
  133. cognite/neat/legacy/rules/importers/_yaml2rules.py +0 -39
  134. cognite/neat/legacy/rules/models/__init__.py +0 -5
  135. cognite/neat/legacy/rules/models/_base.py +0 -151
  136. cognite/neat/legacy/rules/models/raw_rules.py +0 -316
  137. cognite/neat/legacy/rules/models/rdfpath.py +0 -237
  138. cognite/neat/legacy/rules/models/rules.py +0 -1289
  139. cognite/neat/legacy/rules/models/tables.py +0 -9
  140. cognite/neat/legacy/rules/models/value_types.py +0 -118
  141. cognite/neat/legacy/workflows/examples/Export_DMS/workflow.yaml +0 -89
  142. cognite/neat/legacy/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -152
  143. cognite/neat/legacy/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -139
  144. cognite/neat/legacy/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -270
  145. cognite/neat/legacy/workflows/examples/Import_DMS/workflow.yaml +0 -65
  146. cognite/neat/legacy/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -116
  147. cognite/neat/legacy/workflows/examples/Validate_Rules/workflow.yaml +0 -67
  148. cognite/neat/legacy/workflows/examples/Validate_Solution_Model/workflow.yaml +0 -64
  149. cognite/neat/legacy/workflows/examples/Visualize_Data_Model_Using_Mock_Graph/workflow.yaml +0 -95
  150. cognite/neat/legacy/workflows/examples/Visualize_Semantic_Data_Model/workflow.yaml +0 -111
  151. cognite/neat/rules/exceptions.py +0 -2972
  152. cognite/neat/rules/models/_types/_base.py +0 -16
  153. cognite/neat/workflows/examples/Export_Rules_to_Ontology/workflow.yaml +0 -152
  154. cognite/neat/workflows/examples/Extract_DEXPI_Graph_and_Export_Rules/workflow.yaml +0 -139
  155. cognite/neat/workflows/examples/Extract_RDF_Graph_and_Generate_Assets/workflow.yaml +0 -270
  156. cognite/neat/workflows/examples/Ontology_to_Data_Model/workflow.yaml +0 -116
  157. cognite/neat/workflows/migration/__init__.py +0 -0
  158. cognite/neat/workflows/migration/steps.py +0 -91
  159. cognite/neat/workflows/migration/wf_manifests.py +0 -33
  160. cognite/neat/workflows/steps/lib/legacy/__init__.py +0 -7
  161. cognite/neat/workflows/steps/lib/legacy/graph_contextualization.py +0 -82
  162. cognite/neat/workflows/steps/lib/legacy/graph_extractor.py +0 -746
  163. cognite/neat/workflows/steps/lib/legacy/graph_loader.py +0 -606
  164. cognite/neat/workflows/steps/lib/legacy/graph_store.py +0 -307
  165. cognite/neat/workflows/steps/lib/legacy/graph_transformer.py +0 -58
  166. cognite/neat/workflows/steps/lib/legacy/rules_exporter.py +0 -511
  167. cognite/neat/workflows/steps/lib/legacy/rules_importer.py +0 -612
  168. cognite_neat-0.87.6.dist-info/RECORD +0 -319
  169. {cognite_neat-0.87.6.dist-info → cognite_neat-0.88.1.dist-info}/LICENSE +0 -0
  170. {cognite_neat-0.87.6.dist-info → cognite_neat-0.88.1.dist-info}/WHEEL +0 -0
  171. {cognite_neat-0.87.6.dist-info → cognite_neat-0.88.1.dist-info}/entry_points.txt +0 -0
@@ -1,27 +1,24 @@
1
1
  from pathlib import Path
2
2
 
3
3
  from cognite.client import CogniteClient
4
- from cognite.client.data_classes import Asset, AssetUpdate, Relationship, RelationshipUpdate
4
+ from cognite.client.data_classes import (
5
+ Asset,
6
+ AssetUpdate,
7
+ Relationship,
8
+ RelationshipUpdate,
9
+ )
5
10
  from cognite.client.data_classes.data_modeling import EdgeApply, NodeApply
6
11
 
7
- from cognite.neat.legacy.graph.stores import NeatGraphStoreBase
8
- from cognite.neat.legacy.rules.exporters._rules2dms import DMSSchemaComponents
9
- from cognite.neat.legacy.rules.models.rules import Rules
10
- from cognite.neat.rules.models import AssetRules, DMSRules, DomainRules, InformationRules
12
+ from cognite.neat.graph.stores import NeatGraphStore
13
+ from cognite.neat.rules.models import (
14
+ AssetRules,
15
+ DMSRules,
16
+ DomainRules,
17
+ InformationRules,
18
+ )
11
19
  from cognite.neat.workflows.steps.step_model import DataContract
12
20
 
13
21
 
14
- class RulesData(DataContract):
15
- """
16
- This represents the TransformationRules object.
17
-
18
- Args:
19
- rules: The TransformationRules object.
20
- """
21
-
22
- rules: Rules
23
-
24
-
25
22
  class MultiRuleData(DataContract):
26
23
  domain: DomainRules | None = None
27
24
  information: InformationRules | None = None
@@ -53,27 +50,15 @@ class PathData(DataContract):
53
50
  excel_file_path: Path
54
51
 
55
52
 
56
- class SourceGraph(DataContract):
57
- """
58
- This represents the source graph.
59
-
60
- Args:
61
- graph: The source graph.
62
- """
63
-
64
- graph: NeatGraphStoreBase
65
-
66
-
67
- class SolutionGraph(DataContract):
53
+ class NeatGraph(DataContract):
68
54
  """
69
- This represents the solution graph.
55
+ This represents the neat graph.
70
56
 
71
57
  Args:
72
- graph (NeatGraphStoreBase): The solution graph.
73
-
58
+ graph: The neat graph store.
74
59
  """
75
60
 
76
- graph: NeatGraphStoreBase
61
+ graph: NeatGraphStore
77
62
 
78
63
 
79
64
  class ClientData(DataContract):
@@ -130,14 +115,3 @@ class Edges(DataContract):
130
115
  """
131
116
 
132
117
  edges: list[EdgeApply]
133
-
134
-
135
- class DMSSchemaComponentsData(DataContract):
136
- """
137
- This represents DMS Schema Model.
138
-
139
- Args:
140
- components: DMS Schema Components model.
141
- """
142
-
143
- components: DMSSchemaComponents
@@ -3,11 +3,15 @@ import logging
3
3
  from pathlib import Path
4
4
  from typing import ClassVar, cast
5
5
 
6
+ from rdflib import URIRef
7
+
8
+ from cognite.neat.constants import DEFAULT_NAMESPACE
9
+ from cognite.neat.graph.extractors import RdfFileExtractor
6
10
  from cognite.neat.graph.extractors._mock_graph_generator import MockGraphGenerator
7
11
  from cognite.neat.rules._shared import DMSRules, InformationRules
8
12
  from cognite.neat.workflows._exceptions import StepNotInitialized
9
13
  from cognite.neat.workflows.model import FlowMessage, StepExecutionStatus
10
- from cognite.neat.workflows.steps.data_contracts import MultiRuleData, SolutionGraph, SourceGraph
14
+ from cognite.neat.workflows.steps.data_contracts import MultiRuleData, NeatGraph
11
15
  from cognite.neat.workflows.steps.step_model import Configurable, Step
12
16
 
13
17
  __all__ = ["GraphFromRdfFile", "GraphFromMockData"]
@@ -29,11 +33,16 @@ class GraphFromMockData(Step):
29
33
  value="",
30
34
  label="Target number of instances for each class",
31
35
  ),
32
- Configurable(name="Graph", value="solution", label="The name of target graph.", options=["source", "solution"]),
36
+ Configurable(
37
+ name="Graph",
38
+ value="solution",
39
+ label="The name of target graph.",
40
+ options=["source", "solution"],
41
+ ),
33
42
  ]
34
43
 
35
44
  def run( # type: ignore[override, syntax]
36
- self, rules: MultiRuleData, graph_store: SolutionGraph | SourceGraph
45
+ self, rules: MultiRuleData, graph_store: NeatGraph
37
46
  ) -> FlowMessage:
38
47
  if self.configs is None:
39
48
  raise StepNotInitialized(type(self).__name__)
@@ -55,17 +64,12 @@ class GraphFromMockData(Step):
55
64
  step_execution_status=StepExecutionStatus.ABORT_AND_FAIL,
56
65
  )
57
66
 
58
- if self.configs["Graph"] == "solution":
59
- # Todo Anders: Why is the graph fetched from context when it is passed as an argument?
60
- graph_store = cast(SourceGraph | SolutionGraph, self.flow_context["SolutionGraph"])
61
- else:
62
- graph_store = cast(SourceGraph | SolutionGraph, self.flow_context["SourceGraph"])
63
-
64
- logging.info("Initiated generation of mock triples")
67
+ extractor = MockGraphGenerator(
68
+ cast(InformationRules | DMSRules, rules.information or rules.dms),
69
+ class_count,
70
+ )
65
71
 
66
- extractor = MockGraphGenerator(cast(InformationRules | DMSRules, rules.information or rules.dms), class_count)
67
-
68
- graph_store.graph.add_triples(extractor.extract())
72
+ NeatGraph.graph.write(extractor)
69
73
 
70
74
  return FlowMessage(output_text=f"Instances loaded to the {graph_store.__class__.__name__}")
71
75
 
@@ -104,20 +108,20 @@ class GraphFromRdfFile(Step):
104
108
  ),
105
109
  ]
106
110
 
107
- def run(self, source_graph: SourceGraph) -> FlowMessage: # type: ignore[override, syntax]
111
+ def run(self, graph_store: NeatGraph) -> FlowMessage: # type: ignore[override, syntax]
108
112
  if self.configs is None or self.data_store_path is None:
109
113
  raise StepNotInitialized(type(self).__name__)
110
- if source_graph.graph.rdf_store_type.lower() in ("memory", "oxigraph"):
111
- if source_file := self.configs["File path"]:
112
- source_graph.graph.import_from_file(
113
- self.data_store_path / Path(source_file),
114
+
115
+ if source_file := self.configs["File path"]:
116
+ NeatGraph.graph.write(
117
+ RdfFileExtractor( # type: ignore[abstract]
118
+ filepath=self.data_store_path / Path(source_file),
114
119
  mime_type=self.configs["MIME type"], # type: ignore[arg-type]
115
- add_base_iri=self.configs["Add base URI"] == "True",
120
+ base_uri=(URIRef(DEFAULT_NAMESPACE) if self.configs["Add base URI"] == "True" else None),
116
121
  )
117
- logging.info(f"Loaded {source_file} into source graph.")
118
- else:
119
- raise ValueError("You need a source_rdf_store.file specified for source_rdf_store.type=memory")
122
+ )
123
+
120
124
  else:
121
- raise NotImplementedError(f"Graph type {source_graph.graph.rdf_store_type} is not supported.")
125
+ raise ValueError("You need a valid file path to be specified")
122
126
 
123
- return FlowMessage(output_text="Instances loaded to source graph")
127
+ return FlowMessage(output_text="Instances loaded to NeatGraph!")
@@ -1,13 +1,10 @@
1
1
  import time
2
2
  from pathlib import Path
3
- from typing import ClassVar, cast
3
+ from typing import ClassVar
4
4
 
5
5
  from cognite.neat.workflows._exceptions import StepNotInitialized
6
6
  from cognite.neat.workflows.model import FlowMessage
7
- from cognite.neat.workflows.steps.data_contracts import (
8
- SolutionGraph,
9
- SourceGraph,
10
- )
7
+ from cognite.neat.workflows.steps.data_contracts import NeatGraph
11
8
  from cognite.neat.workflows.steps.step_model import Configurable, Step
12
9
 
13
10
  __all__ = [
@@ -26,12 +23,6 @@ class GraphToRdfFile(Step):
26
23
  category = CATEGORY
27
24
  version = "private-beta"
28
25
  configurables: ClassVar[list[Configurable]] = [
29
- Configurable(
30
- name="Graph",
31
- value="source",
32
- options=["source", "solution"],
33
- label=("The graph to be used for loading RDF File." " Supported options : source, solution"),
34
- ),
35
26
  Configurable(
36
27
  name="File path",
37
28
  value="staging/graph_export.ttl",
@@ -40,7 +31,7 @@ class GraphToRdfFile(Step):
40
31
  ]
41
32
 
42
33
  def run( # type: ignore[override, syntax]
43
- self, graph: SourceGraph | SolutionGraph
34
+ self, graph: NeatGraph
44
35
  ) -> FlowMessage: # type: ignore[syntax]
45
36
  if self.configs is None or self.data_store_path is None:
46
37
  raise StepNotInitialized(type(self).__name__)
@@ -48,15 +39,7 @@ class GraphToRdfFile(Step):
48
39
  storage_path = self.data_store_path / Path(self.configs["File path"])
49
40
  relative_graph_file_path = str(storage_path).split("/data/")[1]
50
41
 
51
- graph_name = self.configs["Graph"] or "source"
52
-
53
- if graph_name == "solution":
54
- # Todo Anders: Why is the graph fetched from context when it is passed as an argument?
55
- graph = cast(SourceGraph | SolutionGraph, self.flow_context["SolutionGraph"])
56
- else:
57
- graph = cast(SourceGraph | SolutionGraph, self.flow_context["SourceGraph"])
58
-
59
- graph.graph.serialize(str(storage_path), format="turtle")
42
+ graph.graph.graph.serialize(str(storage_path), format="turtle")
60
43
 
61
44
  output_text = (
62
45
  "<p></p>"
@@ -1,19 +1,14 @@
1
- import logging
2
- from pathlib import Path
3
- from typing import ClassVar, cast
1
+ from typing import ClassVar
4
2
 
5
- from cognite.neat.constants import DEFAULT_NAMESPACE, get_default_prefixes
6
- from cognite.neat.legacy.graph import stores
7
- from cognite.neat.workflows._exceptions import StepNotInitialized
3
+ from cognite.neat.graph.stores import NeatGraphStore
8
4
  from cognite.neat.workflows.model import FlowMessage
9
5
  from cognite.neat.workflows.steps.data_contracts import (
10
- RulesData,
11
- SolutionGraph,
12
- SourceGraph,
6
+ MultiRuleData,
7
+ NeatGraph,
13
8
  )
14
9
  from cognite.neat.workflows.steps.step_model import Configurable, Step
15
10
 
16
- __all__ = ["GraphStoreConfiguration", "GraphStoreReset"]
11
+ __all__ = ["GraphStoreConfiguration"]
17
12
 
18
13
  CATEGORY = __name__.split(".")[-1].replace("_", " ").title()
19
14
 
@@ -27,138 +22,27 @@ class GraphStoreConfiguration(Step):
27
22
  version = "private-beta"
28
23
  category = CATEGORY
29
24
  configurables: ClassVar[list[Configurable]] = [
30
- Configurable(
31
- name="Graph",
32
- value="source",
33
- label="Graph categorization, supported: source, solution ",
34
- options=["source", "solution"],
35
- ),
36
25
  Configurable(
37
26
  name="Graph store type",
38
- value=stores.OxiGraphStore.rdf_store_type,
39
- label="Graph store type, supported: oxigraph, memory,file, graphdb, sparql. ",
40
- options=["oxigraph", "memory", "file", "graphdb", "sparql"],
41
- ),
42
- Configurable(
43
- name="Disk storage directory",
44
- value="source-graph-store",
45
- label="Local directory that is used as local graph store.Only for oxigraph, file store types",
46
- ),
47
- Configurable(
48
- name="Query URL",
49
- value="",
50
- label="Query URL for SPARQL endpoint. Only for SPARQL store type",
51
- ),
52
- Configurable(
53
- name="Update URL",
54
- value="",
55
- label="Update URL for SPARQL endpoint. Only for SPARQL store type",
56
- ),
57
- Configurable(
58
- name="GraphDB API root URL",
59
- value="",
60
- label="Root url for GraphDB. Only for graphdb",
61
- ),
62
- Configurable(
63
- name="Init procedure",
64
- value="reset",
65
- label="Operations to be performed on the graph store as part of init and configuration process. \
66
- Supported options : reset, clear, none",
67
- options=["reset", "none"],
27
+ value="oxigraph",
28
+ label="Graph store type, supported: oxigraph, rdflib",
29
+ options=["oxigraph", "rdflib"],
68
30
  ),
69
31
  ]
70
32
 
71
33
  def run( # type: ignore[override]
72
- self, rules_data: RulesData | None = None
73
- ) -> (FlowMessage, SourceGraph | SolutionGraph): # type: ignore[syntax]
74
- if self.configs is None or self.data_store_path is None:
75
- raise StepNotInitialized(type(self).__name__)
76
- logging.info("Initializing graph")
77
- store_dir = self.data_store_path / Path(value) if (value := self.configs["Disk storage directory"]) else None
78
- store_type = self.configs["Graph store type"]
79
- graph_name_mapping = {"source": "SourceGraph", "solution": "SolutionGraph"}
34
+ self, rules_data: MultiRuleData | None = None
35
+ ) -> (FlowMessage, NeatGraph): # type: ignore[syntax]
36
+ store_type = self.configs.get("Graph store type", "oxigraph")
80
37
 
81
- graph_name = graph_name_mapping[self.configs["Graph"]]
82
- graph_store = cast(SourceGraph | SolutionGraph | None, self.flow_context.get(graph_name, None))
83
- if self.configs["Init procedure"] == "reset":
84
- logging.info("Resetting graph")
85
- reset_store(store_dir, graph_store.graph if graph_store else None)
86
- if graph_name in self.flow_context:
87
- del self.flow_context[graph_name]
88
- graph_store = None
89
- logging.info("Graph reset complete")
90
-
91
- prefixes = rules_data.rules.prefixes if rules_data else get_default_prefixes()
92
-
93
- if store_type == stores.OxiGraphStore.rdf_store_type and graph_store is not None:
94
- # OXIGRAPH doesn't like to be initialized twice without a good reason
95
- graph_store.graph.upsert_prefixes(prefixes)
96
- return FlowMessage(output_text="Stores already configured")
97
- try:
98
- store_cls = stores.STORE_BY_TYPE[store_type]
99
- except KeyError:
100
- return FlowMessage(output_text="Invalid store type")
101
-
102
- new_graph_store = store_cls(prefixes=prefixes, base_prefix="neat", namespace=DEFAULT_NAMESPACE)
103
- new_graph_store.init_graph(
104
- self.configs["Query URL"],
105
- self.configs["Update URL"],
106
- "neat-tnt",
107
- internal_storage_dir=store_dir,
108
- )
38
+ if store_type == "oxigraph":
39
+ store = NeatGraph(graph=NeatGraphStore.from_oxi_store(rules=rules_data.information if rules_data else None))
40
+ else:
41
+ store = NeatGraph(
42
+ graph=NeatGraphStore.from_memory_store(rules=rules_data.information if rules_data else None)
43
+ )
109
44
 
110
45
  return (
111
46
  FlowMessage(output_text="Graph store configured successfully"),
112
- (
113
- SourceGraph(graph=new_graph_store)
114
- if graph_name == "SourceGraph"
115
- else SolutionGraph(graph=new_graph_store)
116
- ),
117
- )
118
-
119
-
120
- def reset_store(data_store_dir: Path | None, graph_store: stores.NeatGraphStoreBase | None = None):
121
- if isinstance(graph_store, stores.OxiGraphStore):
122
- if graph_store:
123
- graph_store.close()
124
- graph_store.drop_graph_store_storage(data_store_dir)
125
- elif data_store_dir:
126
- graph_store.drop_graph_store_storage(data_store_dir)
127
- elif isinstance(graph_store, stores.GraphDBStore):
128
- if graph_store:
129
- graph_store.drop()
130
- graph_store.reinitialize_graph()
131
- return None
132
-
133
-
134
- class GraphStoreReset(Step):
135
- """
136
- This step resets graph stores to their initial state (clears all data)
137
- """
138
-
139
- description = "This step resets graph stores to their initial state (clears all data)."
140
- category = CATEGORY
141
- version = "private-alpha"
142
- configurables: ClassVar[list[Configurable]] = [
143
- Configurable(
144
- name="Graph",
145
- value="source",
146
- label="Graph store to be reset. Supported: solution, source ",
147
- options=["source", "solution"],
47
+ store,
148
48
  )
149
- ]
150
-
151
- def run(self) -> FlowMessage: # type: ignore[override, syntax]
152
- if self.configs is None or self.data_store_path is None:
153
- raise StepNotInitialized(type(self).__name__)
154
- graph_name_mapping = {"source": "SourceGraph", "solution": "SolutionGraph"}
155
-
156
- graph_name = graph_name_mapping[self.configs["Graph"]]
157
- graph_store = cast(SourceGraph | SolutionGraph | None, self.flow_context.get(graph_name, None))
158
- if graph_store is not None:
159
- reset_store(graph_store.graph.internal_storage_dir, graph_store.graph)
160
- if graph_name in self.flow_context:
161
- del self.flow_context[graph_name]
162
- return FlowMessage(output_text="Reset operation completed")
163
- else:
164
- return FlowMessage(output_text="Stores already reset")
@@ -12,7 +12,6 @@ from pydantic import BaseModel
12
12
  # steps
13
13
  import cognite.neat.workflows.steps.lib.current
14
14
  import cognite.neat.workflows.steps.lib.io
15
- import cognite.neat.workflows.steps.lib.legacy
16
15
  from cognite.neat.app.monitoring.metrics import NeatMetricsCollector
17
16
  from cognite.neat.config import Config
18
17
  from cognite.neat.exceptions import InvalidWorkFlowError
@@ -42,7 +41,11 @@ class StepsRegistry:
42
41
  self._step_classes: list[type[Step]] = []
43
42
  self.user_steps_path: Path = config.data_store_path / "steps"
44
43
  self.data_store_path: str = str(config.data_store_path)
45
- self.categorized_steps: dict[str, set] = {"legacy": set(), "current": set(), "io": set()}
44
+ self.categorized_steps: dict[str, set] = {
45
+ "legacy": set(),
46
+ "current": set(),
47
+ "io": set(),
48
+ }
46
49
 
47
50
  def load_step_classes(self):
48
51
  if self._step_classes:
@@ -58,11 +61,6 @@ class StepsRegistry:
58
61
  logging.info(f"Loading NEAT step {name}")
59
62
  self._step_classes.append(step_cls)
60
63
  self.categorized_steps["io"].add(name)
61
- for name, step_cls in inspect.getmembers(cognite.neat.workflows.steps.lib.legacy):
62
- if inspect.isclass(step_cls):
63
- logging.info(f"Loading NEAT step {name}")
64
- self._step_classes.append(step_cls)
65
- self.categorized_steps["legacy"].add(name)
66
64
  sys.path.append(str(Path(self.data_store_path) / "workflows"))
67
65
  try:
68
66
  if self.user_steps_path:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognite-neat
3
- Version: 0.87.6
3
+ Version: 0.88.1
4
4
  Summary: Knowledge graph transformation
5
5
  Home-page: https://cognite-neat.readthedocs-hosted.com/
6
6
  License: Apache-2.0
@@ -146,9 +146,6 @@ Open API docs :
146
146
 
147
147
  `http://localhost:8000/docs`
148
148
 
149
- Prom metrics :
150
-
151
- `http://localhost:8000/metrics`
152
149
 
153
150
  ## Workflows and configurations
154
151
 
@@ -194,8 +191,7 @@ cdf_client:
194
191
  client_id: "623c2450-cfc2-43d6-9036-10e14dad8ccf"
195
192
  client_secret: "my-super-secret"
196
193
  base_url: https://az-power-no-northeurope.cognitedata.com
197
- scopes:
198
- - https://az-power-no-northeurope.cognitedata.com/.default
194
+ scopes: [https://az-power-no-northeurope.cognitedata.com/.default]
199
195
  token_url: https://login.microsoftonline.com/e55e1701-82f8-4c52-af10-28e4d942c589/oauth2/v2.0/token
200
196
 
201
197
  cdf_default_dataset_id: 2626756768281823