Skip to content

Commit 052967a

Browse files
committed
feat(FR-2809): use adminPrometheusQueryPresetPreview for live query template preview (#7240)
Resolves #7239 (FR-2809) ## Summary - Syncs `data/schema.graphql` with the new `adminPrometheusQueryPresetPreview` query and `PreviewQueryDefinitionInput` type added in the backend (BA-5950 / [backend PR #11482](lablup/backend.ai#11482)). - Adds `PrometheusQueryTemplatePreview` — a new component that accepts a raw `queryTemplate` string, debounces it 800 ms, then calls `adminPrometheusQueryPresetPreview` via Relay; server errors are caught by an `ErrorBoundary` and shown as danger text below the field. - Updates `PrometheusQueryPresetEditorModal` to use `Form.useForm()` + `Form.useWatch('queryTemplate')` so the preview works in both **create** and **edit** modes (previously only edit mode had a preview, and it was based on the saved preset ID rather than the live form value).
1 parent 979d465 commit 052967a

28 files changed

Lines changed: 345 additions & 164 deletions

data/schema.graphql

Lines changed: 103 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,41 @@ input BulkCreateUserV2Input
19511951
users: [CreateUserV2Input!]!
19521952
}
19531953

1954+
"""Added in UNRELEASED. Input for bulk-deleting multiple model cards."""
1955+
input BulkDeleteModelCardsV2Input
1956+
@join__type(graph: STRAWBERRY)
1957+
{
1958+
"""List of model card UUIDs to delete."""
1959+
ids: [UUID!]!
1960+
1961+
"""Options for the delete operation."""
1962+
options: DeleteModelCardV2Options = null
1963+
}
1964+
1965+
"""Added in UNRELEASED. Payload for bulk model card deletion."""
1966+
type BulkDeleteModelCardsV2Payload
1967+
@join__type(graph: STRAWBERRY)
1968+
{
1969+
"""UUIDs of model cards that were successfully deleted."""
1970+
successes: [UUID!]!
1971+
1972+
"""List of errors for model cards that failed to delete."""
1973+
failed: [BulkDeleteModelCardV2Error!]!
1974+
}
1975+
1976+
"""
1977+
Added in UNRELEASED. Error information for a model card that failed during bulk deletion.
1978+
"""
1979+
type BulkDeleteModelCardV2Error
1980+
@join__type(graph: STRAWBERRY)
1981+
{
1982+
"""UUID of the model card that failed to delete."""
1983+
cardId: UUID!
1984+
1985+
"""Error message describing the failure."""
1986+
message: String!
1987+
}
1988+
19541989
"""Added in 26.4.2. Input for soft-deleting multiple virtual folders."""
19551990
input BulkDeleteVFoldersV2Input
19561991
@join__type(graph: STRAWBERRY)
@@ -2023,6 +2058,11 @@ input BulkPurgeVFoldersV2Input
20232058
{
20242059
"""List of VFolder UUIDs to purge."""
20252060
ids: [UUID!]!
2061+
2062+
"""
2063+
Added in UNRELEASED. Optional behavior flags applied to every vfolder in the batch. Defaults to all-false when omitted.
2064+
"""
2065+
options: PurgeVFolderOptionsInput!
20262066
}
20272067

20282068
"""Added in 26.4.2. Payload for bulk virtual folder purge."""
@@ -2031,6 +2071,22 @@ type BulkPurgeVFoldersV2Payload
20312071
{
20322072
"""Number of virtual folders successfully purged."""
20332073
purgedCount: Int!
2074+
2075+
"""List of errors for vfolders that failed to purge."""
2076+
failed: [BulkPurgeVFolderV2Error!]!
2077+
}
2078+
2079+
"""
2080+
Added in UNRELEASED. Failure detail for a single vfolder in a bulk purge.
2081+
"""
2082+
type BulkPurgeVFolderV2Error
2083+
@join__type(graph: STRAWBERRY)
2084+
{
2085+
"""UUID of the vfolder that failed to purge."""
2086+
vfolderId: UUID!
2087+
2088+
"""Error message describing the failure."""
2089+
message: String!
20342090
}
20352091

