mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-11 12:30:25 +08:00
Modify tslib/storage following the change of the type
This commit is contained in:
@@ -139,6 +139,8 @@ class JournalStorage {
|
||||
const unionUserAttrs: Set<string> = new Set()
|
||||
const unionSearchSpace: Set<string> = new Set()
|
||||
let intersectionSearchSpace: string[] = []
|
||||
const nameToSearchSpaceItem: Map<string, Optuna.SearchSpaceItem> =
|
||||
new Map()
|
||||
|
||||
study.trials.forEach((trial, index) => {
|
||||
for (const userAttr of trial.user_attrs) {
|
||||
@@ -146,6 +148,12 @@ class JournalStorage {
|
||||
}
|
||||
for (const param of trial.params) {
|
||||
unionSearchSpace.add(param.name)
|
||||
if (!nameToSearchSpaceItem.has(param.name)) {
|
||||
nameToSearchSpaceItem.set(param.name, {
|
||||
name: param.name,
|
||||
distribution: param.distribution,
|
||||
})
|
||||
}
|
||||
}
|
||||
if (index === 0) {
|
||||
intersectionSearchSpace = Array.from(unionSearchSpace)
|
||||
@@ -162,14 +170,10 @@ class JournalStorage {
|
||||
}
|
||||
})
|
||||
study.union_search_space = Array.from(unionSearchSpace).map((name) => {
|
||||
return {
|
||||
name: name,
|
||||
}
|
||||
return nameToSearchSpaceItem.get(name) as Optuna.SearchSpaceItem
|
||||
})
|
||||
study.intersection_search_space = intersectionSearchSpace.map((name) => {
|
||||
return {
|
||||
name: name,
|
||||
}
|
||||
return nameToSearchSpaceItem.get(name) as Optuna.SearchSpaceItem
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -165,24 +165,35 @@ const getStudy = (
|
||||
}
|
||||
|
||||
const params = getTrialParams(db, trial.trial_id)
|
||||
const param_names = new Set<string>()
|
||||
const paramNames = new Set<string>()
|
||||
const paramNameToSearchSpaceItem = new Map<string, Optuna.SearchSpaceItem>()
|
||||
for (const param of params) {
|
||||
param_names.add(param.name)
|
||||
paramNames.add(param.name)
|
||||
if (paramNameToSearchSpaceItem.has(param.name)) {
|
||||
paramNameToSearchSpaceItem.set(param.name, {
|
||||
name: param.name,
|
||||
distribution: param.distribution,
|
||||
})
|
||||
}
|
||||
if (
|
||||
study.union_search_space.findIndex((s) => s.name === param.name) === -1
|
||||
) {
|
||||
study.union_search_space.push({ name: param.name })
|
||||
study.union_search_space.push({
|
||||
name: param.name,
|
||||
distribution: param.distribution,
|
||||
})
|
||||
}
|
||||
}
|
||||
if (intersection_search_space.size === 0) {
|
||||
// biome-ignore lint/complexity/noForEach: <explanation>
|
||||
param_names.forEach((s) => {
|
||||
intersection_search_space.add({ name: s })
|
||||
})
|
||||
for (const s of paramNames) {
|
||||
intersection_search_space.add(
|
||||
paramNameToSearchSpaceItem.get(s) as Optuna.SearchSpaceItem
|
||||
)
|
||||
}
|
||||
} else {
|
||||
intersection_search_space = new Set(
|
||||
Array.from(intersection_search_space).filter((s) =>
|
||||
param_names.has(s.name)
|
||||
paramNames.has(s.name)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user