{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Arena Kubeflow Pipeline Notebook demo\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prepare data volume\n",
    "\n",
    "You should prepare data volume `user-susan` by following [docs](https://github.com/kubeflow/arena/blob/master/docs/userguide/4-tfjob-distributed-data.md). \n",
    "\n",
    "And run `arena data list` to check if it's created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "NAME            ACCESSMODE     DESCRIPTION  OWNER  AGE\r\n",
      "katib-mysql     ReadWriteOnce                      49d\r\n",
      "minio-pv-claim  ReadWriteOnce                      49d\r\n",
      "mysql-pv-claim  ReadWriteOnce                      49d\r\n",
      "user-susan      ReadWriteMany                      49d\r\n"
     ]
    }
   ],
   "source": [
    "! arena data list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define the necessary environment variables and install the KubeFlow Pipeline SDK\n",
    "We assume this notebook kernel has access to Python's site-packages and is in Python3.\n",
    "\n",
    "**Please fill in the below environment variables with you own settings.**\n",
    "\n",
    "- **KFP_PACKAGE**: The latest release of kubeflow pipeline platform library.\n",
    "- **KUBEFLOW_PIPELINE_LINK**: The link to access the KubeFlow pipeline API.\n",
    "- **MOUNT**: The mount configuration to map data above into the training job. The format is 'data:/directory'\n",
    "- **GPUs**: The number of the GPUs for training.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "KFP_SERVICE=\"ml-pipeline.kubeflow.svc.cluster.local:8888\"\n",
    "KFP_PACKAGE = 'http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp/0.1.14/kfp.tar.gz'\n",
    "KFP_ARENA_PACKAGE = 'http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp-arena/kfp-arena-0.3.tar.gz'\n",
    "KUBEFLOW_PIPELINE_LINK = ''\n",
    "MOUNT=\"['user-susan:/training']\"\n",
    "GPUs=1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Install the necessary python packages\n",
    "\n",
    "Note: Please change pip3 to the package manager that's used for this Notebook Kernel."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp/v0.4.0/kfp.tar.gz\n",
      "\u001b[?25l  Downloading http://kubeflow.oss-cn-beijing.aliyuncs.com/kfp/v0.4.0/kfp.tar.gz (133kB)\n",
      "\u001b[K    100% |████████████████████████████████| 143kB 2.0MB/s ta 0:00:01\n",
      "\u001b[?25hRequirement already satisfied, skipping upgrade: urllib3>=1.15 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (1.22)\n",
      "Requirement already satisfied, skipping upgrade: six>=1.10 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (1.11.0)\n",
      "Requirement already satisfied, skipping upgrade: certifi in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (2018.11.29)\n",
      "Requirement already satisfied, skipping upgrade: python-dateutil in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (2.7.5)\n",
      "Requirement already satisfied, skipping upgrade: PyYAML in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (3.13)\n",
      "Requirement already satisfied, skipping upgrade: google-cloud-storage==1.13.0 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (1.13.0)\n",
      "Requirement already satisfied, skipping upgrade: kubernetes==8.0.0 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (8.0.0)\n",
      "Requirement already satisfied, skipping upgrade: PyJWT==1.6.4 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (1.6.4)\n",
      "Requirement already satisfied, skipping upgrade: cryptography==2.4.2 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (2.4.2)\n",
      "Requirement already satisfied, skipping upgrade: google-auth==1.6.1 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (1.6.1)\n",
      "Requirement already satisfied, skipping upgrade: requests_toolbelt==0.8.0 in /opt/conda/lib/python3.6/site-packages (from kfp==0.1) (0.8.0)\n",
      "Requirement already satisfied, skipping upgrade: google-cloud-core<0.29dev,>=0.28.0 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp==0.1) (0.28.1)\n",
      "Requirement already satisfied, skipping upgrade: google-resumable-media>=0.3.1 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp==0.1) (0.3.1)\n",
      "Requirement already satisfied, skipping upgrade: google-api-core<2.0.0dev,>=0.1.1 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp==0.1) (1.6.0)\n",
      "Requirement already satisfied, skipping upgrade: adal>=1.0.2 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp==0.1) (1.2.1)\n",
      "Requirement already satisfied, skipping upgrade: requests-oauthlib in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp==0.1) (1.0.0)\n",
      "Requirement already satisfied, skipping upgrade: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp==0.1) (0.54.0)\n",
      "Requirement already satisfied, skipping upgrade: requests in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp==0.1) (2.18.4)\n",
      "Requirement already satisfied, skipping upgrade: setuptools>=21.0.0 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp==0.1) (38.4.0)\n",
      "Requirement already satisfied, skipping upgrade: cffi!=1.11.3,>=1.7 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp==0.1) (1.11.4)\n",
      "Requirement already satisfied, skipping upgrade: idna>=2.1 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp==0.1) (2.6)\n",
      "Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp==0.1) (0.24.0)\n",
      "Requirement already satisfied, skipping upgrade: pyasn1-modules>=0.2.1 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp==0.1) (0.2.2)\n",
      "Requirement already satisfied, skipping upgrade: cachetools>=2.0.0 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp==0.1) (3.0.0)\n",
      "Requirement already satisfied, skipping upgrade: rsa>=3.1.4 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp==0.1) (4.0)\n",
      "Requirement already satisfied, skipping upgrade: protobuf>=3.4.0 in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp==0.1) (3.6.1)\n",
      "Requirement already satisfied, skipping upgrade: pytz in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp==0.1) (2018.7)\n",
      "Requirement already satisfied, skipping upgrade: googleapis-common-protos!=1.5.4,<2.0dev,>=1.5.3 in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp==0.1) (1.5.5)\n",
      "Requirement already satisfied, skipping upgrade: oauthlib>=0.6.2 in /opt/conda/lib/python3.6/site-packages (from requests-oauthlib->kubernetes==8.0.0->kfp==0.1) (2.1.0)\n",
      "Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /opt/conda/lib/python3.6/site-packages (from requests->kubernetes==8.0.0->kfp==0.1) (3.0.4)\n",
      "Requirement already satisfied, skipping upgrade: pycparser in /opt/conda/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography==2.4.2->kfp==0.1) (2.18)\n",
      "Requirement already satisfied, skipping upgrade: pyasn1<0.5.0,>=0.4.1 in /opt/conda/lib/python3.6/site-packages (from pyasn1-modules>=0.2.1->google-auth==1.6.1->kfp==0.1) (0.4.4)\n",
      "Building wheels for collected packages: kfp\n",
      "  Running setup.py bdist_wheel for kfp ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /tmp/pip-ephem-wheel-cache-1wm5ld15/wheels/f0/e0/47/2f1e28c1a54da10332867d1f9cc25bfb916c0a4b8ea47029db\n",
      "Successfully built kfp\n",
      "Installing collected packages: kfp\n",
      "  Found existing installation: kfp 0.1\n",
      "    Uninstalling kfp-0.1:\n",
      "      Successfully uninstalled kfp-0.1\n",
      "Successfully installed kfp-0.1\n",
      "\u001b[33mYou are using pip version 18.1, however version 19.0.3 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip3 install $KFP_PACKAGE --upgrade"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note: Install arena's python package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting http://kubeflow.oss-cn-beijing.aliyuncs.com/kip-arena/kfp-arena-0.1.tar.gz\n",
      "  Downloading http://kubeflow.oss-cn-beijing.aliyuncs.com/kip-arena/kfp-arena-0.1.tar.gz\n",
      "Requirement already satisfied, skipping upgrade: kfp>=0.1 in /opt/conda/lib/python3.6/site-packages (from kfp-arena==0.1) (0.1)\n",
      "Requirement already satisfied, skipping upgrade: python-dateutil in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (2.7.5)\n",
      "Requirement already satisfied, skipping upgrade: urllib3>=1.15 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (1.22)\n",
      "Requirement already satisfied, skipping upgrade: six>=1.10 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (1.11.0)\n",
      "Requirement already satisfied, skipping upgrade: requests-toolbelt==0.8.0 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (0.8.0)\n",
      "Requirement already satisfied, skipping upgrade: google-auth==1.6.1 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (1.6.1)\n",
      "Requirement already satisfied, skipping upgrade: PyYAML in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (3.13)\n",
      "Requirement already satisfied, skipping upgrade: kubernetes==8.0.0 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (8.0.0)\n",
      "Requirement already satisfied, skipping upgrade: certifi in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (2018.11.29)\n",
      "Requirement already satisfied, skipping upgrade: google-cloud-storage==1.13.0 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (1.13.0)\n",
      "Requirement already satisfied, skipping upgrade: cryptography==2.4.2 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (2.4.2)\n",
      "Requirement already satisfied, skipping upgrade: PyJWT==1.6.4 in /opt/conda/lib/python3.6/site-packages (from kfp>=0.1->kfp-arena==0.1) (1.6.4)\n",
      "Requirement already satisfied, skipping upgrade: requests<3.0.0,>=2.0.1 in /opt/conda/lib/python3.6/site-packages (from requests-toolbelt==0.8.0->kfp>=0.1->kfp-arena==0.1) (2.18.4)\n",
      "Requirement already satisfied, skipping upgrade: cachetools>=2.0.0 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp>=0.1->kfp-arena==0.1) (3.0.0)\n",
      "Requirement already satisfied, skipping upgrade: rsa>=3.1.4 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp>=0.1->kfp-arena==0.1) (4.0)\n",
      "Requirement already satisfied, skipping upgrade: pyasn1-modules>=0.2.1 in /opt/conda/lib/python3.6/site-packages (from google-auth==1.6.1->kfp>=0.1->kfp-arena==0.1) (0.2.2)\n",
      "Requirement already satisfied, skipping upgrade: websocket-client!=0.40.0,!=0.41.*,!=0.42.*,>=0.32.0 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp>=0.1->kfp-arena==0.1) (0.54.0)\n",
      "Requirement already satisfied, skipping upgrade: requests-oauthlib in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp>=0.1->kfp-arena==0.1) (1.0.0)\n",
      "Requirement already satisfied, skipping upgrade: setuptools>=21.0.0 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp>=0.1->kfp-arena==0.1) (38.4.0)\n",
      "Requirement already satisfied, skipping upgrade: adal>=1.0.2 in /opt/conda/lib/python3.6/site-packages (from kubernetes==8.0.0->kfp>=0.1->kfp-arena==0.1) (1.2.1)\n",
      "Requirement already satisfied, skipping upgrade: google-resumable-media>=0.3.1 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (0.3.1)\n",
      "Requirement already satisfied, skipping upgrade: google-api-core<2.0.0dev,>=0.1.1 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (1.6.0)\n",
      "Requirement already satisfied, skipping upgrade: google-cloud-core<0.29dev,>=0.28.0 in /opt/conda/lib/python3.6/site-packages (from google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (0.28.1)\n",
      "Requirement already satisfied, skipping upgrade: cffi!=1.11.3,>=1.7 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp>=0.1->kfp-arena==0.1) (1.11.4)\n",
      "Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp>=0.1->kfp-arena==0.1) (0.24.0)\n",
      "Requirement already satisfied, skipping upgrade: idna>=2.1 in /opt/conda/lib/python3.6/site-packages (from cryptography==2.4.2->kfp>=0.1->kfp-arena==0.1) (2.6)\n",
      "Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /opt/conda/lib/python3.6/site-packages (from requests<3.0.0,>=2.0.1->requests-toolbelt==0.8.0->kfp>=0.1->kfp-arena==0.1) (3.0.4)\n",
      "Requirement already satisfied, skipping upgrade: pyasn1>=0.1.3 in /opt/conda/lib/python3.6/site-packages (from rsa>=3.1.4->google-auth==1.6.1->kfp>=0.1->kfp-arena==0.1) (0.4.4)\n",
      "Requirement already satisfied, skipping upgrade: oauthlib>=0.6.2 in /opt/conda/lib/python3.6/site-packages (from requests-oauthlib->kubernetes==8.0.0->kfp>=0.1->kfp-arena==0.1) (2.1.0)\n",
      "Requirement already satisfied, skipping upgrade: protobuf>=3.4.0 in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (3.6.1)\n",
      "Requirement already satisfied, skipping upgrade: pytz in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (2018.7)\n",
      "Requirement already satisfied, skipping upgrade: googleapis-common-protos!=1.5.4,<2.0dev,>=1.5.3 in /opt/conda/lib/python3.6/site-packages (from google-api-core<2.0.0dev,>=0.1.1->google-cloud-storage==1.13.0->kfp>=0.1->kfp-arena==0.1) (1.5.5)\n",
      "Requirement already satisfied, skipping upgrade: pycparser in /opt/conda/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography==2.4.2->kfp>=0.1->kfp-arena==0.1) (2.18)\n",
      "Building wheels for collected packages: kfp-arena\n",
      "  Running setup.py bdist_wheel for kfp-arena ... \u001b[?25ldone\n",
      "\u001b[?25h  Stored in directory: /home/jovyan/.cache/pip/wheels/6a/d3/d5/f99c7966cacbcbad2922bf614c88c523c869c16d26e549a087\n",
      "Successfully built kfp-arena\n",
      "Installing collected packages: kfp-arena\n",
      "Successfully installed kfp-arena-0.1\n",
      "\u001b[33mYou are using pip version 18.1, however version 19.0.3 is available.\n",
      "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip3 install $KFP_ARENA_PACKAGE --upgrade"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Define pipeline tasks using the kfp library. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import arena\n",
    "import kfp.dsl as dsl\n",
    "\n",
    "@dsl.pipeline(\n",
    "  name='pipeline to run jobs',\n",
    "  description='shows how to run pipeline jobs.'\n",
    ")\n",
    "def sample_pipeline(learning_rate='0.01',\n",
    "    dropout='0.9',\n",
    "    model_version='1'):\n",
    "  \"\"\"A pipeline for end to end machine learning workflow.\"\"\"\n",
    "\n",
    "  # 1. prepare data\n",
    "  prepare_data = arena.StandaloneOp(\n",
    "    name=\"prepare-data\",\n",
    "\timage=\"byrnedo/alpine-curl\",\n",
    "    data=MOUNT,\n",
    "\tcommand=\"mkdir -p /training/dataset/mnist && \\\n",
    "  cd /training/dataset/mnist && \\\n",
    "  curl -O https://code.aliyun.com/xiaozhou/tensorflow-sample-code/raw/master/data/t10k-images-idx3-ubyte.gz && \\\n",
    "  curl -O https://code.aliyun.com/xiaozhou/tensorflow-sample-code/raw/master/data/t10k-labels-idx1-ubyte.gz && \\\n",
    "  curl -O https://code.aliyun.com/xiaozhou/tensorflow-sample-code/raw/master/data/train-images-idx3-ubyte.gz && \\\n",
    "  curl -O https://code.aliyun.com/xiaozhou/tensorflow-sample-code/raw/master/data/train-labels-idx1-ubyte.gz\")\n",
    "  # 2. prepare source code\n",
    "  prepare_code = arena.StandaloneOp(\n",
    "    name=\"source-code\",\n",
    "    image=\"alpine/git\",\n",
    "    data=MOUNT,\n",
    "    command=\"mkdir -p /training/models/ && \\\n",
    "  cd /training/models/ && \\\n",
    "  if [ ! -d /training/models/tensorflow-sample-code ]; then https://github.com/cheyang/tensorflow-sample-code.git; else echo no need download;fi\")\n",
    "\n",
    "  # 3. train the models\n",
    "  train = arena.StandaloneOp(\n",
    "    name=\"train\",\n",
    "    image=\"tensorflow/tensorflow:1.11.0-gpu-py3\",\n",
    "    gpus=GPUs,\n",
    "    data=MOUNT,\n",
    "    command=\"echo %s; \\\n",
    "             echo %s; \\\n",
    "    python /training/models/tensorflow-sample-code/tfjob/docker/mnist/main.py --max_steps 500 --data_dir /training/dataset/mnist --log_dir /training/output/mnist\" % (prepare_data.output, prepare_code.output),\n",
    "    metric_name=\"Train-accuracy\",\n",
    "    metric_unit=\"PERCENTAGE\",\n",
    "  )\n",
    "  # 4. export the model\n",
    "  export_model = arena.StandaloneOp(\n",
    "    name=\"export-model\",\n",
    "    image=\"tensorflow/tensorflow:1.11.0-py3\",\n",
    "    data=MOUNT,\n",
    "    command=\"echo %s; \\\n",
    "    python /training/models/tensorflow-sample-code/tfjob/docker/mnist/export_model.py --model_version=%s --checkpoint_step=400 --checkpoint_path=/training/output/mnist /training/output/models\" % (train.output,model_version))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "Run link <a href=\"/pipeline/#/runs/details/cac8aef4-4aaa-11e9-8264-00163e13f33e\" target=\"_blank\" >here</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The above run link is assuming you ran this cell on JupyterHub that is deployed on the same cluster. The actual run link is /#/runs/details/cac8aef4-4aaa-11e9-8264-00163e13f33e\n"
     ]
    }
   ],
   "source": [
    "learning_rate = \"0.001\"\n",
    "dropout = \"0.8\"\n",
    "model_verison = \"1\"\n",
    "\n",
    "arguments = {\n",
    "  'learning_rate': learning_rate,\n",
    "  'dropout': dropout,\n",
    "  'model_version': model_version,\n",
    "}\n",
    "\n",
    "import kfp\n",
    "client = kfp.Client(host=KUBEFLOW_PIPELINE_LINK)\n",
    "run = client.create_run_from_pipeline_func(sample_pipeline, arguments=arguments).run_info\n",
    "\n",
    "print('The above run link is assuming you ran this cell on JupyterHub that is deployed on the same cluster. ' +\n",
    "      'The actual run link is ' + KUBEFLOW_PIPELINE_LINK + '/#/runs/details/' + run.id)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
