Search in sources :

Example 16 with ExecutableException

use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.

the class CommandServiceSsh_sshjTest method testSLURM.

@Test
public void testSLURM() throws IOException, ExecutableException {
    CommandServiceSsh_sshj cmd = null;
    try {
        cmd = new CommandServiceSsh_sshj("vcell-service.cam.uchc.edu", "vcell", new File("/Users/schaff/.ssh/schaff_rsa"));
        System.out.println("after created cmdService");
        CommandOutput output = cmd.command(new String[] { "sacctls -al | head -4" });
        System.out.println("ls output is: " + output.getStandardOutput());
        output = cmd.command(new String[] { "ls -al | head -9" });
        System.out.println("ls output is: " + output.getStandardOutput());
        output = cmd.command(new String[] { "ls -al | head -4" });
        System.out.println("ls output is: " + output.getStandardOutput());
    } catch (Exception e) {
        e.printStackTrace();
        fail("exception thrown: " + e.getMessage());
    } finally {
        if (cmd != null) {
            cmd.close();
        }
    }
}
Also used : CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput) File(java.io.File) IOException(java.io.IOException) ExecutableException(org.vcell.util.exe.ExecutableException) Test(org.junit.Test)

Example 17 with ExecutableException

use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.

the class VtkServicePython method writeVtkGridAndIndexData.

