From 899be970ada5518b027b7d04acddba384769e660 Mon Sep 17 00:00:00 2001 From: porink0424 Date: Wed, 7 Aug 2024 16:14:05 +0900 Subject: [PATCH] Make the code pass lint checking --- .eslintignore | 4 +- jupyterlab/jupyterlab_optuna/__init__.py | 3 +- jupyterlab/jupyterlab_optuna/handlers.py | 4 +- jupyterlab/src/apiClient.ts | 53 ++++++++----------- .../src/components/JupyterLabEntrypoint.tsx | 2 +- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/.eslintignore b/.eslintignore index dc0d7b3e..9227e18b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,6 @@ venv .venv standalone_app vscode -tslib \ No newline at end of file +tslib +jupyterlab +pkg \ No newline at end of file diff --git a/jupyterlab/jupyterlab_optuna/__init__.py b/jupyterlab/jupyterlab_optuna/__init__.py index 5d693c0e..6ee653e6 100644 --- a/jupyterlab/jupyterlab_optuna/__init__.py +++ b/jupyterlab/jupyterlab_optuna/__init__.py @@ -3,7 +3,8 @@ try: except ImportError: # Fallback when using the package in dev mode without installing # in editable mode with pip. It is highly recommended to install - # the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs + # the package from a stable release or in editable mode: + # https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs import warnings warnings.warn("Importing 'jupyterlab_optuna' outside a proper installation.") __version__ = "dev" diff --git a/jupyterlab/jupyterlab_optuna/handlers.py b/jupyterlab/jupyterlab_optuna/handlers.py index 65e409d8..f8713372 100644 --- a/jupyterlab/jupyterlab_optuna/handlers.py +++ b/jupyterlab/jupyterlab_optuna/handlers.py @@ -4,10 +4,11 @@ import json import threading from typing import TYPE_CHECKING -import tornado from jupyter_server.base.handlers import APIHandler from jupyter_server.utils import url_path_join from optuna_dashboard.artifact._backend_to_store import to_artifact_store +import tornado + try: from optuna.artifacts import FileSystemArtifactStore @@ -19,6 +20,7 @@ from optuna_dashboard import wsgi from tornado.web import FallbackHandler from tornado.wsgi import WSGIContainer + if TYPE_CHECKING: from _typeshed.wsgi import WSGIApplication diff --git a/jupyterlab/src/apiClient.ts b/jupyterlab/src/apiClient.ts index eeae643e..7f004c42 100644 --- a/jupyterlab/src/apiClient.ts +++ b/jupyterlab/src/apiClient.ts @@ -114,6 +114,9 @@ export class JupyterlabAPIClient extends APIClient { ): Promise => requestAPI(`/api/studies/${studyId}`, { method: "DELETE", + body: JSON.stringify({ + remove_associated_artifacts: removeAssociatedArtifacts, + }), }).then(() => { return }) @@ -177,16 +180,13 @@ export class JupyterlabAPIClient extends APIClient { fileName: string, dataUrl: string ): Promise => - requestAPI( - `/api/artifacts/${studyId}`, - { - body: JSON.stringify({ - file: dataUrl, - filename: fileName, - }), - method: "POST", - } - ).then((res) => { + requestAPI(`/api/artifacts/${studyId}`, { + body: JSON.stringify({ + file: dataUrl, + filename: fileName, + }), + method: "POST", + }).then((res) => { return res }) deleteTrialArtifact = ( @@ -194,21 +194,15 @@ export class JupyterlabAPIClient extends APIClient { trialId: number, artifactId: string ): Promise => - requestAPI( - `/api/artifacts/${studyId}/${trialId}/${artifactId}`, - { - method: "DELETE", - } - ).then(() => { + requestAPI(`/api/artifacts/${studyId}/${trialId}/${artifactId}`, { + method: "DELETE", + }).then(() => { return }) deleteStudyArtifact = (studyId: number, artifactId: string): Promise => - requestAPI( - `/api/artifacts/${studyId}/${artifactId}`, - { - method: "DELETE", - } - ).then(() => { + requestAPI(`/api/artifacts/${studyId}/${artifactId}`, { + method: "DELETE", + }).then(() => { return }) tellTrial = async ( @@ -293,17 +287,16 @@ export class JupyterlabAPIClient extends APIClient { }).then(() => { return }) - getPlot = (studyId: number, plotType: PlotType): Promise => - requestAPI(`/api/studies/${studyId}/plot/${plotType}`) - .then((res) => (res)) + getPlot = (studyId: number, plotType: PlotType): Promise => + requestAPI( + `/api/studies/${studyId}/plot/${plotType}` + ).then((res) => res) getCompareStudiesPlot = ( studyIds: number[], plotType: CompareStudiesPlotType ): Promise => { - return requestAPI( - `/api/compare-studies/plot/${plotType}`, { - body: JSON.stringify({ study_ids: studyIds }), - } - ).then((res) => (res)) + return requestAPI(`/api/compare-studies/plot/${plotType}`, { + body: JSON.stringify({ study_ids: studyIds }), + }).then((res) => res) } } diff --git a/jupyterlab/src/components/JupyterLabEntrypoint.tsx b/jupyterlab/src/components/JupyterLabEntrypoint.tsx index 91498949..46dee6c4 100644 --- a/jupyterlab/src/components/JupyterLabEntrypoint.tsx +++ b/jupyterlab/src/components/JupyterLabEntrypoint.tsx @@ -182,7 +182,7 @@ const StartDashboardForm: FC<{ artifact_path: artifactPath, }), }) - .then((res) => { + .then((_res) => { setLoading(false) showOptunaDashboard() })