codalab.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:django-corenlp 作者: arunchaganty 项目源码 文件源码
def launch_job(job_name, cmd=None,
               code_dir=None, excludes='*.ipynb .git .ipynb_checkpoints', dependencies=tuple(),
               queue='john', image='codalab/python', memory='18g',
               debug=False, tail=False):
    """Launch a job on CodaLab (optionally upload code that the job depends on).

    Args:
        job_name: name of the job
        cmd: command to execute
        code_dir: path to code folder. If None, no code is uploaded.
        excludes: file types to exclude from the upload
        dependencies: list of other bundles that we depend on
        debug: if True, prints SSH commands, but does not execute them
        tail: show the streaming output returned by CodaLab once it launches the job
    """
    print 'Remember to set up SSH tunnel and LOG IN through the command line before calling this.'

    def execute(cmd):
        return shell(cmd, verbose=True, debug=debug)

    if code_dir:
        execute('cl up -n code -w {} {} -x {}'.format(worksheet, code_dir, excludes))

    options = '-v -n {} -w {} --request-queue {} --request-docker-image {} --request-memory {}'.format(
        job_name, worksheet, queue, image, memory)
    dep_str = ' '.join(['{0}:{0}'.format(dep) for dep in dependencies])
    cmd = "cl run {} {} '{}'".format(options, dep_str, cmd)
    if tail:
        cmd += ' -t'
    execute(cmd)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号