Skip to content

Commit 8888502

Browse files
committed
Update Spark executor configuration in startup.py and add create_spark function call in demo.ipynb
1 parent 6bfdb19 commit 8888502

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

examples/[email protected]/demo.ipynb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,43 @@
1414
{
1515
"cell_type": "code",
1616
"execution_count": null,
17-
"isExecuted": false,
17+
"isExecuted": true,
18+
"lastExecutionResult": "success",
19+
"lastExecutionTime": "2024-09-11 10:00:50",
1820
"metadata": {},
1921
"outputs": [],
2022
"source": [
21-
"create_spark(\"work/[email protected]/demo.ipynb\")"
23+
"spark = create_spark(\"work/[email protected]/demo.ipynb\")"
2224
]
2325
},
2426
{
2527
"cell_type": "code",
2628
"execution_count": null,
27-
"isExecuted": false,
28-
"lastExecutionResult": "error",
29-
"lastExecutionTime": "2024-08-24 03:21:19",
29+
"isExecuted": true,
30+
"lastExecutionResult": "success",
31+
"lastExecutionTime": "2024-09-11 10:00:52",
3032
"metadata": {},
3133
"outputs": [
3234
{
33-
"ename": "NameError",
34-
"evalue": "name 'spark' is not defined",
35-
"output_type": "error",
36-
"traceback": [
37-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
38-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
39-
"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",
40-
"\u001b[0;31mNameError\u001b[0m: name 'spark' is not defined"
41-
]
35+
"data": {
36+
"text/html": [
37+
"\n",
38+
" <div style=\"border: 1px solid #e8e8e8; padding: 10px;\">\n",
39+
" <h3>Spark Session Information</h3>\n",
40+
" <p><strong>notebook_path: </strong> work/[email protected]/demo.ipynb</p>\n",
41+
" <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",
42+
" <p><strong>Application ID:</strong> app-20240911100050-0002</p>\n",
43+
" <p><strong>Spark UI:</strong> <a href=\"http://localhost:18080/history/app-20240911100050-0002\">http://localhost:18080/history/app-20240911100050-0002</a></p>\n",
44+
" </div>\n",
45+
" "
46+
],
47+
"text/plain": [
48+
"Custom Spark Session (App ID: app-20240911100050-0002) - UI: http://50c98dc46cfd:4040"
49+
]
50+
},
51+
"execution_count": 8,
52+
"metadata": {},
53+
"output_type": "execute_result"
4254
}
4355
],
4456
"source": [
@@ -95,23 +107,11 @@
95107
{
96108
"cell_type": "code",
97109
"execution_count": null,
98-
"isExecuted": false,
99-
"lastExecutionResult": "error",
100-
"lastExecutionTime": "2024-08-24 03:21:20",
110+
"isExecuted": true,
111+
"lastExecutionResult": "success",
112+
"lastExecutionTime": "2024-09-11 10:00:46",
101113
"metadata": {},
102-
"outputs": [
103-
{
104-
"ename": "NameError",
105-
"evalue": "name 'spark' is not defined",
106-
"output_type": "error",
107-
"traceback": [
108-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
109-
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
110-
"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",
111-
"\u001b[0;31mNameError\u001b[0m: name 'spark' is not defined"
112-
]
113-
}
114-
],
114+
"outputs": [],
115115
"source": [
116116
"spark.stop()"
117117
]

webapp/src/components/notebook/content/toolbar/NotebookToolbar.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ const NotebookToolbar = ({
1515

1616
const createSparkSession = () => {
1717
console.log('Creating Spark Session...');
18+
// Insert a cell in notebook
19+
cell = {
20+
cell_type: 'code',
21+
execution_count: null,
22+
metadata: {},
23+
outputs: [],
24+
source: [
25+
'spark = create_spark("work/[email protected]/demo.ipynb")',
26+
'spark'
27+
]
28+
}
29+
notebook.cells.push(cell);
1830
}
1931

2032
return (

0 commit comments

Comments
 (0)