Skip to content

Commit 55cf323

Browse files
committed
Set HOME environment variable for CellMembrane docker containers
1 parent ddc0300 commit 55cf323

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected void executeR(SequenceOutputHandler.JobContext ctx, File rmd, String o
282282
seuratThreads = getProvider().getParameterByName(SEURAT_THREADS).extractValue(ctx.getJob(), getProvider(), getStepIdx(), Integer.class, null);
283283
}
284284

285-
executeR(ctx, getDockerContainerName(), outputPrefix, lines, seuratThreads);
285+
executeR(ctx, getDockerContainerName(), outputPrefix, lines, seuratThreads, getDockerHomeDir());
286286

287287
handlePossibleFailure(ctx, outputPrefix);
288288
}
@@ -294,7 +294,7 @@ protected static SeuratToolParameter getSeuratThreadsParam()
294294
}}, null);
295295
}
296296

297-
public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerContainerName, String outputPrefix, List<String> lines, @Nullable Integer seuratThreads) throws PipelineJobException
297+
public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerContainerName, String outputPrefix, List<String> lines, @Nullable Integer seuratThreads, @Nullable String dockerHomeDir) throws PipelineJobException
298298
{
299299
File localRScript = new File(ctx.getOutputDir(), FileUtil.makeLegalName(outputPrefix + ".R").replaceAll(" ", "_"));
300300
try (PrintWriter writer = PrintWriters.getPrintWriter(localRScript))
@@ -349,6 +349,10 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
349349
writer.println("\t-u $UID \\");
350350
writer.println("\t-e USERID=$UID \\");
351351
writer.println("\t-e TMPDIR=/tmp \\");
352+
if (dockerHomeDir != null)
353+
{
354+
writer.println("\t-e HOME=" + dockerHomeDir + " \\");
355+
}
352356
writer.println("\t-w /work \\");
353357
//NOTE: this seems to disrupt packages installed into home
354358
//writer.println("\t-e HOME=/homeDir \\");
@@ -371,6 +375,11 @@ public static void executeR(SequenceOutputHandler.JobContext ctx, String dockerC
371375
localBashScript.delete();
372376
}
373377

378+
public String getDockerHomeDir()
379+
{
380+
return null;
381+
}
382+
374383
protected void addParameterVariables(SeuratToolParameter pd, List<String> body)
375384
{
376385
String val = StringUtils.trimToNull(pd.extractValue(getPipelineCtx().getJob(), getProvider(), getStepIdx()));

singlecell/resources/chunks/CommonFilters.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ for (datasetId in names(seuratObjects)) {
149149
seuratObj <- subset(seuratObj, cells = negativeCells, invert = TRUE)
150150
print(paste0('After removing cells with negative hashing calls: ', ncol(seuratObj)))
151151
if (ncol(seuratObj) != expectedCells) {
152-
stop(paste0('The subset for negative hashing cells did not work as expected. Expected cells: ', expectedCells, ', actual: ', ncol(seuratObj))
152+
stop(paste0('The subset for negative hashing cells did not work as expected. Expected cells: ', expectedCells, ', actual: ', ncol(seuratObj)))
153153
}
154154
}
155155
}, error = function(e){

singlecell/src/org/labkey/singlecell/analysis/AbstractSingleCellHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ else if (step.createsSeuratObjects())
597597
File finalHtml = new File(ctx.getOutputDir(), "finalHtml.html");
598598
List<String> lines = new ArrayList<>();
599599
lines.add("rmarkdown::render(output_file = '" + finalHtml.getName() + "', input = '" + finalMarkdownFile.getName() + "', intermediates_dir = '/work')");
600-
AbstractSingleCellPipelineStep.executeR(ctx, AbstractCellMembraneStep.CONTAINER_NAME, "pandoc", lines, null);
600+
AbstractSingleCellPipelineStep.executeR(ctx, AbstractCellMembraneStep.CONTAINER_NAME, "pandoc", lines, null, null);
601601
_resumer.getFileManager().addIntermediateFile(finalMarkdownFile);
602602
_resumer.getFileManager().addIntermediateFiles(_resumer.getMarkdownsInOrder());
603603
_resumer.getFileManager().addIntermediateFiles(_resumer.getHtmlFilesInOrder());

singlecell/src/org/labkey/singlecell/pipeline/singlecell/AbstractCellMembraneStep.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract public class AbstractCellMembraneStep extends AbstractSingleCellPipelin
1111
{
1212
public static String CONTAINER_NAME = "ghcr.io/bimberlabinternal/cellmembrane:latest";
1313

14-
public AbstractCellMembraneStep(PipelineStepProvider provider, PipelineContext ctx)
14+
public AbstractCellMembraneStep(PipelineStepProvider<?> provider, PipelineContext ctx)
1515
{
1616
super(provider, ctx);
1717
}
@@ -27,4 +27,11 @@ public String getDockerContainerName()
2727
{
2828
return CONTAINER_NAME;
2929
}
30+
31+
// NOTE: ExperimentHub and similar packages default to saving data to the user's home dir. Set a directory, to avoid issues when not running the container as root
32+
@Override
33+
public String getDockerHomeDir()
34+
{
35+
return "/dockerHomeDir";
36+
}
3037
}

0 commit comments

Comments
 (0)