From d2a135d47477492e0a32369b4f3d78ac249aee82 Mon Sep 17 00:00:00 2001 From: c-bata Date: Fri, 22 Mar 2024 19:36:29 +0900 Subject: [PATCH] Fix CI errors --- .eslintignore | 3 ++- .github/workflows/e2e-standalone-tests.yml | 3 +++ .github/workflows/gh-pages.yml | 2 ++ Makefile | 10 ++++++++-- biome.json | 7 +++++-- package.json | 2 +- standalone_app/src/components/StorageProvider.tsx | 2 +- tslib/storage/src/journal.ts | 12 ++++++------ 8 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.eslintignore b/.eslintignore index d2fabcea..dc0d7b3e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ venv .venv standalone_app -vscode \ No newline at end of file +vscode +tslib \ No newline at end of file diff --git a/.github/workflows/e2e-standalone-tests.yml b/.github/workflows/e2e-standalone-tests.yml index 1ec5b86f..d449e2b7 100644 --- a/.github/workflows/e2e-standalone-tests.yml +++ b/.github/workflows/e2e-standalone-tests.yml @@ -51,6 +51,9 @@ jobs: working-directory: rustlib run: wasm-pack build --target web + - name: Build tslib + run: make tslib + - name: Build standalone_app working-directory: standalone_app run: | diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 74c42a31..93c68a3a 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -33,6 +33,8 @@ jobs: - name: Build rustlib working-directory: rustlib run: wasm-pack build --target web + - name: Build tslib + run: make tslib - name: Build standalone_app working-directory: standalone_app run: | diff --git a/Makefile b/Makefile index ab0a5778..aab17971 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,19 @@ STANDALONE_SRC := $(shell find ./standalone_app/src -name '*.ts' -o -name '*.tsx $(RUSTLIB_OUT): rustlib/src/*.rs rustlib/Cargo.toml cd rustlib && wasm-pack build --target web -vscode/assets/bundle.js: $(RUSTLIB_OUT) $(STANDALONE_SRC) +vscode/assets/bundle.js: $(RUSTLIB_OUT) $(STANDALONE_SRC) tslib cd standalone_app && npm install && npm run build:vscode $(DASHBOARD_TS_OUT): $(DASHBOARD_TS_SRC) cd optuna_dashboard && npm install && npm run build:$(MODE) +.PHONY: tslib +tslib: + cd tslib/types && npm i && npm run build + cd tslib/storage && npm i && npm run build + .PHONY: serve-browser-app -serve-browser-app: $(RUSTLIB_OUT) +serve-browser-app: tslib $(RUSTLIB_OUT) cd standalone_app && npm run watch .PHONY: vscode-extension @@ -46,5 +51,6 @@ fmt: .PHONY: clean clean: + rm -rf tslib/types/pkg tslib/storage/pkg rm -rf optuna_dashboard/public/ doc/_build/ rm -rf rustlib/pkg standalone_app/public/ vscode/assets/ vscode/*.vsix diff --git a/biome.json b/biome.json index 7f3d3f3f..fc74ae38 100644 --- a/biome.json +++ b/biome.json @@ -7,11 +7,14 @@ "standalone_app/src/**/*.ts", "standalone_app/src/**/*.tsx", "vscode/src/**/*.ts", - "vscode/src/**/*.tsx" + "vscode/src/**/*.tsx", + "tslib/**/*.ts", + "tslib/**/*.tsx" ], "ignore": [ "optuna_dashboard/ts/components/PlotlyColorTemplates.ts", - "standalone_app/src/PlotlyDarkMode.ts" + "standalone_app/src/PlotlyDarkMode.ts", + "tslib/**/pkg/*" ] }, "javascript": { diff --git a/package.json b/package.json index 1ac079a0..909dce6c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "fmt": "biome format --write . && biome check standalone_app vscode --apply", "lint": "npm run lint:eslint && npm run lint:biome", "lint:eslint": "eslint . --ext .ts,.tsx --max-warnings 0", - "lint:biome": "biome format . && biome ci standalone_app vscode" + "lint:biome": "biome format . && biome ci standalone_app vscode tslib" }, "devDependencies": { "@biomejs/biome": "1.5.3", diff --git a/standalone_app/src/components/StorageProvider.tsx b/standalone_app/src/components/StorageProvider.tsx index 8ac64e0d..ac6019c5 100644 --- a/standalone_app/src/components/StorageProvider.tsx +++ b/standalone_app/src/components/StorageProvider.tsx @@ -1,6 +1,6 @@ -import React, { FC, createContext, useState } from "react" import { JournalFileStorage } from "@optuna/storage" import { SQLite3Storage } from "@optuna/storage" +import React, { FC, createContext, useState } from "react" export const StorageContext = createContext<{ storage: OptunaStorage | null diff --git a/tslib/storage/src/journal.ts b/tslib/storage/src/journal.ts index 20e96518..ca576e08 100644 --- a/tslib/storage/src/journal.ts +++ b/tslib/storage/src/journal.ts @@ -73,7 +73,7 @@ interface JournalOpSetTrialUserAttr extends JournalOpBase { user_attr: { [key: string]: any } // eslint-disable-line @typescript-eslint/no-explicit-any } -const trialStateNumToTrialState = (state: number): TrialState => { +const trialStateNumToTrialState = (state: number): Optuna.TrialState => { switch (state) { case 0: return "Running" @@ -90,7 +90,7 @@ const trialStateNumToTrialState = (state: number): TrialState => { } } -const parseDistribution = (distribution: string): Distribution => { +const parseDistribution = (distribution: string): Optuna.Distribution => { const distributionJson = JSON.parse(distribution) if (distributionJson.name === "IntDistribution") { return { @@ -114,13 +114,13 @@ const parseDistribution = (distribution: string): Distribution => { } class JournalStorage { - private studies: Study[] = [] + private studies: Optuna.Study[] = [] private nextStudyId = 0 private studyIdToTrialIDs: Map = new Map() private trialIdToStudyId: Map = new Map() private trialID = 0 - public getStudies(): Study[] { + public getStudies(): Optuna.Study[] { for (const study of this.studies) { const unionUserAttrs: Set = new Set() const unionSearchSpace: Set = new Set() @@ -187,7 +187,7 @@ class JournalStorage { return } - const params: TrialParam[] = + const params: Optuna.TrialParam[] = log.params === undefined || log.distributions === undefined ? [] : Object.entries(log.params).map(([name, value]) => { @@ -254,7 +254,7 @@ class JournalStorage { this.trialID++ } - private getStudyAndTrial(trial_id: number): [Study?, Trial?] { + private getStudyAndTrial(trial_id: number): [Optuna.Study?, Optuna.Trial?] { const study = this.studies.find( (item) => item.study_id === this.trialIdToStudyId.get(trial_id) )