blob: 64942f6888e683e2094a3fd67e0dc71cb0a95124 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{144:function(e,n,t){"use strict";t.d(n,"a",(function(){return u})),t.d(n,"b",(function(){return d}));var r=t(0),a=t.n(r);function o(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function i(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function l(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?i(Object(t),!0).forEach((function(n){o(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function c(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}var s=a.a.createContext({}),p=function(e){var n=a.a.useContext(s),t=n;return e&&(t="function"==typeof e?e(n):l(l({},n),e)),t},u=function(e){var n=p(e.components);return a.a.createElement(s.Provider,{value:n},e.children)},b={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},m=a.a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,o=e.originalType,i=e.parentName,s=c(e,["components","mdxType","originalType","parentName"]),u=p(t),m=r,d=u["".concat(i,".").concat(m)]||u[m]||b[m]||o;return t?a.a.createElement(d,l(l({ref:n},s),{},{components:t})):a.a.createElement(d,l({ref:n},s))}));function d(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var o=t.length,i=new Array(o);i[0]=m;var l={};for(var c in n)hasOwnProperty.call(n,c)&&(l[c]=n[c]);l.originalType=e,l.mdxType="string"==typeof e?e:r,i[1]=l;for(var s=2;s<o;s++)i[s]=t[s];return a.a.createElement.apply(null,i)}return a.a.createElement.apply(null,t)}m.displayName="MDXCreateElement"},64:function(e,n,t){"use strict";t.r(n),t.d(n,"frontMatter",(function(){return i})),t.d(n,"metadata",(function(){return l})),t.d(n,"toc",(function(){return c})),t.d(n,"default",(function(){return p}));var r=t(3),a=t(7),o=(t(0),t(144)),i={title:"Submarine Python SDK"},l={unversionedId:"gettingStarted/python-sdk",id:"gettingStarted/python-sdk",isDocsHomePage:!1,title:"Submarine Python SDK",description:"\x3c!--",source:"@site/docs/gettingStarted/python-sdk.md",slug:"/gettingStarted/python-sdk",permalink:"/docs/gettingStarted/python-sdk",editUrl:"https://github.com/apache/submarine/edit/master/website/docs/gettingStarted/python-sdk.md",version:"current",sidebar:"docs",previous:{title:"Notebook Tutorial",permalink:"/docs/gettingStarted/notebook"},next:{title:"Experiment REST API",permalink:"/docs/userDocs/api/experiment"}},c=[{value:"Prepare Python Environment to run Submarine SDK",id:"prepare-python-environment-to-run-submarine-sdk",children:[]},{value:"Install Submarine SDK",id:"install-submarine-sdk",children:[{value:"Install SDK from pypi.org (recommended)",id:"install-sdk-from-pypiorg-recommended",children:[]},{value:"Install SDK from source code",id:"install-sdk-from-source-code",children:[]}]},{value:"Manage Submarine Experiment",id:"manage-submarine-experiment",children:[]},{value:"Training a DeepFM model",id:"training-a-deepfm-model",children:[]}],s={toc:c};function p(e){var n=e.components,t=Object(a.a)(e,["components"]);return Object(o.b)("wrapper",Object(r.a)({},s,t,{components:n,mdxType:"MDXLayout"}),Object(o.b)("p",null,"Submarine Python SDK can runs on any machine and it will talk to Submarine Server via REST API. So you can install Submarine Python SDK on your laptop, a gateway machine, your favorite IDE (like PyCharm/Jupyter, etc.)."),Object(o.b)("p",null,"Furthermore, Submarine supports an extensible package of CTR models based on ",Object(o.b)("strong",{parentName:"p"},"TensorFlow")," and ",Object(o.b)("strong",{parentName:"p"},"PyTorch")," along with lots of core components layers that can be used to easily build custom models. You can train any model with ",Object(o.b)("inlineCode",{parentName:"p"},"model.train()")," and ",Object(o.b)("inlineCode",{parentName:"p"},"model.predict()"),"."),Object(o.b)("h2",{id:"prepare-python-environment-to-run-submarine-sdk"},"Prepare Python Environment to run Submarine SDK"),Object(o.b)("p",null,"Submarine SDK requires Python3.7+.\nIt's better to use a new Python environment created by ",Object(o.b)("inlineCode",{parentName:"p"},"Anoconda")," or Python ",Object(o.b)("inlineCode",{parentName:"p"},"virtualenv")," to try this to avoid trouble to existing Python environment.\nA sample Python virtual env can be setup like this:"),Object(o.b)("pre",null,Object(o.b)("code",{parentName:"pre",className:"language-bash"},"wget https://files.pythonhosted.org/packages/33/bc/fa0b5347139cd9564f0d44ebd2b147ac97c36b2403943dbee8a25fd74012/virtualenv-16.0.0.tar.gz\ntar xf virtualenv-16.0.0.tar.gz\n\n# Make sure to install using Python 3\npython3 virtualenv-16.0.0/virtualenv.py venv\n. venv/bin/activate\n")),Object(o.b)("h2",{id:"install-submarine-sdk"},"Install Submarine SDK"),Object(o.b)("h3",{id:"install-sdk-from-pypiorg-recommended"},"Install SDK from pypi.org (recommended)"),Object(o.b)("p",null,"Starting from ",Object(o.b)("inlineCode",{parentName:"p"},"0.4.0"),", Submarine provides Python SDK. Please change it to a proper version needed. "),Object(o.b)("p",null,"More detail: ",Object(o.b)("a",{parentName:"p",href:"https://pypi.org/project/apache-submarine/"},"https://pypi.org/project/apache-submarine/")),Object(o.b)("pre",null,Object(o.b)("code",{parentName:"pre",className:"language-bash"},"# Install latest stable version\npip install apache-submarine\n# Install specific version\npip install apache-submarine==<REPLACE_VERSION>\n")),Object(o.b)("h3",{id:"install-sdk-from-source-code"},"Install SDK from source code"),Object(o.b)("p",null,"Please first clone code from github or go to ",Object(o.b)("inlineCode",{parentName:"p"},"http://submarine.apache.org/download.html")," to download released source code."),Object(o.b)("pre",null,Object(o.b)("code",{parentName:"pre",className:"language-bash"},"git clone https://github.com/apache/submarine.git\n# (optional) chackout specific branch or release\ngit checkout <correct release tag/branch>\ncd submarine/submarine-sdk/pysubmarine\npip install .\n")),Object(o.b)("h2",{id:"manage-submarine-experiment"},"Manage Submarine Experiment"),Object(o.b)("p",null,"Assuming you've installed submarine on K8s and forward the traefik service to localhost, now you can open a Python shell, Jupyter notebook or any tools with Submarine SDK installed."),Object(o.b)("p",null,"Follow ",Object(o.b)("a",{parentName:"p",href:"https://github.com/apache/submarine/blob/master/submarine-sdk/pysubmarine/example/submarine_experiment_sdk.ipynb"},"SDK experiment example")," to run an experiment."),Object(o.b)("h2",{id:"training-a-deepfm-model"},"Training a DeepFM model"),Object(o.b)("p",null,"The Submarine also supports users to train an easy-to-use CTR model with a few lines of code and a configuration file, so they don\u2019t need to reimplement the model by themself. In addition, they can train the model on both local on distributed systems, such as Hadoop or Kubernetes."),Object(o.b)("p",null,"Follow ",Object(o.b)("a",{parentName:"p",href:"https://github.com/apache/submarine/blob/master/submarine-sdk/pysubmarine/example/deepfm_example.ipynb"},"SDK DeepFM example")," to try the model."))}p.isMDXComponent=!0}}]);