This project has retired. For details please refer to its Attic page.
Experiment Template REST API | Apache Submarine
Skip to main content
Version: 0.6.0

Experiment Template REST API

Create Experiment Template

POST /api/v1/template

Parameters

Field NameTypeInDescription
nameStringbodyExperiment template name. This is required.
authorStringbodyAuthor name.
descriptionStringbodyDescription of the experiment template.
parametersList<ExperimentTemplateParamSpec>bodyParameters of the experiment template.
experimentSpecExperimentSpecbodySpec of the experiment template.

ExperimentTemplateParamSpec

Field NameTypeDescription
nameStringParameter name.
requiredBooleantrue / false. Whether the parameter is required.
descriptionStringDescription of the parameter.
valueStringValue of the parameter.

ExperimentSpec

Field NameTypeDescription
metaExperimentMetaMeta data of the experiment template.
environmentEnvironmentSpecEnvironment of the experiment template.
specMap<String, ExperimentTaskSpec>Spec of pods.
codeCodeSpecExperiment codespec.

ExperimentMeta

Field NameTypeDescription
nameStringExperiment Name.
namespaceStringExperiment namespace.
frameworkStringExperiment framework.
cmdStringCommand.
envVarsMap<String, String>Environmental variables.

EnvironmentSpec

See more details in environment api.

ExperimentTaskSpec

Field NameTypeDescription
replicasIntegerNumbers of replicas.
resourecesStringResouces of the task
nameStringTask name.
imageStringImage name.
cmdStringCommand.
envVarsMap<String, String>Environmental variables.

CodeSpec

Field NameTypeDescription
syncModeStringsync mode of code spec.
urlStringurl of code spec.

Code Example

shell

curl -X POST -H "Content-Type: application/json" -d '
{
"name": "my-tf-mnist-template",
"author": "author",
"description": "This is a template to run tf-mnist",
"parameters": [{
"name": "learning_rate",
"value": 0.1,
"required": true,
"description": "This is learning_rate of training."
},
{
"name": "batch_size",
"value": 150,
"required": true,
"description": "This is batch_size of training."
},
{
"name": "experiment_name",
"value": "tf-mnist1",
"required": true,
"description": "the name of experiment."
}
],
"experimentSpec": {
"meta": {
"cmd": "python /var/tf_mnist/mnist_with_summaries.py --log_dir=/train/log --learning_rate={{learning_rate}} --batch_size={{batch_size}}",
"name": "{{experiment_name}}",
"envVars": {
"ENV1": "ENV1"
},
"framework": "TensorFlow",
"namespace": "default"
},
"spec": {
"Ps": {
"replicas": 1,
"resources": "cpu=1,memory=1024M"
},
"Worker": {
"replicas": 1,
"resources": "cpu=1,memory=1024M"
}
},
"environment": {
"image": "apache/submarine:tf-mnist-with-summaries-1.0"
}
}
}
' http://127.0.0.1:32080/api/v1/template

response

{
"status":"OK",
"code":200,
"success":true,
"message":null,
"result":{
"experimentTemplateId":{
"id":1,
"serverTimestamp":1626160071451
},
"experimentTemplateSpec":{
"name":"my-tf-mnist-template",
"author":"author",
"description":"This is a template to run tf-mnist",
"parameters":
[{
"name":"learning_rate",
"required":"true",
"description":"This is learning_rate of training.",
"value":"0.1"
},
{
"name":"batch_size",
"required":"true",
"description":"This is batch_size of training.",
"value":"150"
},
{
"name":"experiment_name",
"required":"true",
"description":"the name of experiment.",
"value":"tf-mnist1"
},
{
"name":"spec.Ps.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
},
{
"name":"spec.Worker.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.memory",
"required":"false",
"description":"","
value":"1024M"
}],
"experimentSpec":{
"meta":{
"name":"{{experiment_name}}",
"namespace":"default",
"framework":"TensorFlow",
"cmd":"python /var/tf_mnist/mnist_with_summaries.py --log_dir\u003d/train/log --learning_rate\u003d{{learning_rate}} --batch_size\u003d{{batch_size}}",
"envVars":{"ENV1":"ENV1"}
},
"environment":{
"name":null,
"dockerImage":null,
"kernelSpec":null,
"description":null,
"image":"apache/submarine:tf-mnist-with-summaries-1.0"
},
"spec":{
"Ps":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{
"memory":"1024M",
"cpu":"1"
}
},
"Worker":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{
"memory":"1024M",
"cpu":"1"
}
}
},
"code":null
}
}
},
"attributes":{}
}