20362092
"""
@@ -4689,25 +4745,6 @@ type DeleteModelCardPayloadGQL
46894745
id: UUID!
46904746
}
46914747

4692-
"""Added in 26.4.2. Input for deleting multiple model cards."""
4693-
input DeleteModelCardsV2Input
4694-
@join__type(graph: STRAWBERRY)
4695-
{
4696-
"""List of model card UUIDs to delete."""
4697-
ids: [UUID!]!
4698-
4699-
"""Added in UNRELEASED. Options for the delete operation."""
4700-
options: DeleteModelCardV2Options = null
4701-
}
4702-
4703-
"""Added in 26.4.2. Payload for bulk model card deletion."""
4704-
type DeleteModelCardsV2Payload
4705-
@join__type(graph: STRAWBERRY)
4706-
{
4707-
"""Number of model cards successfully deleted."""
4708-
deletedCount: Int!
4709-
}
4710-
47114748
"""Added in UNRELEASED. Options for the model card delete operation."""
47124749
input DeleteModelCardV2Options
47134750
@join__type(graph: STRAWBERRY)
@@ -5279,6 +5316,9 @@ type DeploymentRevisionPresetEnvironEntry
52795316
input DeploymentRevisionPresetFilter
52805317
@join__type(graph: STRAWBERRY)
52815318
{
5319+
"""Added in UNRELEASED. Filter by preset ID."""
5320+
id: UUIDFilter = null
5321+
52825322
"""Name filter."""
52835323
name: StringFilter = null
52845324

@@ -9552,6 +9592,11 @@ type ModelRevision implements Node
95529592
"""Additional volume folder mounts."""
95539593
extraMounts: [ExtraVFolderMountInfoGQL!]!
95549594

9595+
"""
9596+
Added in UNRELEASED. ID of the deployment-level preset that produced this revision. ``None`` when the revision was created without a preset, when the originating preset row has since been deleted (SET NULL FK), or for legacy rows that predate this field.
9597+
"""
9598+
revisionPresetId: UUID
9599+
95559600
"""Timestamp when the revision was created."""
95569601
createdAt: DateTime!
95579602

@@ -9563,6 +9608,11 @@ type ModelRevision implements Node
95639608
"""
95649609
imageV2: ImageV2
95659610

9611+
"""
9612+
Added in UNRELEASED. The deployment-level preset that produced this revision, resolved via DataLoader. ``None`` when the revision was created without a preset, when the originating preset row has since been deleted (SET NULL FK), or for legacy rows that predate this field.
9613+
"""
9614+
revisionPreset: DeploymentRevisionPreset
9615+
95669616
"""Added in 26.4.2. Resource slot allocations for this revision."""
95679617
resourceSlots(filter: AllocatedResourceSlotFilter = null, orderBy: [AllocatedResourceSlotOrderBy!] = null): [AllocatedResourceSlot!]!
95689618
}
@@ -11294,8 +11344,10 @@ type Mutation
1129411344
"""Added in 26.4.2. Delete a model card (admin only)."""
1129511345
adminDeleteModelCardV2(id: UUID!, options: DeleteModelCardV2Options = null): DeleteModelCardPayloadGQL! @join__field(graph: STRAWBERRY)
1129611346

11297-
"""Added in 26.4.2. Delete multiple model cards (admin only)."""
11298-
adminDeleteModelCardsV2(input: DeleteModelCardsV2Input!): DeleteModelCardsV2Payload! @join__field(graph: STRAWBERRY)
11347+
"""
11348+
Added in UNRELEASED. Bulk-delete model cards (admin only) with per-card partial-failure reporting.
11349+
"""
11350+
adminBulkDeleteModelCardsV2(input: BulkDeleteModelCardsV2Input!): BulkDeleteModelCardsV2Payload @join__field(graph: STRAWBERRY)
1129911351

1130011352
"""
1130111353
Added in 26.4.2. Scan a MODEL_STORE project and upsert model cards from vfolder model-definition.yaml files.
@@ -11319,7 +11371,7 @@ type Mutation
1131911371
deleteVfolderV2(vfolderId: UUID!): DeleteVFolderV2Payload! @join__field(graph: STRAWBERRY)
1132011372

1132111373
"""Added in 26.4.2. Permanently purge a virtual folder."""
11322-
purgeVfolderV2(vfolderId: UUID!): PurgeVFolderV2Payload! @join__field(graph: STRAWBERRY)
11374+
purgeVfolderV2(vfolderId: UUID!, options: PurgeVFolderOptionsInput = null): PurgeVFolderV2Payload! @join__field(graph: STRAWBERRY)
1132311375

1132411376
"""
1132511377
Added in UNRELEASED. Restore a trashed virtual folder. RBAC enforced via scope chain.
@@ -12113,6 +12165,16 @@ input PreStartActionInput
1211312165
args: JSON!
1211412166
}
1211512167

