Skip to content

Commit

Permalink
Restored the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Dec 9, 2024
1 parent f63deb6 commit 0ae6245
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 59 deletions.
12 changes: 4 additions & 8 deletions frontend/src/app/routes/models/model-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ export const ModelDetailsPage = () => {
openDialog: openModelFilesDialog,
} = useDialog();
const navigate = useNavigate();
const { data, isPending, isError, error } = useModelDetails(
id as string,
id !== undefined,
10000,
);
const { isAuthenticated } = useAuth();
const { data, isPending, isError, error } = useModelDetails(id as string, id !== undefined, 10000);
const { user } = useAuth();

useEffect(() => {
if (isError) {
Expand All @@ -59,6 +55,7 @@ export const ModelDetailsPage = () => {
if (isPending || isError) {
return <ModelDetailsSkeleton />;
}
const isOwner = user?.osm_id === data?.user?.osm_id;

return (
<>
Expand Down Expand Up @@ -111,7 +108,6 @@ export const ModelDetailsPage = () => {
size="medium"
prefixIcon={StarStackIcon}
onClick={openModelEnhancementDialog}
disabled={!isAuthenticated}
/>
</div>
{/* mobile */}
Expand All @@ -127,7 +123,7 @@ export const ModelDetailsPage = () => {
size="medium"
prefixIcon={StarStackIcon}
onClick={openModelEnhancementDialog}
disabled={!isAuthenticated}
disabled={!isOwner}
/>
</div>
<TrainingHistoryTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@ 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
11 changes: 1 addition & 10 deletions frontend/src/features/model-creation/components/progress-bar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useModelsContext } from "@/app/providers/models-provider";
import CheckIcon from "@/components/ui/icons/check-icon";
import { cn } from "@/utils";
import { memo } from "react";
import { useNavigate } from "react-router-dom";

type ProgressBarProps = {
currentPath: string;
Expand All @@ -12,21 +10,14 @@ type ProgressBarProps = {

const ProgressBar: React.FC<ProgressBarProps> = memo(
({ currentPath, currentPageIndex, pages }) => {
const navigate = useNavigate();
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) => {
{pages.map((step) => {
const activeStep = currentPath.includes(step.path);
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))
}
>
{step.id < currentPageIndex + 1 ? (
<span className="rounded-full bg-primary flex items-center justify-center w-9 h-9">
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/features/models/api/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ 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,12 +20,7 @@ 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: 20 additions & 19 deletions frontend/src/features/models/components/directory-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ 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 @@ -135,24 +136,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: 1 addition & 5 deletions frontend/src/features/models/hooks/use-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ 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 0ae6245

Please sign in to comment.