mirror of https://github.com/kubeflow/examples.git
				
				
				
			Update readme for xgboost-synthetic and remove outdated yaml file (#605)
* Update readme for xgboost-synthetic and remove outdated yaml file. * Update the class name to be more general. * Update readme. * Set google_application_credentials in the notebook. * Install fairing from master branch. * Do not set credentials again. * Update readme.
This commit is contained in:
		
							parent
							
								
									fb6cd69def
								
							
						
					
					
						commit
						6e5ba488e2
					
				|  | @ -1,9 +1,11 @@ | |||
| # xgboost-synthetic | ||||
| Kubeflow fairing, pipelines demo using synthetic data | ||||
| Kubeflow fairing, pipelines demo using synthetic data. This notebook `build-train-deploy.ipynb` can be executed using one of the stock notebook images launched through Kubeflow UI. | ||||
| 
 | ||||
| 1. Launch a notebook | ||||
| 1. Follow the [Set up your notebook](https://www.kubeflow.org/docs/notebooks/setup/) guide to get started with Jupyter notebooks on Kubeflow | ||||
| 
 | ||||
|    ``` | ||||
|    kubectl apply -f notebook.xgboost-synthetic.yaml | ||||
|    ``` | ||||
| 1. Attach an extra data volume named  | ||||
| 1. Open the notebook terminal and run | ||||
|     ``` | ||||
|     $ git clone https://github.com/kubeflow/examples.git | ||||
|     ``` | ||||
| 
 | ||||
| 1. In the directory `xgboost_synthetic`, open the notebook `build-train-deploy.ipynb` | ||||
|  |  | |||
|  | @ -29,6 +29,116 @@ | |||
|     "Import the libraries required to train this model." | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": 2, | ||||
|    "metadata": {}, | ||||
|    "outputs": [ | ||||
|     { | ||||
|      "name": "stdout", | ||||
|      "output_type": "stream", | ||||
|      "text": [ | ||||
|       "Requirement already satisfied: retrying in ./env/lib/python3.6/site-packages\n", | ||||
|       "Requirement already satisfied: six>=1.7.0 in ./env/lib/python3.6/site-packages (from retrying)\n", | ||||
|       "Collecting https://github.com/kubeflow/fairing/archive/master.zip\n", | ||||
|       "  Downloading https://github.com/kubeflow/fairing/archive/master.zip (878kB)\n", | ||||
|       "\u001b[K    100% |████████████████████████████████| 880kB 1.6MB/s eta 0:00:01\n", | ||||
|       "\u001b[?25h  Requirement already satisfied (use --upgrade to upgrade): fairing==0.5.3 from https://github.com/kubeflow/fairing/archive/master.zip in ./env/lib/python3.6/site-packages/fairing-0.5.3-py3.6.egg\n", | ||||
|       "Requirement already satisfied: docker>=3.4.1 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: notebook>=5.6.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: kubernetes>=9.0.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: future>=0.17.1 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: six>=1.11.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-cloud-storage>=1.13.2 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: requests>=2.21.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: setuptools>=34.0.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-auth>=1.6.2 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: httplib2>=0.12.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: oauth2client>=4.0.0 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: tornado<6.0.0,>=5.1.1 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-api-python-client>=1.7.8 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: cloudpickle>=0.8 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: numpy>=1.14 in ./env/lib/python3.6/site-packages (from fairing==0.5.3)\n", | ||||
|       "Collecting urllib3==1.24.2 (from fairing==0.5.3)\n", | ||||
|       "  Using cached https://files.pythonhosted.org/packages/df/1c/59cca3abf96f991f2ec3131a4ffe72ae3d9ea1f5894abe8a9c5e3c77cfee/urllib3-1.24.2-py2.py3-none-any.whl\n", | ||||
|       "Requirement already satisfied: boto3>=1.9.0 in ./env/lib/python3.6/site-packages/boto3-1.9.187-py3.6.egg (from fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: websocket-client>=0.32.0 in ./env/lib/python3.6/site-packages (from docker>=3.4.1->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: nbconvert in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: prometheus-client in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: traitlets>=4.2.1 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pyzmq>=17 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: Send2Trash in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jupyter-client>=5.2.0 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: ipython-genutils in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: nbformat in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: ipykernel in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: terminado>=0.8.1 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jinja2 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jupyter-core>=4.4.0 in ./env/lib/python3.6/site-packages (from notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: certifi>=14.05.14 in ./env/lib/python3.6/site-packages (from kubernetes>=9.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: python-dateutil>=2.5.3 in ./env/lib/python3.6/site-packages (from kubernetes>=9.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: requests-oauthlib in ./env/lib/python3.6/site-packages (from kubernetes>=9.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pyyaml>=3.12 in ./env/lib/python3.6/site-packages (from kubernetes>=9.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-resumable-media>=0.3.1 in ./env/lib/python3.6/site-packages (from google-cloud-storage>=1.13.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-cloud-core<2.0dev,>=1.0.0 in ./env/lib/python3.6/site-packages (from google-cloud-storage>=1.13.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: idna<2.9,>=2.5 in ./env/lib/python3.6/site-packages (from requests>=2.21.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./env/lib/python3.6/site-packages (from requests>=2.21.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: rsa>=3.1.4 in ./env/lib/python3.6/site-packages (from google-auth>=1.6.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: cachetools>=2.0.0 in ./env/lib/python3.6/site-packages (from google-auth>=1.6.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pyasn1-modules>=0.2.1 in ./env/lib/python3.6/site-packages (from google-auth>=1.6.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pyasn1>=0.1.7 in ./env/lib/python3.6/site-packages (from oauth2client>=4.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: uritemplate<4dev,>=3.0.0 in ./env/lib/python3.6/site-packages (from google-api-python-client>=1.7.8->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-auth-httplib2>=0.0.3 in ./env/lib/python3.6/site-packages (from google-api-python-client>=1.7.8->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: botocore<1.13.0,>=1.12.187 in ./env/lib/python3.6/site-packages/botocore-1.12.187-py3.6.egg (from boto3>=1.9.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in ./env/lib/python3.6/site-packages/jmespath-0.9.4-py3.6.egg (from boto3>=1.9.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: s3transfer<0.3.0,>=0.2.0 in ./env/lib/python3.6/site-packages/s3transfer-0.2.1-py3.6.egg (from boto3>=1.9.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pandocfilters>=1.4.1 in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: bleach in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: testpath in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: defusedxml in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: entrypoints>=0.2.2 in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pygments in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: mistune>=0.8.1 in ./env/lib/python3.6/site-packages (from nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: decorator in ./env/lib/python3.6/site-packages (from traitlets>=4.2.1->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in ./env/lib/python3.6/site-packages (from nbformat->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: ipython>=5.0.0 in ./env/lib/python3.6/site-packages (from ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: ptyprocess; os_name != \"nt\" in ./env/lib/python3.6/site-packages (from terminado>=0.8.1->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: MarkupSafe>=0.23 in ./env/lib/python3.6/site-packages (from jinja2->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: oauthlib>=3.0.0 in ./env/lib/python3.6/site-packages (from requests-oauthlib->kubernetes>=9.0.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: google-api-core<2.0.0dev,>=1.11.0 in ./env/lib/python3.6/site-packages (from google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage>=1.13.2->fairing==0.5.3)\n" | ||||
|      ] | ||||
|     }, | ||||
|     { | ||||
|      "name": "stdout", | ||||
|      "output_type": "stream", | ||||
|      "text": [ | ||||
|       "Requirement already satisfied: docutils>=0.10 in ./env/lib/python3.6/site-packages/docutils-0.14-py3.6.egg (from botocore<1.13.0,>=1.12.187->boto3>=1.9.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: webencodings in ./env/lib/python3.6/site-packages (from bleach->nbconvert->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pyrsistent>=0.14.0 in ./env/lib/python3.6/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: attrs>=17.4.0 in ./env/lib/python3.6/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pexpect; sys_platform != \"win32\" in ./env/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: jedi>=0.10 in ./env/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: backcall in ./env/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: prompt-toolkit<2.1.0,>=2.0.0 in ./env/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pickleshare in ./env/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: googleapis-common-protos<2.0dev,>=1.6.0 in ./env/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.11.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage>=1.13.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: pytz in ./env/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.11.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage>=1.13.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: protobuf>=3.4.0 in ./env/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=1.11.0->google-cloud-core<2.0dev,>=1.0.0->google-cloud-storage>=1.13.2->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: parso>=0.3.0 in ./env/lib/python3.6/site-packages (from jedi>=0.10->ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Requirement already satisfied: wcwidth in ./env/lib/python3.6/site-packages (from prompt-toolkit<2.1.0,>=2.0.0->ipython>=5.0.0->ipykernel->notebook>=5.6.0->fairing==0.5.3)\n", | ||||
|       "Installing collected packages: urllib3\n", | ||||
|       "  Found existing installation: urllib3 1.24.3\n", | ||||
|       "    Uninstalling urllib3-1.24.3:\n", | ||||
|       "      Successfully uninstalled urllib3-1.24.3\n", | ||||
|       "Successfully installed urllib3-1.24.2\n" | ||||
|      ] | ||||
|     } | ||||
|    ], | ||||
|    "source": [ | ||||
|     "!pip3 install retrying\n", | ||||
|     "!pip3 install https://github.com/kubeflow/fairing/archive/master.zip" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": 1, | ||||
|  | @ -168,7 +278,7 @@ | |||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "# fairing:include-cell\n", | ||||
|     "class HousingServe(object):\n", | ||||
|     "class ModelServe(object):\n", | ||||
|     "    \n", | ||||
|     "    def __init__(self, model_file=None):\n", | ||||
|     "        self.n_estimators = 50\n", | ||||
|  | @ -298,7 +408,7 @@ | |||
|     } | ||||
|    ], | ||||
|    "source": [ | ||||
|     "HousingServe(model_file=\"mockup-model.dat\").train()" | ||||
|     "ModelServe(model_file=\"mockup-model.dat\").train()" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|  | @ -338,7 +448,7 @@ | |||
|    "source": [ | ||||
|     "(train_X, train_y), (test_X, test_y) =read_synthetic_input()\n", | ||||
|     "\n", | ||||
|     "HousingServe().predict(test_X, None)" | ||||
|     "ModelServe().predict(test_X, None)" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|  | @ -411,7 +521,7 @@ | |||
|    ], | ||||
|    "source": [ | ||||
|     "from fairing.builders import cluster\n", | ||||
|     "preprocessor = ConvertNotebookPreprocessorWithFire(\"HousingServe\")\n", | ||||
|     "preprocessor = ConvertNotebookPreprocessorWithFire(\"ModelServe\")\n", | ||||
|     "\n", | ||||
|     "if not preprocessor.input_files:\n", | ||||
|     "    preprocessor.input_files = set()\n", | ||||
|  | @ -800,7 +910,7 @@ | |||
|     "pod_spec = builder.generate_pod_spec()\n", | ||||
|     "\n", | ||||
|     "module_name = os.path.splitext(preprocessor.executable.name)[0]\n", | ||||
|     "deployer = serving.serving.Serving(module_name + \".HousingServe\",\n", | ||||
|     "deployer = serving.serving.Serving(module_name + \".ModelServe\",\n", | ||||
|     "                                   service_type=\"ClusterIP\",\n", | ||||
|     "                                   labels={\"app\": \"mockup\"})\n", | ||||
|     "    \n", | ||||
|  | @ -859,7 +969,7 @@ | |||
|       "      containers:\r\n", | ||||
|       "      - command:\r\n", | ||||
|       "        - seldon-core-microservice\r\n", | ||||
|       "        - mockup-data-xgboost-build-train-deploy.HousingServe\r\n", | ||||
|       "        - mockup-data-xgboost-build-train-deploy.ModelServe\r\n", | ||||
|       "        - REST\r\n", | ||||
|       "        - --service-type=MODEL\r\n", | ||||
|       "        - --persistence=0\r\n", | ||||
|  | @ -1113,7 +1223,7 @@ | |||
|    "name": "python", | ||||
|    "nbconvert_exporter": "python", | ||||
|    "pygments_lexer": "ipython3", | ||||
|    "version": "3.6.5" | ||||
|    "version": "3.6.6" | ||||
|   } | ||||
|  }, | ||||
|  "nbformat": 4, | ||||
|  |  | |||
|  | @ -1,30 +0,0 @@ | |||
| apiVersion: kubeflow.org/v1alpha1 | ||||
| kind: Notebook | ||||
| metadata: | ||||
|   labels: | ||||
|     app: notebook | ||||
|   name: xgboost-synthetic | ||||
|   namespace: kubeflow | ||||
| spec: | ||||
|   template: | ||||
|     spec: | ||||
|       containers: | ||||
|       - env: [] | ||||
|         image: gcr.io/kubeflow-images-public/tensorflow-1.12.0-notebook-cpu:v0.5.0 | ||||
|         name: tf-cpu | ||||
|         resources: | ||||
|           limits: | ||||
|             cpu: 8 | ||||
|             memory: 16Gi | ||||
|           requests: | ||||
|             cpu: 1 | ||||
|             memory: 1Gi | ||||
|         volumeMounts: | ||||
|         - mountPath: /home/jovyan | ||||
|           name: xgboost-synthetic | ||||
|       serviceAccountName: jupyter-notebook | ||||
|       ttlSecondsAfterFinished: 300 | ||||
|       volumes: | ||||
|       - name: xgboost-synthetic | ||||
|         persistentVolumeClaim: | ||||
|           claimName: xgboost-synthetic | ||||
		Loading…
	
		Reference in New Issue