12168+
"""
12169+
Added in UNRELEASED. Input for previewing a prometheus query template (admin only).
12170+
"""
12171+
input PreviewQueryDefinitionInput
12172+
@join__type(graph: STRAWBERRY)
12173+
{
12174+
"""PromQL template to validate."""
12175+
queryTemplate: String!
12176+
}
12177+
1211612178
"""
1211712179
Added in 26.2.0. Basic project information. Contains identity and descriptive fields for the project.
1211812180
"""
@@ -13034,13 +13096,25 @@ type PurgeUserV2Payload
1303413096
success: Boolean!
1303513097
}
1303613098

13099+
"""
13100+
Added in UNRELEASED. Optional behavior flags for vfolder purge operations.
13101+
"""
13102+
input PurgeVFolderOptionsInput
13103+
@join__type(graph: STRAWBERRY)
13104+
{
13105+
"""
13106+
If true, also delete model card record(s) referencing the vfolder. If false, the request is rejected when any model card still references it.
13107+
"""
13108+
cascadeModelCard: Boolean! = false
13109+
}
13110+
1303713111
"""
1303813112
Added in 26.4.2. Payload returned after permanently purging a virtual folder.
1303913113
"""
1304013114
type PurgeVFolderV2Payload
1304113115
@join__type(graph: STRAWBERRY)
1304213116
{
13043-
"""ID of the purged virtual folder"""
13117+
"""ID of the purged virtual folder."""
1304413118
id: UUID!
1304513119
}
1304613120

@@ -13689,6 +13763,11 @@ type Query
1368913763
"""
1369013764
prometheusQueryPresetResult(id: ID!, timeRange: QueryTimeRangeInput = null, options: ExecuteQueryDefinitionOptionsInput = null, timeWindow: String = null): QueryDefinitionExecuteResult! @join__field(graph: STRAWBERRY)
1369113765

13766+
"""
13767+
Added in UNRELEASED. Preview a prometheus query template before saving it as a preset (admin only).
13768+
"""
13769+
adminPreviewPrometheusQueryPreset(input: PreviewQueryDefinitionInput!): QueryDefinitionExecuteResult @join__field(graph: STRAWBERRY)
13770+
1369213771
"""
1369313772
Added in 26.4.2. Get a single query preset category by ID. Available to any authenticated user.
1369413773
"""
@@ -20400,4 +20479,4 @@ input WebhookSpecInput
2040020479
@join__type(graph: STRAWBERRY)
2040120480
{
2040220481
url: String!
20403-
}
20482+
}

packages/backend.ai-ui/src/helper/useDebouncedDeferredValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useDebounce } from 'ahooks';
22
import type { DebounceOptions } from 'ahooks/lib/useDebounce/debounceOptions';
33
import { useDeferredValue } from 'react';
44

5-
const useDebouncedDeferredValue = <T>(
5+
export const useDebouncedDeferredValue = <T>(
66
value: T,
77
options: DebounceOptions = {
88
wait: 200,

react/src/components/AutoScalingRuleEditorModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { AutoScalingRuleEditorModalUpdateMutation } from '../__generated__/AutoS
1212
import { SIGNED_32BIT_MAX_INT } from '../helper/const-vars';
1313
import { useSuspendedBackendaiClient } from '../hooks';
1414
import ErrorBoundaryWithNullFallback from './ErrorBoundaryWithNullFallback';
15-
import { PrometheusPresetPreview } from './PrometheusPresetPreview';
15+
import PrometheusQueryTemplatePreview from './PrometheusQueryTemplatePreview';
1616
import {
1717
App,
1818
AutoComplete,
@@ -340,9 +340,9 @@ const AutoScalingRuleEditorModalContent: React.FC<{
340340
]}
341341
extra={
342342
selectedPreset ? (
343-
<PrometheusPresetPreview
343+
<PrometheusQueryTemplatePreview
344344
key={selectedPreset.id}
345-
presetGlobalId={selectedPreset.id}
345+
queryTemplate={selectedPreset.queryTemplate}
346346
/>
347347
) : undefined
348348
}

react/src/components/PrometheusPresetPreview.tsx

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)