Skip to content

Commit 1c7f3b3

Browse files
committed
Handle internal error for wf execution
1 parent 975fe76 commit 1c7f3b3

File tree

6 files changed

+42
-24
lines changed

6 files changed

+42
-24
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ metadata and outputs for posterior analysis.
1313

1414
Full documentation is available at [https://disk.readthedocs.io](https://disk.readthedocs.io)
1515

16+
17+
## Installation
18+
19+
Please read the installation guide available at [readthedocs.io](https://disk.readthedocs.io/en/stable/admin-guide/installation/)
20+
1621
## Related repositories
1722

1823
- [DISK User Interface](https://github.com/KnowledgeCaptureAndDiscovery/DISK-UI)

server/src/main/java/org/diskproject/server/db/DiskDB.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,13 @@ public boolean deleteGoal(String id) {
459459
return false;
460460

461461
String goalId = createGoalURI(id);
462-
KBAPI hypKB = getKB(goalId);
462+
KBAPI goalKB = getKB(goalId);
463463

464-
if (domainKB != null && hypKB != null) {
464+
if (domainKB != null && goalKB != null) {
465465
this.rdf.startRead();
466-
KBObject hypitem = domainKB.getIndividual(goalId);
467-
if (hypitem != null) {
468-
ArrayList<KBObject> questionBindings = domainKB.getPropertyValues(hypitem,
466+
KBObject goalItem = domainKB.getIndividual(goalId);
467+
if (goalItem != null) {
468+
ArrayList<KBObject> questionBindings = domainKB.getPropertyValues(goalItem,
469469
DISKOnt.getProperty(DISK.HAS_QUESTION_BINDINGS));
470470
this.rdf.end();
471471
// Remove question template bindings
@@ -474,14 +474,14 @@ public boolean deleteGoal(String id) {
474474
for (KBObject binding : questionBindings) {
475475
domainKB.deleteObject(binding, true, true);
476476
}
477-
domainKB.deleteObject(hypitem, true, true);
477+
domainKB.deleteObject(goalItem, true, false);
478478
this.rdf.save(domainKB);
479479
this.rdf.end();
480480
} else {
481481
this.rdf.end();
482482
}
483483

484-
return this.rdf.startWrite() && hypKB.delete() && this.rdf.save(hypKB) && this.rdf.end();
484+
return this.rdf.startWrite() && goalKB.delete() && this.rdf.save(goalKB) && this.rdf.end();
485485
}
486486
return false;
487487
}
@@ -691,7 +691,7 @@ public boolean deleteLOI(String id) {
691691
this.rdf.startWrite();
692692
KBObject hypitem = domainKB.getIndividual(loiId);
693693
if (hypitem != null)
694-
domainKB.deleteObject(hypitem, true, true);
694+
domainKB.deleteObject(hypitem, true, false);
695695
//TODO: remove query object too.
696696

697697
return this.rdf.save(domainKB) && this.rdf.end();
@@ -1169,7 +1169,7 @@ public boolean deleteTLOI(String id) {
11691169
this.rdf.end();
11701170
if (item != null) {
11711171
this.rdf.startWrite();
1172-
domainKB.deleteObject(item, true, true);
1172+
domainKB.deleteObject(item, true, false);
11731173
return this.rdf.save(domainKB) && this.rdf.end();
11741174
} else {
11751175
return false;

server/src/main/java/org/diskproject/server/quering/Match.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public Match (Goal goal, LineOfInquiry loi, Question question, DataAdapter dataS
5252
return;
5353
}
5454

55-
this.valid = this.analyseWorkflows();
55+
this.valid = this.analyzeWorkflows();
5656
}
5757

58-
private boolean analyseWorkflows () {
58+
private boolean analyzeWorkflows () {
5959
boolean isCSV = false;
6060
List<WorkflowSeed> allSeeds = Stream.concat(loi.getWorkflowSeeds().stream(), loi.getMetaWorkflowSeeds().stream()).collect(Collectors.toList());
6161
Set<String> reqVariables = new HashSet<String>(), arrayVars = new HashSet<String>(), selectVars = new HashSet<String>();
@@ -143,21 +143,31 @@ public String createQueryTemplate () {
143143
String varName = questionVariables.get(varURI);
144144
if (varNames.contains(varName)) {
145145
boolean writtenVarName = false;
146-
for (String value: vb.getBinding()) {
146+
List<String> allValues = vb.getBinding();
147+
for (String value: allValues) {
147148
if (value != null && !value.equals("")) {
148149
String datatype = vb.getDatatype();
149150
if (!writtenVarName) {
150-
query += "\nVALUES " + varName + " {\n";
151+
query += "\n VALUES " + varName + " {";
152+
if (allValues.size() > 1) {
153+
query += "\n";
154+
}
151155
writtenVarName = true;
152156
}
153157
if (datatype != null && datatype.endsWith("anyURI")) {
154-
query += " <" + value + ">\n";
158+
query += " <" + value + ">";
155159
} else {
156-
query += " \"" + value + "\"\n";
160+
query += " \"" + value + "\"";
161+
}
162+
if (allValues.size() > 1) {
163+
query += "\n";
157164
}
158165
}
159166
}
160167
if (writtenVarName) {
168+
if (allValues.size() > 1) {
169+
query += " ";
170+
}
161171
query += "}";
162172
}
163173
}
@@ -245,12 +255,12 @@ private List<WorkflowInstantiation> createWorkflowInstance (WorkflowSeed seed) {
245255
int count = 0, splitSize = filteredResults.size()/runs;
246256
for (DataResult cell: filteredResults) {
247257
count += 1;
258+
lastList.add(cell);
248259
if (count >= splitSize) {
249260
count = 0;
250261
independentResults.add(lastList);
251262
lastList = new ArrayList<DataResult>();
252263
}
253-
lastList.add(cell);
254264
}
255265

256266
List<WorkflowInstantiation> inst = new ArrayList<WorkflowInstantiation>();
@@ -260,7 +270,7 @@ private List<WorkflowInstantiation> createWorkflowInstance (WorkflowSeed seed) {
260270
for (VariableBinding varB: Stream.concat(seed.getInputs().stream(), seed.getParameters().stream()).collect(Collectors.toList())) {
261271
// These only have one value
262272
String wfBiding = varB.getBinding().get(0);
263-
VariableBinding newDatabinding = new VariableBinding(varB);
273+
VariableBinding newDataBinding = new VariableBinding(varB);
264274
List<String> newBindingValues = new ArrayList<String>();
265275
if (wfBiding.equals(SPECIAL.CSV)) {
266276
newBindingValues.add(csvURL);
@@ -283,8 +293,8 @@ private List<WorkflowInstantiation> createWorkflowInstance (WorkflowSeed seed) {
283293
}
284294
}
285295
if (newBindingValues.size() > 0) {
286-
newDatabinding.setBinding(newBindingValues);
287-
dataBindings.add(newDatabinding);
296+
newDataBinding.setBinding(newBindingValues);
297+
dataBindings.add(newDataBinding);
288298
}
289299
}
290300
current.setDataBindings(dataBindings);

server/src/main/java/org/diskproject/server/repository/DiskRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ public Map<LineOfInquiry, List<Map<String, String>>> getLOIByHypothesisId(String
403403
if (allSolutions != null) {
404404
if (allSolutions.size() == 0) {
405405
System.out.println("No solutions for " + loi.getId());
406+
//System.out.println(errorMesString);
406407
//String errorMesString = "No solutions found for the query: \n" + query;
407408
//System.out.println(errorMesString);
408409
// throw new NotFoundException(errorMesString);

server/src/main/java/org/diskproject/server/threads/MonitorThread.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private void updateRun (WorkflowInstantiation wf, Execution run) {
9090

9191
@Override
9292
public void run() {
93-
System.out.println("[M] Running monitoring thread");
93+
//System.out.println("[M] Running monitoring thread");
9494
Execution pendingRun = this.getNextPendingRun();
9595
if (pendingRun == null || pendingRun.getExternalId() == null) {
9696
System.out.println("[M] No more pending runs.");
@@ -106,10 +106,13 @@ public void run() {
106106
Execution updatedRun = methodAdapter.getRunStatus(runId);
107107

108108
// If we cannot get the status but the run was pending, it means that the run is in the WINGS queue.
109-
if (updatedRun == null || updatedRun.getStatus() == null) {
109+
if (updatedRun == null || updatedRun.getStatus() == null || updatedRun.getStatus() == Status.INTERNAL_ERROR) {
110110
System.out.println("[E] Cannot get status for " + tloi.getId() + " - RUN " + runId);
111111
if (pendingRun.getStatus() == Status.PENDING) { // In queue
112112
updatedRun = pendingRun;
113+
} else if (updatedRun != null && updatedRun.getStatus() == Status.INTERNAL_ERROR) {
114+
updatedRun.setStatus(Status.FAILED);
115+
System.out.println("[E] Internal error for run: " + runId);
113116
} else {
114117
System.out.println("[E] This should not happen");
115118
return;
@@ -122,15 +125,15 @@ public void run() {
122125
this.tloi.setStatus(status);
123126
manager.updateTLOI(tloi);
124127

125-
if (status == Status.SUCCESSFUL || status == Status.FAILED) {
128+
if (status == Status.SUCCESSFUL || status == Status.FAILED || status == Status.INTERNAL_ERROR) {
126129
if (status == Status.SUCCESSFUL) {
127130
if (metamode) {
128131
System.out.println("[M] " + this.tloi.getId() + " was successfully executed.");
129132
} else {
130133
System.out.println("[M] Starting metamode after " + this.runList.size() + " runs.");
131134
this.manager.executeTLOI(tloi, true);
132135
}
133-
} else if (status == Status.FAILED) {
136+
} else if (status == Status.FAILED || status == Status.INTERNAL_ERROR) {
134137
if (metamode) {
135138
System.out.println("[M] " + this.tloi.getId() + " was executed with errors.");
136139
} else {

shared/src/main/java/org/diskproject/shared/classes/adapters/MethodAdapter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.diskproject.shared.classes.workflow.Execution;
99
import org.diskproject.shared.classes.workflow.VariableBinding;
1010
import org.diskproject.shared.classes.workflow.WorkflowTemplate;
11-
import org.diskproject.shared.classes.workflow.WorkflowRun;
1211

1312
public abstract class MethodAdapter {
1413
private String name;

0 commit comments

Comments
 (0)