List Experiment Template

GET /api/v1/template

Code Example

shell

curl -X GET http://127.0.0.1:32080/api/v1/template

response

{
"status":"OK",
"code":200,
"success":true,
"message":null,
"result":{
[{
"experimentTemplateId":{
"id":1,
"serverTimestamp":1626160071451
},
"experimentTemplateSpec":{
"name":"my-tf-mnist-template",
"author":"author",
"description":"This is a template to run tf-mnist",
"parameters":
[{
"name":"learning_rate",
"required":"true",
"description":"This is learning_rate of training.",
"value":"0.1"
},
{
"name":"batch_size",
"required":"true",
"description":"This is batch_size of training.",
"value":"150"
},
{
"name":"experiment_name",
"required":"true",
"description":"the name of experiment.",
"value":"tf-mnist1"
},
{
"name":"spec.Ps.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
},
{
"name":"spec.Worker.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.memory",
"required":"false",
"description":"","
value":"1024M"
}],
"experimentSpec":{
"meta":{
"name":"{{experiment_name}}",
"namespace":"default",
"framework":"TensorFlow",
"cmd":"python /var/tf_mnist/mnist_with_summaries.py --log_dir\u003d/train/log --learning_rate\u003d{{learning_rate}} --batch_size\u003d{{batch_size}}",
"envVars":{"ENV1":"ENV1"}
},
"environment":{
"name":null,
"dockerImage":null,
"kernelSpec":null,
"description":null,
"image":"apache/submarine:tf-mnist-with-summaries-1.0"
},
"spec":{
"Ps":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{
"memory":"1024M",
"cpu":"1"
}
},
"Worker":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{
"memory":"1024M",
"cpu":"1"
}
}
},
"code":null
}
}
}],
"attributes":{}
}

Patch Experiment Template

PATCH /api/v1/template{name}

Parameters

Field NameTypeInDescription
nameStringpath and bodyExperiment template name. This is required.
authorStringbodyAuthor name.
descriptionStringbodyDescription of the experiment template.
parametersList<ExperimentTemplateParamSpec>bodyParameters of the experiment template.
experimentSpecExperimentSpecbodySpec of the experiment template.

Code Example

shell

curl -X PATCH -H "Content-Type: application/json" -d '
{
"name": "my-tf-mnist-template",
"author": "author-new",
"description": "This is a template to run tf-mnist",
"parameters": [{
"name": "learning_rate",
"value": 0.1,
"required": true,
"description": "This is learning_rate of training."
},
{
"name": "batch_size",
"value": 150,
"required": true,
"description": "This is batch_size of training."
},
{
"name": "experiment_name",
"value": "tf-mnist1",
"required": true,
"description": "the name of experiment."
}
],
"experimentSpec": {
"meta": {
"cmd": "python /var/tf_mnist/mnist_with_summaries.py --log_dir=/train/log --learning_rate={{learning_rate}} --batch_size={{batch_size}}",
"name": "{{experiment_name}}",
"envVars": {
"ENV1": "ENV1"
},
"framework": "TensorFlow",
"namespace": "default"
},
"spec": {
"Ps": {
"replicas": 1,
"resources": "cpu=1,memory=1024M"
},
"Worker": {
"replicas": 1,
"resources": "cpu=1,memory=1024M"
}
},
"environment": {
"image": "apache/submarine:tf-mnist-with-summaries-1.0"
}
}
}
' http://127.0.0.1:32080/api/v1/template/my-tf-mnist-template

response

{
"status":"OK",
"code":200,
"success":true,
"message":null,
"result":{
"experimentTemplateId":{
"id":2,
"serverTimestamp":1626160071451
},
"experimentTemplateSpec":{
"name":"my-tf-mnist-template",
"author":"author-new",
"description":"This is a template to run tf-mnist",
"parameters":
[{
"name":"learning_rate",
"required":"true",
"description":"This is learning_rate of training.",
"value":"0.1"
},
{
"name":"batch_size",
"required":"true",
"description":"This is batch_size of training.",
"value":"150"
},
{
"name":"experiment_name",
"required":"true",
"description":"the name of experiment.",
"value":"tf-mnist1"
},
{
"name":"spec.Ps.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
},
{
"name":"spec.Worker.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
}],
"experimentSpec":{
"meta":{
"name":"{{experiment_name}}",
"namespace":"default",
"framework":"TensorFlow",
"cmd":"python /var/tf_mnist/mnist_with_summaries.py --log_dir\u003d/train/log --learning_rate\u003d{{learning_rate}} --batch_size\u003d{{batch_size}}",
"envVars":{"ENV1":"ENV1"}
},
"environment":{
"name":null,
"dockerImage":null,
"kernelSpec":null,
"description":null,
"image":"apache/submarine:tf-mnist-with-summaries-1.0"
},
"spec":{
"Ps":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
},
"Worker":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
}
},
"code":null
}
}
},
"attributes":{}
}

