Skip to content

Commit

Permalink
chore: prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jeafreezy committed Dec 6, 2024
1 parent 94e064d commit a80c619
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 43 deletions.
24 changes: 15 additions & 9 deletions frontend/src/app/providers/models-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ const ModelsContext = createContext<{
validateEditMode: boolean;
}>({
formData: initialFormState,
setFormData: () => { },
handleChange: () => { },
setFormData: () => {},
handleChange: () => {},
createNewTrainingDatasetMutation: {} as UseMutationResult<
TTrainingDataset,
Error,
Expand All @@ -238,13 +238,13 @@ const ModelsContext = createContext<{
>,
hasLabeledTrainingAreas: false,
hasAOIsWithGeometry: false,
resetState: () => { },
resetState: () => {},
isEditMode: false,
modelId: "",
getFullPath: () => "",
handleModelCreationAndUpdate: () => { },
handleModelCreationAndUpdate: () => {},
trainingDatasetCreationInProgress: false,
handleTrainingDatasetCreation: () => { },
handleTrainingDatasetCreation: () => {},
validateEditMode: false,
});

Expand Down Expand Up @@ -306,8 +306,11 @@ export const ModelsProvider: React.FC<{
}

handleChange(MODEL_CREATION_FORM_NAME.BASE_MODELS, data.base_model);
handleChange(MODEL_CREATION_FORM_NAME.MODEL_DESCRIPTION, data.description ?? '');
handleChange(MODEL_CREATION_FORM_NAME.MODEL_NAME, data.name ?? '');
handleChange(
MODEL_CREATION_FORM_NAME.MODEL_DESCRIPTION,
data.description ?? "",
);
handleChange(MODEL_CREATION_FORM_NAME.MODEL_NAME, data.name ?? "");
handleChange(
MODEL_CREATION_FORM_NAME.SELECTED_TRAINING_DATASET_ID,
data.dataset,
Expand All @@ -318,10 +321,13 @@ export const ModelsProvider: React.FC<{
useEffect(() => {
if (!isEditMode || trainingDatasetIsPending || trainingDatasetIsError)
return;
handleChange(MODEL_CREATION_FORM_NAME.DATASET_NAME, trainingDataset.name ?? '');
handleChange(
MODEL_CREATION_FORM_NAME.DATASET_NAME,
trainingDataset.name ?? "",
);
handleChange(
MODEL_CREATION_FORM_NAME.TMS_URL,
trainingDataset.source_imagery ?? '',
trainingDataset.source_imagery ?? "",
);
}, [
isEditMode,
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/app/routes/models/model-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export const ModelDetailsPage = () => {
openDialog: openModelFilesDialog,
} = useDialog();
const navigate = useNavigate();
const { data, isPending, isError, error } = useModelDetails(id as string, id !== undefined, 10000);
const { data, isPending, isError, error } = useModelDetails(
id as string,
id !== undefined,
10000,
);
const { isAuthenticated } = useAuth();

useEffect(() => {
Expand All @@ -56,7 +60,6 @@ export const ModelDetailsPage = () => {
return <ModelDetailsSkeleton />;
}


return (
<>
<ModelEnhancementDialog
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/routes/start-mapping/start-mapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const StartMappingPage = () => {
const { modelId } = useParams();
const { isError, isPending, data, error } = useModelDetails(
modelId as string,
modelId !== undefined
modelId !== undefined,
);
const navigate = useNavigate();
const { currentZoom } = useMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ const ModelSummaryForm = () => {
content: [
`${MODEL_CREATION_CONTENT.trainingSettings.form.epoch.label}: ${formData.epoch}`,
`${MODEL_CREATION_CONTENT.trainingSettings.form.batchSize.label}: ${formData.batchSize}`,
formData.baseModel === BASE_MODELS.RAMP ? `${MODEL_CREATION_CONTENT.trainingSettings.form.contactSpacing.label}: ${formData.contactSpacing}` : '',
formData.baseModel === BASE_MODELS.RAMP ? `${MODEL_CREATION_CONTENT.trainingSettings.form.boundaryWidth.label}: ${formData.boundaryWidth}` : '',
formData.baseModel === BASE_MODELS.RAMP
? `${MODEL_CREATION_CONTENT.trainingSettings.form.contactSpacing.label}: ${formData.contactSpacing}`
: "",
formData.baseModel === BASE_MODELS.RAMP
? `${MODEL_CREATION_CONTENT.trainingSettings.form.boundaryWidth.label}: ${formData.boundaryWidth}`
: "",
],
},
];
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/features/model-creation/components/progress-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ type ProgressBarProps = {
const ProgressBar: React.FC<ProgressBarProps> = memo(
({ currentPath, currentPageIndex, pages }) => {
const navigate = useNavigate();
const {
getFullPath, isEditMode,
} = useModelsContext();
const { getFullPath, isEditMode } = useModelsContext();
return (
<div className="flex items-center justify-between w-full gap-x-4 overflow-x-scroll p-1">
{pages.map((step, index) => {
const activeStep = currentPath.includes(step.path);
const isLastPage = index === pages.length - 1
const isLastPage = index === pages.length - 1;
return (
<button
key={`current-form-progress-${step.id}`}
className="flex items-center gap-x-3 cursor-pointer"
disabled={isLastPage}
onClick={() => isEditMode && !isLastPage && navigate(getFullPath(step.path))}
onClick={() =>
isEditMode && !isLastPage && navigate(getFullPath(step.path))
}
>
{step.id < currentPageIndex + 1 ? (
<span className="rounded-full bg-primary flex items-center justify-center w-9 h-9">
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/features/models/api/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ export const getModelsQueryOptions = ({
});
};

export const getModelDetailsQueryOptions = (id: string, refetchInterval: boolean | number) => {
export const getModelDetailsQueryOptions = (
id: string,
refetchInterval: boolean | number,
) => {
return queryOptions({
queryKey: [queryKeys.MODEL_DETAILS(id)],
queryFn: () => getModelDetails(id),
//@ts-expect-error bad type definition
refetchInterval: refetchInterval
refetchInterval: refetchInterval,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const ModelFilesDialog: React.FC<TrainingAreaDialogProps> = ({
closeDialog={closeDialog}
label={APP_CONTENT.models.modelsDetailsCard.modelFilesDialog.dialogTitle}
>
<p className="text-dark text-body-2base px-2 mb-4">{APP_CONTENT.models.modelsDetailsCard.modelFilesDialog.dialogDescription}</p>
<p className="text-dark text-body-2base px-2 mb-4">
{
APP_CONTENT.models.modelsDetailsCard.modelFilesDialog
.dialogDescription
}
</p>
{isOpened && (
<DirectoryTree
trainingId={trainingId}
Expand Down
39 changes: 19 additions & 20 deletions frontend/src/features/models/components/directory-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,9 @@ const DirectoryTree: React.FC<DirectoryTreeProps> = ({
const fetchDirectoryRecursive = async (
currentDirectory: string = "",
currentDepth: number = 0,
maxDepth: number = 2
maxDepth: number = 2,
): Promise<any> => {
if (currentDepth >= maxDepth) {

return {};
}

Expand All @@ -136,24 +135,24 @@ const DirectoryTree: React.FC<DirectoryTreeProps> = ({
const subdirectories =
dir && currentDepth < maxDepth
? await Promise.all(
Object.keys(dir).map(async (key: string) => {
const fullPath = currentDirectory
? `${currentDirectory}/${key}`
: key;
const subDirData = await fetchDirectoryRecursive(
fullPath,
currentDepth + 1,
maxDepth
);
return {
[key]: {
...subDirData,
size: dir[key]?.size || 0,
length: dir[key]?.len || 0,
},
};
})
)
Object.keys(dir).map(async (key: string) => {
const fullPath = currentDirectory
? `${currentDirectory}/${key}`
: key;
const subDirData = await fetchDirectoryRecursive(
fullPath,
currentDepth + 1,
maxDepth,
);
return {
[key]: {
...subDirData,
size: dir[key]?.size || 0,
length: dir[key]?.len || 0,
},
};
}),
)
: [];

return {
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/features/models/hooks/use-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export const useModels = ({
});
};

export const useModelDetails = (id: string, enabled: boolean = true, refetchInterval: boolean | number = false) => {
export const useModelDetails = (
id: string,
enabled: boolean = true,
refetchInterval: boolean | number = false,
) => {
return useQuery({
...getModelDetailsQueryOptions(id, refetchInterval),
//@ts-expect-error bad type definition
Expand Down

0 comments on commit a80c619

Please sign in to comment.