Skip to content

Commit

Permalink
Update notebook execution timestamps and fix styling in TextResult.js…
Browse files Browse the repository at this point in the history
…, refactor code to remove isExecuted property in NotebookModel.js and Cell.js, update dependencies in package.json, merge 0.5.2, refactor notebook execution code and add keyboard shortcut for running cells, refactor styling and add MoveButton component in NotebookHeader.js, refactor naming conventions in Notebook.js, NotebookTitle.js, DeleteDialog.js, Item.js, and RenameDialog.js, refactor styling in CreateFolderDialog.js, CreateNotebookDialog.js, WorkspaceSidebar.js, and Item.js. (#232)
  • Loading branch information
xuwenyihust committed Jun 24, 2024
1 parent 48013eb commit 6ca1eed
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 127 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ PawMark is a platform for big data and AI. It is based on Apache Spark and Kuber
## Versions
<details>
<summary>Details</summary>

| Component | Version |
|--------------|---------|
| Scala | 2.12 |
Expand All @@ -142,6 +143,7 @@ PawMark is a platform for big data and AI. It is based on Apache Spark and Kuber
| Airflow | 2.9.1 |
| Postgres | 13 |
| React | 18.3.1 |

</details>

## License
Expand Down
10 changes: 8 additions & 2 deletions examples/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
"cells": [
{
"cell_type": "markdown",
"isExecuted": false,
"metadata": {},
"source": [
"# Demo Notebook\n",
"\n",
"This is just a demo notebook"
"- This is just a demo notebook\n",
"- For testing"
]
},
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -42,6 +45,7 @@
{
"cell_type": "code",
"execution_count": 1,
"isExecuted": false,
"metadata": {},
"outputs": [
{
Expand All @@ -63,6 +67,7 @@
{
"cell_type": "code",
"execution_count": null,
"isExecuted": false,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -97,7 +102,8 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"uuid": "647a82de-693a-48f0-ae3a-64a771d83da5"
},
"nbformat": 4,
"nbformat_minor": 4
Expand Down
32 changes: 0 additions & 32 deletions examples/notebook-1718195506985.ipynb

This file was deleted.

32 changes: 0 additions & 32 deletions examples/notebook-1718195513502.ipynb

This file was deleted.

37 changes: 0 additions & 37 deletions examples/notebook-1718429485886.ipynb

This file was deleted.

File renamed without changes.
7 changes: 1 addition & 6 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ def handle_request():
data = {"message": "Hello from Flask!"}
return jsonify(data)

# @app.route('/execute_notebook', methods=['POST'])
# def execute_notebook():
# notebook_path = request.json.get('notebook_path')
# # Assuming you have set up Jupyter to accept API requests
# response = requests.post(f'http://jupyter-server:8888/api/notebooks/{notebook_path}/execute')
# return jsonify(response.json())


if __name__ == '__main__':
app.run(debug=True, port=5002)
4 changes: 3 additions & 1 deletion webapp/src/components/notebook/Notebook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import NotebookHeader from './header/NotebookHeader';
import Code from './content/Code';
import Runs from './content/Runs';
import { ContentType } from './content/ContentType';
import { CellStatus } from './content/cell/CellStatus';
import { CellType } from './content/cell/CellType';
Expand Down Expand Up @@ -310,7 +311,8 @@ function Notebook({
setCellExecutedStatus)}
saveNotebook={handleUpdateNotebook}
deleteNotebook={handleDeleteNotebook}
/> : <div>666</div>
/> :
<Runs />
}

</Box>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/notebook/content/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Code = ({
deleteNotebook={deleteNotebook}/>

<Box sx={{
width: '100%',
width: '95%',
display: 'flex',
flexDirection: 'column',
marginTop: '50px',
Expand Down
20 changes: 20 additions & 0 deletions webapp/src/components/notebook/content/Runs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { useEffect, useState } from 'react';

function Runs() {
const [data, setData] = useState(null);

useEffect(() => {
fetch('http://localhost:5002/test')
.then(response => response.json())
.then(data => setData(data))
.catch(error => console.error('Error:', error));
}, []);

return (
<div>
{data ? JSON.stringify(data) : 'Loading...'}
</div>
);
}

export default Runs;
16 changes: 8 additions & 8 deletions webapp/src/components/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ function Sidebar({
height: `${itemHeight}px`
}}>
<ListItemIcon>
<CgAdd style={{ color: openCreateDrawer ? 'white' : 'lightgrey' }} />
<CgAdd style={{ color: openCreateDrawer ? 'white' : 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: openCreateDrawer ? 'white' : 'lightgrey',
color: openCreateDrawer ? 'white' : 'white',
marginLeft: '-30px'
}}>
Create
Expand Down Expand Up @@ -156,15 +156,15 @@ function Sidebar({
height: `${itemHeight}px`
}}>
<ListItemIcon>
<CgAlbum style={{ color: openWorkspaceDrawer ? 'white' : 'lightgrey' }} />
<CgAlbum style={{ color: openWorkspaceDrawer ? 'white' : 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: openWorkspaceDrawer ? 'white' : 'lightgrey',
color: openWorkspaceDrawer ? 'white' : 'white',
marginLeft: '-30px'
}}>
Workspace
Expand Down Expand Up @@ -200,15 +200,15 @@ function Sidebar({
height: `${itemHeight}px`
}}>
<ListItemIcon>
<CgEye style={{ color: 'lightgrey' }} />
<CgEye style={{ color: 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: 'lightgrey',
color: 'white',
marginLeft: '-30px'
}}>
History Server
Expand All @@ -231,15 +231,15 @@ function Sidebar({
height: `${itemHeight}px`
}}>
<ListItemIcon>
<CgCalendarToday style={{ color: 'lightgrey' }} />
<CgCalendarToday style={{ color: 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: 'lightgrey',
color: 'white',
marginLeft: '-30px'
}}>
Scheduler
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/sidebar/create/CreateSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ function CreateSidebar({
}}>
<ListItemIcon>
<CgNotes style={{
color: 'lightgrey',
color: 'white',
marginLeft: '10px' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
style={{ color: 'lightgrey' }}
style={{ color: 'white' }}
sx={{
marginLeft: '-10px'
}}>
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/sidebar/workspace/Back.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ const Back = ({ handleBackClick }) => {
return (
<ListItem button onClick={handleBackClick}>
<ListItemIcon>
<CgArrowLeftR style={{ color: 'lightgrey' }} />
<CgArrowLeftR style={{ color: 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: 'lightgrey',
color: 'white',
marginLeft: '-30px'
}}>
Back
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/sidebar/workspace/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ const Item = ({
closeWorkspaceDrawer();
}}}>
<ListItemIcon>
<IconComponent style={{ color: 'lightgrey' }} />
<IconComponent style={{ color: 'white' }} />
</ListItemIcon>
<ListItemText>
<Typography
variant="body1"
sx={{
fontFamily: 'Roboto',
fontSize: '15px',
color: 'lightgrey',
color: 'white',
marginLeft: '-30px' ,
whiteSpace: 'nowrap',
overflow: 'hidden',
Expand Down
8 changes: 6 additions & 2 deletions webapp/src/models/NotebookModel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CellStatus } from '../components/notebook/content/cell/CellStatus';
import { OutputType } from '../components/notebook/content/cell/result/OutputType';
import { CellExecuteResultType } from "../components/notebook/content/cell/CellExecuteResultType";
import { v4 as uuidv4 } from 'uuid';


class NotebookModel {
Expand Down Expand Up @@ -183,14 +184,17 @@ class NotebookModel {
};

static async updateNotebook(path = '', content = {}) {
console.log("Updating notebook at path with content:", path, content);
const updatedContent = { ...content };

updatedContent.cells = updatedContent.cells.map(cell => {
const updatedCell = { ...cell };
// delete updatedCell.isExecuted;
return updatedCell;
});

// Check if notebook content.metadata has uuid
if (!updatedContent.metadata.hasOwnProperty('uuid')) {
updatedContent.metadata.uuid = uuidv4();
}

const response = await fetch(path, {
method: 'PUT',
Expand Down

0 comments on commit 6ca1eed

Please sign in to comment.