Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogoncalves03 committed Dec 6, 2024
1 parent 0d528fa commit 1d5ebb1
Showing 1 changed file with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@
{
"attachments": {},
"cell_type": "markdown",
"id": "54d88908",
"metadata": {},
"source": [
"## Creating the Sample Notebook\n",
"In this section, we will create a sample notebook to be used in our examples."
],
"id": "54d88908"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a2c382f9",
"metadata": {},
"source": [
"Create the sample notebook in the local filesystem:"
],
"id": "a2c382f9"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "dd837f57",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -70,21 +71,21 @@
" nbf.write(nb, f)\n",
"\n",
"print(\"Notebook 'sample_notebook.ipynb' created successfully in the local filesystem.\")"
],
"id": "dd837f57"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "bb858912",
"metadata": {},
"source": [
"Upload it to the **Data Studio** shared files for later download:"
],
"id": "bb858912"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d39b0564",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -95,53 +96,53 @@
"%sql UPLOAD SHARED FILE TO '{{ sample_notebook_name }}' FROM 'sample_notebook.ipynb';\n",
"\n",
"print(\"Notebook '{}' has been created in the Data Studio shared files.\".format(sample_notebook_name))"
],
"id": "d39b0564"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "4f0cbad1",
"metadata": {},
"source": [
"## Executing the Sample Notebook in the Current Session\n",
"\n",
"In this example, we will execute the previously created sample notebook within the current session. This approach is useful for avoiding code duplication in your notebooks, such as environment setup or reusable functions."
],
"id": "4f0cbad1"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "baefb864",
"metadata": {},
"source": [
"First, we download the notebook to the local filesystem:"
],
"id": "baefb864"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b04db0d5",
"metadata": {},
"outputs": [],
"source": [
"%sql DOWNLOAD SHARED FILE '{{ sample_notebook_name }}' TO 'sample_notebook.ipynb' OVERWRITE\n",
"\n",
"print(\"Notebook 'sample_notebook.ipynb' has been created in the local filesystem.\")"
],
"id": "b04db0d5"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "9c08ff46",
"metadata": {},
"source": [
"Next, we execute the notebook and confirm that the `sample_var` variable set in the sample notebook is accessible in the current session:"
],
"id": "9c08ff46"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "85ad1f06",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -151,12 +152,12 @@
"%run sample_notebook.ipynb\n",
"\n",
"print(\"The value of 'sample_var' is '{}'.\\n\".format(sample_var))"
],
"id": "85ad1f06"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "1a059fcb",
"metadata": {},
"source": [
"## Executing the Sample Notebook in a New Session\n",
Expand All @@ -170,21 +171,21 @@
" <p>SingleStore enforces <a href=\"https://docs.singlestore.com/cloud/developer-resources/notebooks/using-notebooks/#rate-limits\">limits</a> on the number of compute sessions that can be created, which can be increased upon request. Please contact <a href=\"https://support.singlestore.com/hc/en-us\">Support</a> for more information.</p>\n",
" </div>\n",
"</div>"
],
"id": "1a059fcb"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "b5d35764",
"metadata": {},
"source": [
"Run **two jobs** in parallel and wait for their completion (each job will run on a separate session):"
],
"id": "b5d35764"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2cdaea66",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -198,79 +199,78 @@
"success = %sql WAIT ON JOBS {{ job_ids }} WITH TIMEOUT 60 MINUTES\n",
"\n",
"print(f'All jobs completed with success: {bool(success[0].Success)}')"
],
"id": "2cdaea66"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "eaa1de71",
"metadata": {},
"source": [
"View the executions of the jobs we run:"
],
"id": "eaa1de71"
"View the executions of the jobs we ran:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "b81fa588",
"metadata": {},
"outputs": [],
"source": [
"for job_id in job_ids:\n",
" execs = %sql SHOW JOB EXECUTIONS FOR {{ job_id }} from 1 to 1\n",
" print(execs)"
],
"id": "b81fa588"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f64a5020",
"metadata": {},
"source": [
"The jobs can now be dropped:"
],
"id": "f64a5020"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "5f7b74a6",
"metadata": {},
"outputs": [],
"source": [
"for id in job_ids:\n",
" print(f\"Dropping job '{id}'...\")\n",
" %sql DROP JOBS {{id}}"
],
"id": "5f7b74a6"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "48372f6b",
"metadata": {},
"source": [
"## Cleanup"
],
"id": "48372f6b"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "00b5f172",
"metadata": {},
"source": [
"Delete the sample notebook from the **Data Studio** shared files:"
],
"id": "00b5f172"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "c368e8a6",
"metadata": {},
"outputs": [],
"source": [
"%%sql\n",
"DROP SHARED FILE '{{ sample_notebook_name }}'"
],
"id": "c368e8a6"
]
},
{
"id": "7259e797",
Expand Down

0 comments on commit 1d5ebb1

Please sign in to comment.