Skip to content

Commit d5dac32

Browse files
committed
Cleaner method for sbatch to set working dir
1 parent 1084c62 commit d5dac32

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cluster/src/org/labkey/cluster/pipeline/AbstractClusterExecutionEngine.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,11 @@ private ClusterJob getMostRecentClusterSubmission(String jobId, boolean includeI
740740
}
741741

742742
protected List<String> execute(String command)
743+
{
744+
return execute(command, null);
745+
}
746+
747+
protected List<String> execute(String command, @Nullable File workDir)
743748
{
744749
if (command == null)
745750
{
@@ -752,7 +757,7 @@ protected List<String> execute(String command)
752757

753758
try
754759
{
755-
Process p = Runtime.getRuntime().exec(command);
760+
Process p = Runtime.getRuntime().exec(command, null, workDir);
756761
try
757762
{
758763
String output = IOUtils.toString(p.getInputStream(), StringUtilsLabKey.DEFAULT_CHARSET);

cluster/src/org/labkey/cluster/pipeline/SlurmExecutionEngine.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected List<String> submitJobToCluster(ClusterJob j, PipelineJob job) throws
7777
ctx.put("submitScript", getConfig().getClusterPath(submitScript));
7878
String command = getConfig().getSubmitCommandExpr().eval(ctx);
7979

80-
List<String> ret = execute(command);
80+
List<String> ret = execute(command, submitScript.getParentFile());
8181
if (ret != null)
8282
{
8383
//verify success; create job
@@ -531,7 +531,6 @@ private File createSubmitScript(PipelineJob job) throws PipelineJobException
531531
//writer.write("#SBATCH --workdir=\"" + getConfig().getClusterPath(job.getLogFile().getParentFile()) + "\"\n");
532532

533533
String args = StringUtils.join(getConfig().getJobArgs(outDir, serializedJobFile, job, this), " ");
534-
writer.write("cd " + getConfig().getClusterPath(job.getLogFile().getParentFile()) + "\n");
535534
writer.write("srun " + getConfig().getRemoteExecutable() + " " + args);
536535
}
537536
}

0 commit comments

Comments
 (0)