diff --git a/vcell-cli/src/main/java/org/vcell/cli/CLIRecordable.java b/vcell-cli/src/main/java/org/vcell/cli/CLIRecordable.java index 8ce8ab141b..b1a0007f3e 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/CLIRecordable.java +++ b/vcell-cli/src/main/java/org/vcell/cli/CLIRecordable.java @@ -5,16 +5,18 @@ public interface CLIRecordable { - public void writeDetailedErrorList(String message) throws IOException; + void writeDetailedErrorList(String message) throws IOException; - public void writeFullSuccessList(String message) throws IOException; + void writeFullSuccessList(String message) throws IOException; - public void writeErrorList(String message) throws IOException; + void writeErrorList(String message) throws IOException; - public void writeDetailedResultList(String message) throws IOException; + void writeDetailedResultList(String message) throws IOException; + + void writeDetailedSimBreakdown(String message) throws IOException; // we make a list with the omex files that contain (some) spatial simulations (FVSolverStandalone solver) - public void writeSpatialList(String message) throws IOException; + void writeSpatialList(String message) throws IOException; - public void writeImportErrorList(String message) throws IOException; + void writeImportErrorList(String message) throws IOException; } diff --git a/vcell-cli/src/main/java/org/vcell/cli/CLIRecorder.java b/vcell-cli/src/main/java/org/vcell/cli/CLIRecorder.java index e09bcbb686..bb7044dec6 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/CLIRecorder.java +++ b/vcell-cli/src/main/java/org/vcell/cli/CLIRecorder.java @@ -17,7 +17,7 @@ public class CLIRecorder extends Recorder implements CLIRecordable { protected final static boolean DEFAULT_SHOULD_PRINT_LOG_FILES = false, DEFAULT_SHOULD_FLUSH_LOG_FILES = false; protected boolean shouldPrintLogFiles, shouldFlushLogFiles; - protected TextFileRecord detailedErrorLog, fullSuccessLog, errorLog, detailedResultsLog, spatialLog, importErrorLog; + protected TextFileRecord detailedErrorLog, fullSuccessLog, errorLog, detailedResultsLog, detailedSimBreakdown, spatialLog, importErrorLog; protected File outputDirectory; // Note: this constructor is not public @@ -86,6 +86,7 @@ public CLIRecorder(File outputDirectory, boolean forceLogFiles, boolean shouldFl this.fullSuccessLog = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "fullSuccessLog.txt").toString()); this.errorLog = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "errorLog.txt").toString()); this.detailedResultsLog = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "detailedResultLog.txt").toString()); + this.detailedSimBreakdown = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "detailedSimBreakdown.txt").toString()); this.spatialLog = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "hasSpatialLog.txt").toString()); this.importErrorLog = logManager.requestNewRecord(Paths.get(this.outputDirectory.getAbsolutePath(), "importErrorLog.txt").toString()); @@ -152,6 +153,15 @@ public void writeDetailedResultList(String message) throws IOException { this.writeToFileLog(this.detailedResultsLog, message); } + /** + * Write to `detailedSimBreakdown.txt` + * + * @param message string to write to file + */ + public void writeDetailedSimBreakdown(String message) throws IOException { + this.writeToFileLog(this.detailedSimBreakdown, message); + } + /** * Write to `hasSpatialLog.txt` diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteCommand.java b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteCommand.java index ec3f4bae8c..f65d5f846f 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteCommand.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteCommand.java @@ -16,7 +16,7 @@ import java.util.concurrent.Callable; import java.util.Date; -@Command(name = "execute", description = "run .vcml or .omex files via Python API") +@Command(name = "execute", description = "run .vcml or .omex files") public class ExecuteCommand implements Callable { private final static Logger logger = org.apache.logging.log4j.LogManager.getLogger(ExecuteCommand.class); @@ -100,7 +100,7 @@ public Integer call() { bKeepTempFiles, bExactMatchOnly, bEncapsulateOutput, EXECUTABLE_MAX_WALLCLOCK_MILLIS, help, bDebug, bQuiet ); - logger.trace(trace_args); + logger.debug(trace_args); logger.debug("Validating CLI arguments"); if (bDebug && bQuiet) { diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java index 81110f5bc2..7bed318c2a 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/ExecuteImpl.java @@ -44,7 +44,7 @@ public static void batchMode(File dirOfArchivesToProcess, File outputDir, CLIRec logger.info("Preparing output directory..."); // we don't want to accidentally delete the input... - // if the output is a subset of the input file's housing directory, we shouldn't delete!! + // if the output directory is a subset of the input file's housing directory, we shouldn't delete!! if (!inputFile.getParentFile().getCanonicalPath().contains(adjustedOutputDir.getCanonicalPath())) RunUtils.removeAndMakeDirs(adjustedOutputDir); try { diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/RunResults.java b/vcell-cli/src/main/java/org/vcell/cli/run/RunResults.java new file mode 100644 index 0000000000..a448c7f8c4 --- /dev/null +++ b/vcell-cli/src/main/java/org/vcell/cli/run/RunResults.java @@ -0,0 +1,67 @@ +package org.vcell.cli.run; + +import cbit.vcell.biomodel.BioModel; +import cbit.vcell.solver.TempSimulation; +import org.vcell.util.Pair; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class RunResults { + private final Map> bioModelToListOfTemp; + private final Map> tempSimulationToStatus; + + public RunResults() { + this.bioModelToListOfTemp = new HashMap<>(); + this.tempSimulationToStatus = new HashMap<>(); + } + + public List getTempSimulations(BioModel bioModel) { + return this.bioModelToListOfTemp.get(bioModel); + } + + public Pair getStatus(BioModel bioModel, TempSimulation tempSimulation) { + return this.bioModelToListOfTemp.containsKey(bioModel) ? null : tempSimulationToStatus.get(tempSimulation); + } + + public void setStatus(BioModel bioModel, TempSimulation tempSimulation, Integer duration) { + this.setStatus(bioModel, tempSimulation, null, duration); + } + + public void setStatus(BioModel bioModel, TempSimulation tempSimulation, Status status) { + this.setStatus(bioModel, tempSimulation, status, null); + } + + public void setStatus(BioModel bioModel, TempSimulation tempSimulation, Status status, Integer duration){ + if (!this.bioModelToListOfTemp.containsKey(bioModel)) this.bioModelToListOfTemp.put(bioModel, new ArrayList<>()); + List relevantSims = this.bioModelToListOfTemp.get(bioModel); + if (!relevantSims.contains(tempSimulation)) this.bioModelToListOfTemp.get(bioModel).add(tempSimulation); + if (!this.tempSimulationToStatus.containsKey(tempSimulation)) { + this.tempSimulationToStatus.put(tempSimulation, new Pair<>(status, duration)); + } + Pair previousStatuses = this.tempSimulationToStatus.get(tempSimulation); + if (status != null){ + this.tempSimulationToStatus.put(tempSimulation, new Pair<>(status, previousStatuses.two)); + previousStatuses = this.tempSimulationToStatus.get(tempSimulation); + } + + if (duration != null){ + this.tempSimulationToStatus.put(tempSimulation, new Pair<>(previousStatuses.one, duration)); + } + } + + public List generateRecordsOfResults(){ + List results = new ArrayList<>(); + for (BioModel bm : this.bioModelToListOfTemp.keySet()) { + for (TempSimulation ts : this.bioModelToListOfTemp.get(bm)) { + Pair statusAndDuration = this.tempSimulationToStatus.get(ts); + results.add(new IndividualResult(bm, ts, statusAndDuration.one, statusAndDuration.two)); + } + } + return results; + } + + public record IndividualResult(BioModel bioModel, TempSimulation tempSimulation, Status status, Integer duration) {} +} diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java b/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java index e19449a306..1cffd31242 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/SedmlJob.java @@ -1,5 +1,6 @@ package org.vcell.cli.run; +import cbit.vcell.biomodel.BioModel; import cbit.vcell.resource.OperatingSystemInfo; import cbit.vcell.xml.ExternalDocInfo; import org.apache.commons.io.FilenameUtils; @@ -228,7 +229,6 @@ public boolean simulateSedml(HDF5ExecutionResults masterHdf5File) throws Interru ExternalDocInfo externalDocInfo = new ExternalDocInfo(this.MASTER_OMEX_ARCHIVE, true); this.runSimulations(solverHandler, externalDocInfo); - this.recordRunDetails(solverHandler); Span span = null; try { span = Tracer.startSpan(Span.ContextType.PROCESSING_SIMULATION_OUTPUTS, "processOutputs", null); @@ -244,7 +244,7 @@ public boolean simulateSedml(HDF5ExecutionResults masterHdf5File) throws Interru return this.evaluateResults(); } - private void runSimulations(SolverHandler solverHandler, ExternalDocInfo externalDocInfo) throws IOException { + private void runSimulations(SolverHandler solverHandler, ExternalDocInfo externalDocInfo) { /* * - Run solvers and make reports; all failures/exceptions are being caught * - we send both the whole OMEX file and the extracted SEDML file path @@ -256,10 +256,11 @@ private void runSimulations(SolverHandler solverHandler, ExternalDocInfo externa String str = "Building solvers and starting simulation of all tasks... "; logger.info(str); this.logDocumentMessage += str; - solverHandler.simulateAllTasks(externalDocInfo, this.sedml, this.CLI_RECORDER, + RunResults results = solverHandler.simulateAllTasks(externalDocInfo, this.sedml, this.CLI_RECORDER, this.OUTPUT_DIRECTORY_FOR_CURRENT_SEDML, this.RESULTS_DIRECTORY_PATH, this.ROOT_OUTPUT_DIR.getAbsolutePath(), this.SEDML_LOCATION, this.SHOULD_KEEP_TEMP_FILES, this.ACCEPT_EXACT_MATCH_ONLY, this.SHOULD_OVERRIDE_FOR_SMALL_MESH); + this.recordRunDetails(solverHandler, results); } catch (Exception e) { Throwable currentTierOfException = e; StringBuilder errorMessage = new StringBuilder(); @@ -277,8 +278,6 @@ private void runSimulations(SolverHandler solverHandler, ExternalDocInfo externa span.close(); } } - - this.recordRunDetails(solverHandler); } private void processOutputs(SolverHandler solverHandler, HDF5ExecutionResults masterHdf5File) throws InterruptedException, ExecutionException, PythonStreamException { @@ -466,17 +465,27 @@ private void reportProblem(Exception e) throws PythonStreamException, Interrupte PythonCalls.updateSedmlDocStatusYml(this.SEDML_LOCATION, Status.FAILED, this.RESULTS_DIRECTORY_PATH); } - private void recordRunDetails(SolverHandler solverHandler) throws IOException { - String message = this.DOC_STATISTICS.getNumModels() + ","; - message += this.DOC_STATISTICS.getNumSimulations() + ","; - message += this.DOC_STATISTICS.getNumTasks() + ","; - message += this.DOC_STATISTICS.getNumOutputs() + ","; + private void recordRunDetails(SolverHandler solverHandler, RunResults results) throws IOException { + StringBuilder generalMessage = new StringBuilder(this.BIOMODEL_BASE_NAME + ","); + generalMessage.append(this.DOC_STATISTICS.getNumModels()).append(","); + generalMessage.append(this.DOC_STATISTICS.getNumSimulations()).append(","); + generalMessage.append(this.DOC_STATISTICS.getNumTasks()).append(","); + generalMessage.append(this.DOC_STATISTICS.getNumOutputs()).append(","); - message += solverHandler.countBioModels + ","; - message += this.hasOverrides + ","; - message += this.hasScans + ","; - message += solverHandler.countSuccessfulSimulationRuns; - this.CLI_RECORDER.writeDetailedResultList(this.BIOMODEL_BASE_NAME + "," + message); - logger.debug(message); + generalMessage.append(solverHandler.countBioModels).append(","); + generalMessage.append(this.hasOverrides).append(","); + generalMessage.append(this.hasScans).append(","); + generalMessage.append(solverHandler.countSuccessfulSimulationRuns); + this.CLI_RECORDER.writeDetailedResultList(generalMessage.toString()); + + for (RunResults.IndividualResult result : results.generateRecordsOfResults()){ + String individualMessage = result.bioModel() + "," + + result.tempSimulation() + "," + + result.duration() + "," + + result.status() + ","; + this.CLI_RECORDER.writeDetailedSimBreakdown(individualMessage); + } + + logger.debug(generalMessage.toString()); } } diff --git a/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java b/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java index 5f3485beb3..247aafdfa0 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java +++ b/vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java @@ -53,8 +53,8 @@ import org.apache.logging.log4j.Logger; import java.io.*; +import java.nio.file.FileSystems; import java.util.*; -import java.util.stream.Collectors; public class SolverHandler { @@ -65,16 +65,16 @@ public class SolverHandler { private SEDMLImporter sedmlImporter; Map nonSpatialResults = new LinkedHashMap<>(); - Map spatialResults = new LinkedHashMap(); + Map spatialResults = new LinkedHashMap<>(); Map tempSimulationToTaskMap = new LinkedHashMap<> (); // key = vcell simulation, value = sedml topmost task (the imported task id) Map taskToTempSimulationMap = new LinkedHashMap<> (); // the opposite Map origSimulationToTempSimulationMap = new LinkedHashMap<> (); // the opposite - Map> taskToListOfSubTasksMap = new LinkedHashMap> (); // key = topmost AbstractTask, value = recursive list of subtasks - Map> taskToVariableMap = new LinkedHashMap> (); // key = AbstractTask, value = list of variables calculated by this task - Map> taskToChangeTargetMap = new LinkedHashMap> (); // key = RepeatedTask, value = list of the parameters that are being changed - Map> taskToChildRepeatedTasks = new LinkedHashMap> (); // key = Task, value = list of RepeatedTasks ending with this task - Map topTaskToBaseTask = new LinkedHashMap (); // key = TopmostTaskId, value = Tasks at the bottom of the SubTasks chain OR the topmost task itself if instanceof Task + Map> taskToListOfSubTasksMap = new LinkedHashMap<> (); // key = topmost AbstractTask, value = recursive list of subtasks + Map> taskToVariableMap = new LinkedHashMap<> (); // key = AbstractTask, value = list of variables calculated by this task + Map> taskToChangeTargetMap = new LinkedHashMap<> (); // key = RepeatedTask, value = list of the parameters that are being changed + Map> taskToChildRepeatedTasks = new LinkedHashMap<> (); // key = Task, value = list of RepeatedTasks ending with this task + Map topTaskToBaseTask = new LinkedHashMap<> (); // key = TopmostTaskId, value = Tasks at the bottom of the SubTasks chain OR the topmost task itself if instanceof Task private static void sanityCheck(VCDocument doc) { if (doc == null) { @@ -84,10 +84,9 @@ private static void sanityCheck(VCDocument doc) { if (docName == null || docName.isEmpty()) { throw new RuntimeException("The name of the imported VCDocument is null or empty."); } - if (!(doc instanceof BioModel)) { + if (!(doc instanceof BioModel bioModel)) { throw new RuntimeException("The imported VCDocument '" + docName + "' is not a BioModel."); } - BioModel bioModel = (BioModel) doc; if (bioModel.getSimulationContext(0) == null) { throw new RuntimeException("The imported VCDocument '" + docName + "' has no Application"); } @@ -119,9 +118,8 @@ public void initialize(List bioModelList, SedML sedml) throws Expressi // we first make a list of all the sub tasks (sub tasks themselves may be instanceof Task or another RepeatedTask) Set subTasks = new LinkedHashSet<> (); for(AbstractTask at : sedml.getTasks()) { - if(!(at instanceof RepeatedTask)) continue; - RepeatedTask rt = (RepeatedTask)at; - Map subTasksOfRepeatedTask = rt.getSubTasks(); + if(!(at instanceof RepeatedTask rt)) continue; + Map subTasksOfRepeatedTask = rt.getSubTasks(); for (Map.Entry entry : subTasksOfRepeatedTask.entrySet()) { String subTaskId = entry.getKey(); AbstractTask subTask = sedml.getTaskWithId(subTaskId); @@ -312,7 +310,7 @@ public TempSimulation getTempSimulation() { } } - public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecordable cliLogger, + public RunResults simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRecordable cliLogger, File outputDirForSedml, String outDir, String outputBaseDir, String sedmlLocation, boolean keepTempFiles, boolean exactMatchOnly, boolean bSmallMeshOverride ) throws Exception { @@ -321,28 +319,28 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe String inputFile = externalDocInfo.getFile().getAbsolutePath(); String bioModelBaseName = org.vcell.util.FileUtils.getBaseName(inputFile); - List bioModelList = null; - String docName = null; - List tempSims = null; + List bioModelList; + String docName; + List tempSims; //String outDirRoot = outputDirForSedml.toString().substring(0, outputDirForSedml.toString().lastIndexOf(System.getProperty("file.separator"))); this.sedmlImporter = new SEDMLImporter(sedmlImportLogger, externalDocInfo, sedml, exactMatchOnly); try { bioModelList = this.sedmlImporter.getBioModels(); + if (bioModelList == null) throw new RuntimeException("Somehow, bioModelList is null!"); } catch (Exception e) { logger.error("Unable to Parse SED-ML into Bio-Model, failed with err: " + e.getMessage(), e); throw e; } - if(bioModelList != null) { - countBioModels = bioModelList.size(); - } - + this.countBioModels = bioModelList.size(); + this.initialize(bioModelList, sedml); int simulationJobCount = 0; int bioModelCount = 0; boolean hasSomeSpatial = false; boolean bTimeoutFound = false; - + + RunResults results = new RunResults(); for (BioModel bioModel : bioModelList) { Span biomodel_span = null; try { @@ -355,10 +353,8 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe // continue; } docName = bioModel.getName(); - tempSims = Arrays.stream(bioModel.getSimulations()).map(s -> origSimulationToTempSimulationMap.get(s)).collect(Collectors.toList()); + tempSims = Arrays.stream(bioModel.getSimulations()).map(s -> origSimulationToTempSimulationMap.get(s)).toList(); - Map simStatusMap = new LinkedHashMap<>(); - Map simDurationMap = new LinkedHashMap<>(); List simJobsList = new ArrayList<>(); for (TempSimulation tempSimulation : tempSims) { if (tempSimulation.getImportedTaskID() == null) { @@ -366,10 +362,9 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe } AbstractTask task = tempSimulationToTaskMap.get(tempSimulation); - simStatusMap.put(tempSimulation, Status.RUNNING); + results.setStatus(bioModel, tempSimulation, Status.RUNNING, 0); PythonCalls.updateTaskStatusYml(sedmlLocation, task.getId(), Status.RUNNING, outDir, "0", tempSimulation.getSolverTaskDescription().getSolverDescription().getKisao()); - simDurationMap.put(tempSimulation, 0); if (bSmallMeshOverride && tempSimulation.getMeshSpecification() != null) { int maxSize = 11; @@ -399,7 +394,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe SimulationTask simTask; String kisao = "null"; ODESolverResultSet odeSolverResultSet = null; - SolverTaskDescription std = null; + SolverTaskDescription std; SolverDescription sd = null; int solverStatus = SolverStatus.SOLVER_READY; @@ -461,7 +456,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe List funcs = so.getOutputFunctionContext().getOutputFunctionsList(); if (funcs != null) { for (AnnotatedFunction function : funcs) { - FunctionColumnDescription fcd = null; + FunctionColumnDescription fcd; String funcName = function.getName(); Expression funcExp = function.getExpression(); fcd = new FunctionColumnDescription(funcExp, funcName, null, function.getDisplayName(), true); @@ -474,22 +469,23 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe if (solver.getSolverStatus().getStatus() == SolverStatus.SOLVER_FINISHED) { logTaskMessage += "done. "; - logger.info("Succesful execution: Model '" + docName + "' Task '" + sim.getDescription() + "'."); + logger.info("Successful execution: Model '" + docName + "' Task '" + sim.getDescription() + "'."); long endTimeTask = System.currentTimeMillis(); long elapsedTime = endTimeTask - startTimeTask; int duration = (int) Math.ceil(elapsedTime / 1000.0); TempSimulation originalSim = tempSimulationJob.getSimulation(); - int simDuration = simDurationMap.get(originalSim); + int simDuration = results.getStatus(bioModel, originalSim).two; simDuration += duration; - simDurationMap.put(originalSim, simDuration); + results.setStatus(bioModel, originalSim, simDuration); - String msg = "Running simulation " + simTask.getSimulation().getName() + ", " + elapsedTime + " ms"; + String msg = "Ran simulation: " + simTask.getSimulation().getName() + ", " + elapsedTime + " ms"; logger.info(msg); countSuccessfulSimulationRuns++; // we only count the number of simulations (tasks) that succeeded - if (simStatusMap.get(originalSim) != Status.ABORTED && simStatusMap.get(originalSim) != Status.FAILED) { - simStatusMap.put(originalSim, Status.SUCCEEDED); + + if (!List.of(Status.ABORTED, Status.FAILED).contains(results.getStatus(bioModel, originalSim).one)) { + results.setStatus(bioModel, originalSim, Status.SUCCEEDED); } PythonCalls.setOutputMessage(sedmlLocation, sim.getImportedTaskID(), outDir, "task", logTaskMessage); RunUtils.drawBreakLine("-", 100); @@ -519,9 +515,9 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe } else { TempSimulation originalSim = tempSimulationJob.getSimulation(); if (solverStatus == SolverStatus.SOLVER_ABORTED) { - simStatusMap.put(originalSim, Status.ABORTED); + results.setStatus(bioModel, originalSim, Status.ABORTED); } else { - simStatusMap.put(originalSim, Status.FAILED); + results.setStatus(bioModel, originalSim, Status.FAILED); } } // CLIUtils.finalStatusUpdate(CLIUtils.Status.FAILED, outDir); @@ -535,7 +531,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe String type = e.getClass().getSimpleName(); PythonCalls.setOutputMessage(sedmlLocation, sim.getImportedTaskID(), outDir, "task", logTaskMessage); PythonCalls.setExceptionMessage(sedmlLocation, sim.getImportedTaskID(), outDir, "task", type, logTaskError); - String sdl = ""; + String sdl; if (sd != null && sd.getShortDisplayLabel() != null && !sd.getShortDisplayLabel().isEmpty()) { sdl = sd.getShortDisplayLabel(); } else { @@ -559,7 +555,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe } if (sd.isSpatial()) { - File hdf5Results = new File(outDir + System.getProperty("file.separator") + task.getId() + "_job_" + tempSimulationJob.getJobIndex() + "_results.h5"); + File hdf5Results = new File(outDir + FileSystems.getDefault().getSeparator() + task.getId() + "_job_" + tempSimulationJob.getJobIndex() + "_results.h5"); try { RunUtils.exportPDE2HDF5(tempSimulationJob, outputDirForSedml, hdf5Results); spatialResults.put(new TaskJob(task.getId(), tempSimulationJob.getJobIndex()), hdf5Results); @@ -578,21 +574,20 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe this.nonSpatialResults.put(taskJob, nonspatialSimResults); } - if (keepTempFiles == false) { + if (!keepTempFiles) { RunUtils.removeIntermediarySimFiles(outputDirForSedml); } simulationJobCount++; } - for (Map.Entry entry : simStatusMap.entrySet()) { - TempSimulation tempSimulation = entry.getKey(); - Status status = entry.getValue(); + for (TempSimulation tempSimulation : results.getTempSimulations(bioModel)){ + Status status = results.getStatus(bioModel, tempSimulation).one; if (status == Status.RUNNING) { continue; // if this happens somehow, we just don't write anything } AbstractTask task = tempSimulationToTaskMap.get(tempSimulation); // assert task != null; - int duration = simDurationMap.get(tempSimulation); + int duration = results.getStatus(bioModel, tempSimulation).two; SolverTaskDescription std = tempSimulation.getSolverTaskDescription(); SolverDescription sd = std.getSolverDescription(); String kisao = sd.getKisao(); @@ -614,6 +609,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe if(hasSomeSpatial) { cliLogger.writeSpatialList(bioModelBaseName); } + return results; } /** @@ -669,7 +665,7 @@ public static void main(String[] args) throws Exception { BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); - String line = ""; + String line; osw.write("2+2\r\n"); // osw.write("2+2\r\nquit()\r\n"); diff --git a/vcell-cli/src/test/java/org/vcell/cli/run/BSTSBasedOmexExecTest.java b/vcell-cli/src/test/java/org/vcell/cli/run/BSTSBasedOmexExecTest.java index a02819c839..7c9a73af61 100644 --- a/vcell-cli/src/test/java/org/vcell/cli/run/BSTSBasedOmexExecTest.java +++ b/vcell-cli/src/test/java/org/vcell/cli/run/BSTSBasedOmexExecTest.java @@ -160,6 +160,10 @@ public void writeDetailedResultList(String message) { System.out.println("writeDetailedResultList(): " + message); } @Override + public void writeDetailedSimBreakdown(String message) { + System.out.println("writeDetailedSimBreakdown(): " + message); + } + @Override public void writeSpatialList(String message) { System.out.println("writeSpatialList(): " + message); } diff --git a/vcell-cli/src/test/java/org/vcell/cli/run/BiosimulationsExecTest.java b/vcell-cli/src/test/java/org/vcell/cli/run/BiosimulationsExecTest.java index 6c4d694615..3ce3a68be3 100644 --- a/vcell-cli/src/test/java/org/vcell/cli/run/BiosimulationsExecTest.java +++ b/vcell-cli/src/test/java/org/vcell/cli/run/BiosimulationsExecTest.java @@ -120,6 +120,10 @@ public void writeErrorList(String message) { public void writeDetailedResultList(String message) { System.out.println("writeDetailedResultList(): " + message); } + @Override + public void writeDetailedSimBreakdown(String message) { + System.out.println("writeDetailedSimBreakdown(): " + message); + } @Override public void writeSpatialList(String message) { System.out.println("writeSpatialList(): " + message); diff --git a/vcell-cli/src/test/java/org/vcell/cli/run/SpatialExecTest.java b/vcell-cli/src/test/java/org/vcell/cli/run/SpatialExecTest.java index b6f913c95c..10e50a30a8 100644 --- a/vcell-cli/src/test/java/org/vcell/cli/run/SpatialExecTest.java +++ b/vcell-cli/src/test/java/org/vcell/cli/run/SpatialExecTest.java @@ -139,6 +139,10 @@ public void writeDetailedResultList(String message) { System.out.println("writeDetailedResultList(): " + message); } @Override + public void writeDetailedSimBreakdown(String message) { + System.out.println("writeDetailedSimBreakdown(): " + message); + } + @Override public void writeSpatialList(String message) { System.out.println("writeSpatialList(): " + message); }