{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import kfp\n", "from kfp import dsl\n", "\n", "def LoadData():\n", " vop = dsl.VolumeOp(name=\"pvc\",\n", " resource_name=\"pvc\", size='1Gi', \n", " modes=dsl.VOLUME_MODE_RWO)\n", "\n", " return dsl.ContainerOp(\n", " name = 'load-data', \n", " image = 'hubdocker76/bulldozers:v6', \n", " command = ['python3', 'load.py'],\n", "\n", " pvolumes={\n", " '/data': vop.volume\n", " }\n", " )\n", "\n", "def PreProcess(comp1):\n", " return dsl.ContainerOp(\n", " name = 'preprocess',\n", " image = 'hubdocker76/bulldozers-preprocess:v1',\n", " pvolumes={\n", " '/data': comp1.pvolumes['/data']\n", " },\n", " command = ['python3', 'preprocess.py']\n", " )\n", "\n", "def Train(comp2):\n", " return dsl.ContainerOp(\n", " name = 'train',\n", " image = 'hubdocker76/bulldozers-train:v2',\n", " pvolumes={\n", " '/data': comp2.pvolumes['/data']\n", " },\n", " command = ['python3', 'train.py']\n", " )\n", "\n", "def Test(comp3):\n", " return dsl.ContainerOp(\n", " name = 'test',\n", " image = 'hubdocker76/bulldozers-test:v2',\n", " pvolumes={\n", " '/data': comp3.pvolumes['/data']\n", " },\n", " command = ['python3', 'test.py']\n", " )\n", "\n", "\n", "@dsl.pipeline(\n", " name = 'blue book for bulldozers',\n", " description = 'pipeline to run blue book for bulldozers')\n", "\n", "def passing_parameter():\n", " comp1 = LoadData().add_pod_label(\"kaggle-secret\", \"true\")\n", " comp2 = PreProcess(comp1)\n", " comp3 = Train(comp2)\n", " comp4 = Test(comp3)\n", "\n", "if __name__ == '__main__':\n", " import kfp.compiler as compiler\n", " compiler.Compiler().compile(passing_parameter, __file__[:-3]+ '.yaml')\n" ] } ], "metadata": { "language_info": { "name": "python" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }