|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "e81c847e", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Integration with mlflow" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "markdown", |
| 13 | + "id": "b6aa588c", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "### Summary: \n", |
| 17 | + "##### Let's change config parameters to track training with mlflow" |
| 18 | + ] |
| 19 | + }, |
| 20 | + { |
| 21 | + "cell_type": "code", |
| 22 | + "execution_count": 3, |
| 23 | + "id": "35d5f728", |
| 24 | + "metadata": { |
| 25 | + "execution": { |
| 26 | + "iopub.execute_input": "2024-08-21T10:36:36.576223Z", |
| 27 | + "iopub.status.busy": "2024-08-21T10:36:36.575851Z", |
| 28 | + "iopub.status.idle": "2024-08-21T10:36:36.579517Z", |
| 29 | + "shell.execute_reply": "2024-08-21T10:36:36.579010Z", |
| 30 | + "shell.execute_reply.started": "2024-08-21T10:36:36.576205Z" |
| 31 | + } |
| 32 | + }, |
| 33 | + "outputs": [], |
| 34 | + "source": [ |
| 35 | + "# imports for loading the dataset\n", |
| 36 | + "from torch_geometric import datasets\n", |
| 37 | + "import torch\n", |
| 38 | + "import pandas as pd\n", |
| 39 | + "from torch_geometric.data import Data\n", |
| 40 | + "# importing Runner\n", |
| 41 | + "from cool_graph.runners import Runner" |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "code", |
| 46 | + "execution_count": 6, |
| 47 | + "id": "d82a914c", |
| 48 | + "metadata": { |
| 49 | + "execution": { |
| 50 | + "iopub.execute_input": "2024-08-21T10:37:07.692657Z", |
| 51 | + "iopub.status.busy": "2024-08-21T10:37:07.692267Z", |
| 52 | + "iopub.status.idle": "2024-08-21T10:37:29.043296Z", |
| 53 | + "shell.execute_reply": "2024-08-21T10:37:29.042582Z", |
| 54 | + "shell.execute_reply.started": "2024-08-21T10:37:07.692635Z" |
| 55 | + } |
| 56 | + }, |
| 57 | + "outputs": [ |
| 58 | + { |
| 59 | + "name": "stderr", |
| 60 | + "output_type": "stream", |
| 61 | + "text": [ |
| 62 | + "Downloading https://github.com/shchur/gnn-benchmark/raw/master/data/npz/amazon_electronics_computers.npz\n", |
| 63 | + "Processing...\n", |
| 64 | + "Done!\n" |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "data": { |
| 69 | + "text/plain": [ |
| 70 | + "Data(x=[13752, 767], edge_index=[2, 491722], y=[13752])" |
| 71 | + ] |
| 72 | + }, |
| 73 | + "execution_count": 6, |
| 74 | + "metadata": {}, |
| 75 | + "output_type": "execute_result" |
| 76 | + } |
| 77 | + ], |
| 78 | + "source": [ |
| 79 | + "# use simple Amazon dataset with Computers\n", |
| 80 | + "dataset = datasets.Amazon(root='./data/Amazon', name='Computers')\n", |
| 81 | + "data = dataset.data\n", |
| 82 | + "data" |
| 83 | + ] |
| 84 | + }, |
| 85 | + { |
| 86 | + "cell_type": "code", |
| 87 | + "execution_count": 7, |
| 88 | + "id": "3faa80be", |
| 89 | + "metadata": { |
| 90 | + "execution": { |
| 91 | + "iopub.execute_input": "2024-08-21T10:39:13.803082Z", |
| 92 | + "iopub.status.busy": "2024-08-21T10:39:13.802561Z", |
| 93 | + "iopub.status.idle": "2024-08-21T10:39:13.951912Z", |
| 94 | + "shell.execute_reply": "2024-08-21T10:39:13.950993Z", |
| 95 | + "shell.execute_reply.started": "2024-08-21T10:39:13.803052Z" |
| 96 | + } |
| 97 | + }, |
| 98 | + "outputs": [], |
| 99 | + "source": [ |
| 100 | + "# initializing Runner\n", |
| 101 | + "runner = Runner(data)" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "execution_count": 8, |
| 107 | + "id": "c0c84614", |
| 108 | + "metadata": { |
| 109 | + "execution": { |
| 110 | + "iopub.execute_input": "2024-08-21T10:55:27.607989Z", |
| 111 | + "iopub.status.busy": "2024-08-21T10:55:27.607408Z", |
| 112 | + "iopub.status.idle": "2024-08-21T10:55:27.612779Z", |
| 113 | + "shell.execute_reply": "2024-08-21T10:55:27.612280Z", |
| 114 | + "shell.execute_reply.started": "2024-08-21T10:55:27.607965Z" |
| 115 | + } |
| 116 | + }, |
| 117 | + "outputs": [], |
| 118 | + "source": [ |
| 119 | + "import urllib3\n", |
| 120 | + "\n", |
| 121 | + "runner.cfg[\"logging\"][\"use_mlflow\"] = True # making flag True to use mlflow\n", |
| 122 | + "runner.cfg[\"logging\"][\"mlflow\"] = {\n", |
| 123 | + " \"MLFLOW_TRACKING_URI\": \"https://ml-flow.msk.bd-cloud.mts.ru/\", # uri of \n", |
| 124 | + " \"MLFLOW_TRACKING_USERNAME\": \"username\",\n", |
| 125 | + " \"MLFLOW_TRACKING_PASSWORD\": \"password\",\n", |
| 126 | + " \"MLFLOW_S3_ENDPOINT_URL\": \"https://s3.mts-corp.ru\", # to save artifacts\n", |
| 127 | + " \"AWS_ACCESS_KEY_ID\": \"access_key\", # to save artifacts\n", |
| 128 | + " \"AWS_SECRET_ACCESS_KEY\": \"secret_access_key\", # to save artifacts\n", |
| 129 | + " \"MLFLOW_TRACKING_INSECURE_TLS\": \"true\", # to ignore the TLS certificate verification\n", |
| 130 | + " \"MLFLOW_S3_IGNORE_TLS\": \"true\", # to ignore the TLS certificate verification\n", |
| 131 | + " \"MLFLOW_DISABLE_INSECURE_REQUEST_WARNING\": True # to disable warnings\n", |
| 132 | + " }\n", |
| 133 | + "runner.cfg[\"logging\"][\"mlflow_experiment_name\"] = \"coolgraph_example\" # name of experiment\n", |
| 134 | + "\n", |
| 135 | + "urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # disabling request warning" |
| 136 | + ] |
| 137 | + }, |
| 138 | + { |
| 139 | + "cell_type": "code", |
| 140 | + "execution_count": 9, |
| 141 | + "id": "f154a32f", |
| 142 | + "metadata": { |
| 143 | + "execution": { |
| 144 | + "iopub.execute_input": "2024-08-21T10:55:36.670982Z", |
| 145 | + "iopub.status.busy": "2024-08-21T10:55:36.670511Z", |
| 146 | + "iopub.status.idle": "2024-08-21T10:56:53.936843Z", |
| 147 | + "shell.execute_reply": "2024-08-21T10:56:53.935934Z", |
| 148 | + "shell.execute_reply.started": "2024-08-21T10:55:36.670959Z" |
| 149 | + } |
| 150 | + }, |
| 151 | + "outputs": [ |
| 152 | + { |
| 153 | + "name": "stderr", |
| 154 | + "output_type": "stream", |
| 155 | + "text": [ |
| 156 | + "Sample data: 100%|██████████| 42/42 [00:04<00:00, 10.12it/s]\n", |
| 157 | + "Sample data: 100%|██████████| 14/14 [00:00<00:00, 14.57it/s]\n", |
| 158 | + "2024/08/21 13:55:44 INFO mlflow.tracking.fluent: Experiment with name 'coolgraph_example' does not exist. Creating a new experiment.\n", |
| 159 | + "2024-08-21 13:55:51 - epoch 0 test: \n", |
| 160 | + " {'accuracy': 0.505, 'cross_entropy': 1.31, 'f1_weighted': 0.451, 'calc_time': 0.006, 'main_metric': 0.505}\n", |
| 161 | + "2024-08-21 13:55:53 - epoch 0 train: \n", |
| 162 | + " {'accuracy': 0.497, 'cross_entropy': 1.313, 'f1_weighted': 0.442, 'calc_time': 0.016, 'main_metric': 0.497}\n", |
| 163 | + "2024-08-21 13:56:06 - epoch 5 test: \n", |
| 164 | + " {'accuracy': 0.9, 'cross_entropy': 0.299, 'f1_weighted': 0.899, 'calc_time': 0.006, 'main_metric': 0.9}\n", |
| 165 | + "2024-08-21 13:56:07 - epoch 5 train: \n", |
| 166 | + " {'accuracy': 0.919, 'cross_entropy': 0.246, 'f1_weighted': 0.918, 'calc_time': 0.012, 'main_metric': 0.919}\n", |
| 167 | + "2024-08-21 13:56:20 - epoch 10 test: \n", |
| 168 | + " {'accuracy': 0.918, 'cross_entropy': 0.268, 'f1_weighted': 0.918, 'calc_time': 0.006, 'main_metric': 0.918}\n", |
| 169 | + "2024-08-21 13:56:21 - epoch 10 train: \n", |
| 170 | + " {'accuracy': 0.953, 'cross_entropy': 0.156, 'f1_weighted': 0.953, 'calc_time': 0.014, 'main_metric': 0.953}\n", |
| 171 | + "2024-08-21 13:56:34 - epoch 15 test: \n", |
| 172 | + " {'accuracy': 0.92, 'cross_entropy': 0.277, 'f1_weighted': 0.92, 'calc_time': 0.005, 'main_metric': 0.92}\n", |
| 173 | + "2024-08-21 13:56:35 - epoch 15 train: \n", |
| 174 | + " {'accuracy': 0.961, 'cross_entropy': 0.124, 'f1_weighted': 0.961, 'calc_time': 0.011, 'main_metric': 0.961}\n", |
| 175 | + "2024-08-21 13:56:48 - epoch 20 test: \n", |
| 176 | + " {'accuracy': 0.921, 'cross_entropy': 0.296, 'f1_weighted': 0.92, 'calc_time': 0.008, 'main_metric': 0.921}\n", |
| 177 | + "2024-08-21 13:56:50 - epoch 20 train: \n", |
| 178 | + " {'accuracy': 0.969, 'cross_entropy': 0.098, 'f1_weighted': 0.969, 'calc_time': 0.012, 'main_metric': 0.969}\n" |
| 179 | + ] |
| 180 | + } |
| 181 | + ], |
| 182 | + "source": [ |
| 183 | + "result = runner.run()" |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "cell_type": "markdown", |
| 188 | + "id": "c835b041", |
| 189 | + "metadata": {}, |
| 190 | + "source": [ |
| 191 | + "### Let's see the results on Mlflow tracker" |
| 192 | + ] |
| 193 | + }, |
| 194 | + { |
| 195 | + "cell_type": "markdown", |
| 196 | + "id": "c67c3798", |
| 197 | + "metadata": { |
| 198 | + "execution": { |
| 199 | + "iopub.execute_input": "2024-08-21T11:08:43.663318Z", |
| 200 | + "iopub.status.busy": "2024-08-21T11:08:43.662778Z", |
| 201 | + "iopub.status.idle": "2024-08-21T11:08:43.939813Z", |
| 202 | + "shell.execute_reply": "2024-08-21T11:08:43.938751Z", |
| 203 | + "shell.execute_reply.started": "2024-08-21T11:08:43.663287Z" |
| 204 | + } |
| 205 | + }, |
| 206 | + "source": [ |
| 207 | + " " |
| 208 | + ] |
| 209 | + }, |
| 210 | + { |
| 211 | + "cell_type": "markdown", |
| 212 | + "id": "cbac9ca5", |
| 213 | + "metadata": {}, |
| 214 | + "source": [ |
| 215 | + "### Success!" |
| 216 | + ] |
| 217 | + }, |
| 218 | + { |
| 219 | + "cell_type": "code", |
| 220 | + "execution_count": null, |
| 221 | + "id": "686924be", |
| 222 | + "metadata": {}, |
| 223 | + "outputs": [], |
| 224 | + "source": [] |
| 225 | + } |
| 226 | + ], |
| 227 | + "metadata": { |
| 228 | + "kernelspec": { |
| 229 | + "display_name": "CGKerner", |
| 230 | + "language": "python", |
| 231 | + "name": "cgkerner" |
| 232 | + }, |
| 233 | + "language_info": { |
| 234 | + "codemirror_mode": { |
| 235 | + "name": "ipython", |
| 236 | + "version": 3 |
| 237 | + }, |
| 238 | + "file_extension": ".py", |
| 239 | + "mimetype": "text/x-python", |
| 240 | + "name": "python", |
| 241 | + "nbconvert_exporter": "python", |
| 242 | + "pygments_lexer": "ipython3", |
| 243 | + "version": "3.8.13" |
| 244 | + } |
| 245 | + }, |
| 246 | + "nbformat": 4, |
| 247 | + "nbformat_minor": 5 |
| 248 | +} |
0 commit comments