Skip to content

Commit

Permalink
Fixed TSC errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mbsantiago committed Jan 11, 2024
1 parent 8e614fd commit 9502302
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 42 deletions.
1 change: 1 addition & 0 deletions front/src/api/evaluation_sets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type EvaluationSetFilter = z.input<typeof EvaluationSetFilterSchema>;
export const EvaluationSetCreateSchema = z.object({
name: z.string(),
description: z.string().optional(),
task: z.string(),
});

export type EvaluationSetCreate = z.input<typeof EvaluationSetCreateSchema>;
Expand Down
1 change: 1 addition & 0 deletions front/src/app/(base)/evaluation/detail/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const EvaluationSetContext = createContext<EvaluationSet>({
tags: [],
uuid: "",
created_on: new Date(),
task: "sound_event_detection",
});

export default EvaluationSetContext;
25 changes: 0 additions & 25 deletions front/src/app/contexts.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function ProjectActions({
<Link
mode="text"
variant="primary"
href={download}
href={download || ""}
target="_blank"
download
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export default function ClipEvaluationSpectrogram(props: {
height: 0,
};

const { sound_event_evaluations: matches, clip_prediction: clipPrediction } =
clipEvaluation;
const { clip_prediction: clipPrediction } = clipEvaluation;

const { clip } = clipPrediction;
const { recording } = clip;
Expand Down Expand Up @@ -120,6 +119,11 @@ export default function ClipEvaluationSpectrogram(props: {
[clipPrediction.sound_events],
);

const matches = useMemo(
() => clipEvaluation.sound_event_evaluations || [],
[clipEvaluation.sound_event_evaluations],
);

const drawMatches = useMatchDraw({
viewport: spectrogram.viewport,
matches,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function EvaluationSetCreate({
control,
formState: { errors },
register,
} = useForm<EvaluationSet>({
} = useForm<EvaluationSetCreate>({
resolver: zodResolver(EvaluationSetCreateSchema),
mode: "onChange",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default function EvaluationSetUpdateForm({
<DescriptionTerm>Description</DescriptionTerm>
<EditableDescriptionData
value={evaluationSet?.description}
onChange={(description) => updateEvaluationSet({ description })}
onChange={(description) =>
updateEvaluationSet({ description: description || undefined })
}
rows={6}
Input={TextArea}
autoFocus
Expand Down
3 changes: 2 additions & 1 deletion front/src/hooks/api/useEvaluationSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from "react";
import api from "@/app/api";
import useObject from "@/hooks/utils/useObject";

import type { EvaluationSetUpdate } from "@/api/evaluation_sets";
import type { EvaluationSet } from "@/types";
import type { AxiosError } from "axios";

Expand Down Expand Up @@ -40,7 +41,7 @@ export default function useEvaluationSet({
onError,
});

const update = useMutation({
const update = useMutation<EvaluationSetUpdate>({
mutationFn: api.evaluationSets.update,
onSuccess: onUpdate,
});
Expand Down
8 changes: 1 addition & 7 deletions front/src/hooks/api/useModelRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ export default function useModelRun({
onSuccess: onUpdate,
});

const evaluate = useMutation<
{
evaluationSet: EvaluationSet;
task: string;
},
Evaluation
>({
const evaluate = useMutation<EvaluationSet, Evaluation>({
mutationFn: api.modelRuns.evaluate,
onSuccess: onEvaluate,
withUpdate: false,
Expand Down
9 changes: 5 additions & 4 deletions front/src/utils/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
Box,
Dimensions,
SoundEventAnnotation,
SoundEventPrediction,
SpectrogramWindow,
Tag,
TimeInterval,
Expand All @@ -29,7 +30,7 @@ export type Position = {
};

export type TagGroup = {
annotation: SoundEventAnnotation;
annotation: SoundEventAnnotation | SoundEventPrediction;
tags: TagElement[];
position: Position;
active?: boolean;
Expand All @@ -42,7 +43,7 @@ function getTimeIntervalLabelPosition({
window,
dimensions,
}: {
annotation: SoundEventAnnotation;
annotation: SoundEventAnnotation | SoundEventPrediction;
window: SpectrogramWindow;
dimensions: Dimensions;
}): Position {
Expand Down Expand Up @@ -105,7 +106,7 @@ function getTimeStampLabelPosition({
window,
dimensions,
}: {
annotation: SoundEventAnnotation;
annotation: SoundEventAnnotation | SoundEventPrediction;
window: SpectrogramWindow;
dimensions: Dimensions;
}): Position {
Expand Down Expand Up @@ -144,7 +145,7 @@ function getTimeStampLabelPosition({
}

export function getLabelPosition(
annotation: SoundEventAnnotation,
annotation: SoundEventAnnotation | SoundEventPrediction,
window: SpectrogramWindow,
dimensions: Dimensions,
): Position {
Expand Down

0 comments on commit 9502302

Please sign in to comment.