From 514fa33e0c6143cde51c965aa1f0427f16829b67 Mon Sep 17 00:00:00 2001 From: JohnTing Date: Mon, 30 Nov 2020 02:18:29 +0800 Subject: [PATCH] SUBMARINE-678. add pytorch template to mysql ### What is this PR for? The only predefined template currently in the database is tf-mnist I add the pytorch template into the database The following is the content ` { "name": "pytorch-mnist", "author": "author", "description": "This is a template to run pytorch-mnist\n", "parameters": [ { "name": "experiment_name", "required": "true", "description": "experiment name", "value": null } ], "experimentSpec": { "meta": { "name": "{{experiment_name}}", "namespace": "default", "framework": "PyTorch", "cmd": "python /var/mnist.py --backend gloo", "envVars": { "ENV_1": "ENV1" } }, "environment": { "image": "apache/submarine:pytorch-dist-mnist-1.0" }, "spec": { "Master": { "replicas": 1, "resources": "cpu=1,memory=1024M" }, "Worker": { "replicas": 1, "resources": "cpu=1,memory=1024M" } } } } ` ### What type of PR is it? Improvement ### Todos * [O] - add pytorch-mnist to database ### What is the Jira issue? https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-678 ### How should this be tested? ` curl -X POST -H "Content-Type: application/json" -d ' { "params": { "experiment_name":"new-pytorch-mnist" } } ' http://127.0.0.1:8080/api/v1/experiment/pytorch-mnist ` ### Screenshots (if appropriate) ![image](https://user-images.githubusercontent.com/19265751/100550083-6d0bf600-32b2-11eb-87f2-95d7aadd66a9.png) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: JohnTing Closes #466 from JohnTing/SUBMARINE-678 and squashes the following commits: 4c173b3 [JohnTing] add doc 65c0dd1 [JohnTing] Fix typo: pytprch->pytorch 9946e32 [JohnTing] add pytprch-mnist template to database --- docs/database/submarine-data.sql | 2 ++ docs/userdocs/k8s/run-experiment-template-rest.md | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/docs/database/submarine-data.sql b/docs/database/submarine-data.sql index e54322fb00..93ed13d0d7 100644 --- a/docs/database/submarine-data.sql +++ b/docs/database/submarine-data.sql @@ -92,3 +92,5 @@ INSERT INTO `environment` VALUES -- ---------------------------- INSERT INTO `experiment_template` (`id`, `experimentTemplate_name`, `experimentTemplate_spec`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES ('experimentTemplate_1599498007985_0013', 'tf-mnist', '{\"name\": \"tf-mnist\", \"author\": \"author\", \"parameters\": [{\"name\": \"learning_rate\", \"value\": \"0.2\", \"required\": \"false\", \"description\": \"The parameter of train mnist.\"}, {\"name\": \"batch_size\", \"value\": \"150\", \"required\": \"false\", \"description\": \"The parameter of train mnist.\"}, {\"name\": \"experiment_name\", \"required\": \"true\", \"description\": \"experiment name, you should change it to avoid duplication with other experiment names.\"}, {\"name\": \"spec.Ps.replicas\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Ps.resourceMap.cpu\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Ps.resourceMap.memory\", \"value\": \"1000M\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.replicas\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.resourceMap.cpu\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.resourceMap.memory\", \"value\": \"1000M\", \"required\": \"false\", \"description\": \"\"}], \"description\": \"This is a template to run tf-mnist.\", \"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=1000M\", \"resourceMap\": {\"cpu\": \"1\", \"memory\": \"1000M\"}}, \"Worker\": {\"replicas\": 1, \"resources\": \"cpu=1,memory=1000M\", \"resourceMap\": {\"cpu\": \"1\", \"memory\": \"1000M\"}}}, \"environment\": {\"image\": \"apache/submarine:tf-mnist-with-summaries-1.0\"}}}', NULL, '2020-09-10 16:31:32', NULL, '2020-10-19 17:05:21'); + +INSERT INTO `experiment_template` (`id`, `experimentTemplate_name`, `experimentTemplate_spec`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES('experimentTemplate_1606489231336_0014', 'pytorch-mnist', '{\"name\": \"pytorch-mnist\", \"author\": \"author\", \"parameters\": [{\"name\": \"experiment_name\", \"required\": \"true\", \"description\": \"experiment name\"}, {\"name\": \"spec.Master.replicas\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Master.resourceMap.cpu\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Master.resourceMap.memory\", \"value\": \"1024M\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.replicas\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.resourceMap.cpu\", \"value\": \"1\", \"required\": \"false\", \"description\": \"\"}, {\"name\": \"spec.Worker.resourceMap.memory\", \"value\": \"1024M\", \"required\": \"false\", \"description\": \"\"}], \"description\": \"This is a template to run pytorch-mnist\\n\", \"experimentSpec\": {\"meta\": {\"cmd\": \"python /var/mnist.py --backend gloo\", \"name\": \"{{experiment_name}}\", \"envVars\": {\"ENV_1\": \"ENV1\"}, \"framework\": \"PyTorch\", \"namespace\": \"default\"}, \"spec\": {\"Master\": {\"replicas\": 1, \"resources\": \"cpu=1,memory=1024M\", \"resourceMap\": {\"cpu\": \"1\", \"memory\": \"1024M\"}}, \"Worker\": {\"replicas\": 1, \"resources\": \"cpu=1,memory=1024M\", \"resourceMap\": {\"cpu\": \"1\", \"memory\": \"1024M\"}}}, \"environment\": {\"image\": \"apache/submarine:pytorch-dist-mnist-1.0\"}}}', NULL, '2020-11-29 17:56:10', NULL, '2020-11-29 17:56:10'); diff --git a/docs/userdocs/k8s/run-experiment-template-rest.md b/docs/userdocs/k8s/run-experiment-template-rest.md index 055009057e..183f760f43 100644 --- a/docs/userdocs/k8s/run-experiment-template-rest.md +++ b/docs/userdocs/k8s/run-experiment-template-rest.md @@ -40,4 +40,15 @@ curl -X POST -H "Content-Type: application/json" -d ' ' http://127.0.0.1:8080/api/v1/experiment/my-tf-mnist-template ``` +**Example Request:** +```sh +curl -X POST -H "Content-Type: application/json" -d ' +{ + "params": { + "experiment_name":"new-pytorch-mnist" + } +} +' http://127.0.0.1:8080/api/v1/experiment/pytorch-mnist +``` + Register experiment template and more info see [Experiment Template API Reference](api/experiment-template.md).