Skip to content
Snippets Groups Projects
Commit 05061838 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Merge branch 'iss1011' into 'master'

Iss1011

See merge request fiji/haas-java-client!6
parents d31318e2 dcf0b859
No related branches found
No related tags found
1 merge request!6Iss1011
...@@ -14,6 +14,8 @@ import java.util.ArrayList; ...@@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -65,8 +67,8 @@ public class BenchmarkJobManager { ...@@ -65,8 +67,8 @@ public class BenchmarkJobManager {
} }
@Override @Override
public boolean fileExists(Path filePath) { public boolean fileExists(String filePath) {
File f = new File(filePath.toString()); File f = new File(job.getDirectory().resolve(filePath).toString());
return f.exists() && !f.isDirectory(); return f.exists() && !f.isDirectory();
} }
}; };
...@@ -189,6 +191,10 @@ public class BenchmarkJobManager { ...@@ -189,6 +191,10 @@ public class BenchmarkJobManager {
break; break;
} }
scanner.close(); scanner.close();
// Order tasks chronologically
List<String> chronologicList = Constants.STATISTICS_TASK_NAME_MAP.keySet().stream().collect(Collectors.toList());
Collections.sort(tasks, Comparator.comparingInt(task -> chronologicList.indexOf(task.getDescription())));
} }
private void setDownloaded(boolean b) { private void setDownloaded(boolean b) {
......
package cz.it4i.fiji.haas_spim_benchmark.core; package cz.it4i.fiji.haas_spim_benchmark.core;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
public interface Constants { public interface Constants {
...@@ -22,7 +22,7 @@ public interface Constants { ...@@ -22,7 +22,7 @@ public interface Constants {
String STATISTICS_RESOURCES_WALL_TIME = "resources_used.walltime"; String STATISTICS_RESOURCES_WALL_TIME = "resources_used.walltime";
String STATISTICS_RESOURCES_CPU_PERCENTAGE = "resources_used.cpupercent"; String STATISTICS_RESOURCES_CPU_PERCENTAGE = "resources_used.cpupercent";
Map<String, String> STATISTICS_TASK_NAME_MAP = new HashMap<String, String>() { Map<String, String> STATISTICS_TASK_NAME_MAP = new LinkedHashMap<String, String>() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
{ {
put("define_xml_tif", "Define dataset"); put("define_xml_tif", "Define dataset");
...@@ -36,6 +36,7 @@ public interface Constants { ...@@ -36,6 +36,7 @@ public interface Constants {
put("define_output", "Define output"); put("define_output", "Define output");
put("hdf5_xml_output", "Define hdf5 output"); put("hdf5_xml_output", "Define hdf5 output");
put("resave_hdf5_output", "Resave output to hdf5"); put("resave_hdf5_output", "Resave output to hdf5");
put("done", "Done");
}}; }};
String STATISTICS_SUMMARY_FILENAME = "summary.csv"; String STATISTICS_SUMMARY_FILENAME = "summary.csv";
} }
...@@ -5,5 +5,5 @@ import java.nio.file.Path; ...@@ -5,5 +5,5 @@ import java.nio.file.Path;
import cz.it4i.fiji.haas.HaaSOutputHolder; import cz.it4i.fiji.haas.HaaSOutputHolder;
public interface SPIMComputationAccessor extends HaaSOutputHolder { public interface SPIMComputationAccessor extends HaaSOutputHolder {
boolean fileExists(Path fileName); boolean fileExists(String fileName);
} }
...@@ -24,6 +24,7 @@ public class TaskComputation { ...@@ -24,6 +24,7 @@ public class TaskComputation {
} }
} }
private final SPIMComputationAccessor computationAccessor;
private final Task task; private final Task task;
private final int timepoint; private final int timepoint;
private final Collection<String> inputs; private final Collection<String> inputs;
...@@ -34,14 +35,16 @@ public class TaskComputation { ...@@ -34,14 +35,16 @@ public class TaskComputation {
//TASK 1011 what states will be defined and how it will be defined //TASK 1011 what states will be defined and how it will be defined
private JobState state = JobState.Unknown; private JobState state = JobState.Unknown;
public TaskComputation(SPIMComputationAccessor outputHolder, Task task, int timepoint) { public TaskComputation(SPIMComputationAccessor computationAccessor, Task task, int timepoint) {
this.computationAccessor = computationAccessor;
this.task = task; this.task = task;
this.timepoint = timepoint; this.timepoint = timepoint;
ParsedTaskComputationValues parsedValues = parseStuff(outputHolder); ParsedTaskComputationValues parsedValues = parseStuff(computationAccessor);
this.inputs = parsedValues.inputs; this.inputs = parsedValues.inputs;
this.outputs = parsedValues.outputs; this.outputs = parsedValues.outputs;
this.logs = parsedValues.logs; this.logs = parsedValues.logs;
this.id = parsedValues.id; this.id = parsedValues.id;
updateState();
} }
public JobState getState() { public JobState getState() {
...@@ -59,14 +62,39 @@ public class TaskComputation { ...@@ -59,14 +62,39 @@ public class TaskComputation {
private void updateState() { private void updateState() {
//TASK 1011 This should never happen, add some error handling to resolveId() //TASK 1011 This should never happen, add some error handling to resolveId()
if (id == null) { if (id == null) {
state = JobState.Unknown;
return; return;
} }
//String snakeOutput = outputHolder.getActualOutput(); state = JobState.Queued;
//TASK 1011 // Check whether a log file exists
//resolve if job is queued (defined id), started (exists log file), finished (in log is Finished job 10.) or if (!logs.stream().anyMatch(logFile -> computationAccessor.fileExists(logFile))) {
//or failed (some error in log) return;
}
state = JobState.Running;
// Check whether the corresponding job has finished
final String OUTPUT_PARSING_FINISHED_JOB = "Finished job ";
final String desiredPatternFinishedJob = OUTPUT_PARSING_FINISHED_JOB + id.toString();
final String OUTPUT_PARSING_ERRONEOUS_JOB = "Error job ";
final String desiredPatternErroneousJob = OUTPUT_PARSING_ERRONEOUS_JOB + id.toString();
String currentLine;
Scanner scanner = new Scanner(computationAccessor.getActualOutput());
while (scanner.hasNextLine()) {
currentLine = scanner.nextLine();
if (currentLine.contains(desiredPatternErroneousJob)) {
state = JobState.Failed;
break;
} else if (currentLine.contains(desiredPatternFinishedJob)) {
state = JobState.Finished;
break;
}
}
scanner.close();
return;
} }
private Long getId() { private Long getId() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment