cognite-neat 0.104.0__py3-none-any.whl → 0.105.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 (143) hide show
  1. cognite/neat/_client/_api/data_modeling_loaders.py +83 -23
  2. cognite/neat/_client/_api/schema.py +2 -1
  3. cognite/neat/_client/data_classes/neat_sequence.py +261 -0
  4. cognite/neat/_client/data_classes/schema.py +5 -1
  5. cognite/neat/_client/testing.py +33 -0
  6. cognite/neat/_constants.py +57 -0
  7. cognite/neat/_graph/extractors/_classic_cdf/_base.py +6 -5
  8. cognite/neat/_graph/extractors/_classic_cdf/_sequences.py +225 -11
  9. cognite/neat/_graph/extractors/_mock_graph_generator.py +1 -1
  10. cognite/neat/_graph/loaders/_rdf2dms.py +31 -5
  11. cognite/neat/_graph/transformers/__init__.py +3 -1
  12. cognite/neat/_graph/transformers/_classic_cdf.py +39 -51
  13. cognite/neat/_graph/transformers/_rdfpath.py +14 -15
  14. cognite/neat/_graph/transformers/_value_type.py +72 -0
  15. cognite/neat/_issues/__init__.py +0 -2
  16. cognite/neat/_issues/_base.py +19 -35
  17. cognite/neat/_issues/warnings/__init__.py +6 -1
  18. cognite/neat/_issues/warnings/_general.py +7 -0
  19. cognite/neat/_issues/warnings/_properties.py +11 -0
  20. cognite/neat/_issues/warnings/_resources.py +11 -0
  21. cognite/neat/_rules/exporters/_rules2dms.py +35 -1
  22. cognite/neat/_rules/exporters/_rules2excel.py +2 -2
  23. cognite/neat/_rules/importers/_dms2rules.py +66 -55
  24. cognite/neat/_rules/models/_base_rules.py +4 -1
  25. cognite/neat/_rules/models/entities/_wrapped.py +10 -5
  26. cognite/neat/_rules/models/mapping/_classic2core.yaml +239 -38
  27. cognite/neat/_rules/transformers/__init__.py +8 -2
  28. cognite/neat/_rules/transformers/_converters.py +271 -188
  29. cognite/neat/_rules/transformers/_mapping.py +75 -59
  30. cognite/neat/_rules/transformers/_verification.py +2 -3
  31. cognite/neat/_session/_inspect.py +3 -1
  32. cognite/neat/_session/_prepare.py +112 -24
  33. cognite/neat/_session/_read.py +33 -70
  34. cognite/neat/_session/_state.py +2 -2
  35. cognite/neat/_session/_to.py +2 -2
  36. cognite/neat/_store/_rules_store.py +4 -8
  37. cognite/neat/_utils/reader/_base.py +27 -0
  38. cognite/neat/_version.py +1 -1
  39. {cognite_neat-0.104.0.dist-info → cognite_neat-0.105.1.dist-info}/METADATA +4 -3
  40. cognite_neat-0.105.1.dist-info/RECORD +179 -0
  41. {cognite_neat-0.104.0.dist-info → cognite_neat-0.105.1.dist-info}/WHEEL +1 -1
  42. cognite/neat/_app/api/__init__.py +0 -0
  43. cognite/neat/_app/api/asgi/metrics.py +0 -4
  44. cognite/neat/_app/api/configuration.py +0 -98
  45. cognite/neat/_app/api/context_manager/__init__.py +0 -3
  46. cognite/neat/_app/api/context_manager/manager.py +0 -16
  47. cognite/neat/_app/api/data_classes/__init__.py +0 -0
  48. cognite/neat/_app/api/data_classes/rest.py +0 -59
  49. cognite/neat/_app/api/explorer.py +0 -66
  50. cognite/neat/_app/api/routers/configuration.py +0 -25
  51. cognite/neat/_app/api/routers/crud.py +0 -102
  52. cognite/neat/_app/api/routers/metrics.py +0 -10
  53. cognite/neat/_app/api/routers/workflows.py +0 -224
  54. cognite/neat/_app/api/utils/__init__.py +0 -0
  55. cognite/neat/_app/api/utils/data_mapping.py +0 -17
  56. cognite/neat/_app/api/utils/logging.py +0 -26
  57. cognite/neat/_app/api/utils/query_templates.py +0 -92
  58. cognite/neat/_app/main.py +0 -17
  59. cognite/neat/_app/monitoring/__init__.py +0 -0
  60. cognite/neat/_app/monitoring/metrics.py +0 -69
  61. cognite/neat/_app/ui/index.html +0 -1
  62. cognite/neat/_app/ui/neat-app/.gitignore +0 -23
  63. cognite/neat/_app/ui/neat-app/README.md +0 -70
  64. cognite/neat/_app/ui/neat-app/build/asset-manifest.json +0 -14
  65. cognite/neat/_app/ui/neat-app/build/favicon.ico +0 -0
  66. cognite/neat/_app/ui/neat-app/build/img/architect-icon.svg +0 -116
  67. cognite/neat/_app/ui/neat-app/build/img/developer-icon.svg +0 -112
  68. cognite/neat/_app/ui/neat-app/build/img/sme-icon.svg +0 -34
  69. cognite/neat/_app/ui/neat-app/build/index.html +0 -1
  70. cognite/neat/_app/ui/neat-app/build/logo192.png +0 -0
  71. cognite/neat/_app/ui/neat-app/build/manifest.json +0 -25
  72. cognite/neat/_app/ui/neat-app/build/robots.txt +0 -3
  73. cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css +0 -2
  74. cognite/neat/_app/ui/neat-app/build/static/css/main.72e3d92e.css.map +0 -1
  75. cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js +0 -3
  76. cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.LICENSE.txt +0 -88
  77. cognite/neat/_app/ui/neat-app/build/static/js/main.5a52cf09.js.map +0 -1
  78. cognite/neat/_app/ui/neat-app/build/static/media/logo.8093b84df9ed36a174c629d6fe0b730d.svg +0 -1
  79. cognite/neat/_app/ui/neat-app/package-lock.json +0 -18306
  80. cognite/neat/_app/ui/neat-app/package.json +0 -62
  81. cognite/neat/_app/ui/neat-app/public/favicon.ico +0 -0
  82. cognite/neat/_app/ui/neat-app/public/img/architect-icon.svg +0 -116
  83. cognite/neat/_app/ui/neat-app/public/img/developer-icon.svg +0 -112
  84. cognite/neat/_app/ui/neat-app/public/img/sme-icon.svg +0 -34
  85. cognite/neat/_app/ui/neat-app/public/index.html +0 -43
  86. cognite/neat/_app/ui/neat-app/public/logo192.png +0 -0
  87. cognite/neat/_app/ui/neat-app/public/manifest.json +0 -25
  88. cognite/neat/_app/ui/neat-app/public/robots.txt +0 -3
  89. cognite/neat/_app/ui/neat-app/src/App.css +0 -38
  90. cognite/neat/_app/ui/neat-app/src/App.js +0 -17
  91. cognite/neat/_app/ui/neat-app/src/App.test.js +0 -8
  92. cognite/neat/_app/ui/neat-app/src/MainContainer.tsx +0 -70
  93. cognite/neat/_app/ui/neat-app/src/components/JsonViewer.tsx +0 -43
  94. cognite/neat/_app/ui/neat-app/src/components/LocalUploader.tsx +0 -124
  95. cognite/neat/_app/ui/neat-app/src/components/OverviewComponentEditorDialog.tsx +0 -63
  96. cognite/neat/_app/ui/neat-app/src/components/StepEditorDialog.tsx +0 -511
  97. cognite/neat/_app/ui/neat-app/src/components/TabPanel.tsx +0 -36
  98. cognite/neat/_app/ui/neat-app/src/components/Utils.tsx +0 -56
  99. cognite/neat/_app/ui/neat-app/src/components/WorkflowDeleteDialog.tsx +0 -60
  100. cognite/neat/_app/ui/neat-app/src/components/WorkflowExecutionReport.tsx +0 -112
  101. cognite/neat/_app/ui/neat-app/src/components/WorkflowImportExportDialog.tsx +0 -67
  102. cognite/neat/_app/ui/neat-app/src/components/WorkflowMetadataDialog.tsx +0 -79
  103. cognite/neat/_app/ui/neat-app/src/index.css +0 -13
  104. cognite/neat/_app/ui/neat-app/src/index.js +0 -13
  105. cognite/neat/_app/ui/neat-app/src/logo.svg +0 -1
  106. cognite/neat/_app/ui/neat-app/src/reportWebVitals.js +0 -13
  107. cognite/neat/_app/ui/neat-app/src/setupTests.js +0 -5
  108. cognite/neat/_app/ui/neat-app/src/types/WorkflowTypes.ts +0 -388
  109. cognite/neat/_app/ui/neat-app/src/views/AboutView.tsx +0 -61
  110. cognite/neat/_app/ui/neat-app/src/views/ConfigView.tsx +0 -184
  111. cognite/neat/_app/ui/neat-app/src/views/GlobalConfigView.tsx +0 -180
  112. cognite/neat/_app/ui/neat-app/src/views/WorkflowView.tsx +0 -570
  113. cognite/neat/_app/ui/neat-app/tsconfig.json +0 -27
  114. cognite/neat/_workflows/__init__.py +0 -17
  115. cognite/neat/_workflows/base.py +0 -590
  116. cognite/neat/_workflows/cdf_store.py +0 -393
  117. cognite/neat/_workflows/examples/Export_DMS/workflow.yaml +0 -89
  118. cognite/neat/_workflows/examples/Export_Semantic_Data_Model/workflow.yaml +0 -66
  119. cognite/neat/_workflows/examples/Import_DMS/workflow.yaml +0 -65
  120. cognite/neat/_workflows/examples/Validate_Rules/workflow.yaml +0 -67
  121. cognite/neat/_workflows/examples/Validate_Solution_Model/workflow.yaml +0 -64
  122. cognite/neat/_workflows/manager.py +0 -292
  123. cognite/neat/_workflows/model.py +0 -203
  124. cognite/neat/_workflows/steps/__init__.py +0 -0
  125. cognite/neat/_workflows/steps/data_contracts.py +0 -109
  126. cognite/neat/_workflows/steps/lib/__init__.py +0 -0
  127. cognite/neat/_workflows/steps/lib/current/__init__.py +0 -6
  128. cognite/neat/_workflows/steps/lib/current/graph_extractor.py +0 -100
  129. cognite/neat/_workflows/steps/lib/current/graph_loader.py +0 -51
  130. cognite/neat/_workflows/steps/lib/current/graph_store.py +0 -48
  131. cognite/neat/_workflows/steps/lib/current/rules_exporter.py +0 -537
  132. cognite/neat/_workflows/steps/lib/current/rules_importer.py +0 -323
  133. cognite/neat/_workflows/steps/lib/current/rules_validator.py +0 -106
  134. cognite/neat/_workflows/steps/lib/io/__init__.py +0 -1
  135. cognite/neat/_workflows/steps/lib/io/io_steps.py +0 -393
  136. cognite/neat/_workflows/steps/step_model.py +0 -79
  137. cognite/neat/_workflows/steps_registry.py +0 -218
  138. cognite/neat/_workflows/tasks.py +0 -18
  139. cognite/neat/_workflows/triggers.py +0 -169
  140. cognite/neat/_workflows/utils.py +0 -19
  141. cognite_neat-0.104.0.dist-info/RECORD +0 -276
  142. {cognite_neat-0.104.0.dist-info → cognite_neat-0.105.1.dist-info}/LICENSE +0 -0
  143. {cognite_neat-0.104.0.dist-info → cognite_neat-0.105.1.dist-info}/entry_points.txt +0 -0
