Skip to content

Update environment variables and API endpoints in webapp and server code #275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions examples/1/111.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# My Notebook"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# SparkSession: spark is already created\n",
"spark"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
70 changes: 33 additions & 37 deletions examples/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"source": [
"# My Notebook\n",
"\n",
"- Just a demo notebook for testing\n",
"- Just a demo \n",
"- By Wenyi Xu"
]
},
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"isExecuted": true,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-06-24 08:59:25",
"lastExecutionTime": "2024-07-11 03:42:21",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,52 +30,34 @@
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-06-24 08:59:26",
"isExecuted": true,
"lastExecutionResult": "error",
"lastExecutionTime": "2024-07-11 03:42:21",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 1.0\n",
"1 3.0\n",
"2 5.0\n",
"3 NaN\n",
"4 6.0\n",
"5 8.0\n",
"dtype: float64"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
"ename": "NameError",
"evalue": "name 'pd' 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[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",
"\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined"
]
}
],
"source": [
"s = pd.Series([1, 3, 5, np.nan, 6, 8])\n",
"s"
]
},
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-06-24 08:59:46",
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"time.sleep(20)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"isExecuted": false,
"isExecuted": true,
"lastExecutionResult": "error",
"lastExecutionTime": "2024-06-24 08:59:47",
"lastExecutionTime": "2024-07-11 03:42:31",
"metadata": {},
"outputs": [
{
Expand All @@ -85,7 +67,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"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",
"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",
"\u001b[0;31mNameError\u001b[0m: name 'qegnvoign' is not defined"
]
}
Expand All @@ -94,6 +76,19 @@
"print(qegnvoign) "
]
},
{
"cell_type": "code",
"execution_count": null,
"isExecuted": true,
"lastExecutionResult": "success",
"lastExecutionTime": "2024-07-11 03:42:21",
"metadata": {},
"outputs": [],
"source": [
"import time\n",
"time.sleep(20)"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -152,7 +147,8 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"uuid": "15a9f9b0-5f3f-4318-ab4f-0ede0ffa933a"
},
"nbformat": 4,
"nbformat_minor": 4
Expand Down
1 change: 1 addition & 0 deletions webapp/.env.dev
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
REACT_APP_SERVER_BASE_URL=http://localhost:5002
REACT_APP_JUPYTER_BASE_URL=http://localhost:8888
1 change: 1 addition & 0 deletions webapp/public/env.template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
window._env_ = {
REACT_APP_JUPYTER_BASE_URL: "$REACT_APP_JUPYTER_BASE_URL",
REACT_APP_SERVER_BASE_URL: "$REACT_APP_SERVER_BASE_URL",
};
2 changes: 1 addition & 1 deletion webapp/src/components/notebook/header/move/MoveDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const MoveDialog = ({
<Button
style={{ color: 'lightgrey' }}
onClick={() => {
NotebookModel.moveNotebook(baseUrl, notebook.path, destinationDirectory + '/' + notebook.name);
NotebookModel.moveNotebook(notebook.path, destinationDirectory + '/' + notebook.name);
setMoveDialogOpen(false);
}}>
Move
Expand Down
1 change: 1 addition & 0 deletions webapp/src/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const config = {
jupyterBaseUrl: (window._env_ && window._env_.REACT_APP_JUPYTER_BASE_URL) || process.env.REACT_APP_JUPYTER_BASE_URL,
serverBaseUrl: (window._env_ && window._env_.REACT_APP_SERVER_BASE_URL) || process.env.REACT_APP_SERVER_BASE_URL,
};

export default config;
10 changes: 5 additions & 5 deletions webapp/src/models/DirectoryModel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NotebookModel from "./NotebookModel";
import config from '../config';

class DirectoryModel {
constructor(path, files) {
Expand Down Expand Up @@ -27,7 +27,7 @@ class DirectoryModel {
}

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

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

static async renameDirectory(oldPath='', newPath='') {
console.log("Renaming item at path:", oldPath, "to", newPath);
const response = await fetch("http://localhost:5002/directory/" + oldPath, {
const response = await fetch(`${config.serverBaseUrl}/directory/` + oldPath, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Expand All @@ -93,7 +93,7 @@ class DirectoryModel {
} else {
console.log("Deleting item at path:", itemPath);
try {
const response = await fetch("http://localhost:5002/directory/" + itemPath, {
const response = await fetch(`${config.serverBaseUrl}/directory/` + itemPath, {
method: 'DELETE',
});
if (!response.ok) {
Expand Down
18 changes: 10 additions & 8 deletions webapp/src/models/NotebookModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { OutputType } from '../components/notebook/content/cell/result/OutputTyp
import { CellExecuteResultType } from "../components/notebook/content/cell/CellExecuteResultType";
import { v4 as uuidv4 } from 'uuid';
import SessionModel from "./SessionModel"
import config from '../config';


class NotebookModel {
Expand Down Expand Up @@ -40,7 +41,8 @@ class NotebookModel {
};

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

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

static async deleteNotebook(path = '') {
const response = await fetch("http://localhost:5002/notebook/" + path, {
const response = await fetch(`${config.serverBaseUrl}/notebook/` + path, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -103,7 +105,7 @@ class NotebookModel {
updatedContent.metadata.uuid = uuidv4();
}

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

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

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