FlowServerSDK
Introduction¶
We will describe how to use the flow_server_sdk
sdk library to interact with iflearner_flow_server
service.
Installation¶
You can execute the following command to quickly install:
Then you can reference theflow_server_sdk
library for interface calls
Initialization¶
We need to initialize the operation first, mainly to complete the relevant parameters of configuring the connection service, and generate a client object.
Parameters
parameter | required | type | description |
---|---|---|---|
host | yes | string | The host for connecting iflearner_flow_server server |
port | yes | string | The port for connecting iflearner_flow_server server |
Usage
from flow_server_sdk import FlowServerSdk
# use real ip address to initialize SDK
flow_server_client = FlowServerSdk(host="127.0.0.1", port="1235")
Template¶
create¶
Create a task template.
Function
create(
cls,
name: str,
image_url: str,
workdir: str,
command: List[str],
remark: str = None,
hyper_parameter: list = None,
) -> Dict[str, Any]
Parameters
parameter | required | type | description |
---|---|---|---|
name | yes | string | Template name |
image_url | yes | string | Image url address of template configuration |
workdir | yes | string | Image workdir |
command | yes | array | Image startup command |
remark | no | string | Template description |
hyper_parameter | no | array | Hyper parameter passed by image startup |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data.template_id | string | Generated template id |
Call Example
flow_server_client.template.create(
name="template_01",
image_url="iflearner_ocr:0.0.1",
workdir="/data/ocr/script",
command=[],
remark="",
hyper_parameter = [],
)
Return Example
{
"ret_code": 0,
"ret_msg": "success",
"data": {
"template_id": "20f42769b99b492691da1ba2f236b1"
}
}
update¶
Update a specified template.
Function
update(
cls,
template_id: str,
name: str,
image_url: str,
workdir: str,
command: List[str],
remark: str = None,
hyper_parameter: list = None,
) -> Dict[str, Any]
Parameters
parameter | required | type | description |
---|---|---|---|
template_id | yes | string | The id of template |
name | yes | string | Template name |
image_url | yes | string | Image url address of template configuration |
workdir | yes | string | Image workdir |
command | yes | array | Image startup command |
remark | no | string | Template description |
hyper_parameter | no | array | Hyper parameter passed by image startup |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
flow_server_client.template.update(
template_id="20f42769b99b492691da1ba2f236b1",
name="template_01",
image_url="iflearner_ocr:0.0.2",
workdir="/data/ocr/script",
command=[],
)
Return Example
get¶
Query a specified template.
Function
Parameters
parameter | required | type | description |
---|---|---|---|
template_id | yes | string | The id of template |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data.name | string | Template name |
data.remark | string | Template remark |
data.image_url | string | The url address of the template image |
data.workdir | string | The working directory of the template image |
data.command | array | Image startup command |
data.hyper_parameter | array | Hyperparameters for mirror startup |
data.template_id | string | Unique ID of the template |
data.create_time | string | Template creation time |
data.modify_time | string | Template update time |
Call Example
Return 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¶
Batch query template information
Function
Parameters
parameter | required | type | description |
---|---|---|---|
page | no | int | The current page |
limit | no | int | The query num of current page |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data.templates[index].name | string | Template name |
data.templates[index].remark | string | Template remarks |
data.templates[index].image_url | string | URL of template image |
data.templates[index].workdir | string | The working directory of the template image |
data.templates[index].command | array | Image startup command |
data.templates[index].hyper_parameter | array | Hyperparameters for mirror startup |
data.templates[index].template_id | string | Unique ID of the template |
data.templates[index].create_time | string | Template creation time |
data.templates[index].modify_time | string | Template update time |
Call Example
Return 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¶
Delete a specified template.
Function
Parameters
parameter | required | type | description |
---|---|---|---|
template_id | yes | string | The id of template |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
Return Example
Task¶
Create¶
create task
Function
create(
cls,
name: str,
template_id: str,
remark: str,
federate_data: List[Any],
) -> Dict[str, Any]
Parameters
parameter | required | type | description |
---|---|---|---|
name | yes | string | the name of task |
template_id | yes | string | task-related template |
remark | no | string | task remark |
federate_data | yes | array | task-related federate |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data.task_id | string | task id |
Call Example
flow_server_client.task.create(
name="testCase1",
template_id="ea0f10bfbaf64a74a061d54c94cc69",
remark="This is a remark.",
federate_data=[{"federated_id": "federate-1", "federated_data": ""}],
)
Return Example
Update¶
update task
Function
update(cls,
task_id: str,
name: str,
template_id: str,
remark: str,
federate_data: List,
) -> Dict[str, Any]
Parameters
parameter | required | type | description |
---|---|---|---|
task_id | yes | string | task id |
name | yes | string | the name of task |
template_id | yes | string | task-related template |
remark | no | string | task remark |
federate_data | yes | array | task-related federate |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
flow_server_client.task.update(
task_id="0578abed1032425499abd20f2ef67938",
name="testCase",
template_id="ea0f10bfbaf64a74a061d54c94cc69",
remark="This is a remark.",
federate_data=[{"federated_id": "federate-1", "federated_data": "aa"}],
)
Return Example
Get¶
get task detail
Function
Parameters
parameter | required | type | description |
---|---|---|---|
task_id | yes | string | task id |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data | dict | task detail |
Call Example
Return 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¶
get task list
Function
Parameters
parameter | required | type | description |
---|---|---|---|
page | yes | int | page index |
limit | yes | int | page size |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
data.task_count | int | total task number |
data.tasks | array | task list |
Call Example
Return 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¶
delete task
Function
Parameters
parameter | required | type | description |
---|---|---|---|
task_id | yes | string | task id |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
Return Example
Start¶
start task
Function
Parameters
parameter | required | type | description |
---|---|---|---|
task_id | yes | string | task id |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
Return Example
Stop¶
stop task
Function
Parameters
parameter | required | type | description |
---|---|---|---|
task_id | yes | string | task id |
Return
parameter | type | description |
---|---|---|
ret_code | int | Return code |
ret_msg | string | Return information |
Call Example
Return Example