跳转至

FlowServerCLI

Introduction

首先,我们将通过下述命令快速安装:

pip install iflearner-flow-client

接下来,我们将介绍如何使用命令行工具flow_server_cliiflearner_flow_server进行交互,以下是子命令。

Usage: flow_server_cli [OPTIONS] COMMAND [ARGS]...

  Iflearner Flow Server  Cli.

Options:
  -h, --help  Show this message and exit.

Commands:
  init      Iflearner Server Flow Cli Init Command
  task      Task Operations Group
  template  Template Operations Group

具体命令用法如下。

Initialization

在使用命令行之前,我们需要初始化操作,主要是配置连接服务的相关参数

Usage

flow_server_cli init [OPTIONS]

OPTIONS

参数名称 必填 类型 描述
--host string 连接iflearner_flow_server的ip地址
--port string 连接iflearner_flow_server的端口

Request Example

flow_server_cli init --host 127.0.0.1 --port 1235

Request Example

{
  "ret_code": 0,
  "ret_message": "success"
}

Template

create

创建一个任务模板

Usage

flow_server_cli template create [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-n, --template_name string 模板名称
-r, --remark string 模板说明
-i, --image_url string 模板配置的镜像url地址
-w, --workdir string 镜像workdir
-c, --command string 镜像启动命令
-hp, --hyper_parameter string 镜像启动传递的超参

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.template_id string 生成的模板id

Request Example

flow_server_cli template create -n template_01 -r 'template test' -i pytorch_ocr:latest -w /data/ocr -c '["python", "run.py"]' -hp '["epoch=1"]'

Response Example

{
  "ret_code": 0,
  "ret_msg": "success",
  "data": {
    "template_id": "20f42769b99b492691da1ba2f236b1"
  }
}

update

更新一个任务模板

Usage

flow_server_cli template update [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --template_id string 模板的唯一标识
-n, --template_name string 模板名称
-r, --remark string 模板说明
-i, --image_url string 模板配置的镜像url地址
-w, --workdir string 镜像workdir
-c, --command string 镜像启动命令
-hp, --hyper_parameter array 镜像启动传递的超参

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.template_id string 生成的模板id

Request Example

flow_server_cli template update -id 20f42769b99b492691da1ba2f236b1 -n template_01 -r 'template test' -i pytorch_ocr:latest -w /data/ocr -c '["python", "run.py"]' -hp '["epoch=1"]'

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}

get

查询一个任务模板信息

Usage

flow_server_cli template get [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --template_id string 模板的唯一标识

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.name string 模板名称
data.remark string 模板备注
data.image_url string 模板镜像的url地址
data.workdir string 模板镜像的工作目录
data.command array 镜像启动命令
data.hyper_parameter array 镜像启动的超参
data.template_id string 模板的唯一标识
data.create_time string 模板的创建时间
data.modify_time string 模板的更新时间

Request Example

flow_server_cli template get -id 20f42769b99b492691da1ba2f236b1

Response Example

{
  "ret_code": 0,
  "ret_msg": "success",
  "data": {
    "name": "template_003",
    "remark": "template test",
    "image_url": "pytorch_ocr:latest",
    "workdir": "/data/ocr",
    "command": [
      "python",
      "run.py"
    ],
    "hyper_parameter": [
      "epoch=1"
    ],
    "template_id": "20f42769b99b492691da1ba2f236b1",
    "create_time": "Mon, 25 Jul 2022 15:59:55 -0000",
    "modify_time": "Mon, 25 Jul 2022 15:59:55 -0000"
  }
}

list

批量查询模板信息

Usage

flow_server_cli template list [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-p, --page int 当前页,默认为1
-l, --limit int 当前页查询的数目,默认为10

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.templates[index].name string 模板名称
data.templates[index].remark string 模板备注
data.templates[index].image_url string 模板镜像的url地址
data.templates[index].workdir string 模板镜像的工作目录
data.templates[index].command array 镜像启动命令
data.templates[index].hyper_parameter array 镜像启动的超参
data.templates[index].template_id string 模板的唯一标识
data.templates[index].create_time string 模板的创建时间
data.templates[index].modify_time string 模板的更新时间

Request Example

flow_server_cli template list -p 1 -l 2

Rexponse Example

{
  "ret_code": 0,
  "ret_msg": "success",
  "data": {
    "templates": [
      {
        "name": "f5b75371-5dc0-47c6-9a8d-86cd3e06b56a",
        "remark": "",
        "image_url": "iflearner_ocr:0.0.1",
        "workdir": "/data/ocr/script",
        "command": [],
        "hyper_parameter": null,
        "template_id": "0381e7b3bedb4578a3b5a8d11cd65d",
        "create_time": "Wed, 20 Jul 2022 16:39:19 -0000",
        "modify_time": "Wed, 20 Jul 2022 16:39:19 -0000"
      },
      {
        "name": "707fc798-774a-44be-9844-019c4a7e6714",
        "remark": "",
        "image_url": "iflearner_ocr:0.0.1",
        "workdir": "/data/ocr/script",
        "command": [],
        "hyper_parameter": null,
        "template_id": "0596cb767f0448f4b4fa4f11f65fa8",
        "create_time": "Wed, 20 Jul 2022 17:06:20 -0000",
        "modify_time": "Wed, 20 Jul 2022 17:06:20 -0000"
      }
    ],
    "template_count": 108
  }
}

delete

删除一个指定的任务模板

Usage

flow_server_cli template delete [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --template_id string 模板的唯一标识

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息

Request Example

flow_server_cli template delete -id 20f42769b99b492691da1ba2f236b1

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}

Task

create

创建任务

Usage

flow_server_cli task create [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-n, --task_name string 任务名称
-t, --template_id string 任务关联的模板
-r, --remark string 任务备注
-fd, --federate_data array 任务关联的联邦方信息

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.task_id string task id

Request Example

flow_server_cli task create -n task01 -t ea0f10bfbaf64a74a061d54c94cc69 -r "This is a remark." -fd '[{"federated_id": "federate-1", "federated_data": ""}]'

Response Example

{
    "data": {
        "task_id": "b1731d312dae4edba6d07a6fff547b4a"
    },
    "ret_code": 0,
    "ret_msg": "success"
}

update

更新任务

Usage

flow_server_cli task update [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --task_id string 任务id
-n, --task_name string 任务名称
-t, --template_id string 任务关联模板
-r, --remark string 任务备注
-fd, --federate_data array 任务关联的联邦方信息

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息

Request Example

flow_server_cli task update -id bbc0c30e96bc4da29b2b326fb1f8786e -n task01 -t ea0f10bfbaf64a74a061d54c94cc69 -r "This is a new remark." -fd '[{"federated_id": "federate-1", "federated_data": ""}]'

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}

get

获取任务详情

Usage

flow_server_cli task get [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --task_id string 任务id

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data dict 任务详情

Request Example

flow_server_cli task get -id bbc0c30e96bc4da29b2b326fb1f8786e

Response Example

{
    "data": {
        "create_time": "Mon, 25 Jul 2022 20:31:21 -0000",
        "federate_data": [
            {
                "federated_data": "aa",
                "federated_id": "federate-1"
            }
        ],
        "modify_time": "Mon, 25 Jul 2022 20:31:21 -0000",
        "name": "testCase",
        "party_status": null,
        "remark": "This is a remark.",
        "status": null,
        "task_id": "0578abed1032425499abd20f2ef67938",
        "template_id": "ea0f10bfbaf64a74a061d54c94cc69"
    },
    "ret_code": 0,
    "ret_msg": "success"
}

list

获取任务列表

Usage

flow_server_cli task list [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-p, --page int 当前页,默认为1
-l, --limit int 当前页查询的数目,默认为10

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息
data.task_count int 任务总数
data.tasks array 当前页的任务列表

Request Example

flow_server_cli task list -p 1 -l 10

Response Example

{
    "data": {
        "task_count": 1,
        "tasks": [
            {
                "create_time": "Tue, 26 Jul 2022 16:05:59 -0000",
                "federate_data": [
                    {
                        "federated_data": "",
                        "federated_id": "federate-1"
                    }
                ],
                "modify_time": "Tue, 26 Jul 2022 16:05:59 -0000",
                "name": "testCase1",
                "party_status": null,
                "remark": "This is a remark.",
                "status": null,
                "task_id": "b1731d312dae4edba6d07a6fff547b4a",
                "template_id": "ea0f10bfbaf64a74a061d54c94cc69"
            }
        ]
    },
    "ret_code": 0,
    "ret_msg": "success"
}

delete

删除任务

Usage

flow_server_cli task delete [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --task_id string 任务id

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息

Request Example

flow_server_cli task delete -id 20f42769b99b492691da1ba2f236b1

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}

start

开始任务

Usage

flow_server_cli task start [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --task_id string 任务id

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息

Request Example

flow_server_cli task start -id 20f42769b99b492691da1ba2f236b1

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}

stop

停止任务

Usage

flow_server_cli task stop [OPTIONS]

OPTIONS

参数名 必选 类型 说明
-id, --task_id string 任务id

Response

参数名 类型 说明
ret_code int 返回码
ret_msg string 返回信息

Request Example

flow_server_cli task stop -id 20f42769b99b492691da1ba2f236b1

Response Example

{
  "ret_code": 0,
  "ret_msg": "success"
}