Skip to content

Commit 81b3705

Browse files
committed
feat(FR-1318): add button to start model service after cloning folder (#4062)
Resolves #4048 ([FR-1318](https://lablup.atlassian.net/browse/FR-1318)) ## Summary Adds a "Run This Model" button to the ModelCardModal that enables users to start model services immediately after cloning folders if no cloned folder exists. The implementation includes smart folder management, validation, and user confirmation workflows. ## Changes ### Core Implementation - **ModelTryContentButton**: Enhanced component with folder cloning and service creation workflow - Removed `modelCardMetadata` dependency for cleaner interface - Added folder existence checking and validation logic - Implemented smart workflow: clone folder → validate files → create service - Added proper error handling and user confirmation dialogs ### Key Features - **Smart Folder Management**: Detects existing folders vs. new cloning needs - **File Validation**: Checks for required `service-definition.toml` and `model-definition.yaml` files - **User Confirmation**: Modal dialogs for cloning and using existing folders - **Background Tasks**: Progress tracking with notifications for clone and service operations - **Error Handling**: User-friendly error messages when files are missing or operations fail ### UI Integration - **ModelCardModal**: Re-enabled ModelTryContentButton in modal footer - **Internationalization**: Added translation keys across all language files ## Technical Details The component now follows this workflow: 1. Check if similar named folder exists using GraphQL query with filters 2. If no folder exists → Confirm clone → Clone folder → Validate service definition → Create service 3. If folder exists → Confirm use existing → Validate service definition → Create service 4. Show progress notifications throughout the process ## Test Plan > Endpoint: 10.100.6.113 - [ ] Verify "Run This Model" button appears in ModelCardModal - [ ] Test cloning workflow when no similar folder exists - [ ] Test using existing folder workflow - [ ] Verify service-definition.toml validation - [ ] Check error handling for missing files - [ ] Confirm progress notifications work properly - [ ] Test across different language localizations [FR-1318]: https://lablup.atlassian.net/browse/FR-1318?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 7486f48 commit 81b3705

26 files changed

+828
-396
lines changed

react/src/components/FolderExplorerModal.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ export interface FolderExplorerElement extends HTMLDivElement {
4444
handleUpload: (name: 'file' | 'folder') => void;
4545
}
4646

47+
export interface FileItem {
48+
name: string;
49+
type: string;
50+
size: number;
51+
mode: string;
52+
created: string;
53+
modified: string;
54+
}
55+
4756
interface FolderExplorerProps extends BAIModalProps {
4857
vfolderID: string;
4958
onRequestClose: () => void;

react/src/components/ModelCardModal.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ModelCardModalFragment$key } from '../__generated__/ModelCardModalFragment.graphql';
22
import { useBackendAIImageMetaData } from '../hooks';
33
import { useModelCardMetadata } from '../hooks/useModelCardMetadata';
4+
import ErrorBoundaryWithNullFallback from './ErrorBoundaryWithNullFallback';
45
import ModelCardChat from './ModelCardChat';
56
import ModelCloneModal from './ModelCloneModal';
6-
// import ModelTryContentButton from './ModelTryContentButton';
7+
import ModelTryContentButton from './ModelTryContentButton';
78
import ResourceNumber from './ResourceNumber';
89
import { BankOutlined, FileOutlined, CopyOutlined } from '@ant-design/icons';
910
import {
@@ -17,6 +18,7 @@ import {
1718
Typography,
1819
theme,
1920
Skeleton,
21+
Tooltip,
2022
} from 'antd';
2123
import { BAIFlex, BAIModal, BAIModalProps } from 'backend.ai-ui';
2224
import dayjs from 'dayjs';
@@ -112,16 +114,20 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
112114
: '90%'
113115
}
114116
footer={[
115-
// FIXME: ModelTryContentButton is not working properly
116-
// It should be fixed in the future.
117117
// This button is used to clone-and-create/create the model service with the content of the model card.
118-
/*<ModelTryContentButton
119-
vfolderNode={model_card?.vfolder_node || null}
120-
modelStorageHost={model_card?.vfolder?.host as string}
121-
modelCardMetadata={model || null}
122-
modelName={model_card?.name as string}
123-
key="try"
124-
/>,*/
118+
<ErrorBoundaryWithNullFallback key="model-try-content-button">
119+
<Suspense
120+
fallback={
121+
<Tooltip title={t('modelStore.CheckingSettings')}>
122+
<Button loading disabled />
123+
</Tooltip>
124+
}
125+
>
126+
<ModelTryContentButton
127+
vfolderNode={model_card?.vfolder_node || null}
128+
/>
129+
</Suspense>
130+
</ErrorBoundaryWithNullFallback>,
125131
<Button
126132
key="clone"
127133
type="primary"

0 commit comments

Comments
 (0)