MNIST_Example/obs.py

31 lines
1.1 KiB
Python

import os
import argparse
import moxing as mox
from upload import UploadOutput
import json
output_path = '/cache/output'
pretrain_path = '/cache/pretrain/'
### Copy ckpt file from obs to training image###
### To operate on folders, use mox.file.copy_parallel. If copying a file.
### Please use mox.file.copy to operate the file, this operation is to operate the file
def download_model(files):
for obs_url in files:
local_file_path = pretrain_path + obs_url.split('/')[-1]
try:
mox.file.copy(obs_url, local_file_path)
print('Successfully Download {} to {}'.format(obs_url,local_file_path))
except Exception as e:
print('moxing download {} to {} failed: '.format(obs_url, local_file_path) + str(e))
def upload_model(obs_output_url):
### 将训练容器中的新输出模型 回传到启智社区
try:
mox.file.copy_parallel(output_path, obs_output_url)
print("Successfully Upload {} to {}".format(output_path,obs_output_url))
except Exception as e:
print('moxing upload {} to {} failed: '.format(output_path,obs_output_url) + str(e))