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 31, 2025
1 parent 9c53670 commit e258119
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 21 deletions.
153 changes: 151 additions & 2 deletions 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 25.2.0. Default value `system` queries across the entire system.
"""
scope_id: ScopeField

"""Added in 24.09.0."""
Expand Down Expand Up @@ -220,6 +222,12 @@ type Queries {

"""Added in 24.12.0."""
networks(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): NetworkConnection

"""Added in 25.1.0."""
endpoint_auto_scaling_rule_node(id: String!): EndpointAutoScalingRuleNode

"""Added in 25.1.0."""
endpoint_auto_scaling_rule_nodes(endpoint: String!, filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): EndpointAutoScalingRuleConnection
}

"""
Expand Down Expand Up @@ -606,6 +614,14 @@ type KernelNode implements Node {
cluster_hostname: String
session_id: UUID
image: ImageNode

"""Added in 25.2.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 +1237,12 @@ type ComputeSessionNode implements Node {
vfolder_mounts: [String]
occupied_slots: JSONString
requested_slots: JSONString

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

"""Added in 25.2.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 +1493,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 @@ -1651,6 +1675,63 @@ type NetworkEdge {
cursor: String!
}

"""Added in 25.1.0."""
type EndpointAutoScalingRuleNode implements Node {
"""The ID of the object"""
id: ID!
row_id: UUID!
metric_source: AutoScalingMetricSource!
metric_name: String!
threshold: String!
comparator: AutoScalingMetricComparator!
step_size: Int!
cooldown_seconds: Int!
min_replicas: Int
max_replicas: Int
created_at: DateTime!
last_triggered_at: DateTime
endpoint: UUID!
}

"""The source type to fetch metrics. Added in 25.1.0."""
enum AutoScalingMetricSource {
KERNEL
INFERENCE_FRAMEWORK
}

"""
The comparator used to compare the metric value with the threshold. Added in 25.1.0.
"""
enum AutoScalingMetricComparator {
LESS_THAN
LESS_THAN_OR_EQUAL
GREATER_THAN
GREATER_THAN_OR_EQUAL
}

"""Added in 25.1.0."""
type EndpointAutoScalingRuleConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!

"""Contains the nodes in this connection."""
edges: [EndpointAutoScalingRuleEdge]!

"""Total count of the GQL nodes of the query."""
count: Int
}

"""
Added in 25.1.0. A Relay edge containing a `EndpointAutoScalingRule` and its cursor.
"""
type EndpointAutoScalingRuleEdge {
"""The item at the end of the edge"""
node: EndpointAutoScalingRuleNode

"""A cursor for use in pagination"""
cursor: String!
}

"""All available GraphQL mutations."""
type Mutations {
modify_agent(id: String!, props: ModifyAgentInput!): ModifyAgent
Expand Down Expand Up @@ -1715,7 +1796,11 @@ type Mutations {
create_keypair(props: KeyPairInput!, user_id: String!): CreateKeyPair
modify_keypair(access_key: String!, props: ModifyKeyPairInput!): ModifyKeyPair
delete_keypair(access_key: String!): DeleteKeyPair
rescan_images(registry: String): RescanImages
rescan_images(
"""Added in 25.1.0."""
project: String
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
Expand Down Expand Up @@ -1848,8 +1933,23 @@ type Mutations {
"""Object id. Can be either global id or object id. Added in 24.09.0."""
id: String!
): DeleteContainerRegistryNode

"""Added in 25.1.0."""
create_endpoint_auto_scaling_rule_node(endpoint: String!, props: EndpointAutoScalingRuleInput!): CreateEndpointAutoScalingRuleNode

"""Added in 25.1.0."""
modify_endpoint_auto_scaling_rule_node(id: String!, props: ModifyEndpointAutoScalingRuleInput!): ModifyEndpointAutoScalingRuleNode

"""Added in 25.1.0."""
delete_endpoint_auto_scaling_rule_node(id: String!): DeleteEndpointAutoScalingRuleNode

"""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 +2681,56 @@ type DeleteContainerRegistryNode {
container_registry: ContainerRegistryNode
}

"""Added in 25.1.0."""
type CreateEndpointAutoScalingRuleNode {
ok: Boolean
msg: String
rule: EndpointAutoScalingRuleNode
}

"""Added in 25.1.0."""
input EndpointAutoScalingRuleInput {
metric_source: AutoScalingMetricSource!
metric_name: String!
threshold: String!
comparator: AutoScalingMetricComparator!
step_size: Int!
cooldown_seconds: Int!
min_replicas: Int
max_replicas: Int
}

"""Added in 25.1.0."""
type ModifyEndpointAutoScalingRuleNode {
ok: Boolean
msg: String
rule: EndpointAutoScalingRuleNode
}

"""Added in 25.1.0."""
input ModifyEndpointAutoScalingRuleInput {
metric_source: AutoScalingMetricSource
metric_name: String
threshold: String
comparator: AutoScalingMetricComparator
step_size: Int
cooldown_seconds: Int
min_replicas: Int
max_replicas: Int
}

"""Added in 25.1.0."""
type DeleteEndpointAutoScalingRuleNode {
ok: Boolean
msg: String
}

"""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 +2743,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 +2761,7 @@ input ModifyContainerRegistryInput {
is_global: Boolean
}

"""Deprecated since 24.09.0. use `DeleteContainerRegistryNode` instead"""
type DeleteContainerRegistry {
container_registry: ContainerRegistry
}
Expand Down
68 changes: 49 additions & 19 deletions react/src/components/SessionDetailContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ const SessionDetailContent: React.FC<{
}
}
vfolder_mounts
vfolder_nodes @since(version: "25.2.0") {
edges {
node {
id
row_id
name
}
}
count
}
created_at @required(action: NONE)
terminated_at
scaling_group
Expand Down Expand Up @@ -131,6 +141,7 @@ const SessionDetailContent: React.FC<{
legacy_session?.image &&
legacy_session?.architecture &&
legacy_session.image + '@' + legacy_session.architecture;

return session ? (
<Flex direction="column" gap={'sm'} align="stretch">
{session_for_project_id?.group_id !== currentProject.id && (
Expand Down Expand Up @@ -193,25 +204,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>
);
},
)}
{session.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

0 comments on commit e258119

Please sign in to comment.