fix train image filtering for a class with a dash

The backend writes a class with a `-` as `_` in train file names, since it splits those names on `-`, while a dataset folder keeps the dash. Filtering the Train grid by `half-open` compared it with `half_open` and hid every attempt. Both sides are normalized the same way now.
This commit is contained in:
Josh Hawkins
2026-09-18 06:55:36 -05:00
parent 27db8f1d74
commit 885d6776fd
@@ -899,6 +899,14 @@ type TrainGridProps = {
onRefresh: () => void;
onDelete: (ids: string[]) => void;
};
// the backend writes a class with a "-" as "_" in train file names, since it
// splits those names on "-", so a dataset class may still carry the dash
function matchesTrainClass(classes: string[], name: string): boolean {
const target = name.replaceAll("-", "_");
return classes.some((item) => item.replaceAll("-", "_") === target);
}
function TrainGrid({
model,
contentRef,
@@ -936,7 +944,10 @@ function TrainGrid({
return true;
}
if (trainFilter.classes && !trainFilter.classes.includes(data.name)) {
if (
trainFilter.classes &&
!matchesTrainClass(trainFilter.classes, data.name)
) {
return false;
}