cloud_sdk.ipynb
1 { 2 "cells": [ 3 { 4 "metadata": {}, 5 "cell_type": "markdown", 6 "source": "# Initialization", 7 "id": "18aaa30cb5d96f65" 8 }, 9 { 10 "cell_type": "code", 11 "id": "initial_id", 12 "metadata": { 13 "collapsed": true 14 }, 15 "source": [ 16 "from evidently.errors import EvidentlyError\n", 17 "from evidently.ui.workspace import CloudWorkspace" 18 ], 19 "outputs": [], 20 "execution_count": null 21 }, 22 { 23 "metadata": {}, 24 "cell_type": "code", 25 "source": [ 26 "client = CloudWorkspace(\n", 27 " token=\"\",\n", 28 " # Token can be provided as argument or environment variable EVIDENTLY_API_KEY, if it is provided as argument, environment variable is ignored\n", 29 " url=\"http://localhost:8003\",\n", 30 ")" 31 ], 32 "id": "dc8728470343b60a", 33 "outputs": [], 34 "execution_count": null 35 }, 36 { 37 "metadata": {}, 38 "cell_type": "markdown", 39 "source": "# Project Management", 40 "id": "3ffb105d37d491e4" 41 }, 42 { 43 "metadata": {}, 44 "cell_type": "markdown", 45 "source": "## Create project", 46 "id": "233ba74ce7a4f1ab" 47 }, 48 { 49 "metadata": {}, 50 "cell_type": "code", 51 "source": [ 52 "project = client.create_project(\"SDK Project v2\", \"Example project\", \"0194b6e3-f638-767c-b256-991e29cdfa4e\")\n", 53 "project" 54 ], 55 "id": "c76743354c4682f4", 56 "outputs": [], 57 "execution_count": null 58 }, 59 { 60 "metadata": {}, 61 "cell_type": "markdown", 62 "source": "## Get Project by its ID", 63 "id": "157e28de30d74801" 64 }, 65 { 66 "metadata": {}, 67 "cell_type": "code", 68 "source": "client.get_project(project.id)", 69 "id": "c2ce7109574e500a", 70 "outputs": [], 71 "execution_count": null 72 }, 73 { 74 "metadata": {}, 75 "cell_type": "markdown", 76 "source": "## Update Project metadata", 77 "id": "3dbd9984d46eb833" 78 }, 79 { 80 "metadata": {}, 81 "cell_type": "code", 82 "source": [ 83 "project = client.get_project(project.id)\n", 84 "project.name = \"SDK Project v2 (new)\"\n", 85 "project.description = \"Renamed example project\"\n", 86 "project.save()\n", 87 "\n", 88 "client.get_project(project.id)" 89 ], 90 "id": "bbbacb706c9073d4", 91 "outputs": [], 92 "execution_count": null 93 }, 94 { 95 "metadata": {}, 96 "cell_type": "markdown", 97 "source": "## Delete Project", 98 "id": "1a09b2e5a36393bd" 99 }, 100 { 101 "metadata": {}, 102 "cell_type": "code", 103 "source": [ 104 "client.delete_project(project.id)\n", 105 "try:\n", 106 " client.get_project(project.id)\n", 107 "except EvidentlyError as e:\n", 108 " print(e)" 109 ], 110 "id": "e839572e90734be4", 111 "outputs": [], 112 "execution_count": null 113 }, 114 { 115 "metadata": {}, 116 "cell_type": "markdown", 117 "source": "# Dashboard management", 118 "id": "a21361ef689888e2" 119 }, 120 { 121 "metadata": {}, 122 "cell_type": "code", 123 "source": [ 124 "project = client.create_project(\n", 125 " \"SDK Project v2 Dashboard project\",\n", 126 " \"Example dashboard project\",\n", 127 " \"0194b6e3-f638-767c-b256-991e29cdfa4e\"\n", 128 " )" 129 ], 130 "id": "ae39ac416755b6e8", 131 "outputs": [], 132 "execution_count": null 133 }, 134 { 135 "metadata": {}, 136 "cell_type": "markdown", 137 "source": "## Create Dashboard tabs and panels", 138 "id": "4d594e712c454d3" 139 }, 140 { 141 "metadata": {}, 142 "cell_type": "code", 143 "source": [ 144 "from evidently.ui.workspace import PanelMetric\n", 145 "from evidently.ui.workspace import DashboardPanelPlot" 146 ], 147 "id": "69e4ff9cd839c929", 148 "outputs": [], 149 "execution_count": null 150 }, 151 { 152 "metadata": {}, 153 "cell_type": "code", 154 "source": [ 155 "project.dashboard.add_tab(\"General\")\n", 156 "project.dashboard.add_tab(\"Specific\")" 157 ], 158 "id": "d7f70df01e3b3a17", 159 "outputs": [], 160 "execution_count": null 161 }, 162 { 163 "metadata": {}, 164 "cell_type": "code", 165 "source": "project.dashboard", 166 "id": "9398a33e9eb5cb57", 167 "outputs": [], 168 "execution_count": null 169 }, 170 { 171 "metadata": {}, 172 "cell_type": "markdown", 173 "source": "### Add Dashboard Panel to existing tab", 174 "id": "40fb9663c8c595e" 175 }, 176 { 177 "metadata": {}, 178 "cell_type": "code", 179 "source": [ 180 "project.dashboard.add_panel(\n", 181 " DashboardPanelPlot(\n", 182 " title=\"New Panel\", # optional (default: None), panel title, if None - default panel name will be used\n", 183 " subtitle=\"\", # optional (default: None), panel title, if None - default panel name will be used\n", 184 " size=\"half\", # optional (default: \"full\"), panel size - \"full\" - full width of area or \"half\" - only half of width of area.\n", 185 " values=[ # required - list of metrics to plot in panel\n", 186 " PanelMetric(\n", 187 " legend=\"Min value of Numerical_1\", # optional (default: None), name of series in legend,\n", 188 " # if None - server will choose name for series automatically \n", 189 " tags=[], # optional (default: [])\n", 190 " metadata={}, # optional (default: {})\n", 191 " metric=\"evidently:metric_v2:MinValue\", # required\n", 192 " metric_labels={\"column\": \"Numerical_1\"}, # optional (default: {})\n", 193 " view_params={}, # additional parameters for plot series visualization, optional (default: {})\n", 194 " ),\n", 195 " ],\n", 196 " plot_params={ # additional params for panel visualizations\n", 197 " \"plotType\": \"line\", # plot type to use\n", 198 " },\n", 199 " ),\n", 200 " tab=\"Specific\", # tab to place panel in, optional (default: None),\n", 201 " # if None - panel will be placed in first tab in dashboard\n", 202 " # (if no tabs exist - then tab \"General\" will be created and panel will be placed there)\n", 203 " create_if_not_exists=True, # optional (default: True), if True and tab with given name does not exist it will be automatically create,\n", 204 " # otherwise - throw exception\n", 205 ")\n", 206 "\n", 207 "project.dashboard" 208 ], 209 "id": "c1c034ed01dfb380", 210 "outputs": [], 211 "execution_count": null 212 }, 213 { 214 "metadata": {}, 215 "cell_type": "markdown", 216 "source": "### Add panel to default (first) tab", 217 "id": "bfa9c51b3e0552f0" 218 }, 219 { 220 "metadata": {}, 221 "cell_type": "code", 222 "source": [ 223 "project.dashboard.add_panel(\n", 224 " DashboardPanelPlot(\n", 225 " title=\"New Panel 2\",\n", 226 " size=\"half\",\n", 227 " values=[\n", 228 " PanelMetric(metric=\"evidently:metric_v2:MinValue\", metric_labels={\"column\": \"Numerical_1\"}),\n", 229 " ],\n", 230 " plot_params={\n", 231 " \"plotType\": \"line\",\n", 232 " },\n", 233 " ),\n", 234 ")\n", 235 "\n", 236 "project.dashboard" 237 ], 238 "id": "6d3b554eb090a7a0", 239 "outputs": [], 240 "execution_count": null 241 }, 242 { 243 "metadata": {}, 244 "cell_type": "markdown", 245 "source": "### Add panel to a new tab", 246 "id": "5342c5775b58104c" 247 }, 248 { 249 "metadata": {}, 250 "cell_type": "code", 251 "source": [ 252 "project.dashboard.add_panel(\n", 253 " DashboardPanelPlot(\n", 254 " title=\"New Panel 3\",\n", 255 " size=\"half\",\n", 256 " values=[\n", 257 " PanelMetric(metric=\"evidently:metric_v2:MinValue\", metric_labels={\"column\": \"Numerical_1\"}),\n", 258 " ],\n", 259 " plot_params={\n", 260 " \"plotType\": \"line\",\n", 261 " },\n", 262 " ),\n", 263 " tab=\"Auto created Tab\"\n", 264 ")\n", 265 "\n", 266 "project.dashboard" 267 ], 268 "id": "444be1d732dd0d1", 269 "outputs": [], 270 "execution_count": null 271 }, 272 { 273 "metadata": {}, 274 "cell_type": "markdown", 275 "source": "### Delete panel from tab", 276 "id": "859d0db33d35c8f8" 277 }, 278 { 279 "metadata": {}, 280 "cell_type": "code", 281 "source": [ 282 "project.dashboard.delete_panel(\"New Panel 2\", \"General\")\n", 283 "project.dashboard" 284 ], 285 "id": "365aba73c441165c", 286 "outputs": [], 287 "execution_count": null 288 }, 289 { 290 "metadata": {}, 291 "cell_type": "markdown", 292 "source": "### Delete tab from dashboard", 293 "id": "7a12d6f0a4dedb" 294 }, 295 { 296 "metadata": {}, 297 "cell_type": "code", 298 "source": [ 299 "project.dashboard.delete_tab(\"Auto created Tab\")\n", 300 "project.dashboard" 301 ], 302 "id": "750aa619d387f9ab", 303 "outputs": [], 304 "execution_count": null 305 }, 306 { 307 "metadata": {}, 308 "cell_type": "code", 309 "source": "", 310 "id": "48e1e708ee3178e4", 311 "outputs": [], 312 "execution_count": null 313 }, 314 { 315 "metadata": {}, 316 "cell_type": "code", 317 "source": "", 318 "id": "c6a7d88f5c620d8f", 319 "outputs": [], 320 "execution_count": null 321 }, 322 { 323 "metadata": {}, 324 "cell_type": "code", 325 "source": "", 326 "id": "881f8632916c0982", 327 "outputs": [], 328 "execution_count": null 329 } 330 ], 331 "metadata": { 332 "kernelspec": { 333 "display_name": "Python 3", 334 "language": "python", 335 "name": "python3" 336 }, 337 "language_info": { 338 "codemirror_mode": { 339 "name": "ipython", 340 "version": 2 341 }, 342 "file_extension": ".py", 343 "mimetype": "text/x-python", 344 "name": "python", 345 "nbconvert_exporter": "python", 346 "pygments_lexer": "ipython2", 347 "version": "2.7.6" 348 } 349 }, 350 "nbformat": 4, 351 "nbformat_minor": 5 352 }