mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Support metric_names for tslib/storage
This commit is contained in:
@@ -29,6 +29,13 @@ interface JournalOpDeleteStudy extends JournalOpBase {
|
||||
study_id: number
|
||||
}
|
||||
|
||||
interface JournalOpSetStudySystemAttr extends JournalOpBase {
|
||||
study_id: number
|
||||
system_attr: {
|
||||
"study:metric_names": string[]
|
||||
}
|
||||
}
|
||||
|
||||
interface JournalOpCreateTrial extends JournalOpBase {
|
||||
study_id: number
|
||||
datetime_start?: string
|
||||
@@ -179,6 +186,14 @@ class JournalStorage {
|
||||
this.studies = this.studies.filter((item) => item.id !== log.study_id)
|
||||
}
|
||||
|
||||
public applyStudySystemAttr(log: JournalOpSetStudySystemAttr): void {
|
||||
const thisStudy = this.studies.find((item) => item.id === log.study_id)
|
||||
if (thisStudy === undefined) {
|
||||
return
|
||||
}
|
||||
thisStudy.metric_names = log.system_attr["study:metric_names"]
|
||||
}
|
||||
|
||||
public applyCreateTrial(log: JournalOpCreateTrial): void {
|
||||
const thisStudy = this.studies.find((item) => item.id === log.study_id)
|
||||
if (thisStudy === undefined) {
|
||||
@@ -393,7 +408,9 @@ const loadJournalStorage = (
|
||||
// Unsupported
|
||||
break
|
||||
case JournalOperation.SET_STUDY_SYSTEM_ATTR:
|
||||
// Unsupported
|
||||
journalStorage.applyStudySystemAttr(
|
||||
parsedLog as JournalOpSetStudySystemAttr
|
||||
)
|
||||
break
|
||||
case JournalOperation.CREATE_TRIAL:
|
||||
journalStorage.applyCreateTrial(parsedLog as JournalOpCreateTrial)
|
||||
|
||||
@@ -144,6 +144,11 @@ const getStudy = (
|
||||
trials: [],
|
||||
}
|
||||
|
||||
const studySystemAttrs = getStudySystemAttributes(db, summary.id)
|
||||
if (studySystemAttrs !== undefined) {
|
||||
study.metric_names = studySystemAttrs.metric_names
|
||||
}
|
||||
|
||||
let intersection_search_space: Set<Optuna.SearchSpaceItem> = new Set()
|
||||
study.trials = getTrials(db, summary.id, schemaVersion)
|
||||
for (const trial of study.trials) {
|
||||
@@ -367,6 +372,23 @@ const parseDistributionJSON = (t: string): Optuna.Distribution => {
|
||||
}
|
||||
}
|
||||
|
||||
const getStudySystemAttributes = (
|
||||
db: SQLite3DB,
|
||||
studyId: number
|
||||
) => {
|
||||
let attrs: { metric_names: string[] } | undefined
|
||||
db.exec({
|
||||
sql: `SELECT key, value_json FROM study_system_attributes WHERE study_id = ${studyId} AND key = 'dashboard:objective_names'`,
|
||||
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
||||
callback: (vals: any[]) => {
|
||||
attrs = {
|
||||
metric_names: JSON.parse(vals[1]),
|
||||
}
|
||||
},
|
||||
})
|
||||
return attrs
|
||||
}
|
||||
|
||||
const getTrialUserAttributes = (
|
||||
db: SQLite3DB,
|
||||
trialId: number
|
||||
|
||||
Reference in New Issue
Block a user