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('..')
评论列表
文章目录