Пример #1
0
    def test_no_job_created_when_failed_job_exists(self):
        experiment = setup_experiment([], ["GSM001"])

        # create a failed job for that experiment
        processor_job = ProcessorJob()
        processor_job.pipeline_applied = ProcessorPipeline.SALMON
        processor_job.ram_amount = 1024
        processor_job.success = False
        processor_job.retried = False
        processor_job.no_retry = False
        processor_job.save()

        assoc = ProcessorJobOriginalFileAssociation()
        assoc.original_file = experiment.samples.first().original_files.first()
        assoc.processor_job = processor_job
        assoc.save()

        # Run command
        update_salmon_all_experiments()

        dl_jobs = DownloaderJob.objects.all()
        self.assertEqual(dl_jobs.count(), 0)
Пример #2
0
def setup_experiment() -> Dict:
    """ Create an experiment with two samples where one of them has a processor job that failed
    because Batch restarted it."""

    # Create the experiment
    experiment_accession = "SRP095529"
    experiment = Experiment.objects.create(accession_code=experiment_accession,
                                           technology="RNA-SEQ")

    zebrafish = Organism.get_object_for_name("DANIO_RERIO")

    accession_code = "S001"
    sample = Sample.objects.create(
        accession_code=accession_code,
        organism=zebrafish,
        source_database="SRA",
        technology="RNA-SEQ",
        platform_accession_code="IlluminaHiSeq1000",
    )
    ExperimentSampleAssociation.objects.create(experiment=experiment,
                                               sample=sample)

    original_file = OriginalFile()
    original_file.filename = accession_code + ".SRA"
    original_file.source_filename = accession_code + ".SRA"
    original_file.save()

    OriginalFileSampleAssociation.objects.get_or_create(
        original_file=original_file, sample=sample)

    accession_code = "S002"
    sample = Sample.objects.create(
        accession_code=accession_code,
        organism=zebrafish,
        source_database="SRA",
        technology="RNA-SEQ",
        platform_accession_code="IlluminaHiSeq1000",
    )
    ExperimentSampleAssociation.objects.create(experiment=experiment,
                                               sample=sample)

    original_file = OriginalFile()
    original_file.filename = accession_code + ".SRA"
    original_file.source_filename = accession_code + ".SRA"
    original_file.save()

    OriginalFileSampleAssociation.objects.get_or_create(
        original_file=original_file, sample=sample)

    # add a failed processor job for the second sample
    processor_job = ProcessorJob()
    processor_job.start_time = timezone.now()
    processor_job.end_time = timezone.now()
    processor_job.no_retry = True
    processor_job.success = False
    processor_job.failure_reason = (
        "ProcessorJob has already completed with a fail - why are we here again?"
    )
    processor_job.save()

    processor_assoc = ProcessorJobOriginalFileAssociation()
    processor_assoc.original_file = original_file
    processor_assoc.processor_job = processor_job
    processor_assoc.save()

    return experiment