diff --git a/vcell-cli/src/main/java/org/vcell/cli/commands/TimeLimitedCommand.java b/vcell-cli/src/main/java/org/vcell/cli/commands/TimeLimitedCommand.java index 2798e77531..e8c20e1ac5 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/commands/TimeLimitedCommand.java +++ b/vcell-cli/src/main/java/org/vcell/cli/commands/TimeLimitedCommand.java @@ -24,7 +24,7 @@ public abstract class TimeLimitedCommand implements Callable { * Perform the desired command * @return return code of the command */ - protected abstract Integer executeCommand(); + protected abstract Integer executeCommand() throws Exception; protected long getTimeout() {return this.timeout;} diff --git a/vcell-cli/src/main/java/org/vcell/cli/commands/execution/ExecuteOmexCommand.java b/vcell-cli/src/main/java/org/vcell/cli/commands/execution/ExecuteOmexCommand.java index 89c4579d36..7bc7f6c9e9 100644 --- a/vcell-cli/src/main/java/org/vcell/cli/commands/execution/ExecuteOmexCommand.java +++ b/vcell-cli/src/main/java/org/vcell/cli/commands/execution/ExecuteOmexCommand.java @@ -64,27 +64,10 @@ public class ExecuteOmexCommand extends ExecutionBasedCommand { @Override public Integer call() throws Exception { if (!this.executionShouldContinue()) return 0; - CLIRecordable cliTracer = new CliTracer(); ExecutorService executor = Executors.newSingleThreadExecutor(); Future futureResult = executor.submit(this::executeCommand); long startTime_ms = System.currentTimeMillis(); - try { - File tmpDirExec = Files.createTempDirectory("VCell_CLI_" + Long.toHexString(new Date().getTime())).toFile(); - File tmpDirConv = Files.createTempDirectory("VCell_CLI_" + Long.toHexString(new Date().getTime())).toFile(); - Tracer.clearTraceEvents(); - - startTime_ms = System.currentTimeMillis(); - boolean needsNoConversion = !this.inputFilePath.getName().endsWith(".vcml"); - File inFile = needsNoConversion ? this.inputFilePath : ExecuteOmexCommand.performInputFileConversion(this.inputFilePath, tmpDirConv); - - if (inFile != null) - ExecuteImpl.singleMode(inFile, tmpDirExec, cliTracer, - this.bKeepTempFiles, this.bExactMatchOnly, this.bEncapsulateOutput, this.bSmallMeshOverride); - - - FileUtils.copyDirectoryContents(tmpDirExec, this.outputFilePath, true, null); - Integer ignored; try { // This try is explicitly for timeouts if (this.getTimeout() == 0) { futureResult.get(); @@ -94,6 +77,7 @@ public Integer call() throws Exception { } catch (TimeoutException e) { // In the event of timeout, we want to log like we're talking from the command in question // We'll leave an in-log reference to the actual class and method + futureResult.cancel(true); String debugSnipIt = logger.getLevel().isInRange(Level.TRACE, Level.DEBUG) ? "(TimeLimitedCommand::call) " : ""; String msg = String.format("%sTask too too long, exceeding %s %s.", debugSnipIt, this.getTimeout(), this.getTimeUnit().toString().toLowerCase()); LogManager.getLogger(this.getClass()).error(msg); @@ -171,8 +155,23 @@ protected boolean executionShouldContinue() { * @return return code of the command */ @Override - protected Integer executeCommand() { - return 0; + protected Integer executeCommand() throws Exception { + File tmpDirExec = Files.createTempDirectory("VCell_CLI_" + Long.toHexString(new Date().getTime())).toFile(); + File tmpDirConv = Files.createTempDirectory("VCell_CLI_" + Long.toHexString(new Date().getTime())).toFile(); + Tracer.clearTraceEvents(); + + boolean needsNoConversion = !this.inputFilePath.getName().endsWith(".vcml"); + File inFile = needsNoConversion ? this.inputFilePath : ExecuteOmexCommand.performInputFileConversion(this.inputFilePath, tmpDirConv); + + CLIRecordable cliTracer = new CliTracer(); + if (inFile != null) + ExecuteImpl.singleMode(inFile, tmpDirExec, cliTracer, + this.bKeepTempFiles, this.bExactMatchOnly, this.bEncapsulateOutput, this.bSmallMeshOverride); + + + FileUtils.copyDirectoryContents(tmpDirExec, this.outputFilePath, true, null); + return 0; + } private static File performInputFileConversion(File inputFile, File outputDir) { 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 9568a77fcd..0d0e7fcd9c 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 @@ -4,6 +4,7 @@ import cbit.vcell.solver.ode.ODESolverResultSet; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jlibsedml.XMLException; import org.vcell.cli.messaging.CLIRecordable; import org.vcell.cli.exceptions.ExecutionException; import org.vcell.cli.run.hdf5.BiosimulationsHdfWriterException; @@ -118,14 +119,14 @@ private static void runSingleExecOmex(File inputFile, File outputDir, CLIRecorda public static void singleMode(File inputFile, File rootOutputDir, CLIRecordable cliLogger, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, - boolean bSmallMeshOverride) throws Exception{ + boolean bSmallMeshOverride) throws IOException, BiosimulationsHdfWriterException, ExecutionException, XMLException { ExecuteImpl.singleMode(inputFile, rootOutputDir, cliLogger, bKeepTempFiles, bExactMatchOnly, bEncapsulateOutput, bSmallMeshOverride, false); } public static void singleMode(File inputFile, File rootOutputDir, CLIRecordable cliLogger, boolean bKeepTempFiles, boolean bExactMatchOnly, boolean bEncapsulateOutput, - boolean bSmallMeshOverride, boolean bBioSimMode) throws Exception { + boolean bSmallMeshOverride, boolean bBioSimMode) throws IOException, BiosimulationsHdfWriterException, ExecutionException, XMLException { // Build statuses String bioModelBaseName = FileUtils.getBaseName(inputFile.getName()); // bioModelBaseName = input file without the path String outputBaseDir = rootOutputDir.getAbsolutePath(); @@ -209,13 +210,13 @@ public static void singleExecVcml(File vcmlFile, File outputDir, CLIRecordable c somethingFailed = somethingDidFail(); } catch (ExpressionException e) { Tracer.failure(e, "ExpressionException while processing VCML " + vcmlFile.getName()); - logger.error("InterruptedException while creating results CSV from VCML " + vcmlFile.getName(), e); + logger.error("ExpressionException while creating results CSV from VCML " + vcmlFile.getName(), e); somethingFailed = somethingDidFail(); - } catch (InterruptedException e) { + } /*catch (InterruptedException e) { Tracer.failure(e, "InterruptedException while processing VCML " + vcmlFile.getName()); logger.error("InterruptedException while transposing CSV from VCML " + vcmlFile.getName(), e); somethingFailed = somethingDidFail(); - } catch (Exception e) { + }*/ catch (Exception e) { Tracer.failure(e, "Unexpected exception while processing VCML " + vcmlFile.getName()); String errorMessage = String.format("Unexpected exception while transposing CSV from VCML <%s>\n%s", vcmlFile.getName(), e.toString()); logger.error(errorMessage, e);