Delete Experiment Template

DELETE /api/v1/template{name}

Parameters

Field NameTypeInDescription
nameStringpathExperiment template name. This is required.

Code Example

shell

curl -X DELETE http://127.0.0.1:32080/api/v1/template/my-tf-mnist-template

reponse

{
"status":"OK",
"code":200,
"success":true,
"message":null,
"result":{
"experimentTemplateId":{
"id":2,
"serverTimestamp":1626160071451
},
"experimentTemplateSpec":{
"name":"my-tf-mnist-template",
"author":"author-new",
"description":"This is a template to run tf-mnist",
"parameters":
[{
"name":"learning_rate",
"required":"true",
"description":"This is learning_rate of training.",
"value":"0.1"
},
{
"name":"batch_size",
"required":"true",
"description":"This is batch_size of training.",
"value":"150"
},
{
"name":"experiment_name",
"required":"true",
"description":"the name of experiment.",
"value":"tf-mnist1"
},
{
"name":"spec.Ps.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Ps.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
},
{
"name":"spec.Worker.replicas",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.cpu",
"required":"false",
"description":"",
"value":"1"
},
{
"name":"spec.Worker.resourceMap.memory",
"required":"false",
"description":"",
"value":"1024M"
}],
"experimentSpec":{
"meta":{
"name":"{{experiment_name}}",
"namespace":"default",
"framework":"TensorFlow",
"cmd":"python /var/tf_mnist/mnist_with_summaries.py --log_dir\u003d/train/log --learning_rate\u003d{{learning_rate}} --batch_size\u003d{{batch_size}}",
"envVars":{"ENV1":"ENV1"}
},
"environment":{
"name":null,
"dockerImage":null,
"kernelSpec":null,
"description":null,
"image":"apache/submarine:tf-mnist-with-summaries-1.0"
},
"spec":{
"Ps":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
},
"Worker":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
}
},
"code":null
}
}
},
"attributes":{}
}

Use Template to Create a Experiment

POST /api/v1/experiment/{template_name}

Parameters

Field NameTypeInDescription
template_nameStringpathExperiment template name.
nameStringbodyExperiment template name.
paramsMap<String, String>bodyParameters of the experiment including experiment_name.

Code Example

shell

curl -X POST -H "Content-Type: application/json" -d '
{
"name": "tf-mnist",
"params": {
"learning_rate":"0.01",
"batch_size":"150",
"experiment_name":"newexperiment1"
}
}
' http://127.0.0.1:32080/api/v1/experiment/my-tf-mnist-template

response

{
"status":"OK",
"code":200,
"success":true,
"message":null,
"result":{
"experimentId":"experiment_1626160071451_0001",
"name":"newexperiment1",
"uid":"b895985c-411c-4e89-90e0-c60a2a8a4235",
"status":"Accepted",
"acceptedTime":"2021-07-13T16:21:31.000+08:00",
"createdTime":null,
"runningTime":null,
"finishedTime":null,
"spec":{
"meta":{
"name":"newexperiment1",
"namespace":"default",
"framework":"TensorFlow",
"cmd":"python /var/tf_mnist/mnist_with_summaries.py --log_dir\u003d/train/log --learning_rate\u003d0.01 --batch_size\u003d150",
"envVars":{"ENV1":"ENV1"}
},
"environment":{
"name":null,
"dockerImage":null,
"kernelSpec":null,
"description":null,
"image":"apache/submarine:tf-mnist-with-summaries-1.0"
},
"spec":{
"Ps":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
},
"Worker":{
"replicas":1,
"resources":"cpu\u003d1,memory\u003d1024M",
"name":null,
"image":null,
"cmd":null,
"envVars":null,
"resourceMap":{"memory":"1024M","cpu":"1"}
}
},
"code":null
}
},
"attributes":{}
}