Skip to content

Commit 56ea9e4

Browse files
authored
Update environment variables and API endpoints in webapp and server code (#275)
1 parent e32ea1c commit 56ea9e4

File tree

8 files changed

+84
-51
lines changed

8 files changed

+84
-51
lines changed

examples/1/111.ipynb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# My Notebook"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 1,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"# SparkSession: spark is already created\n",
17+
"spark"
18+
]
19+
}
20+
],
21+
"metadata": {
22+
"kernelspec": {
23+
"display_name": "Python 3",
24+
"name": "python3"
25+
},
26+
"language_info": {
27+
"name": "python"
28+
}
29+
},
30+
"nbformat": 4,
31+
"nbformat_minor": 4
32+
}

examples/notebook.ipynb

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
"source": [
1111
"# My Notebook\n",
1212
"\n",
13-
"- Just a demo notebook for testing\n",
13+
"- Just a demo \n",
1414
"- By Wenyi Xu"
1515
]
1616
},
1717
{
1818
"cell_type": "code",
1919
"execution_count": null,
20-
"isExecuted": false,
20+
"isExecuted": true,
2121
"lastExecutionResult": "success",
22-
"lastExecutionTime": "2024-06-24 08:59:25",
22+
"lastExecutionTime": "2024-07-11 03:42:21",
2323
"metadata": {},
2424
"outputs": [],
2525
"source": [
@@ -30,52 +30,34 @@
3030
{
3131
"cell_type": "code",
3232
"execution_count": null,
33-
"isExecuted": false,
34-
"lastExecutionResult": "success",
35-
"lastExecutionTime": "2024-06-24 08:59:26",
33+
"isExecuted": true,
34+
"lastExecutionResult": "error",
35+
"lastExecutionTime": "2024-07-11 03:42:21",
3636
"metadata": {},
3737
"outputs": [
3838
{
39-
"data": {
40-
"text/plain": [
41-
"0 1.0\n",
42-
"1 3.0\n",
43-
"2 5.0\n",
44-
"3 NaN\n",
45-
"4 6.0\n",
46-
"5 8.0\n",
47-
"dtype: float64"
48-
]
49-
},
50-
"execution_count": 8,
51-
"metadata": {},
52-
"output_type": "execute_result"
39+
"ename": "NameError",
40+
"evalue": "name 'pd' is not defined",
41+
"output_type": "error",
42+
"traceback": [
43+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
44+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
45+
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m s \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241m.\u001b[39mSeries([\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m3\u001b[39m, \u001b[38;5;241m5\u001b[39m, np\u001b[38;5;241m.\u001b[39mnan, \u001b[38;5;241m6\u001b[39m, \u001b[38;5;241m8\u001b[39m])\n\u001b[1;32m 2\u001b[0m s\n",
46+
"\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined"
47+
]
5348
}
5449
],
5550
"source": [
5651
"s = pd.Series([1, 3, 5, np.nan, 6, 8])\n",
5752
"s"
5853
]
5954
},
60-
{
61-
"cell_type": "code",
62-
"execution_count": null,
63-
"isExecuted": false,
64-
"lastExecutionResult": "success",
65-
"lastExecutionTime": "2024-06-24 08:59:46",
66-
"metadata": {},
67-
"outputs": [],
68-
"source": [
69-
"import time\n",
70-
"time.sleep(20)"
71-
]
72-
},
7355
{
7456
"cell_type": "code",
7557
"execution_count": 1,
76-
"isExecuted": false,
58+
"isExecuted": true,
7759
"lastExecutionResult": "error",
78-
"lastExecutionTime": "2024-06-24 08:59:47",
60+
"lastExecutionTime": "2024-07-11 03:42:31",
7961
"metadata": {},
8062
"outputs": [
8163
{
@@ -85,7 +67,7 @@
8567
"traceback": [
8668
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
8769
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
88-
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mqegnvoign\u001b[49m) \n",
70+
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mqegnvoign\u001b[49m) \n",
8971
"\u001b[0;31mNameError\u001b[0m: name 'qegnvoign' is not defined"
9072
]
9173
}
@@ -94,6 +76,19 @@
9476
"print(qegnvoign) "
9577
]
9678
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"isExecuted": true,
83+
"lastExecutionResult": "success",
84+
"lastExecutionTime": "2024-07-11 03:42:21",
85+
"metadata": {},
86+
"outputs": [],
87+
"source": [
88+
"import time\n",
89+
"time.sleep(20)"
90+
]
91+
},
9792
{
9893
"cell_type": "code",
9994
"execution_count": null,
@@ -152,7 +147,8 @@
152147
"nbconvert_exporter": "python",
153148
"pygments_lexer": "ipython3",
154149
"version": "3.11.6"
155-
}
150+
},
151+
"uuid": "15a9f9b0-5f3f-4318-ab4f-0ede0ffa933a"
156152
},
157153
"nbformat": 4,
158154
"nbformat_minor": 4

webapp/.env.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
REACT_APP_SERVER_BASE_URL=http://localhost:5002
12
REACT_APP_JUPYTER_BASE_URL=http://localhost:8888

webapp/public/env.template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
window._env_ = {
22
REACT_APP_JUPYTER_BASE_URL: "$REACT_APP_JUPYTER_BASE_URL",
3+
REACT_APP_SERVER_BASE_URL: "$REACT_APP_SERVER_BASE_URL",
34
};

webapp/src/components/notebook/header/move/MoveDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const MoveDialog = ({
8282
<Button
8383
style={{ color: 'lightgrey' }}
8484
onClick={() => {
85-
NotebookModel.moveNotebook(baseUrl, notebook.path, destinationDirectory + '/' + notebook.name);
85+
NotebookModel.moveNotebook(notebook.path, destinationDirectory + '/' + notebook.name);
8686
setMoveDialogOpen(false);
8787
}}>
8888
Move

webapp/src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const config = {
22
jupyterBaseUrl: (window._env_ && window._env_.REACT_APP_JUPYTER_BASE_URL) || process.env.REACT_APP_JUPYTER_BASE_URL,
3+
serverBaseUrl: (window._env_ && window._env_.REACT_APP_SERVER_BASE_URL) || process.env.REACT_APP_SERVER_BASE_URL,
34
};
45

56
export default config;

webapp/src/models/DirectoryModel.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import NotebookModel from "./NotebookModel";
1+
import config from '../config';
22

33
class DirectoryModel {
44
constructor(path, files) {
@@ -27,7 +27,7 @@ class DirectoryModel {
2727
}
2828

2929
static async getChildren(path = '') {
30-
const response = await fetch("http://localhost:5002/directory/" + path);
30+
const response = await fetch(`${config.serverBaseUrl}/directory/` + path);
3131
if (!response.ok) {
3232
throw new Error('Failed to fetch files');
3333
} else {
@@ -49,7 +49,7 @@ class DirectoryModel {
4949

5050
static async createDirectory(path = '', directoryName = '') {
5151
console.log("Creating directory at path:", path + '/' + directoryName);
52-
const response = await fetch("http://localhost:5002/directory", {
52+
const response = await fetch(`${config.serverBaseUrl}/directory`, {
5353
method: 'POST',
5454
headers: {
5555
'Content-Type': 'application/json',
@@ -69,7 +69,7 @@ class DirectoryModel {
6969

7070
static async renameDirectory(oldPath='', newPath='') {
7171
console.log("Renaming item at path:", oldPath, "to", newPath);
72-
const response = await fetch("http://localhost:5002/directory/" + oldPath, {
72+
const response = await fetch(`${config.serverBaseUrl}/directory/` + oldPath, {
7373
method: 'PATCH',
7474
headers: {
7575
'Content-Type': 'application/json',
@@ -93,7 +93,7 @@ class DirectoryModel {
9393
} else {
9494
console.log("Deleting item at path:", itemPath);
9595
try {
96-
const response = await fetch("http://localhost:5002/directory/" + itemPath, {
96+
const response = await fetch(`${config.serverBaseUrl}/directory/` + itemPath, {
9797
method: 'DELETE',
9898
});
9999
if (!response.ok) {

webapp/src/models/NotebookModel.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { OutputType } from '../components/notebook/content/cell/result/OutputTyp
33
import { CellExecuteResultType } from "../components/notebook/content/cell/CellExecuteResultType";
44
import { v4 as uuidv4 } from 'uuid';
55
import SessionModel from "./SessionModel"
6+
import config from '../config';
67

78

89
class NotebookModel {
@@ -40,7 +41,8 @@ class NotebookModel {
4041
};
4142

4243
static async fetchNotebook(path = '') {
43-
const response = await fetch("http://localhost:5002/notebook/" + path, {
44+
console.log(config)
45+
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
4446
method: 'GET',
4547
headers: {
4648
'Content-Type': 'application/json',
@@ -55,7 +57,7 @@ class NotebookModel {
5557
}
5658

5759
static async createNotebook(path = '', notebookName = '') {
58-
const response = await fetch("http://localhost:5002/notebook", {
60+
const response = await fetch(`${config.serverBaseUrl}/notebook`, {
5961
method: 'POST',
6062
headers: {
6163
'Content-Type': 'application/json',
@@ -75,7 +77,7 @@ class NotebookModel {
7577
};
7678

7779
static async deleteNotebook(path = '') {
78-
const response = await fetch("http://localhost:5002/notebook/" + path, {
80+
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
7981
method: 'DELETE',
8082
headers: {
8183
'Content-Type': 'application/json',
@@ -103,7 +105,7 @@ class NotebookModel {
103105
updatedContent.metadata.uuid = uuidv4();
104106
}
105107

106-
const response = await fetch("http://localhost:5002/notebook/" + path, {
108+
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
107109
method: 'PUT',
108110
headers: {
109111
'Content-Type': 'application/json',
@@ -123,7 +125,7 @@ class NotebookModel {
123125
static async renameNotebook(path = '', newName = '') {
124126
console.log("Renaming notebook at path:", path, "to:", newName);
125127

126-
const response = await fetch("http://localhost:5002/notebook/" + path, {
128+
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
127129
method: 'PATCH',
128130
headers: {
129131
'Content-Type': 'application/json',
@@ -140,9 +142,9 @@ class NotebookModel {
140142
return data;
141143
};
142144

143-
static async moveNotebook(basePath = '', path = '', destination = '') {
144-
console.log("Moving notebook at path:", basePath + '/' + path, "to:", destination);
145-
const response = await fetch("http://localhost:5002/notebook/" + path, {
145+
static async moveNotebook(path = '', destination = '') {
146+
console.log("Moving notebook at path:", path, "to:", destination);
147+
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
146148
method: 'PATCH',
147149
headers: {
148150
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)