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();
}
}
}
use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.
the class PythonSupport method checkPython.
private static boolean checkPython(File pythonExe) {
String[] cmd;
if (OperatingSystemInfo.getInstance().isWindows()) {
// cmd = new String[] {"cmd", "/C", managedMiniconda.pythonExe.getAbsolutePath(), "--version"};
cmd = new String[] { pythonExe.getAbsolutePath(), "--version" };
} else {
cmd = new String[] { pythonExe.getAbsolutePath(), "--version" };
}
IExecutable exe = new Executable(cmd);
try {
exe.start(new int[] { 0 });
System.out.println("Exit value: " + exe.getExitValue());
System.out.println("stdout=\"" + exe.getStdoutString() + "\"");
System.out.println("stderr=\"" + exe.getStderrString() + "\"");
if (exe.getExitValue() != 0) {
throw new RuntimeException("Python test failed with return code " + exe.getExitValue() + ": " + exe.getStderrString());
}
// }
return true;
} catch (ExecutableException e) {
e.printStackTrace();
throw new RuntimeException("Python test invocation failed: " + e.getMessage(), e);
}
}
use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.
the class PythonSupport method checkPackage.
private static boolean checkPackage(File pythonExe, PythonPackage pythonPackage) {
String[] cmd;
if (OperatingSystemInfo.getInstance().isWindows()) {
// cmd = new String[] { "cmd", "/C", condaExe.getAbsolutePath(), "-c", "'import "+pythonPackage.pythonModuleName+"'"};
cmd = new String[] { pythonExe.getAbsolutePath(), "-c", "\"import " + pythonPackage.pythonModuleName + "\"" };
} else {
cmd = new String[] { "bash", "-c", pythonExe.getAbsolutePath() + " -c 'import " + pythonPackage.pythonModuleName + "'" };
}
System.out.println(Arrays.asList(cmd).toString());
IExecutable exe = new Executable(cmd);
try {
System.out.println("checking package " + pythonPackage.condaName);
exe.start(new int[] { 0 });
System.out.println("Exit value: " + exe.getExitValue());
System.out.println(exe.getStdoutString());
System.out.println(exe.getStderrString());
return true;
} catch (ExecutableException e) {
// e.printStackTrace();
System.out.println("Exit value: " + exe.getExitValue());
System.out.println(exe.getStdoutString());
System.out.println(exe.getStderrString());
return false;
}
}
use of org.vcell.util.exe.ExecutableException in project vcell by virtualcell.
the class SlurmProxyTest method testSingularitySupport.
@Test
public void testSingularitySupport() throws IOException, ExecutableException {
CommandServiceSshNative cmd = null;
try {
Random r = new Random();
System.setProperty("log4j2.trace", "true");
System.setProperty(PropertyLoader.vcellServerIDProperty, "Test2");
System.setProperty(PropertyLoader.htcLogDirExternal, "/Volumes/vcell/htclogs");
VCMongoMessage.enabled = false;
String[] partitions = new String[] { "vcell", "vcell2" };
System.setProperty(PropertyLoader.slurm_partition, partitions[1]);
cmd = new CommandServiceSshNative(new String[] { "vcell-service.cam.uchc.edu" }, "vcell", new File("/Users/schaff/.ssh/schaff_rsa"));
SlurmProxy slurmProxy = new SlurmProxy(cmd, "vcell");
String jobName = "V_TEST2_999999999_0_" + r.nextInt(10000);
System.out.println("job name is " + jobName);
File sub_file_localpath = new File("/Volumes/vcell/htclogs/" + jobName + ".slurm.sub");
File sub_file_remotepath = new File("/share/apps/vcell3/htclogs/" + jobName + ".slurm.sub");
StringBuffer subfileContent = new StringBuffer();
subfileContent.append("#!/usr/bin/bash\n");
String partition = PropertyLoader.getRequiredProperty(PropertyLoader.slurm_partition);
subfileContent.append("#SBATCH --partition=" + partition + "\n");
subfileContent.append("#SBATCH -J " + jobName + "\n");
subfileContent.append("#SBATCH -o /share/apps/vcell3/htclogs/" + jobName + ".slurm.log\n");
subfileContent.append("#SBATCH -e /share/apps/vcell3/htclogs/" + jobName + ".slurm.log\n");
subfileContent.append("#SBATCH --mem=1000M\n");
subfileContent.append("#SBATCH --no-kill\n");
subfileContent.append("#SBATCH --no-requeue\n");
subfileContent.append("env\n");
subfileContent.append("echo `hostname`\n");
subfileContent.append("python -c \"some_str = ' ' * 51200000\"\n");
subfileContent.append("retcode=$?\n");
subfileContent.append("echo \"return code was $retcode\"\n");
subfileContent.append("if [[ $retcode == 137 ]]; then\n");
subfileContent.append(" echo \"job was killed via kill -9 (probably out of memory)\"\n");
subfileContent.append("fi\n");
subfileContent.append("sleep 20\n");
subfileContent.append("exit $retcode\n");
// subfileContent.append("export MODULEPATH=/isg/shared/modulefiles:/tgcapps/modulefiles\n");
// subfileContent.append("source /usr/share/Modules/init/bash\n");
// subfileContent.append("module load singularity\n");
// subfileContent.append("if command -v singularity >/dev/null 2>&1; then\n");
// subfileContent.append(" echo 'singularity command exists'\n");
// subfileContent.append(" exit 0\n");
// subfileContent.append("else\n");
// subfileContent.append(" echo 'singularity command not found'\n");
// subfileContent.append(" exit 1\n");
// subfileContent.append("fi\n");
FileUtils.writeStringToFile(sub_file_localpath, subfileContent.toString());
HtcJobID htcJobId = slurmProxy.submitJobFile(sub_file_remotepath);
System.out.println("running job " + htcJobId);
HtcJobInfo htcJobInfo = new HtcJobInfo(htcJobId, jobName);
ArrayList<HtcJobInfo> jobInfos = new ArrayList<HtcJobInfo>();
jobInfos.add(htcJobInfo);
Map<HtcJobInfo, HtcJobStatus> jobStatusMap = slurmProxy.getJobStatus(jobInfos);
int attempts = 0;
while (attempts < 80 && (jobStatusMap.get(htcJobInfo) == null || !jobStatusMap.get(htcJobInfo).isDone())) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
jobStatusMap = slurmProxy.getJobStatus(jobInfos);
System.out.println(jobStatusMap.get(htcJobInfo));
if (attempts == 5) {
slurmProxy.killJobs(jobName);
}
attempts++;
}
System.out.println(jobStatusMap.get(htcJobInfo));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
if (cmd != null) {
cmd.close();
}
}
}
Aggregations