Skip to content

Commit c39547c

Browse files
authored
feat: add notebook to upgrade shared tier (#136)
* feat: add notebook to upgrade shared tier * Update nootebook * update python-udf-template/notebook.ipynb according to commit hooks * apply comments * Extend notebook to also migrate scheduled jobs * rename notebook * update notebook to match new API spec * update warnings * udate mng api and comments * minor fixes * minor fixes
1 parent 6c273a1 commit c39547c

File tree

4 files changed

+353
-20
lines changed

4 files changed

+353
-20
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[meta]
2+
authors=["singlestore"]
3+
title="Migrate Your Virtual Workspace"
4+
description="""\
5+
Learn how to migrate Your VirtualWorkspace\
6+
to a fullfledged Workspace in a dedicated
7+
Workspace Group.
8+
"""
9+
icon="browser"
10+
difficulty="intermediate"
11+
tags=["starter", "notebooks"]
12+
lesson_areas=[]
13+
destinations=["spaces"]
14+
minimum_tier="standard"
Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
{
2+
"cells": [
3+
{
4+
"id": "89f14efd",
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"<div id=\"singlestore-header\" style=\"display: flex; background-color: rgba(235, 249, 245, 0.25); padding: 5px;\">\n",
9+
" <div id=\"icon-image\" style=\"width: 90px; height: 90px;\">\n",
10+
" <img width=\"100%\" height=\"100%\" src=\"https://raw.githubusercontent.com/singlestore-labs/spaces-notebooks/master/common/images/header-icons/browser.png\" />\n",
11+
" </div>\n",
12+
" <div id=\"text\" style=\"padding: 5px; margin-left: 10px;\">\n",
13+
" <div id=\"badge\" style=\"display: inline-block; background-color: rgba(0, 0, 0, 0.15); border-radius: 4px; padding: 4px 8px; align-items: center; margin-top: 6px; margin-bottom: -2px; font-size: 80%\">SingleStore Notebooks</div>\n",
14+
" <h1 style=\"font-weight: 500; margin: 8px 0 0 4px;\">Migrate Your Virtual Workspace</h1>\n",
15+
" </div>\n",
16+
"</div>"
17+
]
18+
},
19+
{
20+
"cell_type": "markdown",
21+
"id": "067bfdc9",
22+
"metadata": {},
23+
"source": [
24+
"<div class=\"alert alert-block alert-warning\">\n",
25+
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
26+
" <div>\n",
27+
" <p><b>Note</b></p>\n",
28+
" <p>This notebook is in preview and requires your Organization to have access to the Migrate Shared Deployment Feature. Please reach out to us if you'd like to request access.</p>\n",
29+
" <p>This notebook should be run on any shared deployment (including on a Free Starter Workspace) in an Organization whose plan allow for the creation of a new dedicated deployment.</p>\n",
30+
" <p>To create a Free Starter Workspace navigate to <tt>Start</tt> using the left nav.</p>\n",
31+
" </div>\n",
32+
"</div>"
33+
]
34+
},
35+
{
36+
"attachments": {},
37+
"cell_type": "markdown",
38+
"id": "750ba802",
39+
"metadata": {},
40+
"source": [
41+
"This notebook will show you how to migrate your shared deployment to a new dedicated deployment.\n",
42+
"All the fields have default values set, but we encourage you to customize them.\n",
43+
"The required information is:\n",
44+
"- a new name for your new Workspace in the dedicated deployment\n",
45+
"- the desired size of your new Workspace in the dedicated deployment (see: https://www.singlestore.com/cloud-pricing/)\n",
46+
"- a custom name for your new workspace group\n",
47+
"- the id of the region to create your new workspace group"
48+
]
49+
},
50+
{
51+
"attachments": {},
52+
"cell_type": "markdown",
53+
"id": "d492e34d",
54+
"metadata": {},
55+
"source": [
56+
"<div class=\"alert alert-block alert-warning\">\n",
57+
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
58+
" <div>\n",
59+
" <p><b>Warning</b></p>\n",
60+
" <p>During the migration process data written to the shared deployment may not be moved to the new dedicated deployment. The shared deployment will remain available during (and after) the migration process, however any writes to the shared deployment after the migration process begins may not be reflected on the new deployment.</p>\n",
61+
" <p>The migration process will copy your data to the new deployment and, by default, move any jobs you had scheduled for your shared deployment to the new deployment. You can elect not to move your scheduled jobs. If you do so, you can manually move them later from the Jobs page.</p>\n",
62+
" <p>While your migrated data will also remain available on your shared deployment, if you decided to migrate your Jobs, they are going to be unavailable until the migration process is finished.</p>\n",
63+
" <p></p>\n",
64+
" <p>Please account for this behavior when migrating.</p>\n",
65+
" </div>\n",
66+
"</div>"
67+
]
68+
},
69+
{
70+
"attachments": {},
71+
"cell_type": "markdown",
72+
"id": "f3dfd325",
73+
"metadata": {},
74+
"source": [
75+
"## Choose a Region for the new deployment\n",
76+
"Please select the Region you desire your new deployment to be created on from the dropdown after the next cell."
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 1,
82+
"id": "91c80425",
83+
"metadata": {},
84+
"outputs": [],
85+
"source": [
86+
"import requests, os\n",
87+
"from ipywidgets import widgets\n",
88+
"\n",
89+
"api_url = os.environ['SINGLESTOREDB_MANAGEMENT_BASE_URL']\n",
90+
"region_response = requests.get('{}/v2/regions'.format(api_url), headers={'Authorization': 'Bearer {}'.format(connection_password)})\n",
91+
"regions = [[f\"{r['region']} : {r['provider']} - {r['regionName']}\", [r['provider'], r['regionName']]] for r in region_response.json()]\n",
92+
"region_dropdown = widgets.Dropdown(\n",
93+
" options = regions,\n",
94+
" value = regions[0][1],\n",
95+
" description = 'Region:',\n",
96+
" disabled = False,\n",
97+
")\n",
98+
"\n",
99+
"display(region_dropdown)"
100+
]
101+
},
102+
{
103+
"attachments": {},
104+
"cell_type": "markdown",
105+
"id": "d612fde9",
106+
"metadata": {},
107+
"source": [
108+
"## Choose a Name for the new workspace group\n",
109+
"Please insert the name for your new Workspace Group in text box after the next cell."
110+
]
111+
},
112+
{
113+
"cell_type": "code",
114+
"execution_count": 2,
115+
"id": "1b2e37e2",
116+
"metadata": {},
117+
"outputs": [],
118+
"source": [
119+
"from ipywidgets import widgets\n",
120+
"\n",
121+
"workspace_group_name_text_box = widgets.Text(\n",
122+
" value='MigrationGroup',\n",
123+
" placeholder='Insert a name',\n",
124+
" description='Name:'\n",
125+
")\n",
126+
"\n",
127+
"display(workspace_group_name_text_box)"
128+
]
129+
},
130+
{
131+
"attachments": {},
132+
"cell_type": "markdown",
133+
"id": "cfd310c0",
134+
"metadata": {},
135+
"source": [
136+
"## Choose a Name for the new workspace\n",
137+
"Please insert the name for your new Workspace in text box after the next cell."
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"execution_count": 3,
143+
"id": "3032d557",
144+
"metadata": {},
145+
"outputs": [],
146+
"source": [
147+
"from ipywidgets import widgets\n",
148+
"\n",
149+
"workspace_name_text_box = widgets.Text(\n",
150+
" value='migrated-workspace',\n",
151+
" placeholder='Insert a name',\n",
152+
" description='Name:'\n",
153+
")\n",
154+
"\n",
155+
"display(workspace_name_text_box)"
156+
]
157+
},
158+
{
159+
"attachments": {},
160+
"cell_type": "markdown",
161+
"id": "2bcb9f24",
162+
"metadata": {},
163+
"source": [
164+
"## Choose the size for the new workspace\n",
165+
"Please insert the size for your new Workspace in text box after the next cell.\n",
166+
"If you are unsure which size to choose, you can check them [here](https://www.singlestore.com/cloud-pricing/)."
167+
]
168+
},
169+
{
170+
"cell_type": "code",
171+
"execution_count": 4,
172+
"id": "703ff15e",
173+
"metadata": {},
174+
"outputs": [],
175+
"source": [
176+
"from ipywidgets import widgets\n",
177+
"\n",
178+
"size_text_box = widgets.Text(\n",
179+
" value='S-00',\n",
180+
" placeholder='Insert a size',\n",
181+
" description='Size:',\n",
182+
" layout={'width': 'max-content'}\n",
183+
")\n",
184+
"\n",
185+
"display(size_text_box)"
186+
]
187+
},
188+
{
189+
"attachments": {},
190+
"cell_type": "markdown",
191+
"id": "ad57d499",
192+
"metadata": {},
193+
"source": [
194+
"<div class=\"alert alert-block alert-warning\">\n",
195+
" <b class=\"fa fa-solid fa-exclamation-circle\"></b>\n",
196+
" <div>\n",
197+
" <p><b>Warning</b></p>\n",
198+
" <p>After runnig the next cell, data written to the shared deployment may not be moved to the new Workspace.</p>\n",
199+
" <p>If you do not wish to move your scheduled jobs, you should set \"migrateScheduledJobs\" to false on the request body below.</p>\n",
200+
" <p></p>\n",
201+
" </div>\n",
202+
"</div>"
203+
]
204+
},
205+
{
206+
"attachments": {},
207+
"cell_type": "markdown",
208+
"id": "04adceb6",
209+
"metadata": {},
210+
"source": [
211+
"## Begin the migration process\n",
212+
"Runing the next cell will start the migration process"
213+
]
214+
},
215+
{
216+
"cell_type": "code",
217+
"execution_count": 5,
218+
"id": "edce432c",
219+
"metadata": {},
220+
"outputs": [],
221+
"source": [
222+
"import requests, os\n",
223+
"from ipywidgets import widgets\n",
224+
"\n",
225+
"workspace_id = os.environ['SINGLESTOREDB_VIRTUAL_WORKSPACE']\n",
226+
"api_url = os.environ['SINGLESTOREDB_MANAGEMENT_BASE_URL']\n",
227+
"\n",
228+
"migrate_response = requests.post('{}/v1/sharedtier/virtualWorkspaces/{}/migrate'.format(api_url, workspace_id), headers={'Authorization': 'Bearer {}'.format(connection_password)}, json={\n",
229+
" \"migrateScheduledJobs\": True,\n",
230+
" \"destinationWorkspace\": {\n",
231+
" \"name\": workspace_name_text_box.value,\n",
232+
" \"provider\": region_dropdown.value[0],\n",
233+
" \"regionName\": region_dropdown.value[1],\n",
234+
" \"size\": size_text_box.value,\n",
235+
" \"workspaceGroupName\": workspace_group_name_text_box.value\n",
236+
" }\n",
237+
"})\n",
238+
"\n",
239+
"if migrate_response.status_code == 200:\n",
240+
" display(widgets.HTML(f\"<div class='alert alert-block alert-success'><b class='fa fa-solid fa-check-circle'></b><div><p><b>Migration Started</b></p><p>See next cell for progress</p></div></div>\"))\n",
241+
"else:\n",
242+
" display(widgets.HTML(f\"<div class='alert alert-block alert-danger'><b class='fa fa-solid fa-exclamation-triangle'></b><div><p><b>Failed to Start Migration</b></p><p>{migrate_response.status_code} - {migrate_response.text}</p></div></div>\"))"
243+
]
244+
},
245+
{
246+
"attachments": {},
247+
"cell_type": "markdown",
248+
"id": "fb825bce",
249+
"metadata": {},
250+
"source": [
251+
"## Check the progress of the migration\n",
252+
"Running the next cell will give you progress on the migration"
253+
]
254+
},
255+
{
256+
"cell_type": "code",
257+
"execution_count": 6,
258+
"id": "9885c925",
259+
"metadata": {},
260+
"outputs": [],
261+
"source": [
262+
"import requests, os, time\n",
263+
"from ipywidgets import widgets\n",
264+
"\n",
265+
"workspace_id = os.environ['SINGLESTOREDB_VIRTUAL_WORKSPACE']\n",
266+
"organization_id = os.environ['SINGLESTOREDB_ORGANIZATION']\n",
267+
"api_url = os.environ['SINGLESTOREDB_MANAGEMENT_BASE_URL']\n",
268+
"\n",
269+
"status_response = requests.get('{}/v1/sharedtier/virtualWorkspaces/{}/migrations'.format(api_url, workspace_id), headers={'Authorization': 'Bearer {}'.format(connection_password)})\n",
270+
"\n",
271+
"if status_response.json()[0][\"migrationStatus\"] == \"SUCCEEDED\":\n",
272+
" display(widgets.HTML('<div class=\"alert alert-block alert-success\"><b class=\"fa fa-solid fa-check-circle\"></b><div><p><b>Success</b></p><p>The migration has completed succesfully! you can now visit your new workpace in the deployments page. If you wish to do so, you can now terminate your shared deployment from the deployments page.</p></div></div>'))\n",
273+
"\n",
274+
"else:\n",
275+
" display(widgets.HTML('<div class=\"alert alert-block alert-info\"><b class=\"fa fa-solid fa-info-circle\"></b><div><p><b>In Progress</b></p><p>your Shared Deployment is being migrated.</p></div></div>'))\n",
276+
"\n",
277+
" while status_response.json()[0][\"migrationStatus\"] not in [\"SUCCEEDED\", \"FAILED\"]:\n",
278+
" time.sleep(30)\n",
279+
" status_response = requests.get('{}/v1/sharedtier/virtualWorkspaces/{}/migrations'.format(api_url, workspace_id), headers={'Authorization': 'Bearer {}'.format(connection_password)})\n",
280+
"\n",
281+
"\n",
282+
" if status_response.json()[0][\"migrationStatus\"] == \"SUCCEEDED\":\n",
283+
" display(widgets.HTML('<div class=\"alert alert-block alert-success\"><b class=\"fa fa-solid fa-check-circle\"></b><div><p><b>Success</b></p><p>The migration has completed succesfully! you can now visit your new workpace in the deployments page. If you wish to do so, you can now terminate your shared deployment from the deployments page.</p></div></div>'))\n",
284+
" else:\n",
285+
" display(widgets.HTML(\"<div class='alert alert-block alert-danger'><b class='fa fa-solid fa-exclamation-triangle'></b><div><p><b>Failed to Complete Migrate</b></p><p>The migration process failed, please contact support</p></div></div>\"))"
286+
]
287+
},
288+
{
289+
"id": "33019b76",
290+
"cell_type": "markdown",
291+
"metadata": {},
292+
"source": [
293+
"<div id=\"singlestore-footer\" style=\"background-color: rgba(194, 193, 199, 0.25); height:2px; margin-bottom:10px\"></div>\n",
294+
"<div><img src=\"https://raw.githubusercontent.com/singlestore-labs/spaces-notebooks/master/common/images/singlestore-logo-grey.png\" style=\"padding: 0px; margin: 0px; height: 24px\"/></div>"
295+
]
296+
}
297+
],
298+
"metadata": {
299+
"kernelspec": {
300+
"display_name": ".venv",
301+
"language": "python",
302+
"name": "python3"
303+
},
304+
"language_info": {
305+
"codemirror_mode": {
306+
"name": "ipython",
307+
"version": 3
308+
},
309+
"file_extension": ".py",
310+
"mimetype": "text/x-python",
311+
"name": "python",
312+
"nbconvert_exporter": "python",
313+
"pygments_lexer": "ipython3",
314+
"version": "3.12.3"
315+
}
316+
},
317+
"nbformat": 4,
318+
"nbformat_minor": 5
319+
}

notebooks/notebook-style-guide/notebook.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@
502502
],
503503
"metadata": {
504504
"kernelspec": {
505-
"display_name": "Python 3 (ipykernel)",
505+
"display_name": ".venv",
506506
"language": "python",
507507
"name": "python3"
508508
},
@@ -516,7 +516,7 @@
516516
"name": "python",
517517
"nbconvert_exporter": "python",
518518
"pygments_lexer": "ipython3",
519-
"version": "3.11.3"
519+
"version": "3.12.3"
520520
}
521521
},
522522
"nbformat": 4,

0 commit comments

Comments
 (0)