Skip to content

Commit

Permalink
feat: background task notification for cloning a model folder (#2494)
Browse files Browse the repository at this point in the history
> [!CAUTION]
> This PR should be merged after  lablup/backend.ai#2161

This PR includes

- Background task notification for cloning a model folder
- Modify frontend components to reflect schema changes and improve user interaction with vFolders.
- Update internationalization files to include messages related to folder cloning and handling errors in multiple languages.

## How to Test
- Make sure related core PR: lablup/backend.ai#2161
- Create a 'model' project folder in the 'model-store' project.
- Upload `model-definition.yml`.
  - [model-definition.yml.zip](https://github.com/user-attachments/files/15982404/model-definition.yml.zip)
- Navigate to the model store list on the `/data` page.
- Click on a model card item and then click the "Clone" button.
- You should see the notification and the cloned 'model' folder in the model tab of the `/data` page.

<!--
Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes,
and how it affects the users and other developers.
-->

**Checklist:** (if applicable)

- [ ] Mention to the original issue
- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
  • Loading branch information
yomybaby committed Jul 1, 2024
1 parent db62f9a commit 119f64e
Show file tree
Hide file tree
Showing 24 changed files with 335 additions and 118 deletions.
65 changes: 57 additions & 8 deletions react/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,20 @@ type Queries {
"""Added in 24.03.1"""
id: String
reference: String
architecture: String = "x86_64"
architecture: String = "aarch64"
): Image
images(is_installed: Boolean, is_operation: Boolean): [Image]
images(
"""
Added in 19.09.0. If it is specified, fetch images installed on at least one agent.
"""
is_installed: Boolean
is_operation: Boolean @deprecated(reason: "Deprecated since 24.03.4. This field is ignored if `image_filters` is specified and is not null.")

"""
Added in 24.03.4. Allowed values are: [operational, customized]. When superuser queries with `customized` option set the resolver will return every customized images (including those not owned by callee). To resolve images owned by user only call `customized_images`.
"""
image_filters: [String] = null
): [Image]

"""Added in 24.03.1"""
customized_images: [ImageNode]
Expand Down Expand Up @@ -96,7 +107,7 @@ type Queries {
legacy_compute_session(sess_id: String!, domain_name: String, access_key: String): LegacyComputeSession
vfolder_host_permissions: PredefinedAtomicPermission
endpoint(endpoint_id: UUID!): Endpoint
endpoint_list(limit: Int!, offset: Int!, filter: String, order: String, domain_name: String, group_id: String, access_key: String, project: UUID): EndpointList
endpoint_list(limit: Int!, offset: Int!, filter: String, order: String, domain_name: String, group_id: String, user_uuid: String, project: UUID): EndpointList
routing(routing_id: UUID!): Routing
routing_list(limit: Int!, offset: Int!, filter: String, order: String, endpoint_id: UUID): RoutingList
endpoint_token(token: String!): EndpointToken
Expand Down Expand Up @@ -222,6 +233,9 @@ scalar UUID
type ImageNode implements Node {
"""The ID of the object"""
id: ID!

"""Added in 24.03.4. The undecoded id value stored in DB."""
row_id: UUID
name: String
humanized_name: String
tag: String
Expand All @@ -233,6 +247,9 @@ type ImageNode implements Node {
size_bytes: BigInt
resource_limits: [ResourceLimit]
supported_accelerators: [String]

"""Added in 24.03.4. The array of image aliases."""
aliases: [String]
}

type KVPair {
Expand Down Expand Up @@ -888,6 +905,9 @@ type Endpoint implements Item {
cluster_mode: String
cluster_size: Int
open_to_public: Boolean

"""Added in 24.03.5."""
runtime_variant: RuntimeVariantInfo
created_at: DateTime!
destroyed_at: DateTime
routings: [Routing]
Expand All @@ -897,6 +917,12 @@ type Endpoint implements Item {
errors: [InferenceSessionError!]!
}

"""Added in 24.03.5."""
type RuntimeVariantInfo {
name: String
human_readable_name: String
}

type Routing implements Item {
id: ID
routing_id: UUID
Expand Down Expand Up @@ -979,6 +1005,9 @@ type ModelCard implements Node {
id: ID!
name: String
vfolder: VirtualFolder

"""Added in 24.09.0."""
vfolder_node: VirtualFolderNode
author: String

"""Human readable name of the model."""
Expand Down Expand Up @@ -1087,15 +1116,15 @@ type Mutations {
rescan_images(registry: String): RescanImages
preload_image(references: [String]!, target_agents: [String]!): PreloadImage
unload_image(references: [String]!, target_agents: [String]!): UnloadImage
modify_image(architecture: String = "x86_64", props: ModifyImageInput!, target: String!): ModifyImage
modify_image(architecture: String = "aarch64", props: ModifyImageInput!, target: String!): ModifyImage

"""Added in 24.03.0"""
forget_image_by_id(image_id: String!): ForgetImageById
forget_image(architecture: String = "x86_64", reference: String!): ForgetImage
forget_image(architecture: String = "aarch64", reference: String!): ForgetImage

"""Added in 24.03.1"""
untag_image_from_registry(image_id: String!): UntagImageFromRegistry
alias_image(alias: String!, architecture: String = "x86_64", target: String!): AliasImage
alias_image(alias: String!, architecture: String = "aarch64", target: String!): AliasImage
dealias_image(alias: String!): DealiasImage
clear_images(registry: String): ClearImages
create_keypair_resource_policy(name: String!, props: CreateKeyPairResourcePolicyInput!): CreateKeyPairResourcePolicy
Expand Down Expand Up @@ -1777,12 +1806,22 @@ input ModifyEndpointInput {
name: String
resource_group: String

"""Added in 24.03.4."""
"""
Added in 24.03.4. Must be set to `/models` when choosing `runtime_variant` other than `CUSTOM` or `CMD`.
"""
model_definition_path: String
open_to_public: Boolean

"""Added in 24.03.4."""
"""
Added in 24.03.4. MODEL type VFolders are not allowed to be attached to model service session with this option.
"""
extra_mounts: [ExtraMountInput]

"""Added in 24.03.5."""
environ: JSONString

"""Added in 24.03.5."""
runtime_variant: String
}

input ImageRefType {
Expand All @@ -1795,4 +1834,14 @@ input ImageRefType {
input ExtraMountInput {
vfolder_id: String
mount_destination: String

"""
Added in 24.03.4. Set bind type of this mount. Shoud be one of (volume,bind,tmpfs,k8s-generic,k8s-hostpath). Default is 'bind'.
"""
type: String

"""
Added in 24.03.4. Set permission of this mount. Should be one of (ro,rw,wd). Default is null
"""
permission: String
}
21 changes: 8 additions & 13 deletions react/src/components/ModelCardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import Flex from './Flex';
import ModelCloneModal from './ModelCloneModal';
import ResourceNumber from './ResourceNumber';
import { ModelCardModalFragment$key } from './__generated__/ModelCardModalFragment.graphql';
import {
BankOutlined,
CopyOutlined,
DownloadOutlined,
FileOutlined,
} from '@ant-design/icons';
import { BankOutlined, CopyOutlined, FileOutlined } from '@ant-design/icons';
import {
Button,
Card,
Expand Down Expand Up @@ -69,9 +64,10 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
architecture
framework
vfolder {
name
cloneable
host
}
vfolder_node {
...ModelCloneModalVFolderFragment
}
}
`,
Expand Down Expand Up @@ -142,15 +138,15 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
)}
</Flex>
<Flex direction="row" justify="end" gap={'sm'}>
<Button
{/* <Button
type="primary"
ghost
icon={<DownloadOutlined />}
size="small"
disabled
>
{t('button.Download')}
</Button>
</Button> */}
<Button
type="primary"
ghost
Expand All @@ -169,7 +165,7 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
setVisibleCloneModal(true);
}}
>
{t('button.Clone')}
{t('modelStore.CloneToFolder')}
</Button>
</Flex>
</Flex>
Expand Down Expand Up @@ -307,8 +303,7 @@ const ModelCardModal: React.FC<ModelCardModalProps> = ({
</Row>
<Suspense>
<ModelCloneModal
sourceFolderName={model_card?.vfolder?.name || ''}
sourceFolderHost={model_card?.vfolder?.host || ''}
vfolderNode={model_card?.vfolder_node || null}
title={t('modelStore.CloneAsFolder')}
open={visibleCloneModal}
onOk={() => {
Expand Down
Loading

0 comments on commit 119f64e

Please sign in to comment.