Commit 18c137d7 authored by liugaoling's avatar liugaoling

add work script

parent 55d62004
...@@ -64,14 +64,14 @@ public class CreateJobRequest extends CloudamRequest<CreateJobResponse> { ...@@ -64,14 +64,14 @@ public class CreateJobRequest extends CloudamRequest<CreateJobResponse> {
// sbatch -n 1 -c 8 --comment disk:CLOUD_SSD:2700G:s-NV0tQ0PL run_local.sh // sbatch -n 1 -c 8 --comment disk:CLOUD_SSD:2700G:s-NV0tQ0PL run_local.sh
// sbatch -n 1 -c 8 -p c-52-2 -q eco cpu.sh // sbatch -n 1 -c 8 -p c-52-2 -q eco cpu.sh
StringBuffer commandBuffer = new StringBuffer("#!/bin/sh\n"); StringBuffer commandBuffer = new StringBuffer("#!/bin/sh\n");
BiConsumer<String, String> stringValidAppend = (key, agrs) -> { BiConsumer<String, String> stringValidAppend = (key, args) -> {
if (StringUtils.isNotBlank(key)) { if (StringUtils.isNotBlank(key)) {
commandBuffer.append("#SBATCH ").append(agrs).append(" ").append(key).append("\n"); commandBuffer.append("#SBATCH ").append(args).append(" ").append(key).append("\n");
} }
}; };
BiConsumer<Integer, String> intValidAppend = (key, agrs) -> { BiConsumer<Integer, String> intValidAppend = (key, args) -> {
if (key != null && key != 0) { if (key != null && key != 0) {
commandBuffer.append("#SBATCH ").append(agrs).append(" ").append(key).append("\n"); commandBuffer.append("#SBATCH ").append(args).append(" ").append(key).append("\n");
} }
}; };
stringValidAppend.accept(jobDescription.getName(), "-J"); stringValidAppend.accept(jobDescription.getName(), "-J");
...@@ -82,11 +82,7 @@ public class CreateJobRequest extends CloudamRequest<CreateJobResponse> { ...@@ -82,11 +82,7 @@ public class CreateJobRequest extends CloudamRequest<CreateJobResponse> {
intValidAppend.accept(jobDescription.getNtasks(), "-n"); intValidAppend.accept(jobDescription.getNtasks(), "-n");
intValidAppend.accept(jobDescription.getTimeout(), "-t"); intValidAppend.accept(jobDescription.getTimeout(), "-t");
String workScript = jobDescription.getEnvs().get("cwd") + "/script"; commandBuffer.append(jobDescription.getWorkScript()).append("\n");
if (Os.Windows != jobDescription.getAutoCluster().getOs()) {
commandBuffer.append("dos2unix ").append(workScript).append("\n");
}
commandBuffer.append("bash ").append(workScript).append("\n");
return commandBuffer.toString(); return commandBuffer.toString();
} }
} }
...@@ -29,6 +29,11 @@ public class JobDescription { ...@@ -29,6 +29,11 @@ public class JobDescription {
*/ */
private AutoCluster autoCluster; private AutoCluster autoCluster;
/**
*
*/
private String workScript;
/** /**
* 环境变量 * 环境变量
*/ */
...@@ -86,6 +91,14 @@ public class JobDescription { ...@@ -86,6 +91,14 @@ public class JobDescription {
this.autoCluster = autoCluster; this.autoCluster = autoCluster;
} }
public String getWorkScript() {
return workScript;
}
public void setWorkScript(String workScript) {
this.workScript = workScript;
}
public Map<String, String> getEnvs() { public Map<String, String> getEnvs() {
return envs; return envs;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment