import argparse
import os
from psf.file.psf_file import PsfFile
from manas.model2 import repository
from manas.aisample.dataset import mfile
from manas.pipeline.sdk.utils import json_utils
from manas.dataset.path_util import real_path



def upload_model_weight(source_model_path, target_model_path):
    if source_model_path and target_model_path:
        try:
            hdfs_real_path = real_path(target_model_path)
            mfile.copy_from_local(source_model_path, hdfs_real_path)
        except Exception as exception:
            raise Exception('model weight upload error !')
    else:
        raise Exception('The model weight path does not exist!')

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Download a model parameters.')
    parser.add_argument('--source-model-path', type=str, help='train output  weight path.')
    parser.add_argument('--target-model-path', type=str, help='upload the model to.')
    args = parser.parse_args()
    upload_model_weight(args.source_model_path, args.target_model_path)