private void writeVtkGridAndIndexData(String visMeshType, VisMesh visMesh, String domainName, File vtkFile, File indexFile) throws IOException {
    if (lg.isDebugEnabled()) {
        lg.debug("writeVtkGridAndIndexData (python) for domain " + domainName);
    }
    File PYTHON = PythonSupport.getPythonExe();
    InstallStatus copasiInstallStatus = PythonSupport.getPythonPackageStatus(PythonPackage.VTK);
    if (copasiInstallStatus == InstallStatus.FAILED) {
        throw new RuntimeException("failed to install VTK python package, consider re-installing VCell-managed python\n ...see Preferences->Python->Re-install");
    }
    if (copasiInstallStatus == InstallStatus.INITIALIZING) {
        throw new RuntimeException("VCell is currently installing or verifying the VTK python package ... please try again in a minute");
    }
    String baseFilename = vtkFile.getName().replace(".vtu", ".visMesh");
    File visMeshFile = new File(vtkFile.getParentFile(), baseFilename);
    VisMeshUtils.writeVisMesh(visMeshFile, visMesh);
    File vtkServiceFile = new File(ResourceUtil.getVCellVTKPythonDir(), "vtkService.py");
    // It's 2015 -- forward slash works for all operating systems
    String[] cmd = new String[] { PYTHON.getAbsolutePath(), vtkServiceFile.getAbsolutePath(), visMeshType, domainName, visMeshFile.getAbsolutePath(), vtkFile.getAbsolutePath(), indexFile.getAbsolutePath() };
    IExecutable exe = prepareExecutable(cmd);
    try {
        exe.start(new int[] { 0 });
        if (exe.getExitValue() != 0) {
            throw new RuntimeException("mesh generation script for domain " + domainName + " failed with return code " + exe.getExitValue() + ": " + exe.getStderrString());
        }
    } catch (ExecutableException e) {
        e.printStackTrace();
        throw new RuntimeException("vtkService.py invocation failed: " + e.getMessage(), e);
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) InstallStatus(cbit.vcell.resource.PythonSupport.InstallStatus) File(java.io.File) IExecutable(org.vcell.util.exe.IExecutable)

Example 18 with ExecutableException

use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.

the class SlurmProxy method submitJob.

@Override
public HtcJobID submitJob(String jobName, String sub_file_internal, String sub_file_external, ExecutableCommand.Container commandSet, int ncpus, double memSize, Collection<PortableCommand> postProcessingCommands) throws ExecutableException {
    try {
        if (LG.isDebugEnabled()) {
            LG.debug("generating local SLURM submit script for jobName=" + jobName);
        }
        String text = generateScript(jobName, commandSet, ncpus, memSize, postProcessingCommands);
        File tempFile = File.createTempFile("tempSubFile", ".sub");
        writeUnixStyleTextFile(tempFile, text);
        // move submission file to final location (either locally or remotely).
        if (LG.isDebugEnabled()) {
            LG.debug("moving local SLURM submit file '" + tempFile.getAbsolutePath() + "' to remote file '" + sub_file_external + "'");
        }
        FileUtils.copyFile(tempFile, new File(sub_file_internal));
        tempFile.delete();
    } catch (IOException ex) {
        ex.printStackTrace(System.out);
        return null;
    }
    /**
     * > sbatch /share/apps/vcell2/deployed/test/htclogs/V_TEST_107643258_0_0.slurm.sub
     * Submitted batch job 5174
     */
    String[] completeCommand = new String[] { Slurm_HOME + JOB_CMD_SUBMIT, sub_file_external };
    if (LG.isDebugEnabled()) {
        LG.debug("submitting SLURM job: '" + CommandOutput.concatCommandStrings(completeCommand) + "'");
    }
    CommandOutput commandOutput = commandService.command(completeCommand);
    String jobid = commandOutput.getStandardOutput().trim();
    final String EXPECTED_STDOUT_PREFIX = "Submitted batch job ";
    if (jobid.startsWith(EXPECTED_STDOUT_PREFIX)) {
        jobid = jobid.replace(EXPECTED_STDOUT_PREFIX, "");
    } else {
        LG.error("failed to submit SLURM job '" + sub_file_external + "', stdout='" + commandOutput.getStandardOutput() + "', stderr='" + commandOutput.getStandardError() + "'");
        throw new ExecutableException("unexpected response from '" + JOB_CMD_SUBMIT + "' while submitting simulation: '" + jobid + "'");
    }
    HtcJobID htcJobID = new HtcJobID(jobid, BatchSystemType.SLURM);
    if (LG.isDebugEnabled()) {
        LG.debug("SLURM job '" + CommandOutput.concatCommandStrings(completeCommand) + "' started as htcJobId '" + htcJobID + "'");
    }
    return htcJobID;
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput) IOException(java.io.IOException) HtcJobID(cbit.vcell.server.HtcJobID) File(java.io.File)

Example 19 with ExecutableException

use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.

the class SlurmProxy method killJob.

@Override
public void killJob(HtcJobID htcJobId) throws ExecutableException, HtcException {
    String[] cmd = new String[] { Slurm_HOME + JOB_CMD_DELETE, Long.toString(htcJobId.getJobNumber()) };
    try {
        // CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, QDEL_JOB_NOT_FOUND_RETURN_CODE });
        if (LG.isDebugEnabled()) {
            LG.debug("killing SLURM job htcJobId=" + htcJobId + ": '" + CommandOutput.concatCommandStrings(cmd) + "'");
        }
        CommandOutput commandOutput = commandService.command(cmd, new int[] { 0, SCANCEL_JOB_NOT_FOUND_RETURN_CODE });
        Integer exitStatus = commandOutput.getExitStatus();
        String standardOut = commandOutput.getStandardOutput();
        if (exitStatus != null && exitStatus.intValue() == SCANCEL_JOB_NOT_FOUND_RETURN_CODE && standardOut != null && standardOut.toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            LG.error("failed to cancel SLURM htcJobId=" + htcJobId + ", job not found");
            throw new HtcJobNotFoundException(standardOut, htcJobId);
        }
    } catch (ExecutableException e) {
        LG.error("failed to cancel SLURM htcJobId=" + htcJobId, e);
        if (!e.getMessage().toLowerCase().contains(SCANCEL_UNKNOWN_JOB_RESPONSE.toLowerCase())) {
            throw e;
        } else {
            throw new HtcJobNotFoundException(e.getMessage(), htcJobId);
        }
    }
}
Also used : ExecutableException(org.vcell.util.exe.ExecutableException) HtcJobNotFoundException(cbit.vcell.message.server.htc.HtcJobNotFoundException) CommandOutput(cbit.vcell.message.server.cmd.CommandService.CommandOutput)

Aggregations

ExecutableException (org.vcell.util.exe.ExecutableException)19 File (java.io.File)12 IOException (java.io.IOException)12 CommandOutput (cbit.vcell.message.server.cmd.CommandService.CommandOutput)6 Test (org.junit.Test)5 Executable (org.vcell.util.exe.Executable)5 ArrayList (java.util.ArrayList)4 IExecutable (org.vcell.util.exe.IExecutable)4 InstallStatus (cbit.vcell.resource.PythonSupport.InstallStatus)2 HtcJobID (cbit.vcell.server.HtcJobID)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 SocketTimeoutException (java.net.SocketTimeoutException)2 URISyntaxException (java.net.URISyntaxException)2 StringTokenizer (java.util.StringTokenizer)2 CommandServiceSshNative (cbit.vcell.message.server.cmd.CommandServiceSshNative)1 HtcJobNotFoundException (cbit.vcell.message.server.htc.HtcJobNotFoundException)1 HtcJobStatus (cbit.vcell.message.server.htc.HtcJobStatus)1 JobInfoAndStatus (cbit.vcell.message.server.htc.HtcProxy.JobInfoAndStatus)1 OperatingSystemInfo (cbit.vcell.resource.OperatingSystemInfo)1