Skip to content

Commit 8b926dd

Browse files
committed
Rscript debugging
1 parent 4690391 commit 8b926dd

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

singlecell/api-src/org/labkey/api/singlecell/pipeline/AbstractSingleCellPipelineStep.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
248248
ctx.getLogger().info("R script exists, re-using: " + localRScript.getPath());
249249
}
250250

251-
File localBashScript = new File(ctx.getOutputDir(), "wrapper.sh");
251+
File localBashScript = new File(ctx.getOutputDir(), "dockerWrapper.sh");
252+
File rWrapperScript = new File(ctx.getOutputDir(), "rWrapper.sh");
252253
try (PrintWriter writer = PrintWriters.getPrintWriter(localBashScript))
253254
{
254255
writer.println("#!/bin/bash");
255-
writer.println("set -e");
256256
writer.println("set -x");
257257
writer.println("WD=`pwd`");
258258
writer.println("HOME=`echo ~/`");
@@ -283,7 +283,7 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
283283
writer.println("\t-w /work \\");
284284
writer.println("\t-e HOME=/homeDir \\");
285285
writer.println("\t" + dockerContainerName + " \\");
286-
writer.println("\tRscript --vanilla " + localRScript.getName() + " && echo 'Done!'");
286+
writer.println("\t" + rWrapperScript.getName());
287287
writer.println("");
288288
writer.println("echo 'Bash script complete'");
289289

@@ -293,6 +293,24 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
293293
throw new PipelineJobException(e);
294294
}
295295

296+
try (PrintWriter writer = PrintWriters.getPrintWriter(rWrapperScript))
297+
{
298+
writer.println("#!/bin/bash");
299+
writer.println("set -x");
300+
301+
writer.println("if Rscript --vanilla " + localRScript.getName());
302+
writer.println("then");
303+
writer.println("\texit 0");
304+
writer.println("else");
305+
writer.println("\techo \"Rscript exited with value $?\"");
306+
writer.println("\texit 0");
307+
writer.println("fi");
308+
}
309+
catch (IOException e)
310+
{
311+
throw new PipelineJobException(e);
312+
}
313+
296314
SimpleScriptWrapper rWrapper = new SimpleScriptWrapper(ctx.getLogger());
297315
rWrapper.setWorkingDir(ctx.getOutputDir());
298316
rWrapper.execute(Arrays.asList("/bin/bash", localBashScript.getName()));

0 commit comments

Comments
 (0)