Skip to content

Commit

Permalink
Refactor Spark app route and simplify notebook path handling
Browse files Browse the repository at this point in the history
- Removed unused JWT and user identification decorators from the Spark app route in spark_app.py for cleaner code.
- Simplified the notebook path handling in getSparkApps method of NotebookModel.js by removing unnecessary path simplification logic, allowing direct usage of the provided notebook path.
- Enhanced code readability and maintainability by streamlining the logic in both files.
  • Loading branch information
xuwenyihust committed Dec 10, 2024
1 parent 17516bb commit b433992
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
2 changes: 0 additions & 2 deletions server/app/routes/spark_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

logging.basicConfig(level=logging.INFO)

# @jwt_required()
# @identify_user
@spark_app_blueprint.route('/spark_app/<path:notbook_path>/config', methods=['GET'])
def get_spark_app_config(notbook_path):
logging.info(f"Getting spark app config for notebook path: {notbook_path}")
Expand Down
15 changes: 1 addition & 14 deletions webapp/src/models/NotebookModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,8 @@ class NotebookModel {

static async getSparkApps(notebookPath = '') {
const token = sessionStorage.getItem('token');

// Safely handle notebook path
let simplifiedPath = notebookPath;
const pathParts = notebookPath.split('/');

// Only modify path if it matches the pattern work/user@domain/notebook.ipynb
if (pathParts.length >= 3 &&
pathParts[0] === 'work' &&
pathParts[1].includes('@')) {
// Remove the username part and rejoin
simplifiedPath = [pathParts[0], ...pathParts.slice(2)].join('/');
console.log('Simplified notebook path:', simplifiedPath);
}

const response = await fetch(`${config.serverBaseUrl}/notebook/spark_app/${simplifiedPath}`, {
const response = await fetch(`${config.serverBaseUrl}/notebook/spark_app/${notebookPath}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Expand Down

0 comments on commit b433992

Please sign in to comment.