BoostV / process-optimizer-frontend

A web frontend for ProcessOptimizer
BSD 3-Clause "New" or "Revised" License
10 stars 3 forks source link

Editing factor name does not update data points #265

Closed j-or closed 1 year ago

j-or commented 1 year ago

Editing the name of a factor (input model variable) visually removes the factor from data points, because the name is not updated in data points.

langdal commented 1 year ago

I didn't notice this bug report and just spent an hour reaching the same conclusion :) A side effect of the data points not updating is that the Python backend fails because of a mismatch between input and data space

langdal commented 1 year ago

For future reference, the following Zod code will validate that all datapoints have a name that is defined in in variable definitions:

export const experimentSchema = z
  .object({
    id: z.string(),
    lastEvaluationHash: z.string().optional(),
    changedSinceLastEvaluation: z.boolean(),
    info: infoSchema,
    extras: z.record(z.unknown()),
    categoricalVariables: z.array(categorialVariableSchema),
    valueVariables: z.array(valueVariableSchema),
    scoreVariables: z.array(scoreVariableSchema),
    optimizerConfig: optimizerSchema,
    results: experimentResultSchema,
    dataPoints: z.array(dataEntrySchema),
  })
  .refine(s =>
    s.dataPoints.reduce(
      (prev, curr) =>
        prev
          ? curr.data.reduce(
              (acc, dp) =>
                acc
                  ? s.categoricalVariables.find(cv => cv.name === dp.name) !==
                      undefined ||
                    s.valueVariables.find(cv => cv.name === dp.name) !==
                      undefined ||
                    s.scoreVariables.find(cv => cv.name === dp.name) !==
                      undefined
                  : false,
              true
            )
          : false,
      true
    )
  )