Пример #1
0
 def test_parse_maxcompute_dsn(self):
     self.assertEqual(
         ("access_id", "access_key", "http://maxcompute-service.com/api",
          "test_ci"),
         parseMaxComputeDSN(
             "access_id:[email protected]/api?curr_project=test_ci&scheme=http"
         ))
Пример #2
0
def get_oss_model_save_path(datasource, model_name):
    if not model_name:
        return None
    dsn = get_datasource_dsn(datasource)
    user, _, _, project = db.parseMaxComputeDSN(dsn)
    user = user or "unknown"
    return "/".join([project, user, model_name])
Пример #3
0
def get_project(datasource):
    """Get the project info from given datasource

    Args:
        datasource: The odps url to extract project
    """
    dsn = get_datasource_dsn(datasource)
    _, _, _, project = db.parseMaxComputeDSN(dsn)
    return project
Пример #4
0
def drop_pai_model(datasource, model_name):
    """Drop PAI model

    Args:
        datasource: current datasource
        model_name: name of the model to drop
    """
    dsn = get_datasource_dsn(datasource)
    user, passwd, address, database = db.parseMaxComputeDSN(dsn)
    cmd = "drop offlinemodel if exists %s" % model_name
    subprocess.run([
        "odpscmd", "-u", user, "-p", passwd, "--project", database,
        "--endpoint", address, "-e", cmd
    ],
                   check=True)
Пример #5
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
    """
    dsn = get_datasource_dsn(datasource)
    user, passwd, address, project = db.parseMaxComputeDSN(dsn)
    cmd = [
        "odpscmd", "--instance-priority", "9", "-u", user, "-p", passwd,
        "--project", project, "--endpoint", address, "-e", pai_cmd
    ]
    print(" ".join(cmd))
    if subprocess.call(cmd) != 0:
        raise SQLFlowDiagnostic("Execute odps cmd fail: cmd is %s" %
                                " ".join(cmd))