|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "eb98ef8f", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "from intrinsic.solutions import deployments\n", |
| 11 | + "from intrinsic.solutions import behavior_tree as bt" |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "markdown", |
| 16 | + "id": "50e02e1c", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "First, connect to the deployed solution:" |
| 20 | + ] |
| 21 | + }, |
| 22 | + { |
| 23 | + "cell_type": "code", |
| 24 | + "execution_count": null, |
| 25 | + "id": "e827eb16", |
| 26 | + "metadata": {}, |
| 27 | + "outputs": [], |
| 28 | + "source": [ |
| 29 | + "solution = deployments.connect_to_selected_solution()\n", |
| 30 | + "executive = solution.executive\n", |
| 31 | + "skills = solution.skills\n", |
| 32 | + "points_crud_skill = skills.com.example.points_crud" |
| 33 | + ] |
| 34 | + }, |
| 35 | + { |
| 36 | + "cell_type": "markdown", |
| 37 | + "id": "e622f4bc", |
| 38 | + "metadata": {}, |
| 39 | + "source": [ |
| 40 | + "Store two points in the KV storage:" |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "cell_type": "code", |
| 45 | + "execution_count": null, |
| 46 | + "id": "6878fdea", |
| 47 | + "metadata": {}, |
| 48 | + "outputs": [], |
| 49 | + "source": [ |
| 50 | + "create_points = points_crud_skill(create=True, return_value_key=\"create_points_log\")\n", |
| 51 | + "executive.run(create_points)\n", |
| 52 | + "\n", |
| 53 | + "result = executive.get_value(create_points.result)\n", |
| 54 | + "print(result)" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "markdown", |
| 59 | + "id": "91ed1cc6", |
| 60 | + "metadata": {}, |
| 61 | + "source": [ |
| 62 | + "## Redeploy your solution now\n", |
| 63 | + "\n", |
| 64 | + "It will demonstrate that data in the key-value storage survives redeployment.\n", |
| 65 | + "\n", |
| 66 | + "- In Flowstate, select File -> Redeploy.\n", |
| 67 | + "- Wait for redeployment to complete before running code in cells below." |
| 68 | + ] |
| 69 | + }, |
| 70 | + { |
| 71 | + "cell_type": "markdown", |
| 72 | + "id": "981462b5", |
| 73 | + "metadata": {}, |
| 74 | + "source": [ |
| 75 | + "Reconnect to the solution after it has been redeployed:" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": null, |
| 81 | + "id": "5b593596", |
| 82 | + "metadata": {}, |
| 83 | + "outputs": [], |
| 84 | + "source": [ |
| 85 | + "solution = deployments.connect_to_selected_solution()\n", |
| 86 | + "executive = solution.executive\n", |
| 87 | + "skills = solution.skills\n", |
| 88 | + "points_crud_skill = skills.com.example.points_crud" |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "cell_type": "markdown", |
| 93 | + "id": "e48f731b", |
| 94 | + "metadata": {}, |
| 95 | + "source": [ |
| 96 | + "Confirm that the contents of the KV storage survived the redeployment:" |
| 97 | + ] |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "code", |
| 101 | + "execution_count": null, |
| 102 | + "id": "b2f7c05d", |
| 103 | + "metadata": {}, |
| 104 | + "outputs": [], |
| 105 | + "source": [ |
| 106 | + "read_points = points_crud_skill(read=True, return_value_key=\"read_log\")\n", |
| 107 | + "executive.run(read_points)\n", |
| 108 | + "result = executive.get_value(read_points.result)\n", |
| 109 | + "print(result)" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "markdown", |
| 114 | + "id": "ce5bf121", |
| 115 | + "metadata": {}, |
| 116 | + "source": [ |
| 117 | + "Update a value stored in the KV storage:" |
| 118 | + ] |
| 119 | + }, |
| 120 | + { |
| 121 | + "cell_type": "code", |
| 122 | + "execution_count": null, |
| 123 | + "id": "c06faaea", |
| 124 | + "metadata": {}, |
| 125 | + "outputs": [], |
| 126 | + "source": [ |
| 127 | + "update_point = points_crud_skill(update=True, return_value_key=\"update_log\")\n", |
| 128 | + "executive.run(update_point)\n", |
| 129 | + "result = executive.get_value(update_point.result)\n", |
| 130 | + "print(result)" |
| 131 | + ] |
| 132 | + }, |
| 133 | + { |
| 134 | + "cell_type": "markdown", |
| 135 | + "id": "94cd7a0e", |
| 136 | + "metadata": {}, |
| 137 | + "source": [ |
| 138 | + "Finally, delete all points from the KV storage:" |
| 139 | + ] |
| 140 | + }, |
| 141 | + { |
| 142 | + "cell_type": "code", |
| 143 | + "execution_count": null, |
| 144 | + "id": "3c6b46db", |
| 145 | + "metadata": {}, |
| 146 | + "outputs": [], |
| 147 | + "source": [ |
| 148 | + "delete_points = points_crud_skill(delete=True, return_value_key=\"delete_log\")\n", |
| 149 | + "executive.run(delete_points)\n", |
| 150 | + "result = executive.get_value(delete_points.result)\n", |
| 151 | + "print(result)" |
| 152 | + ] |
| 153 | + } |
| 154 | + ], |
| 155 | + "metadata": { |
| 156 | + "kernelspec": { |
| 157 | + "display_name": "Python 3", |
| 158 | + "language": "python", |
| 159 | + "name": "python3" |
| 160 | + }, |
| 161 | + "language_info": { |
| 162 | + "codemirror_mode": { |
| 163 | + "name": "ipython", |
| 164 | + "version": 3 |
| 165 | + }, |
| 166 | + "file_extension": ".py", |
| 167 | + "mimetype": "text/x-python", |
| 168 | + "name": "python", |
| 169 | + "nbconvert_exporter": "python", |
| 170 | + "pygments_lexer": "ipython3", |
| 171 | + "version": "3.11.13" |
| 172 | + } |
| 173 | + }, |
| 174 | + "nbformat": 4, |
| 175 | + "nbformat_minor": 5 |
| 176 | +} |
0 commit comments