Beispiel #1
0
def get_oss_model_save_path(datasource, model_name, user=""):
    if not model_name:
        return None
    _, _, _, project = MaxComputeConnection.get_uri_parts(datasource)
    if user == "":
        user = "******"
    return "/".join([project, user, model_name])
Beispiel #2
0
def get_project(datasource):
    """Get the project info from given datasource

    Args:
        datasource: The odps url to extract project
    """
    _, _, _, project = MaxComputeConnection.get_uri_parts(datasource)
    return project
Beispiel #3
0
def drop_pai_model(datasource, model_name):
    """Drop PAI model

    Args:
        datasource: current datasource
        model_name: name of the model to drop
    """
    user, passwd, address, database = MaxComputeConnection.get_uri_parts(
        datasource)
    cmd = "drop offlinemodel if exists %s" % model_name
    subprocess.run([
        "odpscmd", "-u", user, "-p", passwd, "--project", database,
        "--endpoint", address, "-e", cmd
    ],
                   check=True)
Beispiel #4
0
def submit_pai_task(pai_cmd, datasource):
    """Submit given cmd to PAI which manipulate datasource

    Args:
        pai_cmd: The command to submit
        datasource: The datasource this cmd will manipulate
    """
    user, passwd, address, project = MaxComputeConnection.get_uri_parts(
        datasource)
    cmd = [
        "odpscmd", "--instance-priority", "9", "-u", user, "-p", passwd,
        "--project", project, "--endpoint", address, "-e", pai_cmd
    ]
    exitcode = run_command_and_log(cmd)
    if exitcode != 0:
        raise SQLFlowDiagnostic("Execute odps cmd fail: cmd is %s" %
                                " ".join(cmd))
Beispiel #5
0
def parse_maxcompute_dsn(datasource):
    return MaxComputeConnection.get_uri_parts(datasource)