{ "apiVersion":"kubeflow.org/v1beta1", "kind":"Experiment", "metadata":{ "creationTimestamp":"2023-02-09T17:51:36Z", "finalizers":[ "update-prometheus-metrics" ], "generation":1, "managedFields":[ { "apiVersion":"kubeflow.org/v1beta1", "fieldsType":"FieldsV1", "fieldsV1":{ "f:spec":{ ".":{ }, "f:algorithm":{ ".":{ }, "f:algorithmName":{ } }, "f:maxFailedTrialCount":{ }, "f:maxTrialCount":{ }, "f:metricsCollectorSpec":{ ".":{ }, "f:collector":{ ".":{ }, "f:customCollector":{ ".":{ }, "f:args":{ }, "f:image":{ }, "f:imagePullPolicy":{ }, "f:name":{ }, "f:resources":{ } }, "f:kind":{ } } }, "f:objective":{ ".":{ }, "f:additionalMetricNames":{ }, "f:goal":{ }, "f:objectiveMetricName":{ }, "f:type":{ } }, "f:parallelTrialCount":{ }, "f:parameters":{ }, "f:trialTemplate":{ ".":{ }, "f:failureCondition":{ }, "f:primaryContainerName":{ }, "f:primaryPodLabels":{ ".":{ }, "f:katib.kubeflow.org/model-training":{ } }, "f:retain":{ }, "f:successCondition":{ }, "f:trialParameters":{ }, "f:trialSpec":{ ".":{ }, "f:apiVersion":{ }, "f:kind":{ }, "f:metadata":{ ".":{ }, "f:annotations":{ ".":{ }, "f:pipelines.kubeflow.org/kfp_sdk_version":{ }, "f:pipelines.kubeflow.org/pipeline_compilation_time":{ }, "f:pipelines.kubeflow.org/pipeline_spec":{ } }, "f:generateName":{ }, "f:labels":{ ".":{ }, "f:pipelines.kubeflow.org/kfp_sdk_version":{ } } }, "f:spec":{ ".":{ }, "f:arguments":{ ".":{ }, "f:parameters":{ } }, "f:entrypoint":{ }, "f:serviceAccountName":{ }, "f:templates":{ } } } } } }, "manager":"katib-ui", "operation":"Update", "time":"2023-02-09T17:51:36Z" }, { "apiVersion":"kubeflow.org/v1beta1", "fieldsType":"FieldsV1", "fieldsV1":{ "f:metadata":{ "f:finalizers":{ ".":{ }, "v:\"update-prometheus-metrics\"":{ } } } }, "manager":"katib-controller", "operation":"Update", "time":"2023-02-09T17:51:37Z" }, { "apiVersion":"kubeflow.org/v1beta1", "fieldsType":"FieldsV1", "fieldsV1":{ "f:status":{ ".":{ }, "f:completionTime":{ }, "f:conditions":{ }, "f:currentOptimalTrial":{ ".":{ }, "f:observation":{ } }, "f:failedTrialList":{ }, "f:startTime":{ }, "f:trials":{ }, "f:trialsFailed":{ } } }, "manager":"katib-controller", "operation":"Update", "subresource":"status", "time":"2023-02-09T17:56:53Z" } ], "name":"katib-kfp-mnist-custom", "namespace":"vito-zanotelli", "resourceVersion":"1274600", "uid":"2afedcf7-c105-4a17-8fd6-f0a425070176" }, "spec":{ "algorithm":{ "algorithmName":"random" }, "maxFailedTrialCount":1, "maxTrialCount":2, "metricsCollectorSpec":{ "collector":{ "customCollector":{ "args":[ "--db_manager_server_addr", "katib-db-manager.kubeflow:6789" ], "image":"votti/kfpv1-metricscollector:v0.0.1", "imagePullPolicy":"Always", "name":"custom-metrics-logger-and-collector", "resources":{ } }, "kind":"Custom" } }, "objective":{ "additionalMetricNames":[ "accuracy" ], "goal":0.9, "metricStrategies":[ { "name":"val-accuracy", "value":"max" }, { "name":"accuracy", "value":"max" } ], "objectiveMetricName":"val-accuracy", "type":"maximize" }, "parallelTrialCount":2, "parameters":[ { "feasibleSpace":{ "max":"0.001", "min":"0.00001" }, "name":"learning_rate", "parameterType":"double" } ], "resumePolicy":"LongRunning", "trialTemplate":{ "failureCondition":"status.[@this].#(phase==\"Failed\")#", "primaryContainerName":"main", "primaryPodLabels":{ "katib.kubeflow.org/model-training":"true" }, "retain":true, "successCondition":"status.[@this].#(phase==\"Succeeded\")#", "trialParameters":[ { "description":"Learning rate for the training model", "name":"learningRate", "reference":"learning_rate" } ], "trialSpec":{ "apiVersion":"argoproj.io/v1alpha1", "kind":"Workflow", "metadata":{ "annotations":{ "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline_compilation_time":"2023-02-09T11:24:49.497718", "pipelines.kubeflow.org/pipeline_spec":"{\"inputs\": [{\"default\": \"0.0001\", \"name\": \"lr\", \"optional\": true, \"type\": \"Float\"}, {\"default\": \"Adam\", \"name\": \"optimizer\", \"optional\": true, \"type\": \"String\"}, {\"default\": \"categorical_crossentropy\", \"name\": \"loss\", \"optional\": true, \"type\": \"String\"}, {\"default\": \"1\", \"name\": \"epochs\", \"optional\": true, \"type\": \"Integer\"}, {\"default\": \"32\", \"name\": \"batch_size\", \"optional\": true, \"type\": \"Integer\"}, {\"default\": \"${trialParameters.learningRate}\", \"name\": \"lr\"}], \"name\": \"Mnist training pipeline katib\"}" }, "generateName":"mnist-training-pipeline-katib-", "labels":{ "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18" } }, "spec":{ "arguments":{ "parameters":[ { "name":"lr", "value":"${trialParameters.learningRate}" }, { "name":"optimizer", "value":"Adam" }, { "name":"loss", "value":"categorical_crossentropy" }, { "name":"epochs", "value":"1" }, { "name":"batch_size", "value":"32" } ] }, "entrypoint":"mnist-training-pipeline-katib", "serviceAccountName":"default-editor", "templates":[ { "container":{ "args":[ ], "command":[ "sh", "-exc", "url=\"$0\"\noutput_path=\"$1\"\ncurl_options=\"$2\"\n\nmkdir -p \"$(dirname \"$output_path\")\"\ncurl --get \"$url\" --output \"$output_path\" $curl_options\n", "http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz", "/tmp/outputs/Data/data", "--location" ], "image":"byrnedo/alpine-curl@sha256:548379d0a4a0c08b9e55d9d87a592b7d35d9ab3037f4936f5ccd09d0b625a342" }, "metadata":{ "annotations":{ "author":"Alexey Volkov ", "canonical_location":"https://raw.githubusercontent.com/Ark-kun/pipeline_components/master/components/web/Download/component.yaml", "pipelines.kubeflow.org/arguments.parameters":"{\"Url\": \"http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz\", \"curl options\": \"--location\"}", "pipelines.kubeflow.org/component_ref":"{\"digest\": \"2f61f2edf713f214934bd286791877a1a3a37f31a4de4368b90e3b76743f1523\", \"url\": \"https://raw.githubusercontent.com/kubeflow/pipelines/master/components/contrib/web/Download/component.yaml\"}", "pipelines.kubeflow.org/component_spec":"{\"implementation\": {\"container\": {\"command\": [\"sh\", \"-exc\", \"url=\\\"$0\\\"\\noutput_path=\\\"$1\\\"\\ncurl_options=\\\"$2\\\"\\n\\nmkdir -p \\\"$(dirname \\\"$output_path\\\")\\\"\\ncurl --get \\\"$url\\\" --output \\\"$output_path\\\" $curl_options\\n\", {\"inputValue\": \"Url\"}, {\"outputPath\": \"Data\"}, {\"inputValue\": \"curl options\"}], \"image\": \"byrnedo/alpine-curl@sha256:548379d0a4a0c08b9e55d9d87a592b7d35d9ab3037f4936f5ccd09d0b625a342\"}}, \"inputs\": [{\"name\": \"Url\", \"type\": \"URI\"}, {\"default\": \"--location\", \"description\": \"Additional options given to the curl bprogram. See https://curl.haxx.se/docs/manpage.html\", \"name\": \"curl options\", \"type\": \"string\"}], \"metadata\": {\"annotations\": {\"author\": \"Alexey Volkov \", \"canonical_location\": \"https://raw.githubusercontent.com/Ark-kun/pipeline_components/master/components/web/Download/component.yaml\"}}, \"name\": \"Download data\", \"outputs\": [{\"name\": \"Data\"}]}", "pipelines.kubeflow.org/task_display_name":"Download training images" }, "labels":{ "pipelines.kubeflow.org/cache_enabled":"true", "pipelines.kubeflow.org/enable_caching":"true", "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline-sdk-type":"kfp" } }, "name":"download-data", "outputs":{ "artifacts":[ { "name":"download-data-Data", "path":"/tmp/outputs/Data/data" } ] } }, { "container":{ "args":[ ], "command":[ "sh", "-exc", "url=\"$0\"\noutput_path=\"$1\"\ncurl_options=\"$2\"\n\nmkdir -p \"$(dirname \"$output_path\")\"\ncurl --get \"$url\" --output \"$output_path\" $curl_options\n", "http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz", "/tmp/outputs/Data/data", "--location" ], "image":"byrnedo/alpine-curl@sha256:548379d0a4a0c08b9e55d9d87a592b7d35d9ab3037f4936f5ccd09d0b625a342" }, "metadata":{ "annotations":{ "author":"Alexey Volkov ", "canonical_location":"https://raw.githubusercontent.com/Ark-kun/pipeline_components/master/components/web/Download/component.yaml", "pipelines.kubeflow.org/arguments.parameters":"{\"Url\": \"http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz\", \"curl options\": \"--location\"}", "pipelines.kubeflow.org/component_ref":"{\"digest\": \"2f61f2edf713f214934bd286791877a1a3a37f31a4de4368b90e3b76743f1523\", \"url\": \"https://raw.githubusercontent.com/kubeflow/pipelines/master/components/contrib/web/Download/component.yaml\"}", "pipelines.kubeflow.org/component_spec":"{\"implementation\": {\"container\": {\"command\": [\"sh\", \"-exc\", \"url=\\\"$0\\\"\\noutput_path=\\\"$1\\\"\\ncurl_options=\\\"$2\\\"\\n\\nmkdir -p \\\"$(dirname \\\"$output_path\\\")\\\"\\ncurl --get \\\"$url\\\" --output \\\"$output_path\\\" $curl_options\\n\", {\"inputValue\": \"Url\"}, {\"outputPath\": \"Data\"}, {\"inputValue\": \"curl options\"}], \"image\": \"byrnedo/alpine-curl@sha256:548379d0a4a0c08b9e55d9d87a592b7d35d9ab3037f4936f5ccd09d0b625a342\"}}, \"inputs\": [{\"name\": \"Url\", \"type\": \"URI\"}, {\"default\": \"--location\", \"description\": \"Additional options given to the curl bprogram. See https://curl.haxx.se/docs/manpage.html\", \"name\": \"curl options\", \"type\": \"string\"}], \"metadata\": {\"annotations\": {\"author\": \"Alexey Volkov \", \"canonical_location\": \"https://raw.githubusercontent.com/Ark-kun/pipeline_components/master/components/web/Download/component.yaml\"}}, \"name\": \"Download data\", \"outputs\": [{\"name\": \"Data\"}]}", "pipelines.kubeflow.org/task_display_name":"Download training labels" }, "labels":{ "pipelines.kubeflow.org/cache_enabled":"true", "pipelines.kubeflow.org/enable_caching":"true", "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline-sdk-type":"kfp" } }, "name":"download-data-2", "outputs":{ "artifacts":[ { "name":"download-data-2-Data", "path":"/tmp/outputs/Data/data" } ] } }, { "dag":{ "tasks":[ { "name":"download-data", "template":"download-data" }, { "name":"download-data-2", "template":"download-data-2" }, { "arguments":{ "artifacts":[ { "from":"{{tasks.download-data-2.outputs.artifacts.download-data-2-Data}}", "name":"download-data-2-Data" }, { "from":"{{tasks.download-data.outputs.artifacts.download-data-Data}}", "name":"download-data-Data" } ] }, "dependencies":[ "download-data", "download-data-2" ], "name":"parse-mnist", "template":"parse-mnist" }, { "arguments":{ "artifacts":[ { "from":"{{tasks.parse-mnist.outputs.artifacts.parse-mnist-Dataset}}", "name":"parse-mnist-Dataset" } ] }, "dependencies":[ "parse-mnist" ], "name":"process", "template":"process" }, { "arguments":{ "artifacts":[ { "from":"{{tasks.process.outputs.artifacts.process-data_processed}}", "name":"process-data_processed" } ], "parameters":[ { "name":"batch_size", "value":"{{inputs.parameters.batch_size}}" }, { "name":"epochs", "value":"{{inputs.parameters.epochs}}" }, { "name":"loss", "value":"{{inputs.parameters.loss}}" }, { "name":"lr", "value":"{{inputs.parameters.lr}}" }, { "name":"optimizer", "value":"{{inputs.parameters.optimizer}}" } ] }, "dependencies":[ "process" ], "name":"train", "template":"train" } ] }, "inputs":{ "parameters":[ { "name":"batch_size" }, { "name":"epochs" }, { "name":"loss" }, { "name":"lr" }, { "name":"optimizer" } ] }, "name":"mnist-training-pipeline-katib" }, { "container":{ "args":[ ], "command":[ "sh", "-ec", "# This is how additional packages can be installed dynamically\npython3 -m pip install pip idx2numpy\n# Run the rest of the command after installing the packages.\n\"$0\" \"$@\"\n", "python3", "-u", "-c", "import gzip\nimport idx2numpy\nimport sys\nfrom pathlib import Path\nimport pickle\nimport tensorflow as tf\nimg_path = sys.argv[1]\nlabel_path = sys.argv[2]\noutput_path = sys.argv[3]\nwith gzip.open(img_path, 'rb') as f:\n x = idx2numpy.convert_from_string(f.read())\nwith gzip.open(label_path, 'rb') as f:\n y = idx2numpy.convert_from_string(f.read())\n#one-hot encode the categories\nx_out = tf.convert_to_tensor(x)\ny_out = tf.keras.utils.to_categorical(y)\nPath(output_path).parent.mkdir(parents=True, exist_ok=True)\nwith open(output_path, 'wb') as output_file:\n pickle.dump((x_out, y_out), output_file)\n", "/tmp/inputs/Images/data", "/tmp/inputs/Labels/data", "/tmp/outputs/Dataset/data" ], "image":"tensorflow/tensorflow:2.7.1" }, "inputs":{ "artifacts":[ { "name":"download-data-Data", "path":"/tmp/inputs/Images/data" }, { "name":"download-data-2-Data", "path":"/tmp/inputs/Labels/data" } ] }, "metadata":{ "annotations":{ "author":"Vito Zanotelli", "description":"Based on https://github.com/kubeflow/pipelines/blob/master/components/contrib/sample/Python_script/component.yaml", "pipelines.kubeflow.org/component_ref":"{\"digest\": \"7fa19555055a35cb66ac960540176715ac3caf8d0d28d15fe1ca9ddaa79f0d94\"}", "pipelines.kubeflow.org/component_spec":"{\"implementation\": {\"container\": {\"command\": [\"sh\", \"-ec\", \"# This is how additional packages can be installed dynamically\\npython3 -m pip install pip idx2numpy\\n# Run the rest of the command after installing the packages.\\n\\\"$0\\\" \\\"$@\\\"\\n\", \"python3\", \"-u\", \"-c\", \"import gzip\\nimport idx2numpy\\nimport sys\\nfrom pathlib import Path\\nimport pickle\\nimport tensorflow as tf\\nimg_path = sys.argv[1]\\nlabel_path = sys.argv[2]\\noutput_path = sys.argv[3]\\nwith gzip.open(img_path, \\'rb\\') as f:\\n x = idx2numpy.convert_from_string(f.read())\\nwith gzip.open(label_path, \\'rb\\') as f:\\n y = idx2numpy.convert_from_string(f.read())\\n#one-hot encode the categories\\nx_out = tf.convert_to_tensor(x)\\ny_out = tf.keras.utils.to_categorical(y)\\nPath(output_path).parent.mkdir(parents=True, exist_ok=True)\\nwith open(output_path, \\'wb\\') as output_file:\\n pickle.dump((x_out, y_out), output_file)\\n\", {\"inputPath\": \"Images\"}, {\"inputPath\": \"Labels\"}, {\"outputPath\": \"Dataset\"}], \"image\": \"tensorflow/tensorflow:2.7.1\"}}, \"inputs\": [{\"description\": \"gziped images in the idx format\", \"name\": \"Images\"}, {\"description\": \"gziped labels in the idx format\", \"name\": \"Labels\"}], \"metadata\": {\"annotations\": {\"author\": \"Vito Zanotelli\", \"description\": \"Based on https://github.com/kubeflow/pipelines/blob/master/components/contrib/sample/Python_script/component.yaml\"}}, \"name\": \"Parse MNIST\", \"outputs\": [{\"name\": \"Dataset\"}]}", "pipelines.kubeflow.org/task_display_name":"Prepare train dataset" }, "labels":{ "pipelines.kubeflow.org/enable_caching":"true", "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline-sdk-type":"kfp" } }, "name":"parse-mnist", "outputs":{ "artifacts":[ { "name":"parse-mnist-Dataset", "path":"/tmp/outputs/Dataset/data" } ] } }, { "container":{ "args":[ "--data-raw", "/tmp/inputs/data_raw/data", "--val-pct", "0.2", "--trainset-flag", "True", "--data-processed", "/tmp/outputs/data_processed/data" ], "command":[ "sh", "-c", "(PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scikit-learn\\' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scikit-learn\\' --user) && \"$0\" \"$@\"", "sh", "-ec", "program_path=$(mktemp)\nprintf \"%s\" \"$0\" > \"$program_path\"\npython3 -u \"$program_path\" \"$@\"\n", "def _make_parent_dirs_and_return_path(file_path: str):\n import os\n os.makedirs(os.path.dirname(file_path), exist_ok=True)\n return file_path\n\ndef process(\n data_raw_path, # type: ignore\n data_processed_path, # type: ignore\n val_pct = 0.2,\n trainset_flag = True,\n):\n \"\"\"\n Here we do all the preprocessing\n if the data path is for training data we:\n (1) Normalize the data\n (2) split the train and val data\n If it is for unseen test data, we:\n (1) Normalize the data\n This function returns in any case the processed data path\n \"\"\"\n # sklearn\n from sklearn.model_selection import train_test_split\n import pickle\n import numpy as np\n\n def img_norm(x):\n return np.reshape(x / 255, list(x.shape) + [1])\n\n with open(data_raw_path, \"rb\") as f:\n x, y = pickle.load(f)\n if trainset_flag:\n\n x_ = img_norm(x)\n x_train, x_val, y_train, y_val = train_test_split(\n x_, y, test_size=val_pct, stratify=y, random_state=42\n )\n\n with open(data_processed_path, \"wb\") as output_file:\n pickle.dump((x_train, y_train, x_val, y_val), output_file)\n\n else:\n x_ = img_norm(x)\n with open(data_processed_path, \"wb\") as output_file:\n pickle.dump((x_, y), output_file)\n\ndef _deserialize_bool(s) -> bool:\n from distutils.util import strtobool\n return strtobool(s) == 1\n\nimport argparse\n_parser = argparse.ArgumentParser(prog=\\'Process\\', description=\\'Here we do all the preprocessing\\')\n_parser.add_argument(\"--data-raw\", dest=\"data_raw_path\", type=str, required=True, default=argparse.SUPPRESS)\n_parser.add_argument(\"--val-pct\", dest=\"val_pct\", type=float, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--trainset-flag\", dest=\"trainset_flag\", type=_deserialize_bool, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--data-processed\", dest=\"data_processed_path\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\n_parsed_args = vars(_parser.parse_args())\n\n_outputs = process(**_parsed_args)\n" ], "image":"tensorflow/tensorflow:2.7.1" }, "inputs":{ "artifacts":[ { "name":"parse-mnist-Dataset", "path":"/tmp/inputs/data_raw/data" } ] }, "metadata":{ "annotations":{ "pipelines.kubeflow.org/arguments.parameters":"{\"trainset_flag\": \"True\", \"val_pct\": \"0.2\"}", "pipelines.kubeflow.org/component_ref":"{}", "pipelines.kubeflow.org/component_spec":"{\"description\": \"Here we do all the preprocessing\", \"implementation\": {\"container\": {\"args\": [\"--data-raw\", {\"inputPath\": \"data_raw\"}, {\"if\": {\"cond\": {\"isPresent\": \"val_pct\"}, \"then\": [\"--val-pct\", {\"inputValue\": \"val_pct\"}]}}, {\"if\": {\"cond\": {\"isPresent\": \"trainset_flag\"}, \"then\": [\"--trainset-flag\", {\"inputValue\": \"trainset_flag\"}]}}, \"--data-processed\", {\"outputPath\": \"data_processed\"}], \"command\": [\"sh\", \"-c\", \"(PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scikit-learn\\' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scikit-learn\\' --user) && \\\"$0\\\" \\\"$@\\\"\", \"sh\", \"-ec\", \"program_path=$(mktemp)\\nprintf \\\"%s\\\" \\\"$0\\\" > \\\"$program_path\\\"\\npython3 -u \\\"$program_path\\\" \\\"$@\\\"\\n\", \"def _make_parent_dirs_and_return_path(file_path: str):\\n import os\\n os.makedirs(os.path.dirname(file_path), exist_ok=True)\\n return file_path\\n\\ndef process(\\n data_raw_path, # type: ignore\\n data_processed_path, # type: ignore\\n val_pct = 0.2,\\n trainset_flag = True,\\n):\\n \\\"\\\"\\\"\\n Here we do all the preprocessing\\n if the data path is for training data we:\\n (1) Normalize the data\\n (2) split the train and val data\\n If it is for unseen test data, we:\\n (1) Normalize the data\\n This function returns in any case the processed data path\\n \\\"\\\"\\\"\\n # sklearn\\n from sklearn.model_selection import train_test_split\\n import pickle\\n import numpy as np\\n\\n def img_norm(x):\\n return np.reshape(x / 255, list(x.shape) + [1])\\n\\n with open(data_raw_path, \\\"rb\\\") as f:\\n x, y = pickle.load(f)\\n if trainset_flag:\\n\\n x_ = img_norm(x)\\n x_train, x_val, y_train, y_val = train_test_split(\\n x_, y, test_size=val_pct, stratify=y, random_state=42\\n )\\n\\n with open(data_processed_path, \\\"wb\\\") as output_file:\\n pickle.dump((x_train, y_train, x_val, y_val), output_file)\\n\\n else:\\n x_ = img_norm(x)\\n with open(data_processed_path, \\\"wb\\\") as output_file:\\n pickle.dump((x_, y), output_file)\\n\\ndef _deserialize_bool(s) -> bool:\\n from distutils.util import strtobool\\n return strtobool(s) == 1\\n\\nimport argparse\\n_parser = argparse.ArgumentParser(prog=\\'Process\\', description=\\'Here we do all the preprocessing\\')\\n_parser.add_argument(\\\"--data-raw\\\", dest=\\\"data_raw_path\\\", type=str, required=True, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--val-pct\\\", dest=\\\"val_pct\\\", type=float, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--trainset-flag\\\", dest=\\\"trainset_flag\\\", type=_deserialize_bool, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--data-processed\\\", dest=\\\"data_processed_path\\\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\\n_parsed_args = vars(_parser.parse_args())\\n\\n_outputs = process(**_parsed_args)\\n\"], \"image\": \"tensorflow/tensorflow:2.7.1\"}}, \"inputs\": [{\"name\": \"data_raw\", \"type\": \"String\"}, {\"default\": \"0.2\", \"name\": \"val_pct\", \"optional\": true, \"type\": \"Float\"}, {\"default\": \"True\", \"name\": \"trainset_flag\", \"optional\": true, \"type\": \"Boolean\"}], \"name\": \"Process\", \"outputs\": [{\"name\": \"data_processed\", \"type\": \"String\"}]}", "pipelines.kubeflow.org/task_display_name":"Preprocess images" }, "labels":{ "pipelines.kubeflow.org/enable_caching":"true", "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline-sdk-type":"kfp" } }, "name":"process", "outputs":{ "artifacts":[ { "name":"process-data_processed", "path":"/tmp/outputs/data_processed/data" } ] } }, { "container":{ "args":[ "--data-train", "/tmp/inputs/data_train/data", "--lr", "{{inputs.parameters.lr}}", "--optimizer", "{{inputs.parameters.optimizer}}", "--loss", "{{inputs.parameters.loss}}", "--epochs", "{{inputs.parameters.epochs}}", "--batch-size", "{{inputs.parameters.batch_size}}", "--model-out", "/tmp/outputs/model_out/data", "--mlpipeline-metrics", "/tmp/outputs/mlpipeline_metrics/data", "--metrics-log", "/tmp/outputs/metrics_log/data" ], "command":[ "sh", "-c", "(PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scipy\\' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scipy\\' --user) && \"$0\" \"$@\"", "sh", "-ec", "program_path=$(mktemp)\nprintf \"%s\" \"$0\" > \"$program_path\"\npython3 -u \"$program_path\" \"$@\"\n", "def _make_parent_dirs_and_return_path(file_path: str):\n import os\n os.makedirs(os.path.dirname(file_path), exist_ok=True)\n return file_path\n\ndef train(\n data_train_path, # type: ignore\n model_out_path, # type: ignore\n mlpipeline_metrics_path, # type: ignore # noqa: F821\n metrics_log_path, # type: ignore\n lr = 1e-4,\n optimizer = \"Adam\",\n loss = \"categorical_crossentropy\",\n epochs = 1,\n batch_size = 32,\n):\n \"\"\"\n This is the simulated train part of our ML pipeline where training is performed\n \"\"\"\n\n import tensorflow as tf\n import pickle\n from tensorflow.keras.preprocessing.image import ImageDataGenerator\n import json\n\n with open(data_train_path, \"rb\") as f:\n x_train, y_train, x_val, y_val = pickle.load(f)\n\n model = tf.keras.Sequential(\n [\n tf.keras.layers.Conv2D(\n 64, (3, 3), activation=\"relu\", input_shape=(28, 28, 1)\n ),\n tf.keras.layers.MaxPooling2D(2, 2),\n tf.keras.layers.Conv2D(64, (3, 3), activation=\"relu\"),\n tf.keras.layers.MaxPooling2D(2, 2),\n tf.keras.layers.Flatten(),\n tf.keras.layers.Dense(128, activation=\"relu\"),\n tf.keras.layers.Dense(10, activation=\"softmax\"),\n ]\n )\n\n if optimizer.lower() == \"sgd\":\n optimizer = tf.keras.optimizers.SGD(lr)\n else:\n optimizer = tf.keras.optimizers.Adam(lr)\n\n model.compile(loss=loss, optimizer=optimizer, metrics=[\"accuracy\"])\n\n # fit the model\n model_early_stopping_callback = tf.keras.callbacks.EarlyStopping(\n monitor=\"val_accuracy\", patience=10, verbose=1, restore_best_weights=True\n )\n\n train_datagen = ImageDataGenerator(horizontal_flip=False)\n\n validation_datagen = ImageDataGenerator()\n history = model.fit(\n train_datagen.flow(x_train, y_train, batch_size=batch_size),\n epochs=epochs,\n validation_data=validation_datagen.flow(x_val, y_val, batch_size=batch_size),\n shuffle=False,\n callbacks=[model_early_stopping_callback],\n )\n\n model.save(model_out_path, save_format=\"tf\")\n # Log accuracz\n print(history.history[\"accuracy\"])\n print(history.history[\"val_accuracy\"])\n\n metrics = {\n \"metrics\": [\n {\n \"name\": \"accuracy\", # The name of the metric. Visualized as the column name in the runs table.\n \"numberValue\": history.history[\"accuracy\"][\n -1\n ], # The value of the metric. Must be a numeric value.\n \"format\": \"PERCENTAGE\", # The optional format of the metric. Supported values are \"RAW\" (displayed in raw format) and \"PERCENTAGE\" (displayed in percentage format).\n },\n {\n \"name\": \"val-accuracy\", # The name of the metric. Visualized as the column name in the runs table.\n \"numberValue\": history.history[\"val_accuracy\"][\n -1\n ], # The value of the metric. Must be a numeric value.\n \"format\": \"PERCENTAGE\", # The optional format of the metric. Supported values are \"RAW\" (displayed in raw format) and \"PERCENTAGE\" (displayed in percentage format).\n },\n ]\n }\n with open(mlpipeline_metrics_path, \"w\") as f:\n json.dump(metrics, f)\n\n # Output metrics for Katib\n with open(metrics_log_path, \"w\") as f:\n f.write(f\"val-accuracy={history.history[\\'val_accuracy\\'][0]}\\n\")\n f.write(f\"accuracy={history.history[\\'accuracy\\'][0]}\\n\")\n print(metrics_log_path)\n\nimport argparse\n_parser = argparse.ArgumentParser(prog=\\'Train\\', description=\\'This is the simulated train part of our ML pipeline where training is performed\\')\n_parser.add_argument(\"--data-train\", dest=\"data_train_path\", type=str, required=True, default=argparse.SUPPRESS)\n_parser.add_argument(\"--lr\", dest=\"lr\", type=float, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--optimizer\", dest=\"optimizer\", type=str, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--loss\", dest=\"loss\", type=str, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--epochs\", dest=\"epochs\", type=int, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--batch-size\", dest=\"batch_size\", type=int, required=False, default=argparse.SUPPRESS)\n_parser.add_argument(\"--model-out\", dest=\"model_out_path\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\n_parser.add_argument(\"--mlpipeline-metrics\", dest=\"mlpipeline_metrics_path\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\n_parser.add_argument(\"--metrics-log\", dest=\"metrics_log_path\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\n_parsed_args = vars(_parser.parse_args())\n\n_outputs = train(**_parsed_args)\n" ], "image":"tensorflow/tensorflow:2.7.1" }, "inputs":{ "artifacts":[ { "name":"process-data_processed", "path":"/tmp/inputs/data_train/data" } ], "parameters":[ { "name":"batch_size" }, { "name":"epochs" }, { "name":"loss" }, { "name":"lr" }, { "name":"optimizer" } ] }, "metadata":{ "annotations":{ "pipelines.kubeflow.org/arguments.parameters":"{\"batch_size\": \"{{inputs.parameters.batch_size}}\", \"epochs\": \"{{inputs.parameters.epochs}}\", \"loss\": \"{{inputs.parameters.loss}}\", \"lr\": \"{{inputs.parameters.lr}}\", \"optimizer\": \"{{inputs.parameters.optimizer}}\"}", "pipelines.kubeflow.org/component_ref":"{}", "pipelines.kubeflow.org/component_spec":"{\"description\": \"This is the simulated train part of our ML pipeline where training is performed\", \"implementation\": {\"container\": {\"args\": [\"--data-train\", {\"inputPath\": \"data_train\"}, {\"if\": {\"cond\": {\"isPresent\": \"lr\"}, \"then\": [\"--lr\", {\"inputValue\": \"lr\"}]}}, {\"if\": {\"cond\": {\"isPresent\": \"optimizer\"}, \"then\": [\"--optimizer\", {\"inputValue\": \"optimizer\"}]}}, {\"if\": {\"cond\": {\"isPresent\": \"loss\"}, \"then\": [\"--loss\", {\"inputValue\": \"loss\"}]}}, {\"if\": {\"cond\": {\"isPresent\": \"epochs\"}, \"then\": [\"--epochs\", {\"inputValue\": \"epochs\"}]}}, {\"if\": {\"cond\": {\"isPresent\": \"batch_size\"}, \"then\": [\"--batch-size\", {\"inputValue\": \"batch_size\"}]}}, \"--model-out\", {\"outputPath\": \"model_out\"}, \"--mlpipeline-metrics\", {\"outputPath\": \"mlpipeline_metrics\"}, \"--metrics-log\", {\"outputPath\": \"metrics_log\"}], \"command\": [\"sh\", \"-c\", \"(PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scipy\\' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location \\'scipy\\' --user) && \\\"$0\\\" \\\"$@\\\"\", \"sh\", \"-ec\", \"program_path=$(mktemp)\\nprintf \\\"%s\\\" \\\"$0\\\" > \\\"$program_path\\\"\\npython3 -u \\\"$program_path\\\" \\\"$@\\\"\\n\", \"def _make_parent_dirs_and_return_path(file_path: str):\\n import os\\n os.makedirs(os.path.dirname(file_path), exist_ok=True)\\n return file_path\\n\\ndef train(\\n data_train_path, # type: ignore\\n model_out_path, # type: ignore\\n mlpipeline_metrics_path, # type: ignore # noqa: F821\\n metrics_log_path, # type: ignore\\n lr = 1e-4,\\n optimizer = \\\"Adam\\\",\\n loss = \\\"categorical_crossentropy\\\",\\n epochs = 1,\\n batch_size = 32,\\n):\\n \\\"\\\"\\\"\\n This is the simulated train part of our ML pipeline where training is performed\\n \\\"\\\"\\\"\\n\\n import tensorflow as tf\\n import pickle\\n from tensorflow.keras.preprocessing.image import ImageDataGenerator\\n import json\\n\\n with open(data_train_path, \\\"rb\\\") as f:\\n x_train, y_train, x_val, y_val = pickle.load(f)\\n\\n model = tf.keras.Sequential(\\n [\\n tf.keras.layers.Conv2D(\\n 64, (3, 3), activation=\\\"relu\\\", input_shape=(28, 28, 1)\\n ),\\n tf.keras.layers.MaxPooling2D(2, 2),\\n tf.keras.layers.Conv2D(64, (3, 3), activation=\\\"relu\\\"),\\n tf.keras.layers.MaxPooling2D(2, 2),\\n tf.keras.layers.Flatten(),\\n tf.keras.layers.Dense(128, activation=\\\"relu\\\"),\\n tf.keras.layers.Dense(10, activation=\\\"softmax\\\"),\\n ]\\n )\\n\\n if optimizer.lower() == \\\"sgd\\\":\\n optimizer = tf.keras.optimizers.SGD(lr)\\n else:\\n optimizer = tf.keras.optimizers.Adam(lr)\\n\\n model.compile(loss=loss, optimizer=optimizer, metrics=[\\\"accuracy\\\"])\\n\\n # fit the model\\n model_early_stopping_callback = tf.keras.callbacks.EarlyStopping(\\n monitor=\\\"val_accuracy\\\", patience=10, verbose=1, restore_best_weights=True\\n )\\n\\n train_datagen = ImageDataGenerator(horizontal_flip=False)\\n\\n validation_datagen = ImageDataGenerator()\\n history = model.fit(\\n train_datagen.flow(x_train, y_train, batch_size=batch_size),\\n epochs=epochs,\\n validation_data=validation_datagen.flow(x_val, y_val, batch_size=batch_size),\\n shuffle=False,\\n callbacks=[model_early_stopping_callback],\\n )\\n\\n model.save(model_out_path, save_format=\\\"tf\\\")\\n # Log accuracz\\n print(history.history[\\\"accuracy\\\"])\\n print(history.history[\\\"val_accuracy\\\"])\\n\\n metrics = {\\n \\\"metrics\\\": [\\n {\\n \\\"name\\\": \\\"accuracy\\\", # The name of the metric. Visualized as the column name in the runs table.\\n \\\"numberValue\\\": history.history[\\\"accuracy\\\"][\\n -1\\n ], # The value of the metric. Must be a numeric value.\\n \\\"format\\\": \\\"PERCENTAGE\\\", # The optional format of the metric. Supported values are \\\"RAW\\\" (displayed in raw format) and \\\"PERCENTAGE\\\" (displayed in percentage format).\\n },\\n {\\n \\\"name\\\": \\\"val-accuracy\\\", # The name of the metric. Visualized as the column name in the runs table.\\n \\\"numberValue\\\": history.history[\\\"val_accuracy\\\"][\\n -1\\n ], # The value of the metric. Must be a numeric value.\\n \\\"format\\\": \\\"PERCENTAGE\\\", # The optional format of the metric. Supported values are \\\"RAW\\\" (displayed in raw format) and \\\"PERCENTAGE\\\" (displayed in percentage format).\\n },\\n ]\\n }\\n with open(mlpipeline_metrics_path, \\\"w\\\") as f:\\n json.dump(metrics, f)\\n\\n # Output metrics for Katib\\n with open(metrics_log_path, \\\"w\\\") as f:\\n f.write(f\\\"val-accuracy={history.history[\\'val_accuracy\\'][0]}\\\\n\\\")\\n f.write(f\\\"accuracy={history.history[\\'accuracy\\'][0]}\\\\n\\\")\\n print(metrics_log_path)\\n\\nimport argparse\\n_parser = argparse.ArgumentParser(prog=\\'Train\\', description=\\'This is the simulated train part of our ML pipeline where training is performed\\')\\n_parser.add_argument(\\\"--data-train\\\", dest=\\\"data_train_path\\\", type=str, required=True, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--lr\\\", dest=\\\"lr\\\", type=float, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--optimizer\\\", dest=\\\"optimizer\\\", type=str, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--loss\\\", dest=\\\"loss\\\", type=str, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--epochs\\\", dest=\\\"epochs\\\", type=int, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--batch-size\\\", dest=\\\"batch_size\\\", type=int, required=False, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--model-out\\\", dest=\\\"model_out_path\\\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--mlpipeline-metrics\\\", dest=\\\"mlpipeline_metrics_path\\\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\\n_parser.add_argument(\\\"--metrics-log\\\", dest=\\\"metrics_log_path\\\", type=_make_parent_dirs_and_return_path, required=True, default=argparse.SUPPRESS)\\n_parsed_args = vars(_parser.parse_args())\\n\\n_outputs = train(**_parsed_args)\\n\"], \"image\": \"tensorflow/tensorflow:2.7.1\"}}, \"inputs\": [{\"name\": \"data_train\", \"type\": \"String\"}, {\"default\": \"0.0001\", \"name\": \"lr\", \"optional\": true, \"type\": \"Float\"}, {\"default\": \"Adam\", \"name\": \"optimizer\", \"optional\": true, \"type\": \"String\"}, {\"default\": \"categorical_crossentropy\", \"name\": \"loss\", \"optional\": true, \"type\": \"String\"}, {\"default\": \"1\", \"name\": \"epochs\", \"optional\": true, \"type\": \"Integer\"}, {\"default\": \"32\", \"name\": \"batch_size\", \"optional\": true, \"type\": \"Integer\"}], \"name\": \"Train\", \"outputs\": [{\"name\": \"model_out\", \"type\": \"String\"}, {\"name\": \"mlpipeline_metrics\", \"type\": \"Metrics\"}, {\"name\": \"metrics_log\", \"type\": \"String\"}]}", "pipelines.kubeflow.org/max_cache_staleness":"P0D" }, "labels":{ "katib.kubeflow.org/model-training":"true", "pipelines.kubeflow.org/cache_enabled":"true", "pipelines.kubeflow.org/enable_caching":"true", "pipelines.kubeflow.org/kfp_sdk_version":"1.8.18", "pipelines.kubeflow.org/pipeline-sdk-type":"kfp" } }, "name":"train", "outputs":{ "artifacts":[ { "name":"mlpipeline-metrics", "path":"/tmp/outputs/mlpipeline_metrics/data" }, { "name":"train-metrics_log", "path":"/tmp/outputs/metrics_log/data" }, { "name":"train-model_out", "path":"/tmp/outputs/model_out/data" } ] } } ] } } } }, "status":{ "completionTime":"2023-02-09T17:56:51Z", "conditions":[ { "lastTransitionTime":"2023-02-09T17:51:37Z", "lastUpdateTime":"2023-02-09T17:51:37Z", "message":"Experiment is created", "reason":"ExperimentCreated", "status":"True", "type":"Created" }, { "lastTransitionTime":"2023-02-09T17:56:51Z", "lastUpdateTime":"2023-02-09T17:56:51Z", "message":"Experiment is running", "reason":"ExperimentRunning", "status":"False", "type":"Running" }, { "lastTransitionTime":"2023-02-09T17:56:51Z", "lastUpdateTime":"2023-02-09T17:56:51Z", "message":"Experiment has failed because max failed count has reached", "reason":"ExperimentFailed", "status":"True", "type":"Failed" } ], "currentOptimalTrial":{ "observation":{ } }, "failedTrialList":[ "katib-kfp-mnist-custom-5z9nd67c", "katib-kfp-mnist-custom-fvw9bv9g" ], "startTime":"2023-02-09T17:51:37Z", "trials":2, "trialsFailed":2 } }