blob: 9e86099bb364abafceba16c23a6cb3708a835c54 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{144:function(e,t,n){"use strict";n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return d}));var r=n(0),a=n.n(r);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var p=a.a.createContext({}),s=function(e){var t=a.a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},b=function(e){var t=s(e.components);return a.a.createElement(p.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return a.a.createElement(a.a.Fragment,{},t)}},u=a.a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,o=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),b=s(n),u=r,d=b["".concat(o,".").concat(u)]||b[u]||m[u]||i;return n?a.a.createElement(d,c(c({ref:t},p),{},{components:n})):a.a.createElement(d,c({ref:t},p))}));function d(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=u;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c.mdxType="string"==typeof e?e:r,o[1]=c;for(var p=2;p<i;p++)o[p]=n[p];return a.a.createElement.apply(null,o)}return a.a.createElement.apply(null,n)}u.displayName="MDXCreateElement"},63:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return o})),n.d(t,"metadata",(function(){return c})),n.d(t,"toc",(function(){return l})),n.d(t,"default",(function(){return s}));var r=n(3),a=n(7),i=(n(0),n(144)),o={title:"Experiment Client"},c={unversionedId:"userDocs/submarine-sdk/experiment-client",id:"userDocs/submarine-sdk/experiment-client",isDocsHomePage:!1,title:"Experiment Client",description:"\x3c!--",source:"@site/docs/userDocs/submarine-sdk/experiment-client.md",slug:"/userDocs/submarine-sdk/experiment-client",permalink:"/docs/userDocs/submarine-sdk/experiment-client",editUrl:"https://github.com/apache/submarine/edit/master/website/docs/userDocs/submarine-sdk/experiment-client.md",version:"current",sidebar:"docs",previous:{title:"Notebook REST API",permalink:"/docs/userDocs/api/notebook"},next:{title:"Model Client",permalink:"/docs/userDocs/submarine-sdk/model-client"}},l=[{value:"class ExperimentClient()",id:"class-experimentclient",children:[{value:"<code>create_experiment(experiment_spec: json) -&gt; dict</code>",id:"create_experimentexperiment_spec-json---dict",children:[]},{value:"<code>patch_experiment(id: str, experiment_spec: json) -&gt; dict</code>",id:"patch_experimentid-str-experiment_spec-json---dict",children:[]},{value:"<code>get_experiment(id: str) -&gt; dict</code>",id:"get_experimentid-str---dict",children:[]},{value:"<code>list_experiments(status: Optional[str]=None) -&gt; list[dict]</code>",id:"list_experimentsstatus-optionalstrnone---listdict",children:[]},{value:"<code>delete_experiment(id: str) -&gt; dict</code>",id:"delete_experimentid-str---dict",children:[]},{value:"<code>get_log(id: str, onlyMaster: Optional[bool]=False) -&gt; None</code>",id:"get_logid-str-onlymaster-optionalboolfalse---none",children:[]},{value:"<code>list_log(status: str) -&gt; list[dict]</code>",id:"list_logstatus-str---listdict",children:[]},{value:"<code>wait_for_finish(id: str, polling_interval: Optional[int]=10) -&gt; dict</code>",id:"wait_for_finishid-str-polling_interval-optionalint10---dict",children:[]}]}],p={toc:l};function s(e){var t=e.components,n=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(r.a)({},p,n,{components:t,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"class-experimentclient"},"class ExperimentClient()"),Object(i.b)("p",null,"Client of a submarine server that creates and manages experients and logs."),Object(i.b)("h3",{id:"create_experimentexperiment_spec-json---dict"},Object(i.b)("inlineCode",{parentName:"h3"},"create_experiment(experiment_spec: json) -> dict")),Object(i.b)("p",null,"Create an experiment."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"experiment_spec"),": Submarine experiment spec. More detailed information can be found at ",Object(i.b)("a",{parentName:"li",href:"https://submarine.apache.org/docs/userDocs/api/experiment"},"Experiment API"),".\nReturns"),Object(i.b)("li",{parentName:"ul"},"The detailed info about the submarine experiment."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'from submarine import *\nclient = ExperimentClient()\nclient.create_experiment({\n "meta": {\n "name": "tf-mnist-json",\n "namespace": "default",\n "framework": "TensorFlow",\n "cmd": "python /var/tf_mnist/mnist_with_summaries.py --log_dir=/train/log --learning_rate=0.01 --batch_size=150",\n "envVars": {\n "ENV_1": "ENV1"\n }\n },\n "environment": {\n "image": "apache/submarine:tf-mnist-with-summaries-1.0"\n },\n "spec": {\n "Ps": {\n "replicas": 1,\n "resources": "cpu=1,memory=1024M"\n },\n "Worker": {\n "replicas": 1,\n "resources": "cpu=1,memory=1024M"\n }\n }\n})\n')),Object(i.b)("p",null,"Output"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},"{\n 'experimentId': 'experiment_1626160071451_0008', \n 'name': 'tf-mnist-json', 'uid': '3513233e-33f2-4399-8fba-2a44ca2af730', \n 'status': 'Accepted', \n 'acceptedTime': '2021-07-13T21:29:33.000+08:00', \n 'createdTime': None, \n 'runningTime': None, \n 'finishedTime': None, \n 'spec': {\n 'meta': {\n 'name': 'tf-mnist-json', \n 'namespace': 'default', \n 'framework': 'TensorFlow', \n 'cmd': 'python /var/tf_mnist/mnist_with_summaries.py --log_dir=/train/log --learning_rate=0.01 --batch_size=150', \n 'envVars': {'ENV_1': 'ENV1'}\n }, \n 'environment': {\n 'name': None, \n 'dockerImage': None, \n 'kernelSpec': None, \n 'description': None, \n 'image': 'apache/submarine:tf-mnist-with-summaries-1.0'\n }, \n 'spec': {\n 'Ps': {\n 'replicas': 1, \n 'resources': 'cpu=1,memory=1024M', \n 'name': None, \n 'image': None, \n 'cmd': None, \n 'envVars': None, \n 'resourceMap': {'memory': '1024M', 'cpu': '1'}\n }, \n 'Worker': {\n 'replicas': 1, \n 'resources': 'cpu=1,memory=1024M', \n 'name': None, \n 'image': None, \n 'cmd': None, \n 'envVars': None, \n 'resourceMap': {'memory': '1024M', 'cpu': '1'}\n }\n }, \n 'code': None\n }\n}\n")),Object(i.b)("h3",{id:"patch_experimentid-str-experiment_spec-json---dict"},Object(i.b)("inlineCode",{parentName:"h3"},"patch_experiment(id: str, experiment_spec: json) -> dict")),Object(i.b)("p",null,"Patch an experiment."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"id"),": Submarine experiment id. "),Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"experiment_spec"),": Submarine experiment spec. More detailed information can be found at ",Object(i.b)("a",{parentName:"li",href:"https://submarine.apache.org/docs/userDocs/api/experiment"},"Experiment API"),".\n",Object(i.b)("strong",{parentName:"li"},"Returns")),Object(i.b)("li",{parentName:"ul"},"The detailed info about the submarine experiment."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'client.patch_experiment("experiment_1626160071451_0008", {\n "meta": {\n "name": "tf-mnist-json",\n "namespace": "default",\n "framework": "TensorFlow",\n "cmd": "python /var/tf_mnist/mnist_with_summaries.py --log_dir=/train/log --learning_rate=0.01 --batch_size=150",\n "envVars": {\n "ENV_1": "ENV1"\n }\n },\n "environment": {\n "image": "apache/submarine:tf-mnist-with-summaries-1.0"\n },\n "spec": {\n "Worker": {\n "replicas": 2,\n "resources": "cpu=1,memory=1024M"\n }\n }\n})\n')),Object(i.b)("h3",{id:"get_experimentid-str---dict"},Object(i.b)("inlineCode",{parentName:"h3"},"get_experiment(id: str) -> dict")),Object(i.b)("p",null,"Get the experiment's detailed info by id."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"id"),": Submarine experiment id."))),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Returns")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},"The detailed info about the submarine experiment."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'experiment = client.get_experiment("experiment_1626160071451_0008")\n')),Object(i.b)("h3",{id:"list_experimentsstatus-optionalstrnone---listdict"},Object(i.b)("inlineCode",{parentName:"h3"},"list_experiments(status: Optional[str]=None) -> list[dict]")),Object(i.b)("p",null,"List all experiment for the user."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"status"),": Accepted, Created, Running, Succeeded, Deleted."))),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Returns")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},"List of submarine experiments."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},"experiments = client.list_experiments()\n")),Object(i.b)("h3",{id:"delete_experimentid-str---dict"},Object(i.b)("inlineCode",{parentName:"h3"},"delete_experiment(id: str) -> dict")),Object(i.b)("p",null,"Delete the submarine experiment."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"id"),": Submarine experiment id."))),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Returns")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},"The detailed info about the deleted submarine experiment."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'client.delete_experiment("experiment_1626160071451_0008")\n')),Object(i.b)("h3",{id:"get_logid-str-onlymaster-optionalboolfalse---none"},Object(i.b)("inlineCode",{parentName:"h3"},"get_log(id: str, onlyMaster: Optional[bool]=False) -> None")),Object(i.b)("p",null,"Print training logs of all pod of the experiment.\nBy default print all the logs of Pod."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"id"),": Submarine experiment id."),Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"onlyMaster"),': By default include pod log of "master" which might be Tensorflow PS/Chief or PyTorch master.'))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'client.get_log("experiment_1626160071451_0009")\n')),Object(i.b)("p",null,"Output"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre"},"The logs of Pod tf-mnist-json-2-ps-0:\n\nThe logs of Pod tf-mnist-json-2-worker-0:\n\n")),Object(i.b)("h3",{id:"list_logstatus-str---listdict"},Object(i.b)("inlineCode",{parentName:"h3"},"list_log(status: str) -> list[dict]")),Object(i.b)("p",null,"List experiment log."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"status"),": Accepted, Created, Running, Succeeded, Deleted.\n",Object(i.b)("strong",{parentName:"li"},"Returns")),Object(i.b)("li",{parentName:"ul"},"List of submarine experiment logs."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'logs = client.list_log("Succeeded")\n')),Object(i.b)("p",null,"Output"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},"[{'experimentId': 'experiment_1626160071451_0009',\n 'logContent': \n [{'podName': 'tf-mnist-json-2-ps-0', 'podLog': []},\n {'podName': 'tf-mnist-json-2-worker-0', 'podLog': []}]\n}]\n")),Object(i.b)("h3",{id:"wait_for_finishid-str-polling_interval-optionalint10---dict"},Object(i.b)("inlineCode",{parentName:"h3"},"wait_for_finish(id: str, polling_interval: Optional[int]=10) -> dict")),Object(i.b)("p",null,"Waits until the experiment is finished or failed."),Object(i.b)("blockquote",null,Object(i.b)("p",{parentName:"blockquote"},Object(i.b)("strong",{parentName:"p"},"Parameters")),Object(i.b)("ul",{parentName:"blockquote"},Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"id"),": Submarine experiment id."),Object(i.b)("li",{parentName:"ul"},Object(i.b)("strong",{parentName:"li"},"polling_interval"),": How many seconds between two polls for the status of the experiment.\n",Object(i.b)("strong",{parentName:"li"},"Returns")),Object(i.b)("li",{parentName:"ul"},"Submarine experiment logs."))),Object(i.b)("p",null,"Example"),Object(i.b)("pre",null,Object(i.b)("code",{parentName:"pre",className:"language-python"},'logs = client.wait_for_finish("experiment_1626160071451_0009", 5)\n')))}s.isMDXComponent=!0}}]);