Skip to content

Commit

Permalink
feat: open folder explorer from session detail panel using vfolder_nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Jan 23, 2025
1 parent 61191e3 commit 2027255
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 20 deletions.
31 changes: 30 additions & 1 deletion react/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ type Queries {

"""Added in 24.09.0."""
compute_session_nodes(
"""Added in 24.12.0."""
"""
Added in 24.12.0. Default value `system` queries across the entire system.
"""
scope_id: ScopeField

"""Added in 24.09.0."""
Expand Down Expand Up @@ -606,6 +608,14 @@ type KernelNode implements Node {
cluster_hostname: String
session_id: UUID
image: ImageNode

"""Added in 24.12.0."""
image_reference: String

"""
Added in 24.12.0. The architecture that the image of this kernel requires
"""
architecture: String
status: String
status_changed: DateTime
status_info: String
Expand Down Expand Up @@ -1221,6 +1231,12 @@ type ComputeSessionNode implements Node {
vfolder_mounts: [String]
occupied_slots: JSONString
requested_slots: JSONString

"""Added in 24.12.0."""
image_references: [String]

"""Added in 24.12.0."""
vfolder_nodes(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): VirtualFolderConnection
num_queries: BigInt
inference_metrics: JSONString
kernel_nodes(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): KernelConnection
Expand Down Expand Up @@ -1471,13 +1487,15 @@ type QuotaDetails {
hard_limit_bytes: BigInt
}

"""Deprecated since 24.09.0. use `ContainerRegistryNode` instead"""
type ContainerRegistry implements Node {
"""The ID of the object"""
id: ID!
hostname: String
config: ContainerRegistryConfig
}

"""Deprecated since 24.09.0."""
type ContainerRegistryConfig {
url: String!
type: String!
Expand Down Expand Up @@ -1848,8 +1866,14 @@ type Mutations {
"""Object id. Can be either global id or object id. Added in 24.09.0."""
id: String!
): DeleteContainerRegistryNode

"""Deprecated since 24.09.0. use `CreateContainerRegistryNode` instead"""
create_container_registry(hostname: String!, props: CreateContainerRegistryInput!): CreateContainerRegistry

"""Deprecated since 24.09.0. use `ModifyContainerRegistryNode` instead"""
modify_container_registry(hostname: String!, props: ModifyContainerRegistryInput!): ModifyContainerRegistry

"""Deprecated since 24.09.0. use `DeleteContainerRegistryNode` instead"""
delete_container_registry(hostname: String!): DeleteContainerRegistry
modify_endpoint(endpoint_id: UUID!, props: ModifyEndpointInput!): ModifyEndpoint

Expand Down Expand Up @@ -2581,10 +2605,12 @@ type DeleteContainerRegistryNode {
container_registry: ContainerRegistryNode
}

"""Deprecated since 24.09.0. use `CreateContainerRegistryNode` instead"""
type CreateContainerRegistry {
container_registry: ContainerRegistry
}

"""Deprecated since 24.09.0."""
input CreateContainerRegistryInput {
url: String!
type: String!
Expand All @@ -2597,10 +2623,12 @@ input CreateContainerRegistryInput {
is_global: Boolean
}

"""Deprecated since 24.09.0. use `ModifyContainerRegistryNode` instead"""
type ModifyContainerRegistry {
container_registry: ContainerRegistry
}

"""Deprecated since 24.09.0."""
input ModifyContainerRegistryInput {
url: String
type: String
Expand All @@ -2613,6 +2641,7 @@ input ModifyContainerRegistryInput {
is_global: Boolean
}

"""Deprecated since 24.09.0. use `DeleteContainerRegistryNode` instead"""
type DeleteContainerRegistry {
container_registry: ContainerRegistry
}
Expand Down
69 changes: 50 additions & 19 deletions react/src/components/SessionDetailContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SessionKernelTags from '../components/ImageTags';
import { toGlobalId } from '../helper';
import { useSuspendedBackendaiClient } from '../hooks';
import { useCurrentUserRole } from '../hooks/backendai';
import { useCurrentProjectValue } from '../hooks/useCurrentProject';
import { ResourceNumbersOfSession } from '../pages/SessionLauncherPage';
Expand Down Expand Up @@ -40,6 +41,7 @@ const SessionDetailContent: React.FC<{
const { open } = useFolderExplorerOpener();
const currentProject = useCurrentProjectValue();
const userRole = useCurrentUserRole();
const baiClient = useSuspendedBackendaiClient();

const { md } = Grid.useBreakpoint();
// TODO: remove and refactor this waterfall request after v24.12.0
Expand Down Expand Up @@ -91,6 +93,16 @@ const SessionDetailContent: React.FC<{
}
}
vfolder_mounts
vfolder_nodes @since(version: "24.12.0") {
edges {
node {
id
row_id
name
}
}
count
}
created_at @required(action: NONE)
terminated_at
scaling_group
Expand Down Expand Up @@ -193,25 +205,44 @@ const SessionDetailContent: React.FC<{
)}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.MountedFolders')}>
{_.map(
_.zip(legacy_session?.mounts, session?.vfolder_mounts),
(mountInfo) => {
const [name, id] = mountInfo;
return (
<Button
key={id}
type="link"
size="small"
icon={<FolderOutlined />}
onClick={() => {
open(id ?? '');
}}
>
{name}
</Button>
);
},
)}
{baiClient.supports('vfolder-nodes')
? _.map(session?.vfolder_nodes?.edges, (vfolder) => {
return (
<Button
key={vfolder?.node?.id}
type="link"
size="small"
icon={<FolderOutlined />}
onClick={() => {
open(vfolder?.node?.row_id ?? '');
}}
>
{vfolder?.node?.name}
</Button>
);
})
: _.map(
// compute_session_node query's vfolder_mounts is not include name.
// To provide vfolder name in compute_session_node, schema must be changed.
// legacy_session.mounts (name) and session.vfolder_mounts (id) give vfolder information in same order.
_.zip(legacy_session?.mounts, session?.vfolder_mounts),
(mountInfo) => {
const [name, id] = mountInfo;
return (
<Button
key={id}
type="link"
size="small"
icon={<FolderOutlined />}
onClick={() => {
open(id ?? '');
}}
>
{name}
</Button>
);
},
)}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.ResourceAllocation')}>
<Flex gap={'sm'} wrap="wrap">
Expand Down
1 change: 1 addition & 0 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ class Client {
this._features['creating-session-status'] = true;
this._features['max_network_count'] = true;
this._features['replicas'] = true;
this._features['vfolder-nodes'] = true;
}
if (this.isManagerVersionCompatibleWith(['25.1.0', '24.09.6', '24.03.12'])) {
this._features['vfolder-id-based'] = true;
Expand Down

0 comments on commit 2027255

Please sign in to comment.