mirror of https://github.com/kubeflow/examples.git
127 lines
3.2 KiB
Plaintext
127 lines
3.2 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import kfp\n",
|
|
"from kfp import dsl\n",
|
|
"\n",
|
|
"\n",
|
|
"def SendMsg(trial, epoch, patience):\n",
|
|
" vop = dsl.VolumeOp(name=\"pvc\",\n",
|
|
" resource_name=\"pvc\", size='5Gi', \n",
|
|
" modes=dsl.VOLUME_MODE_RWO)\n",
|
|
"\n",
|
|
" return dsl.ContainerOp(\n",
|
|
" name = 'Train', \n",
|
|
" image = 'hubdocker76/demotrain:v8', # use this prebuilt image or replace image with your own custom image\n",
|
|
" command = ['python3', 'train.py'],\n",
|
|
" arguments=[\n",
|
|
" '--trial', trial,\n",
|
|
" '--epoch', epoch,\n",
|
|
" '--patience', patience\n",
|
|
" ],\n",
|
|
" pvolumes={\n",
|
|
" '/data': vop.volume\n",
|
|
" }\n",
|
|
" )\n",
|
|
"\n",
|
|
"def GetMsg(comp1):\n",
|
|
" return dsl.ContainerOp(\n",
|
|
" name = 'Evaluate',\n",
|
|
" image = 'hubdocker76/demoeval:v3', # use this prebuilt image or replace image with your own custom image\n",
|
|
" pvolumes={\n",
|
|
" '/data': comp1.pvolumes['/data']\n",
|
|
" },\n",
|
|
" command = ['python3', 'eval.py']\n",
|
|
" )\n",
|
|
"\n",
|
|
"@dsl.pipeline(\n",
|
|
" name = 'face pipeline',\n",
|
|
" description = 'pipeline to detect facial landmarks')\n",
|
|
"def passing_parameter(trial, epoch, patience):\n",
|
|
" comp1 = SendMsg(trial, epoch, patience).add_pod_label(\"kaggle-secret\", \"true\")\n",
|
|
" comp2 = GetMsg(comp1)\n",
|
|
"\n",
|
|
"if __name__ == '__main__':\n",
|
|
" import kfp.compiler as compiler\n",
|
|
" compiler.Compiler().compile(passing_parameter, 'facial-keypoints-detection-kfp.py.yaml')\n",
|
|
"\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"kubeflow_notebook": {
|
|
"autosnapshot": true,
|
|
"experiment": {
|
|
"id": "",
|
|
"name": ""
|
|
},
|
|
"experiment_name": "",
|
|
"katib_metadata": {
|
|
"algorithm": {
|
|
"algorithmName": "grid"
|
|
},
|
|
"maxFailedTrialCount": 3,
|
|
"maxTrialCount": 12,
|
|
"objective": {
|
|
"objectiveMetricName": "",
|
|
"type": "minimize"
|
|
},
|
|
"parallelTrialCount": 3,
|
|
"parameters": []
|
|
},
|
|
"katib_run": false,
|
|
"pipeline_description": "",
|
|
"pipeline_name": "",
|
|
"snapshot_volumes": true,
|
|
"steps_defaults": [
|
|
"label:access-ml-pipeline:true",
|
|
"label:access-rok:true"
|
|
],
|
|
"volume_access_mode": "rwm",
|
|
"volumes": [
|
|
{
|
|
"annotations": [],
|
|
"mount_point": "/home/jovyan",
|
|
"name": "test-face-keypoint-workspace-54wqj",
|
|
"size": 5,
|
|
"size_type": "Gi",
|
|
"snapshot": false,
|
|
"type": "clone"
|
|
}
|
|
]
|
|
},
|
|
"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.9"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|