コード例 #1
0
def create_container(app):
    avail.get_image(image_version(app))
    dirs = {
        "output": fs.get_task_dir_path(app, 'tmp'),
        "metadata": fs.get_task_dir_path(app, 'meta')
    }
    return image.create_container(image_version(app),
                                  image_type(app).biobox_args(app), dirs,
                                  image_task(app))
コード例 #2
0
def test_executing_container():
    out_dir = tempfile.mkdtemp()
    cnt = exe.create_container(IMAGE, biobox_cfg(hlp.short_read_fastq()),
                               {"output": out_dir}, "default",
                               {"detach": False})
    id_ = cnt['Id']
    util.client().start(id_)
    util.client().wait(id_)
    assert funcy.get_in(util.client().inspect_container(id_),
                        ['State', 'ExitCode']) == 0
    assert os.path.isfile(os.path.join(out_dir, 'contigs.fa'))
    hlp.clean_up_container(id_)
コード例 #3
0
def test_create_container_with_cgroup_data():
    # Currently {'cpuset' : "0"} is too hard to test because I don't know
    # how to get the CPU IDs for the machine being used for testing
    args = [{'cpu_shares' : 1}, {'mem_limit' : 10000000}]
    out_dir = tempfile.mkdtemp()
    for arg in args:
        cnt = exe.create_container(
                IMAGE,
                CONFIG,
                {"output" : out_dir},
                "default",
                arg)
        helper.clean_up_container(cnt['Id'])
コード例 #4
0
def test_executing_container():
    out_dir = tempfile.mkdtemp()
    cnt = exe.create_container(
            IMAGE,
            biobox_cfg(hlp.short_read_fastq()),
            {"output" : out_dir},
            "default",
            {"detach" : False})
    id_ = cnt['Id']
    util.client().start(id_)
    util.client().wait(id_)
    assert funcy.get_in(util.client().inspect_container(id_), ['State', 'ExitCode']) == 0
    assert os.path.isfile(os.path.join(out_dir, 'contigs.fa'))
    hlp.clean_up_container(id_)
コード例 #5
0
    def run(self, argv):
        doc = inspect.getdoc(inspect.getmodule(self))
        opts = util.parse_docopt(doc, argv, False)
        task        = opts['--task']
        image       = opts['<image>']
        output      = opts['--output']

        # Check the image exists
        ctn.exit_if_no_image_available(image)

        # Additional non-biobox args to pass to the docker daemon
        docker_args = {'mem_limit': opts['--memory'],
                       'cpuset': opts['--cpuset'],
                       'cpu_shares': int_or_none(opts['--cpu-shares'])}

        output_dir = tempfile.mkdtemp()

        ctnr = biobox.create_container(image, self.prepare_config(opts), output_dir, task, docker_args)
        ctn.run(ctnr)
        self.after_run(output, output_dir)
        return ctnr