Skip to content

Commit

Permalink
Update Spark executor configuration in startup.py and add create_spar…
Browse files Browse the repository at this point in the history
…k function call in demo.ipynb
  • Loading branch information
xuwenyihust committed Sep 11, 2024
1 parent 6bfdb19 commit 8888502
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
60 changes: 30 additions & 30 deletions examples/[email protected]/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,43 @@
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"isExecuted": true,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-09-11 10:00:50",
"metadata": {},
"outputs": [],
"source": [
"create_spark(\"work/[email protected]/demo.ipynb\")"
"spark = create_spark(\"work/[email protected]/demo.ipynb\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"lastExecutionResult": "error",
"lastExecutionTime": "2024-08-24 03:21:19",
"isExecuted": true,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-09-11 10:00:52",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'spark' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[3], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# SparkSession is already defined in `spark` variable\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[43mspark\u001b[49m\n",
"\u001b[0;31mNameError\u001b[0m: name 'spark' is not defined"
]
"data": {
"text/html": [
"\n",
" <div style=\"border: 1px solid #e8e8e8; padding: 10px;\">\n",
" <h3>Spark Session Information</h3>\n",
" <p><strong>notebook_path: </strong> work/[email protected]/demo.ipynb</p>\n",
" <p><strong>Config:</strong> {'spark.driver.memory': '1g', 'spark.driver.cores': 1, 'spark.executor.memory': '1g', 'spark.executor.cores': 1, 'spark.executor.instances': 1, 'spark.dynamicAllocation.enabled': False}</p>\n",
" <p><strong>Application ID:</strong> app-20240911100050-0002</p>\n",
" <p><strong>Spark UI:</strong> <a href=\"http://localhost:18080/history/app-20240911100050-0002\">http://localhost:18080/history/app-20240911100050-0002</a></p>\n",
" </div>\n",
" "
],
"text/plain": [
"Custom Spark Session (App ID: app-20240911100050-0002) - UI: http://50c98dc46cfd:4040"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand Down Expand Up @@ -95,23 +107,11 @@
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"lastExecutionResult": "error",
"lastExecutionTime": "2024-08-24 03:21:20",
"isExecuted": true,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-09-11 10:00:46",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'spark' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[6], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mspark\u001b[49m\u001b[38;5;241m.\u001b[39mstop()\n",
"\u001b[0;31mNameError\u001b[0m: name 'spark' is not defined"
]
}
],
"outputs": [],
"source": [
"spark.stop()"
]
Expand Down
12 changes: 12 additions & 0 deletions webapp/src/components/notebook/content/toolbar/NotebookToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ const NotebookToolbar = ({

const createSparkSession = () => {
console.log('Creating Spark Session...');
// Insert a cell in notebook
cell = {
cell_type: 'code',
execution_count: null,
metadata: {},
outputs: [],
source: [
'spark = create_spark("work/[email protected]/demo.ipynb")',
'spark'
]
}
notebook.cells.push(cell);
}

return (
Expand Down

0 comments on commit 8888502

Please sign in to comment.