build.py 文件源码

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

项目:deeppavlov 作者: deepmipt 项目源码 文件源码
def archive_model(project):
    """
    Use 'pyb -P model_name="<model_name>" archive_model' to create '<model_name>_CURRENTDATE.tar.gz'
    in 'build' directory. If model_name == 'deeppavlov_docs', then documentation from build/docs will be archived.
    """
    import tarfile, datetime
    os.chdir('build')
    model_name = project.get_property('model_name')
    archive_name = model_name + '_' + datetime.date.today().strftime("%y%m%d")

    if model_name == 'deeppavlov_docs':
        import shutil
        shutil.make_archive(archive_name, 'gztar', 'docs', 'deeppavlov')
        os.chdir('..')
        return

    with tarfile.open(archive_name + '.tar.gz', "w:gz") as archive:
        os.chdir(model_name)
        for f in os.listdir('.'):
            if os.path.isfile(f) and (('h5' in f) or ('json' in f) or ('pkl' in f)or ('dict' in f) or ('threshold' in f)
                                      or ('data' in f) or ('index' in f) or ('meta' in f) or ('checkpoint' in f)):
                archive.add(f)
        os.chdir('..')
    os.chdir('..')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号