From 6270e7eebf86bc84c139ec71fe3d52b729bd898e Mon Sep 17 00:00:00 2001 From: chenzh Date: Fri, 21 Apr 2023 18:18:26 +0800 Subject: [PATCH] add obs --- .idea/.gitignore | 8 +++++ .idea/MNIST_Example.iml | 12 ++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++ .idea/misc.xml | 4 +++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ obs.py | 30 +++++++++++++++++++ 7 files changed, 74 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/MNIST_Example.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 obs.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/MNIST_Example.iml b/.idea/MNIST_Example.iml new file mode 100644 index 0000000..8b8c395 --- /dev/null +++ b/.idea/MNIST_Example.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d56657a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0d4f0b9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/obs.py b/obs.py new file mode 100644 index 0000000..40d0f9e --- /dev/null +++ b/obs.py @@ -0,0 +1,30 @@ +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)) + +