Пример #1
0
def test_custom_lsf_per_core_env(tmpdir):
    jobstore = tmpdir.join("jobstore").strpath
    log = tmpdir.join("log.txt").strpath
    options = parsers.ToilBaseArgumentParser().parse_args(
        [jobstore, "--logFile", log])
    options.batchSystem = "custom_lsf"
    options.disableCaching = True

    # Set total memory per job
    os.environ["TOIL_CONTAINER_LSF_PER_CORE"] = "N"
    job_1 = jobs.ContainerJob(options, runtime=1, cores=2, memory="10G")
    jobs.ContainerJob.Runner.startToil(job_1, options)
    with open(log, "rt", encoding="utf-8") as f:
        assert "-M 10000MB -n 2" in f.read()

    # Set total memory per core
    os.environ["TOIL_CONTAINER_LSF_PER_CORE"] = "Y"
    job_2 = jobs.ContainerJob(options, runtime=1, cores=2, memory="10G")
    jobs.ContainerJob.Runner.startToil(job_2, options)
    with open(log, "rt", encoding="utf-8") as f:
        assert "-M 5000MB -n 2" in f.read()

    # Use per_core_reservation() from lsf config
    del os.environ["TOIL_CONTAINER_LSF_PER_CORE"]
    job_3 = jobs.ContainerJob(options, runtime=1, cores=2, memory="10G")
    jobs.ContainerJob.Runner.startToil(job_3, options)
    with open(log, "rt", encoding="utf-8") as f:
        assert ("-M 5000MB -n 2"
                if per_core_reservation() else "-M 10000MB -n 2") in f.read()
Пример #2
0
def test_custom_lsf_resource_retry_runtime(tmpdir):
    jobstore = tmpdir.join("jobstore").strpath
    log = tmpdir.join("log.txt").strpath
    options = parsers.ToilBaseArgumentParser().parse_args([jobstore, "--logFile", log])
    options.batchSystem = "CustomLSF"
    job = testJobRuntimeRetry(options, memory="10G", runtime=1)
    testJobRuntimeRetry.Runner.startToil(job, options)

    with open(log) as f:
        assert "Detected job killed by LSF" in f.read()
Пример #3
0
def test_custom_lsf_batch_system(tmpdir):
    jobstore = tmpdir.join("jobstore").strpath
    log = tmpdir.join("log.txt").strpath
    options = parsers.ToilBaseArgumentParser().parse_args([jobstore, "--logFile", log])
    options.batchSystem = "CustomLSF"
    job = jobs.ContainerJob(options, memory="10G", runtime=1)
    jobs.ContainerJob.Runner.startToil(job, options)

    with open(log) as f:
        assert "-W 1" in f.read()
Пример #4
0
def test_custom_lsf_resource_retry_runtime(tmpdir):
    jobstore = tmpdir.join("jobstore").strpath
    log = tmpdir.join("log.txt").strpath
    options = parsers.ToilBaseArgumentParser().parse_args(
        [jobstore, "--logFile", log])
    options.batchSystem = "custom_lsf"
    options.disableCaching = True
    job = testJobRuntimeRetry(options, runtime=1)
    testJobRuntimeRetry.Runner.startToil(job, options)

    with open(log, encoding="utf-8") as f:
        assert "Detected job killed by LSF" in f.read()
Пример #5
0
def test_custom_lsf_batch_system(tmpdir):
    jobstore = tmpdir.join("jobstore").strpath
    log = tmpdir.join("log.txt").strpath
    options = parsers.ToilBaseArgumentParser().parse_args(
        [jobstore, "--logFile", log])
    options.batchSystem = "custom_lsf"
    options.disableCaching = True
    job = jobs.ContainerJob(options, runtime=1)
    jobs.ContainerJob.Runner.startToil(job, options)

    with open(log, encoding="utf-8") as f:
        assert "-W 1" in f.read()
Пример #6
0
def test_parser_add_version():
    parser = parsers.ToilBaseArgumentParser(version="foo")
    assert "version" in parser.format_help()