Merge remote-tracking branch 'upstream/main' into register-user-attr-form-widgets

This commit is contained in:
Kenshin Abe
2023-03-16 17:20:05 +09:00
9 changed files with 71 additions and 38 deletions
+1 -1
View File
@@ -10,4 +10,4 @@ from ._objective_form_widget import register_objective_form_widgets # noqa
from ._objective_form_widget import register_user_attr_form_widgets # noqa
__version__ = "0.9.0b6"
__version__ = "0.9.0"
+40 -13
View File
@@ -447,17 +447,9 @@ export const actionCreator = () => {
})
}
const tellTrial = (
studyId: number,
trialId: number,
state: TrialStateFinished,
values?: number[]
): void => {
const message =
values === undefined
? `id=${trialId}, state=${state}`
: `id=${trialId}, state=${state}, values=${values}`
tellTrialAPI(trialId, state, values)
const makeTrialFail = (studyId: number, trialId: number): void => {
const message = `id=${trialId}, state=Fail`
tellTrialAPI(trialId, "Fail")
.then(() => {
const index = studyDetails[studyId].trials.findIndex(
(t) => t.trial_id === trialId
@@ -468,7 +460,41 @@ export const actionCreator = () => {
})
return
}
setTrialStateValues(studyId, index, state, values)
setTrialStateValues(studyId, index, "Fail")
enqueueSnackbar(`Successfully updated trial (${message})`, {
variant: "success",
})
})
.catch((err) => {
const reason = err.response?.data.reason
enqueueSnackbar(
`Failed to update trial (${message}). Reason: ${reason}`,
{
variant: "error",
}
)
console.log(err)
})
}
const makeTrialComplete = (
studyId: number,
trialId: number,
values: number[]
): void => {
const message = `id=${trialId}, state=Complete, values=${values}`
tellTrialAPI(trialId, "Complete", values)
.then(() => {
const index = studyDetails[studyId].trials.findIndex(
(t) => t.trial_id === trialId
)
if (index === -1) {
enqueueSnackbar(`Unexpected error happens. Please reload the page.`, {
variant: "error",
})
return
}
setTrialStateValues(studyId, index, "Complete", values)
enqueueSnackbar(`Successfully updated trial (${message})`, {
variant: "success",
})
@@ -535,7 +561,8 @@ export const actionCreator = () => {
saveTrialNote,
uploadArtifact,
deleteArtifact,
tellTrial,
makeTrialComplete,
makeTrialFail,
saveTrialUserAttrs,
}
}
@@ -32,16 +32,22 @@ export const BestTrialsCard: FC<{
header = `Best Trial (number=${bestTrial.number})`
content = (
<>
<Typography
variant="h3"
sx={{
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(2),
}}
color="secondary"
>
{bestTrial.values}
</Typography>
{bestTrial.values === undefined || bestTrial.values.length === 1 ? (
<Typography
variant="h3"
sx={{
fontWeight: theme.typography.fontWeightBold,
marginBottom: theme.spacing(2),
}}
color="secondary"
>
{bestTrial.values}
</Typography>
) : (
<Typography>
Objective Values = [{bestTrial.values?.join(", ")}]
</Typography>
)}
<Typography>
Params = [
{bestTrial.params
@@ -70,7 +70,7 @@ export const ObjectiveForm: FC<{
if (filtered.length !== directions.length) {
return
}
action.tellTrial(trial.study_id, trial.trial_id, "Complete", filtered)
action.makeTrialComplete(trial.study_id, trial.trial_id, filtered)
} else if (outputType == "user_attr") {
const user_attrs = Object.fromEntries(widgets.map((widget, i) => [widget.description, values[i]]))
action.saveTrialUserAttrs(trial.study_id, trial.trial_id, user_attrs)
@@ -268,7 +268,7 @@ export const ObjectiveForm: FC<{
variant="outlined"
color="error"
onClick={() => {
action.tellTrial(trial.study_id, trial.trial_id, "Fail")
action.makeTrialFail(trial.study_id, trial.trial_id)
}}
>
Fail Trial
+1 -1
View File
@@ -160,7 +160,7 @@ const TrialListDetail: FC<{
const params = trial.state === "Waiting" ? trial.fixed_params : trial.params
const info: [string, string | null | ReactNode][] = [
["Value", trial.values?.map((v) => v.toString()).join(" ") || "None"],
["Value", trial.values?.map((v) => v.toString()).join(", ") || "None"],
[
"Intermediate Values",
<Box>
@@ -295,7 +295,7 @@ export const TrialTable: FC<{
return
}
action.tellTrial(studyId, trialId, "Complete", objectiveValues)
action.makeTrialComplete(studyId, trialId, objectiveValues)
}
const handleFailTrial = (e: MouseEvent<HTMLButtonElement>): void => {
@@ -304,7 +304,7 @@ export const TrialTable: FC<{
}
const studyId = studyDetail.id
const trialId = trials[index].trial_id
action.tellTrial(studyId, trialId, "Fail")
action.makeTrialFail(studyId, trialId)
}
return (
+1 -1
View File
@@ -27,7 +27,7 @@ export const getDominatedTrials = (
const dominatedTrials: boolean[] = []
normalizedValues.forEach((values0: number[], i: number) => {
const dominated = normalizedValues.some((values1: number[], j: number) => {
if (i === j) {
if (i === j || values0.every((v, i) => v == values1[i])) {
return false
}
return values0.every((value0: number, k: number) => {
+7 -7
View File
@@ -49,7 +49,7 @@
"ts-jest": "^29.0.3",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2"
}
},
@@ -13310,9 +13310,9 @@
}
},
"node_modules/webpack": {
"version": "5.75.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
"version": "5.76.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz",
"integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==",
"dev": true,
"dependencies": {
"@types/eslint-scope": "^3.7.3",
@@ -23273,9 +23273,9 @@
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g=="
},
"webpack": {
"version": "5.75.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.75.0.tgz",
"integrity": "sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ==",
"version": "5.76.0",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.76.0.tgz",
"integrity": "sha512-l5sOdYBDunyf72HW8dF23rFtWq/7Zgvt/9ftMof71E/yUb1YLOBmTgA2K4vQthB3kotMrSj609txVE0dnr2fjA==",
"dev": true,
"requires": {
"@types/eslint-scope": "^3.7.3",
+1 -1
View File
@@ -56,7 +56,7 @@
"ts-jest": "^29.0.3",
"ts-loader": "^9.2.7",
"typescript": "^4.6.2",
"webpack": "^5.70.0",
"webpack": "^5.76.0",
"webpack-cli": "^4.9.2"
}
}