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,570 +0,0 @@
1
- import { useCallback, useRef } from 'react';
2
- import ReactFlow, {
3
- MiniMap,
4
- Controls,
5
- Background,
6
- useNodesState,
7
- useEdgesState,
8
- addEdge,
9
- Node,
10
- updateEdge,
11
- Panel,
12
- NodeChange,
13
- EdgeChange,
14
- } from 'reactflow';
15
- // 👇 you need to import the reactflow styles
16
-
17
- import LinearProgress from '@mui/material/LinearProgress';
18
- import { Typography } from '@mui/material';
19
- import Stack from '@mui/material/Stack';
20
- import { styled } from '@mui/material/styles';
21
- import Paper from '@mui/material/Paper';
22
- import FormControl from '@mui/material/FormControl';
23
- import InputLabel from '@mui/material/InputLabel';
24
- import Select, { SelectChangeEvent } from '@mui/material/Select';
25
- import { Box } from '@mui/system';
26
- import MenuItem from '@mui/material/MenuItem';
27
-
28
-
29
- import 'reactflow/dist/style.css';
30
- import Button from '@mui/material/Button';
31
- import { useState, useEffect } from 'react';
32
-
33
- import { StepRegistry, UIConfig, WorkflowDefinition, WorkflowStepDefinition, WorkflowSystemComponent} from 'types/WorkflowTypes';
34
- import { getNeatApiRootUrl, getSelectedWorkflowName, setSelectedWorkflowName } from 'components/Utils';
35
- import WorkflowExecutionReport from 'components/WorkflowExecutionReport';
36
- import ConfigView from './ConfigView';
37
- import OverviewComponentEditorDialog from 'components/OverviewComponentEditorDialog';
38
- import StepEditorDialog from 'components/StepEditorDialog';
39
- import WorkflowMetadataDialog from 'components/WorkflowMetadataDialog';
40
- import WorkflowDeleteDialog from 'components/WorkflowDeleteDialog';
41
- import WorkflowImportExportDialog from 'components/WorkflowImportExportDialog';
42
-
43
-
44
- export interface ExecutionLog {
45
- id: string;
46
- label: string;
47
- state: string;
48
- elapsed_time: number;
49
- timestamp: string;
50
- error: string;
51
- output_text: string;
52
- data: any;
53
- }
54
-
55
- export interface WorkflowStats {
56
- state: string;
57
- elapsed_time: number;
58
- last_error: string;
59
- execution_log: ExecutionLog[];
60
- }
61
-
62
- const Item = styled(Paper)(({ theme }) => ({
63
- backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
64
- ...theme.typography.body2,
65
- padding: theme.spacing(1),
66
- textAlign: 'left',
67
- color: theme.palette.text.secondary,
68
- }));
69
-
70
-
71
-
72
- export default function WorkflowView() {
73
- const neatApiRootUrl = getNeatApiRootUrl();
74
- const edgeUpdateSuccessful = useRef(true);
75
- const [nodes, setNodes, onNodesChange] = useNodesState([]);
76
- const [edges, setEdges, onEdgesChange] = useEdgesState([]);
77
- const [workflowStats, setWorkflowStats] = useState<WorkflowStats>();
78
- const [timerInterval, setTimerInterval] = useState(null);
79
- const [workflowDefinitions, setWorkflowDefinitions] = useState<WorkflowDefinition>();
80
- const [selectedWorkflow, setSelectedWorkflow] = useState<string>(getSelectedWorkflowName());
81
- const [listOfWorkflows, setListOfWorkflows] = useState<string[]>([]);
82
- const [viewType, setViewType] = useState<string>("steps");
83
- const [dialogOpen, setDialogOpen] = useState(false);
84
- const [workflowMetadataDialogOpen, setWorkflowMetadataDialogOpen] = useState(false);
85
- const [openOverviewComponentEditorDialog, setOpenOverviewComponentEditorDialog] = useState(false);
86
- const [selectedStep, setSelectedStep] = useState<WorkflowStepDefinition>();
87
- const [selectedComponent, setSelectedComponent] = useState<WorkflowSystemComponent>();
88
- const [fileContent, setFileContent] = useState('');
89
- const [stepRegistry, setStepRegistry] = useState<StepRegistry>();
90
- const [editState, setEditState] = useState<string>("");
91
- const [loading , setLoading] = useState<boolean>(false);
92
- const [errorText, setErrorText] = useState<string>("");
93
- const [packageLink, setPackageLink] = useState<string>("");
94
-
95
- useEffect(() => {
96
- loadListOfWorkflows();
97
- loadRegisteredSteps();
98
- if (getSelectedWorkflowName())
99
- loadWorkflowDefinitions(getSelectedWorkflowName());
100
- else
101
- setEditState("Please select one of provided workflows or create new one");
102
- }, []);
103
-
104
- useEffect(() => {
105
- syncWorkflowDefToNodesAndEdges(viewType);
106
-
107
- console.dir(workflowDefinitions);
108
- startStatePolling(selectedWorkflow);
109
- }, [workflowDefinitions]);
110
-
111
- const startStatePolling = (workflowName:string) => {
112
- if (timerInterval) {
113
- clearInterval(timerInterval);
114
- }
115
- let newTimerInterval = setInterval(() => {
116
- loadWorkflowStats(workflowName);
117
- }, 2000);
118
- setTimerInterval(newTimerInterval);
119
- }
120
-
121
- const stopStatePolling = () => {
122
- clearInterval(timerInterval);
123
- }
124
-
125
- const loadListOfWorkflows = () => {
126
- const url = neatApiRootUrl + "/api/workflow/workflows";
127
- fetch(url).then((response) => response.json()).then((data) => {
128
- setListOfWorkflows(data.workflows);
129
- }).catch((error) => {
130
- console.error('Error:', error);
131
- }).finally(() => { });
132
- }
133
-
134
- const loadWorkflowDefinitions = (workflowName: string = "") => {
135
- if (workflowName == "")
136
- workflowName = selectedWorkflow;
137
- const url = neatApiRootUrl + "/api/workflow/workflow-definition/" + workflowName;
138
- fetch(url).then((response) => {
139
- if(response.ok)
140
- return response.json()
141
- else
142
- setErrorText("Workflow definition can't be loaded . Error:"+response.statusText+", code:"+response.status);
143
- return null
144
- }).then((data) => {
145
- if (!data) {
146
- return
147
- }
148
- const workflows = WorkflowDefinition.fromJSON(data.definition);
149
- setWorkflowDefinitions(workflows);
150
- setEditState("");
151
- setErrorText("");
152
- // loadWorkflowStats(workflowName);
153
- }).catch ((error) => {
154
- setErrorText(error.message);
155
- }).finally(() => { });
156
- }
157
-
158
- const loadRegisteredSteps = () => {
159
- const url = neatApiRootUrl + "/api/workflow/registered-steps";
160
- fetch(url).then((response) => response.json()).then((data) => {
161
- const steps = StepRegistry.fromJSON(data.steps);
162
- setStepRegistry(steps);
163
- }).catch ((error) => {
164
- console.error('Error:', error);
165
- }).finally(() => { });
166
- }
167
-
168
-
169
-
170
- const filterStats = (stats: WorkflowStats) => {
171
-
172
- console.dir(stats)
173
- // detelete all log RUNNING entries that have both RUNNING and COMPLETED entries for the same step
174
- if (stats.execution_log == null)
175
- return stats;
176
-
177
- const filteredLog = stats.execution_log!.filter((log, index) => {
178
- if (log.state == "STARTED") {
179
- const nextLog = stats.execution_log[index + 1];
180
- if (nextLog && nextLog.state == "COMPLETED" && nextLog.id == log.id)
181
- return false;
182
- }
183
- return true;
184
- })
185
- stats.execution_log = filteredLog;
186
- return stats;
187
- }
188
-
189
- const enrichWorkflowStats = (stats: WorkflowStats) => {
190
-
191
- // set labels from workflow definition
192
- for (let i = 0; i < stats.execution_log.length; i++) {
193
- const log = stats.execution_log[i];
194
- if (workflowDefinitions != null){
195
- const step = workflowDefinitions.getStepById(log.id);
196
- if (step)
197
- log.label = step.label;
198
- }else {
199
- log.label ="";
200
- }
201
- }
202
- return stats;
203
- }
204
-
205
- const loadWorkflowStats = (workflowName: string = "") => {
206
- if (workflowName == "")
207
- workflowName = selectedWorkflow;
208
- const url = neatApiRootUrl + "/api/workflow/stats/" + workflowName;
209
- setErrorText("");
210
- fetch(url).then((response) => {
211
- if (!response.ok) {
212
- setErrorText("Workflow state can't be saved . Error code :"+response.status+", message :"+response.statusText);
213
- return null;
214
- }
215
- return response.json()
216
- }).then((data) => {
217
- if(!data)
218
- return;
219
- const enrichedStats = enrichWorkflowStats(data);
220
- setWorkflowStats(enrichedStats);
221
- if (data.state == "RUNNING") {
222
- // startStatePolling();
223
- } else if (data.state == "COMPLETED" || data.state == "FAILED") {
224
- // stopStatePolling();
225
- }
226
-
227
- }).catch((error) => {
228
- setErrorText("Workflow state can't be fetched from API , most likely backend is not running")
229
- console.error('Error:', error);
230
- })
231
- }
232
-
233
- const startWorkflow = () => {
234
- const url = neatApiRootUrl + "/api/workflow/start";
235
- const params = { name: selectedWorkflow, config: "", start_step: "" };
236
- fetch(url, {
237
- method: "post", body: JSON.stringify(params), headers: {
238
- 'Content-Type': 'application/json;charset=utf-8'
239
- }
240
- }).then((response) => response.json()).then((data) => {
241
- console.dir(data)
242
- setWorkflowStats(data);
243
- startStatePolling(selectedWorkflow);
244
- loadWorkflowStats();
245
- }).catch((error) => {
246
- setErrorText(error.message);
247
- console.error('Error:', error);
248
- })
249
- }
250
-
251
- const saveWorkflow = () => {
252
- console.dir(nodes);
253
- syncNodesAndEdgesToWorkflowDef();
254
- let wdef = workflowDefinitions;
255
- console.dir(wdef);
256
- setLoading(true);
257
- setErrorText("");
258
- const url = neatApiRootUrl + "/api/workflow/workflow-definition/" + selectedWorkflow;
259
- fetch(url, {
260
- method: "post", body: wdef.serializeToJson(), headers: {
261
- 'Content-Type': 'application/json;charset=utf-8'
262
- }
263
- }).then((response) => {
264
- if (!response.ok) {
265
- setErrorText("Workflow can't be saved . Error code :"+response.status+", message :"+response.statusText);
266
- return null;
267
- }
268
- return response.json()
269
- }
270
- ).then((data) => {
271
- if(!data)
272
- return;
273
- console.dir(data)
274
- setLoading(false);
275
- setEditState("");
276
- }
277
- ).catch((error) => {
278
- console.error('Error:', error);
279
- setErrorText(error);
280
- })
281
- };
282
-
283
- const syncNodesAndEdgesToWorkflowDef = () => {
284
- if (workflowDefinitions) {
285
- workflowDefinitions.updatePositions(nodes);
286
- if (viewType == "system")
287
- workflowDefinitions.updateSystemComponentTransitions(edges);
288
- else
289
- workflowDefinitions.updateStepTransitions(edges);
290
- } else {
291
- console.error("workflowDefinitions is null");
292
- }
293
-
294
- }
295
-
296
- const syncWorkflowDefToNodesAndEdges = (viewType:string) => {
297
- if (!workflowDefinitions)
298
- return;
299
- switch (viewType) {
300
- case 'steps':
301
- setNodes(workflowDefinitions.convertStepsToNodes());
302
- setEdges(workflowDefinitions.convertStepsToEdges());
303
- break;
304
- case 'system':
305
- setNodes(workflowDefinitions.convertSystemComponentsToNodes());
306
- setEdges(workflowDefinitions.convertSystemComponentsToEdges());
307
- }
308
- }
309
-
310
-
311
- const reloadWorkflows = () => {
312
- const url = neatApiRootUrl + "/api/workflow/reload-single-workflow/"+selectedWorkflow;
313
- fetch(url, {
314
- method: "post", body: "", headers: {
315
- 'Content-Type': 'application/json;charset=utf-8'
316
- }
317
- }).then((response) => response.json()).then((data) => {
318
- loadWorkflowDefinitions();
319
- loadListOfWorkflows();
320
- }
321
- ).catch((error) => {
322
- console.error('Error:', error);
323
- })
324
- };
325
-
326
-
327
- const switchToWorkflow = (workflowName: string) => {
328
- setSelectedWorkflowName(workflowName);
329
- setSelectedWorkflow(workflowName);
330
- loadWorkflowDefinitions(workflowName);
331
- setViewType("steps");
332
- syncWorkflowDefToNodesAndEdges("steps");
333
- startStatePolling(workflowName);
334
- }
335
-
336
- const handleWorkflowSelectorChange = (event: SelectChangeEvent) => {
337
- switchToWorkflow(event.target.value);
338
- };
339
-
340
- const handleViewTypeChange = (
341
- event: React.MouseEvent<HTMLElement>,
342
- newViewType: string,
343
- ) => {
344
-
345
- setViewType(newViewType);
346
- syncWorkflowDefToNodesAndEdges(newViewType);
347
-
348
- };
349
-
350
- const onConnect = useCallback((params) => {
351
-
352
- setEdges((eds) => addEdge(params, eds))
353
- syncNodesAndEdgesToWorkflowDef();
354
- setEditState("Unsaved");
355
- }, [setEdges]);
356
-
357
- const onEdgeUpdateStart = useCallback(() => {
358
-
359
- edgeUpdateSuccessful.current = false;
360
- }, []);
361
-
362
- const onEdgeUpdate = useCallback((oldEdge, newConnection) => {
363
-
364
- edgeUpdateSuccessful.current = true;
365
- setEdges((els) => updateEdge(oldEdge, newConnection, els));
366
- setEditState("Unsaved");
367
- }, [setEdges]);
368
-
369
- const onEdgeUpdateEnd = useCallback((_, edge) => {
370
-
371
- if (!edgeUpdateSuccessful.current) {
372
- setEdges((eds) => eds.filter((e) => e.id !== edge.id));
373
- syncNodesAndEdgesToWorkflowDef();
374
- }
375
- setEditState("Unsaved");
376
-
377
- edgeUpdateSuccessful.current = true;
378
- }, [setEdges]);
379
-
380
- const onNodeClick = useCallback((event, node) => {
381
-
382
- console.dir(node);
383
- handleDialogClickOpen(node.id, viewType);
384
- }, [workflowDefinitions, viewType]);
385
-
386
- const onAddStep = (() => {
387
-
388
- setEditState("Unsaved");
389
- const ui_config = new UIConfig();
390
- ui_config.pos_x = Math.round(window.innerWidth * 0.3);
391
- ui_config.pos_y = Math.round(window.innerHeight * 0.3);
392
- if (viewType == "steps") {
393
- const step = new WorkflowStepDefinition();
394
- step.id = "step_" + Math.floor(Math.random() * 1000000);
395
- step.label = "New step";
396
- step.ui_config = ui_config;
397
- step.stype = "stdstep";
398
- workflowDefinitions.steps.push(step);
399
- } else {
400
- const systemComponent = new WorkflowSystemComponent();
401
- systemComponent.id = "system_comp_" + Math.floor(Math.random() * 1000000);
402
- systemComponent.label = "New component";
403
- systemComponent.ui_config = ui_config;
404
- if (workflowDefinitions.system_components == null)
405
- workflowDefinitions.system_components = [];
406
- workflowDefinitions.system_components.push(systemComponent);
407
- }
408
- syncWorkflowDefToNodesAndEdges(viewType);
409
- });
410
-
411
- const handleDialogClickOpen = (id: string, viewType: string) => {
412
-
413
- if (viewType == "steps") {
414
- setSelectedStep(workflowDefinitions.getStepById(id));
415
- setDialogOpen(true);
416
- } else {
417
- setSelectedComponent(workflowDefinitions.getSystemComponentById(id));
418
- setOpenOverviewComponentEditorDialog(true);
419
- }
420
- };
421
-
422
- const handleDialogClose = (step:WorkflowStepDefinition,action:string) => {
423
- setDialogOpen(false);
424
- switch (action) {
425
- case "delete":
426
- workflowDefinitions.deleteStep(selectedStep.id);
427
- syncWorkflowDefToNodesAndEdges(viewType);
428
- setEditState("Unsaved");
429
- break;
430
- case "save":
431
- workflowDefinitions.updateStep(selectedStep.id, step);
432
- setSelectedStep(step);
433
- syncWorkflowDefToNodesAndEdges(viewType);
434
- setEditState("Unsaved");
435
- break;
436
- }
437
- };
438
-
439
- const solutionComponentEditorDialogHandler = (component: WorkflowSystemComponent,action: string) => {
440
-
441
- console.dir(component)
442
- switch (action) {
443
- case "save":
444
- workflowDefinitions.updateSystemComponent(selectedComponent.id, component);
445
- setSelectedComponent(component);
446
- syncWorkflowDefToNodesAndEdges(viewType);
447
- break;
448
- case "delete":
449
- workflowDefinitions.deleteSystemComponent(component.id);
450
- syncWorkflowDefToNodesAndEdges(viewType);
451
- break;
452
- }
453
- setEditState("Unsaved");
454
- setOpenOverviewComponentEditorDialog(false);
455
- }
456
-
457
- const handleCreateWorkflow = (wdef:WorkflowDefinition,action: string) => {
458
- // send workflowMeta to backend
459
- console.dir(wdef);
460
- if (action != "save")
461
- return;
462
-
463
- const url = neatApiRootUrl + "/api/workflow/create";
464
- fetch(url, {
465
- method: "post", body: wdef.serializeToJson(), headers: {
466
- 'Content-Type': 'application/json;charset=utf-8'
467
- }
468
- }).then((response) => response.json()).then((data) => {
469
- switchToWorkflow(wdef.name);
470
- window.location.reload();
471
- }
472
- ).catch((error) => {
473
- console.error('Error:', error);
474
- })
475
-
476
- }
477
-
478
- const onNodesChangeN = useCallback((nodeChanges: NodeChange[]) => {
479
-
480
- // console.dir(nodeChanges);
481
- onNodesChange(nodeChanges);
482
- syncNodesAndEdgesToWorkflowDef();
483
- // setEditState("Unsaved");
484
- }, [workflowDefinitions,nodes,edges]);
485
-
486
- const onEdgesChangeN = useCallback((edgeChanges: EdgeChange[]) => {
487
-
488
- console.dir(edgeChanges);
489
- onEdgesChange(edgeChanges);
490
- syncNodesAndEdgesToWorkflowDef();
491
- // setEditState("Unsaved");
492
- }, [workflowDefinitions,nodes,edges]);
493
-
494
- return (
495
- <div style={{ height: '85vh', width: '97vw' }}>
496
- <Box>
497
- <FormControl sx={{ width: 300, marginBottom: 2 }}>
498
- <InputLabel id="workflowSelectorLabel">Selector</InputLabel>
499
- <Select
500
- labelId="workflowSelectorLabel"
501
- id="workflowSelector"
502
- value={selectedWorkflow}
503
- size='small'
504
- label="Query template"
505
- onChange={handleWorkflowSelectorChange}
506
- >
507
- {
508
- listOfWorkflows && listOfWorkflows.map((item, i) => (
509
- <MenuItem value={item} key={item}>{item} </MenuItem>
510
- ))
511
- }
512
- </Select>
513
- </FormControl>
514
- <WorkflowMetadataDialog open = {workflowMetadataDialogOpen} onClose={handleCreateWorkflow}/>
515
- <WorkflowDeleteDialog name={selectedWorkflow} onDelete = {()=> loadListOfWorkflows()}/>
516
-
517
- </Box>
518
- { editState && (<Typography color={"red"} variant="overline"> {editState} </Typography> ) }
519
- { errorText && (<Typography color={"red"} variant="caption"> Error messages : {errorText} </Typography> ) }
520
- { loading &&( <LinearProgress />) }
521
- {(viewType == "system" || viewType == "steps") && (
522
- <Stack direction="row" spacing={1} justifyContent="left"
523
- alignItems="left">
524
- <Item>
525
- <OverviewComponentEditorDialog open={openOverviewComponentEditorDialog} component={selectedComponent} onClose={solutionComponentEditorDialogHandler} />
526
- <StepEditorDialog open={dialogOpen} step={selectedStep} workflowName={selectedWorkflow} stepRegistry={stepRegistry} workflowDefinitions={workflowDefinitions} onClose={handleDialogClose} />
527
-
528
- <div style={{ height: '75vh', width: '70vw' }}>
529
- <ReactFlow
530
- nodes={nodes}
531
- edges={edges}
532
- onNodeClick={onNodeClick}
533
- onNodesChange={onNodesChangeN}
534
- onEdgesChange={onEdgesChangeN}
535
- onEdgeUpdate={onEdgeUpdate}
536
- onEdgeUpdateStart={onEdgeUpdateStart}
537
- onEdgeUpdateEnd={onEdgeUpdateEnd}
538
- onConnect={onConnect}
539
- >
540
- <MiniMap />
541
- <Controls />
542
- <Background />
543
- <Panel position="bottom-center">
544
- {viewType == "system" && (<Button variant="outlined" onClick={onAddStep}>Add solution component</Button>)}
545
- {viewType == "steps" && (<Button variant="outlined" onClick={onAddStep}>Add workflow step</Button>)}
546
- </Panel>
547
- </ReactFlow>
548
-
549
- <Button variant="outlined" onClick={ () => {saveWorkflow(); startWorkflow()} } sx={{ marginTop: 2, marginRight: 1 }}>Start workflow</Button>
550
- <Button variant="outlined" onClick={saveWorkflow} sx={{ marginTop: 2, marginRight: 1 }}>Save workflow</Button>
551
- <Button variant="outlined" onClick={reloadWorkflows} sx={{ marginTop: 2, marginRight: 1 }} >Reload</Button>
552
- <WorkflowImportExportDialog onDownloaded = {()=> reloadWorkflows()} />
553
-
554
- </div>
555
-
556
- </Item>
557
- <Item >
558
- <WorkflowExecutionReport report={workflowStats} />
559
- </Item>
560
- </Stack>
561
- )}
562
- {viewType == "configurations" && (
563
- <ConfigView></ConfigView>
564
- )}
565
-
566
- </div>
567
-
568
-
569
- );
570
- }
@@ -1,27 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "display": "Create React App",
4
-
5
-
6
- "compilerOptions": {
7
- "lib": ["dom", "dom.iterable", "esnext"],
8
- "module": "esnext",
9
- "target": "es2015",
10
-
11
- "baseUrl": "src",
12
- "allowJs": true,
13
- "allowSyntheticDefaultImports": true,
14
- "esModuleInterop": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "isolatedModules": true,
17
- "jsx": "react-jsx",
18
- "moduleResolution": "node",
19
- "noEmit": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "resolveJsonModule": true,
22
- "skipLibCheck": true,
23
- "strict": false
24
- },
25
- "include": ["src"]
26
-
27
- }
@@ -1,17 +0,0 @@
1
- from cognite.neat._workflows.base import BaseWorkflow
2
- from cognite.neat._workflows.manager import WorkflowManager
3
- from cognite.neat._workflows.model import (
4
- FlowMessage,
5
- WorkflowFullStateReport,
6
- WorkflowStepDefinition,
7
- WorkflowStepEvent,
8
- )
9
-
10
- __all__ = [
11
- "BaseWorkflow",
12
- "FlowMessage",
13
- "WorkflowFullStateReport",
14
- "WorkflowManager",
15
- "WorkflowStepDefinition",
16
- "WorkflowStepEvent",
17
- ]