| 78 | |
| 79 | |
| 80 | def archive_code(arc_path, filetypes=['.py']): |
| 81 | print(f"Archiving code to {arc_path}") |
| 82 | xmkdir(os.path.dirname(arc_path)) |
| 83 | zipf = zipfile.ZipFile(arc_path, 'w', zipfile.ZIP_DEFLATED) |
| 84 | cur_dir = os.getcwd() |
| 85 | flist = [] |
| 86 | for ftype in filetypes: |
| 87 | flist.extend(glob.glob(os.path.join(cur_dir, '[!results]*', '**', '*'+ftype), recursive=True)) # ignore results folder |
| 88 | flist.extend(glob.glob(os.path.join(cur_dir, '*'+ftype))) |
| 89 | [zipf.write(f, arcname=f.replace(cur_dir,'archived_code', 1)) for f in flist] |
| 90 | zipf.close() |
| 91 | |
| 92 | |
| 93 | def get_model_device(model): |