@@ -1,393 +0,0 @@
1
- import json
2
- import logging
3
- import os
4
- import shutil
5
- import time
6
- import zipfile
7
- from pathlib import Path
8
-
9
- from cognite.client import CogniteClient
10
- from cognite.client.data_classes import Event, FileMetadataUpdate
11
- from fastapi.encoders import jsonable_encoder
12
- from pydantic import BaseModel
13
-
14
- from cognite.neat._issues.errors import WorkflowConfigurationNotSetError
15
- from cognite.neat._workflows.model import WorkflowFullStateReport, WorkflowState, WorkflowStepEvent
16
- from cognite.neat._workflows.utils import get_file_hash
17
-
18
-
19
- class NeatCdfResource(BaseModel):
20
- id: int | None = None
21
- name: str | None
22
- rtype: str
23
- last_updated_time: int | None = None
24
- last_updated_by: str | None = None
25
- version: str | None = None
26
- tag: str | None = None
27
- comments: str | None = None
28
- external_id: str | None = None
29
- is_latest: bool = False
30
-
31
-
32
- class CdfStore:
33
- def __init__(
34
- self,
35
- client: CogniteClient,
36
- data_set_id: int,
37
- workflows_storage_path: Path | None = None,
38
- rules_storage_path: Path | None = None,
39
- ):
40
- self.client = client
41
- self.data_set_id = data_set_id
42
- self.workflows_storage_path = workflows_storage_path
43
- self.rules_storage_path = rules_storage_path
44
- self.workflows_storage_type = "file"
45
-
46
- def init_cdf_resources(self, resource_type="all"):
47
- if self.client and self.data_set_id:
48
- try:
49
- logging.info("Nothing to initialize")
50
- except Exception as e:
51
- logging.debug(f"Failed to create labels.{e}")
52
-
53
- def package_workflow(self, workflow_name: str) -> str:
54
- """Creates a zip archive from a folder"""
55
- if self.workflows_storage_path is None:
56
- raise WorkflowConfigurationNotSetError("workflows_storage_path")
57
- folder_path = self.workflows_storage_path / workflow_name
58
- archive_path = self.workflows_storage_path / f"{workflow_name}.zip"
59
- # Make sure the folder exists
60
- if not folder_path.is_dir():
61
- logging.error(f"Error: {folder_path} is not a directory")
62
- raise Exception(f"Can't package workflow.Error: {folder_path} is not a directory")
63
-
64
- # Create a ZipFile object with write mode
65
- with zipfile.ZipFile(archive_path, "w", zipfile.ZIP_DEFLATED) as zipf:
66
- # Walk through the directory and add each json file to the archive
67
- for root, _, files in os.walk(folder_path):
68
- for file in files:
69
- file_path = Path(root) / Path(file)
70
- # Check if the file has a .json extension
71
- if not (file.endswith(".pyc") and file.endswith(".DS_Store")):
72
- # Add the file to the archive
73
- zipf.write(file_path, os.path.relpath(file_path, folder_path))
74
- return f"{workflow_name}.zip"
75
-
76
- def extract_workflow_package(self, workflow_name: str):
77
- # Make sure the archive exists
78
- workflow_name = workflow_name.replace(".zip", "")
79
- if self.workflows_storage_path is None:
80
- raise WorkflowConfigurationNotSetError("workflows_storage_path")
81
- package_full_path = Path(self.workflows_storage_path) / f"{workflow_name}.zip"
82
- output_folder = Path(self.workflows_storage_path) / workflow_name
83
- if not package_full_path.is_file():
84
- print(f"Error: {package_full_path} is not a file")
85
- raise Exception(f"Can't extract workflow package. Error: {package_full_path} is not a file")
86
-
87
- # Remove the output folder if it already exists
88
- if output_folder.exists():
89
- shutil.rmtree(output_folder)
90
- # Create the output folder if it does not exist
91
- output_folder.mkdir(parents=True, exist_ok=True)
92
-
93
- # Extract the contents of the archive to the output folder
94
- with zipfile.ZipFile(package_full_path, "r") as zipf:
95
- zipf.extractall(output_folder)
96
-
97
- def load_workflows_from_cfg_by_filter(self, config_filter: list[str] | None = None) -> None:
98
- """Load workflow package from CDF and extract it to the storage path"""
99
- # filter syntax: name:workflow_name=version; tag:tag_name
100
- try:
101
- for filter_item in config_filter or []:
102
- filter_type = filter_item.split(":")[0]
103
- if filter_type == "name":
104
- filter_workflow_name_with_version_l = filter_item.split(":")[1].split("=")
105
- filter_workflow_name = filter_workflow_name_with_version_l[0]
106
- if len(filter_workflow_name_with_version_l) > 1:
107
- filter_workflow_version = filter_workflow_name_with_version_l[1]
108
- else:
109
- filter_workflow_version = None
110
- logging.info(
111
- f"Loading workflow filtered by name: {filter_workflow_name} version: {filter_workflow_version}"
112
- )
113
- self.load_workflows_from_cdf(filter_workflow_name, filter_workflow_version)
114
- elif filter_type == "tag":
115
- tag = filter_item.split(":")[1]
116
- logging.info(f"Loading workflow filtered by tag: {tag}")
117
- self.load_workflows_from_cdf(metadata_filter={"tag": tag})
118
-
119
- except Exception as e:
120
- logging.error(f"Failed to load workflows by filter. Error: {e}")
121
-
122
- def load_workflows_from_cdf(
123
- self,
124
- workflow_name: str | None = None,
125
- version: str | None = None,
126
- metadata_filter: dict[str, str] | None = None,
127
- ) -> list[str]:
128
- """Load workflow package or multiple workfllows from CDF and extract it to the storage path"""
129
- # TODO: Add workflow and tag filters
130
- if self.data_set_id and self.client:
131
- if workflow_name:
132
- workflow_name = workflow_name if ".zip" in workflow_name else f"{workflow_name}.zip"
133
- meta = metadata_filter or {}
134
- if version:
135
- meta["hash"] = version
136
- else:
137
- meta["is_latest"] = "true"
138
- if workflow_name:
139
- files_metada = self.client.files.list(source="neat", name=workflow_name, metadata=meta)
140
- elif metadata_filter:
141
- files_metada = self.client.files.list(source="neat", metadata=meta)
142
- else:
143
- raise Exception("Workflow name or metadata_filter is required")
144
-
145
- files_external_ids: list[str] = []
146
- if self.workflows_storage_path is None:
147
- raise Exception("Workflow storage path is not defined")
148
- for file_meta in files_metada:
149
- self.client.files.download(self.workflows_storage_path, external_id=file_meta.external_id)
150
- logging.info(
151
- f"Workflow {file_meta.name} , "
152
- f"external_id = {file_meta.external_id} syccessfully downloaded from CDF"
153
- )
154
- self.extract_workflow_package(file_meta.name or "Unknown Workflow")
155
- if file_meta.external_id:
156
- files_external_ids.append(file_meta.external_id)
157
- return files_external_ids
158
- else:
159
- logging.error("No CDF client or data set id provided")
160
- return []
161
-
162
- def save_workflow_to_cdf(self, name: str, tag: str = "", changed_by: str = "", comments: str = "") -> None:
163
- """Saves entire workflow (all artifacts) to CDF."""
164
- self.package_workflow(name)
165
- if self.data_set_id and self.client and self.workflows_storage_path:
166
- zip_file = Path(self.workflows_storage_path) / f"{name}.zip"
167
- if zip_file.exists():
168
- self.save_resource_to_cdf(name, "workflow-package", zip_file, tag, changed_by, comments)
169
- zip_file.unlink()
170
- logging.info(f"Workflow package {name} uploaded to CDF")
171
- else:
172
- logging.error(f"Workflow package {name} not found, skipping")
173
- else:
174
- logging.error("No CDF client, data set id or workflow_storage_path provided")
175
-
176
- def save_resource_to_cdf(
177
- self,
178
- workflow_name: str,
179
- resource_type: str,
180
- file_path: Path,
181
- tag: str = "",
182
- changed_by: str = "",
183
- comments: str = "",
184
- ) -> None:
185
- """Saves resources to cdf. For instance workflow package, rules file, etc"""
186
- if self.data_set_id and self.client:
187
- if not file_path.exists():
188
- logging.error(f"File {file_path} not found, skipping")
189
- return
190
- # removing the latest tag from all files related to this workflow
191
- files_metada = self.client.files.list(
192
- name=file_path.name,
193
- source="neat",
194
- metadata={"workflow_name": workflow_name, "resource_type": resource_type, "is_latest": "true"},
195
- )
196
- for file_meta in files_metada:
197
- files_meta_metadata = file_meta.metadata or {}
198
- files_meta_metadata["is_latest"] = "false"
199
- meta_update = FileMetadataUpdate(id=file_meta.id).metadata.set(files_meta_metadata)
200
- self.client.files.update(meta_update)
201
-
202
- hash_ = get_file_hash(file_path)
203
- self.client.files.upload(
204
- str(file_path),
205
- name=file_path.name,
206
- external_id=f"neat-wf-{hash_}",
207
- metadata={
208
- "tag": tag,
209
- "hash": hash_,
210
- "workflow_name": workflow_name,
211
- "resource_type": resource_type,
212
- "changed_by": changed_by,
213
- "comments": comments,
214
- "is_latest": "true",
215
- },
216
- source="neat",
217
- overwrite=True,
218
- data_set_id=self.data_set_id,
219
- )
220
- else:
221
- logging.error("No CDF client or data set id provided")
222
-
223
- def load_rules_file_from_cdf(self, name: str, version: str | None = None):
224
- logging.info(f"Loading rules file {name} (version = {version} ) from CDF ")
225
- if version:
226
- metadata = {"hash": str(version)}
227
- else:
228
- metadata = {"is_latest": "true"}
229
- files_metadata = self.client.files.list(name=name, source="neat", metadata=metadata)
230
- if len(files_metadata) > 0 and self.rules_storage_path:
231
- self.client.files.download(self.rules_storage_path, external_id=files_metadata[0].external_id)
232
- else:
233
- raise Exception(f"Rules file {name} with version {version} not found in CDF")
234
-
235
- def get_list_of_resources_from_cdf(self, resource_type: str) -> list[NeatCdfResource]:
236
- logging.info(f"Getting list of resources of type {resource_type} from CDF")
237
- if not self.data_set_id:
238
- return []
239
-
240
- files_metadata = self.client.files.list(source="neat", metadata={"resource_type": resource_type})
241
-
242
- output: list[NeatCdfResource] = []
243
- for file_meta in files_metadata:
244
- if file_meta.metadata:
245
- is_latest = file_meta.metadata.get("is_latest", "false") == "true"
246
- else:
247
- is_latest = False
248
-
249
- metadata = file_meta.metadata or {}
250
- neat_cdf_resource = NeatCdfResource(
251
- id=file_meta.id,
252
- name=file_meta.name,
253
- external_id=file_meta.external_id,
254
- version=metadata["hash"],
255
- rtype=metadata["resource_type"],
256
- comments=metadata["comments"],
257
- last_updated_by=metadata["changed_by"],
258
- tag=metadata["tag"],
259
- last_updated_time=file_meta.last_updated_time,
260
- is_latest=is_latest,
261
- )
262
- output.append(neat_cdf_resource)
263
- return output
264
-
265
- def get_list_of_workflow_executions_from_cdf(self, limit=70) -> list[WorkflowFullStateReport]:
266
- """Returns list of workflow executions from CDF."""
267
- logging.debug("Getting list of workflow executions from CDF")
268
- if not self.data_set_id:
269
- return []
270
- events = self.client.events.list(type="neat-workflow-run", source="neat", sort=["startTime:desc"], limit=limit)
271
- executions = []
272
- for event in events:
273
- if (time.time() - (event.start_time or 0) > 24 * 60 * 60) and event.subtype == "RUNNING":
274
- event.subtype = "EXPIRED"
275
- metadata = event.metadata or {}
276
- try:
277
- executions.append(
278
- WorkflowFullStateReport(
279
- run_id=metadata["run_id"],
280
- elapsed_time=float(metadata["elapsed_time"]) if "elapsed_time" in metadata else 0,
281
- last_error=metadata["error"] if "error" in metadata else "",
282
- execution_log=[],
283
- workflow_name=metadata["workflow_name"] if "workflow_name" in metadata else "",
284
- last_updated_time=event.last_updated_time,
285
- start_time=event.start_time,
286
- end_time=event.end_time,
287
- state=WorkflowState((event.subtype or WorkflowState.UNKNOWN).upper()),
288
- )
289
- )
290
- except Exception as e:
291
- logging.info(
292
- f"Failed to parse workflow execution event for workflow, "
293
- f"run_id = {metadata['run_id']}, error = {e}"
294
- )
295
- return executions
296
-
297
- def get_detailed_workflow_execution_report_from_cdf(self, run_id: str) -> WorkflowFullStateReport | None:
298
- """Returns detailed workflow execution report from CDF"""
299
- logging.debug(f"Getting detailed workflow execution {run_id} from CDF")
300
- external_id = f"neat-wf-run-{run_id}"
301
- if not self.data_set_id:
302
- return None
303
- event = self.client.events.retrieve(external_id=external_id)
304
- if event:
305
- metadata = event.metadata or {}
306
- try:
307
- if "execution_log" in metadata:
308
- steps_log = json.loads(metadata["execution_log"])
309
- else:
310
- external_id = f"neat-wf-execution-log-{run_id}"
311
- steps_log = self.client.files.download_bytes(external_id=external_id)
312
- except Exception as e:
313
- logging.info(
314
- f"Failed to parse execution log for workflow {metadata['workflow_name']}, "
315
- f"run_id = {metadata['run_id']}, error = {e}"
316
- )
317
- steps_log = []
318
-
319
- metadata = event.metadata or {}
320
- return WorkflowFullStateReport(
321
- run_id=metadata["run_id"],
322
- elapsed_time=float(metadata["elapsed_time"]) if "elapsed_time" in metadata else 0,
323
- last_error=metadata["error"] if "error" in metadata else "",
324
- execution_log=steps_log,
325
- workflow_name=metadata["workflow_name"] if "workflow_name" in metadata else "",
326
- last_updated_time=event.last_updated_time,
327
- start_time=event.start_time,
328
- end_time=event.end_time,
329
- state=WorkflowState((event.subtype or WorkflowState.UNKNOWN).upper()),
330
- )
331
- raise Exception(f"Workflow execution with run_id = {run_id} not found")
332
-
333
- def report_workflow_execution_to_cdf(self, report: WorkflowFullStateReport):
334
- # Report workflow run to CDF as single event with all the steps attached either in metadata
335
- # or attached file (depends on the size)
336
- if not self.data_set_id:
337
- return
338
- metadata: dict[str, str] = {
339
- "run_id": str(report.run_id),
340
- "elapsed_time": str(report.elapsed_time),
341
- "error": str(report.last_error),
342
- "execution_log": "",
343
- "workflow_name": str(report.workflow_name),
344
- }
345
- external_id = f"neat-wf-run-{report.run_id}"
346
- serialized_execution_log = json.dumps(jsonable_encoder(report.execution_log))
347
- execution_log_size = bytes(serialized_execution_log, "utf-8").__sizeof__()
348
- logging.debug(f"Serialized execution log size: {execution_log_size}")
349
-
350
- if report.start_time:
351
- report.start_time = report.start_time * 1000
352
- if report.end_time:
353
- report.end_time = report.end_time * 1000
354
-
355
- event = Event(
356
- external_id=external_id,
357
- type="neat-workflow-run",
358
- subtype=report.state,
359
- start_time=report.start_time,
360
- end_time=report.end_time,
361
- source="neat",
362
- metadata=metadata,
363
- data_set_id=self.data_set_id,
364
- )
365
-
366
- if execution_log_size > 128000: # 128K limit for Event metadata
367
- self.client.files.upload_bytes(
368
- serialized_execution_log,
369
- name="neat-workflow-execution-log.json",
370
- external_id=f"neat-wf-execution-log-{report.run_id}",
371
- metadata={"run_id": str(report.run_id), "workflow_name": str(report.workflow_name)},
372
- source="neat",
373
- overwrite=True,
374
- data_set_id=self.data_set_id,
375
- )
376
- elif serialized_execution_log:
377
- event.metadata["execution_log"] = serialized_execution_log # type: ignore[index]
378
-
379
- if report.state in [WorkflowState.CREATED, WorkflowState.RUNNING]:
380
- res = self.client.events.create(event)
381
- elif report.state in [WorkflowState.COMPLETED, WorkflowState.FAILED]:
382
- res = self.client.events.update(event)
383
- else:
384
- logging.error(f"Unknown workflow state {report.state}")
385
- return
386
-
387
- if res.external_id == external_id:
388
- logging.debug(f"Workflow run {report.run_id} reported to CDF")
389
- else:
390
- logging.error(f"Workflow run {report.run_id} not reported to CDF due to error: {res}")
391
-
392
- def report_step_event_to_cdf(self, event: WorkflowStepEvent):
393
- pass
@@ -1,89 +0,0 @@
1
- configs: []
2
- description: null
3
- implementation_module: null
4
- name: Export DMS
5
- steps:
6
- - complex_configs: {}
7
- configs: {}
8
- description: null
9
- enabled: true
10
- id: step_861205
11
- label: Upload Rules Spreadsheet
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_295479
21
- trigger: true
22
- ui_config:
23
- pos_x: 629
24
- pos_y: 57
25
- - complex_configs: {}
26
- configs:
27
- File name: ''
28
- Report formatter: BasicHTML
29
- Role: infer
30
- description: null
31
- enabled: true
32
- id: step_295479
33
- label: Validate
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_50885
42
- trigger: false
43
- ui_config:
44
- pos_x: 629
45
- pos_y: 161
46
- - complex_configs:
47
- Components:
48
- containers: true
49
- data_models: true
50
- spaces: true
51
- views: true
52
- configs:
53
- Dry run: 'False'
54
- Existing component handling: update
55
- Multi-space components create: 'True'
56
- description: null
57
- enabled: true
58
- id: step_50885
59
- label: Export Data Model to CDF
60
- max_retries: 0
61
- method: RulesToDMS
62
- params: {}
63
- retry_delay: 3
64
- stype: stdstep
65
- system_component_id: null
66
- transition_to:
67
- - step_171560
68
- trigger: false
69
- ui_config:
70
- pos_x: 629
71
- pos_y: 243
72
- - complex_configs: {}
73
- configs: {}
74
- description: null
75
- enabled: true
76
- id: step_171560
77
- label: Export Transformations
78
- max_retries: 0
79
- method: RulesToCDFTransformations
80
- params: {}
81
- retry_delay: 3
82
- stype: stdstep
83
- system_component_id: null
84
- transition_to: []
85
- trigger: false
86
- ui_config:
87
- pos_x: 629
88
- pos_y: 342
89
- system_components: []
@@ -1,66 +0,0 @@
1
- configs: []
2
- description: null
3
- implementation_module: null
4
- name: Export 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
- system_components: []
@@ -1,65 +0,0 @@
1
- configs: []
2
- description: null
3
- implementation_module: null
4
- name: Import DMS
5
- steps:
6
- - complex_configs: {}
7
- configs:
8
- Data model id: playground_nordic44:nordic44
9
- Report formatter: BasicHTML
10
- Role: information_architect
11
- description: null
12
- enabled: true
13
- id: step_725987
14
- label: Import DMS
15
- max_retries: 0
16
- method: DMSToRules
17
- params: {}
18
- retry_delay: 3
19
- stype: stdstep
20
- system_component_id: null
21
- transition_to:
22
- - step_419138
23
- trigger: false
24
- ui_config:
25
- pos_x: 541
26
- pos_y: 84
27
- - complex_configs: {}
28
- configs:
29
- Styling: default
30
- description: null
31
- enabled: true
32
- id: step_419138
33
- label: Create Excel Spreadsheet
34
- max_retries: 0
35
- method: RulesToExcel
36
- params: {}
37
- retry_delay: 3
38
- stype: stdstep
39
- system_component_id: null
40
- transition_to: []
41
- trigger: false
42
- ui_config:
43
- pos_x: 540
44
- pos_y: 193
45
- - complex_configs: {}
46
- configs: {}
47
- description: null
48
- enabled: true
49
- id: step_431484
50
- label: Trigger Workflow
51
- max_retries: 0
52
- method: null
53
- params:
54
- sync: 'false'
55
- workflow_name: ''
56
- retry_delay: 3
57
- stype: http_trigger
58
- system_component_id: null
59
- transition_to:
60
- - step_725987
61
- trigger: true
62
- ui_config:
63
- pos_x: 541
64
- pos_y: -13
65
- system_components: []
@@ -1,67 +0,0 @@
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: []