Skip to content

Commit d81e274

Browse files
committed
After failure, ensure we delete the working copy of the GenomicsDB workspace and remake.
1 parent 4cd3f96 commit d81e274

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

SequenceAnalysis/src/org/labkey/sequenceanalysis/run/util/AbstractGenomicsDBImportHandler.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ public void init(PipelineJob job, SequenceAnalysisJobSupport support, List<Seque
371371
{
372372
File workspace = getSourceWorkspace(params, support);
373373
uniqueSamples.addAll(getSamplesForWorkspace(workspace));
374+
job.getLogger().info("Samples in the existing workspace: " + uniqueSamples.size());
374375
}
375376

376377
for (SequenceOutputFile so : inputFiles)
@@ -453,10 +454,14 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
453454

454455
Set<File> toDelete = new HashSet<>();
455456
File doneFile = new File(destinationWorkspaceFolder, "genomicsdb.done");
456-
boolean isResume = doneFile.exists();
457+
File startedFile = new File(destinationWorkspaceFolder, "genomicsdb.started");
458+
boolean genomicsDbCompleted = doneFile.exists();
459+
boolean genomicsDbStarted = startedFile.exists();
460+
ctx.getFileManager().addIntermediateFile(doneFile);
461+
ctx.getFileManager().addIntermediateFile(startedFile);
457462
if (_append)
458463
{
459-
if (isResume)
464+
if (genomicsDbCompleted)
460465
{
461466
ctx.getLogger().debug("GenomicsDB previously completed, resuming");
462467
}
@@ -477,14 +482,16 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
477482
File destContigFolder = new File(destinationWorkspaceFolder, sourceFolder.getName());
478483
File copyDone = new File(destContigFolder.getPath() + ".copy.done");
479484
toDelete.add(copyDone);
480-
if (copyDone.exists())
485+
486+
//NOTE: if GenomicsDB has started, but dies mid-job, the resulting workspace probably cannot be resumed
487+
if (!genomicsDbStarted && copyDone.exists())
481488
{
482489
ctx.getLogger().info("has been copied, skipping");
483490
continue;
484491
}
485492

486493
//Allow the above to complete so we track the .done files
487-
if (isResume)
494+
if (genomicsDbCompleted)
488495
{
489496
continue;
490497
}
@@ -517,7 +524,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
517524
}
518525
else
519526
{
520-
if (isResume)
527+
if (genomicsDbCompleted)
521528
{
522529
ctx.getLogger().debug("GenomicsDB previously completed, resuming");
523530
}
@@ -542,7 +549,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
542549
if (doCopyGVcfLocal)
543550
{
544551
ctx.getLogger().info("making local copies of gVCFs");
545-
vcfsToProcess.addAll(GenotypeGVCFsWrapper.copyVcfsLocally(inputVcfs, toDelete, null, ctx.getLogger(), isResume));
552+
vcfsToProcess.addAll(GenotypeGVCFsWrapper.copyVcfsLocally(inputVcfs, toDelete, null, ctx.getLogger(), genomicsDbCompleted));
546553
}
547554
else
548555
{
@@ -558,13 +565,15 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
558565
wrapper.addToEnvironment("TILEDB_DISABLE_FILE_LOCKING", "1");
559566
}
560567

561-
if (!isResume)
568+
if (!genomicsDbCompleted)
562569
{
563-
List<Interval> intervals = getIntervals(ctx);
564-
wrapper.execute(genome, vcfsToProcess, destinationWorkspaceFolder, intervals, options, _append);
565-
566570
try
567571
{
572+
FileUtils.touch(startedFile);
573+
574+
List<Interval> intervals = getIntervals(ctx);
575+
wrapper.execute(genome, vcfsToProcess, destinationWorkspaceFolder, intervals, options, _append);
576+
568577
FileUtils.touch(doneFile);
569578
ctx.getLogger().debug("GenomicsDB complete, touching file: " + doneFile.getPath());
570579
}

0 commit comments

Comments
 (0)