Exemple #1
0
def upload_resource_and_submit_alisa_task(datasource, local_tar_file,
                                          params_file, alisa_exec_code):
    """Upload the packed resource and submit an Alisa task

    Args:
        datasource: the datasource to use
        local_tar_file: zipped local resource, including code and params
        params_file: the params file
        alisa_exec_code: the command to submit a PAI task
    """
    oss_code_obj = gen_rand_string(16)
    bucket = getAlisaBucket()
    oss_code_url = upload_resource(local_tar_file, oss_code_obj, bucket)

    # upload params.txt for additional training parameters.
    oss_params_obj = gen_rand_string(16)
    oss_params_url = upload_resource(params_file, oss_params_obj, bucket)
    conf = {
        "codeResourceURL": oss_code_url,
        "paramsResourceURL": oss_params_url,
        "resourceName": local_tar_file,
        "paramsFile": params_file,
    }
    submit_alisa_task(datasource, AlisaTaskTypePAI, alisa_exec_code, conf)

    bucket.delete_object(oss_code_obj)
    bucket.delete_object(oss_params_obj)
Exemple #2
0
def upload_resource_and_submit_alisa_task(datasource, job_file, params_file,
                                          pai_cmd):
    """Upload the packed resource and submit an Alisa task

    Args:
        datasource: the datasource to use
        job_file: zipped local resource, including code and libs
        params_file: the extra params file
        pai_cmd: the command to run on PAI
    """
    oss_code_obj = gen_rand_string(16)
    bucket = getAlisaBucket()
    oss_code_url = upload_resource(job_file, oss_code_obj, bucket)

    # upload params.txt for additional training parameters.
    oss_params_obj = gen_rand_string(16)
    oss_params_url = upload_resource(params_file, oss_params_obj, bucket)
    conf = {
        "codeResourceURL": oss_code_url,
        "paramsResourceURL": oss_params_url,
        "resourceName": job_file,
        "paramsFile": params_file,
    }
    submit_alisa_task(datasource, AlisaTaskTypePAI, pai_cmd, conf)

    bucket.delete_object(oss_code_obj)
    bucket.delete_object(oss_params_obj)