Skip to content

Commit 3c3dfcf

Browse files
committed
feat(api): update tag parameter to be optional in timeseries results
1 parent 1b497e4 commit 3c3dfcf

File tree

11 files changed

+83
-58
lines changed

11 files changed

+83
-58
lines changed

docs/oas/openapi.json

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,17 +4478,6 @@
44784478
},
44794479
"description": "Chip ID"
44804480
},
4481-
{
4482-
"name": "tag",
4483-
"in": "query",
4484-
"required": true,
4485-
"schema": {
4486-
"type": "string",
4487-
"description": "Tag to filter by",
4488-
"title": "Tag"
4489-
},
4490-
"description": "Tag to filter by"
4491-
},
44924481
{
44934482
"name": "parameter",
44944483
"in": "query",
@@ -4522,6 +4511,24 @@
45224511
},
45234512
"description": "End time in ISO format"
45244513
},
4514+
{
4515+
"name": "tag",
4516+
"in": "query",
4517+
"required": false,
4518+
"schema": {
4519+
"anyOf": [
4520+
{
4521+
"type": "string"
4522+
},
4523+
{
4524+
"type": "null"
4525+
}
4526+
],
4527+
"description": "Tag to filter by",
4528+
"title": "Tag"
4529+
},
4530+
"description": "Tag to filter by"
4531+
},
45254532
{
45264533
"name": "qid",
45274534
"in": "query",
@@ -8922,6 +8929,18 @@
89228929
],
89238930
"title": "Parameter Overrides",
89248931
"description": "Optional parameter overrides: {run: {...}, input: {...}}"
8932+
},
8933+
"update_params": {
8934+
"type": "boolean",
8935+
"title": "Update Params",
8936+
"description": "Update backend parameters (e.g. qubex YAML) after execution",
8937+
"default": true
8938+
},
8939+
"reconfigure": {
8940+
"type": "boolean",
8941+
"title": "Reconfigure",
8942+
"description": "Run Configure (system_manager load + push) before executing the task",
8943+
"default": false
89258944
}
89268945
},
89278946
"type": "object",
@@ -9296,7 +9315,7 @@
92969315
"type": "number",
92979316
"title": "Delta Per Step",
92989317
"description": "Average delta per step",
9299-
"default": 0
9318+
"default": 0.0
93009319
},
93019320
"current_value": {
93029321
"anyOf": [
@@ -10590,7 +10609,12 @@
1059010609
"severity": {
1059110610
"anyOf": [
1059210611
{
10593-
"type": "string"
10612+
"type": "string",
10613+
"enum": [
10614+
"critical",
10615+
"warning",
10616+
"info"
10617+
]
1059410618
},
1059510619
{
1059610620
"type": "null"
@@ -10644,7 +10668,8 @@
1064410668
"items": {
1064510669
"type": "string"
1064610670
},
10647-
"type": "array"
10671+
"type": "array",
10672+
"maxItems": 50
1064810673
},
1064910674
{
1065010675
"type": "null"
@@ -12077,7 +12102,7 @@
1207712102
"error": {
1207812103
"type": "number",
1207912104
"title": "Error",
12080-
"default": 0
12105+
"default": 0.0
1208112106
},
1208212107
"previous_error": {
1208312108
"anyOf": [
@@ -12315,7 +12340,7 @@
1231512340
"error": {
1231612341
"type": "number",
1231712342
"title": "Error",
12318-
"default": 0
12343+
"default": 0.0
1231912344
},
1232012345
"version": {
1232112346
"type": "integer",
@@ -12456,7 +12481,7 @@
1245612481
"error": {
1245712482
"type": "number",
1245812483
"title": "Error",
12459-
"default": 0
12484+
"default": 0.0
1246012485
},
1246112486
"valid_from": {
1246212487
"anyOf": [
@@ -15375,4 +15400,4 @@
1537515400
"url": "/api"
1537615401
}
1537715402
]
15378-
}
15403+
}

src/qdash/api/routers/task_result.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,12 @@ def get_coupling_task_history(
347347
)
348348
def get_timeseries_task_results(
349349
chip_id: Annotated[str, Query(description="Chip ID")],
350-
tag: Annotated[str, Query(description="Tag to filter by")],
351350
parameter: Annotated[str, Query(description="Parameter name")],
352351
start_at: Annotated[str, Query(description="Start time in ISO format")],
353352
end_at: Annotated[str, Query(description="End time in ISO format")],
354353
ctx: Annotated[ProjectContext, Depends(get_project_context)],
355354
service: Annotated[TaskResultService, Depends(get_task_result_service)],
355+
tag: Annotated[str | None, Query(description="Tag to filter by")] = None,
356356
qid: Annotated[str | None, Query(description="Optional qubit ID to filter by")] = None,
357357
) -> TimeSeriesData:
358358
"""Get timeseries task results filtered by tag and parameter.

src/qdash/api/services/task_result_service.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import zipfile
1212
from datetime import datetime, timedelta
1313
from pathlib import Path
14-
from typing import TYPE_CHECKING
14+
from typing import TYPE_CHECKING, Any
1515

1616
from bunnet import SortDirection
1717
from qdash.api.schemas.task_result import (
@@ -234,7 +234,7 @@ def get_history(
234234
def get_timeseries(
235235
self,
236236
chip_id: str,
237-
tag: str,
237+
tag: str | None,
238238
parameter: str,
239239
project_id: str,
240240
target_qid: str | None = None,
@@ -272,14 +272,17 @@ def get_timeseries(
272272
start_at_dt = datetime.fromisoformat(start_at)
273273
end_at_dt = datetime.fromisoformat(end_at)
274274

275+
query_filter: dict[str, Any] = {
276+
"project_id": project_id,
277+
"chip_id": chip_id,
278+
"output_parameter_names": parameter,
279+
"start_at": {"$gte": start_at_dt, "$lte": end_at_dt},
280+
}
281+
if tag is not None:
282+
query_filter["tags"] = tag
283+
275284
task_results = self._task_result_repo.find_with_projection(
276-
{
277-
"project_id": project_id,
278-
"chip_id": chip_id,
279-
"tags": tag,
280-
"output_parameter_names": parameter,
281-
"start_at": {"$gte": start_at_dt, "$lte": end_at_dt},
282-
},
285+
query_filter,
283286
projection_model=TimeSeriesProjection,
284287
sort=[("start_at", SortDirection.ASCENDING)],
285288
)

ui/src/components/features/analysis/TimeSeriesView/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ export function TimeSeriesView() {
207207
{
208208
chip_id: selectedChip,
209209
parameter: selectedParameter as ParameterKey,
210-
tag: selectedTag as TagKey,
210+
tag: (selectedTag || undefined) as TagKey,
211211
start_at: timeRange.startAt,
212212
end_at: timeRange.endAt,
213213
},
214214
{
215215
query: {
216-
enabled: Boolean(selectedChip && selectedParameter && selectedTag),
216+
enabled: Boolean(selectedChip && selectedParameter),
217217
staleTime: 30000, // Keep data fresh for 30 seconds
218218
},
219219
},
@@ -229,13 +229,13 @@ export function TimeSeriesView() {
229229
{
230230
chip_id: selectedChip,
231231
parameter: secondaryParameter as ParameterKey,
232-
tag: selectedTag as TagKey,
232+
tag: (selectedTag || undefined) as TagKey,
233233
start_at: timeRange.startAt,
234234
end_at: timeRange.endAt,
235235
},
236236
{
237237
query: {
238-
enabled: Boolean(selectedChip && secondaryParameter && selectedTag),
238+
enabled: Boolean(selectedChip && secondaryParameter),
239239
staleTime: 30000,
240240
},
241241
},
@@ -1064,13 +1064,10 @@ export function TimeSeriesView() {
10641064
}
10651065
isLoading={isLoadingTimeseries || isLoadingSecondary}
10661066
hasData={Boolean(
1067-
selectedChip &&
1068-
selectedParameter &&
1069-
selectedTag &&
1070-
plotData.length > 0,
1067+
selectedChip && selectedParameter && plotData.length > 0,
10711068
)}
10721069
emptyStateMessage={
1073-
!selectedChip || !selectedParameter || !selectedTag
1070+
!selectedChip || !selectedParameter
10741071
? "Select chip and parameters to visualize data"
10751072
: "No data available for the selected parameters"
10761073
}

ui/src/components/features/issue-knowledge/IssueKnowledgeDetailPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function IssueKnowledgeDetailPage({
138138
const handleSave = async () => {
139139
await update({
140140
title: editTitle,
141-
severity: editSeverity,
141+
severity: editSeverity as "critical" | "warning" | "info" | null,
142142
symptom: editSymptom,
143143
root_cause: editRootCause,
144144
resolution: editResolution,

ui/src/components/selectors/TagSelector/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ export function TagSelector({
2929
}));
3030

3131
const handleChange = (option: SingleValue<TagOption>) => {
32-
if (option) {
33-
onTagSelect(option.value);
34-
}
32+
onTagSelect(option ? option.value : "");
3533
};
3634

3735
return (
3836
<Select<TagOption>
37+
isClearable
3938
options={options}
40-
value={options.find((option) => option.value === selectedTag)}
39+
value={options.find((option) => option.value === selectedTag) ?? null}
4140
onChange={handleChange}
4241
placeholder="Select tag"
4342
className="text-base-content w-full"

ui/src/hooks/url-state/useAnalysisUrlState.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ export function useAnalysisUrlState(): UseAnalysisUrlStateResult {
8181

8282
const setSelectedTag = useCallback(
8383
(tag: string) => {
84-
// Always include tag in URL for complete state management
85-
setSelectedTagState(tag);
84+
setSelectedTagState(tag || null);
8685
},
8786
[setSelectedTagState],
8887
);
@@ -99,7 +98,7 @@ export function useAnalysisUrlState(): UseAnalysisUrlStateResult {
9998
selectedChip: selectedChip ?? "",
10099
selectedParameter: selectedParameter ?? "t1",
101100
selectedParameters: selectedParameters ?? [],
102-
selectedTag: selectedTag ?? "daily",
101+
selectedTag: selectedTag ?? "",
103102
analysisViewType: analysisViewType ?? "timeseries",
104103
setSelectedChip,
105104
setSelectedParameter,

ui/src/hooks/useIssueKnowledge.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useDeleteIssueKnowledge,
1414
useExtractIssueKnowledge,
1515
} from "@/client/issue-knowledge/issue-knowledge";
16+
import type { IssueKnowledgeUpdate } from "@/schemas/issueKnowledgeUpdate";
1617

1718
type StatusFilter = "draft" | "approved" | "rejected" | "all";
1819

@@ -125,14 +126,7 @@ export function useIssueKnowledgeDetail(knowledgeId: string) {
125126
}, [queryClient, knowledgeId]);
126127

127128
const update = useCallback(
128-
async (updates: {
129-
title?: string;
130-
severity?: string;
131-
symptom?: string;
132-
root_cause?: string;
133-
resolution?: string;
134-
lesson_learned?: string[];
135-
}) => {
129+
async (updates: IssueKnowledgeUpdate) => {
136130
await updateMutation.mutateAsync({
137131
knowledgeId,
138132
data: updates,

ui/src/schemas/bodyReExecuteTaskResult.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ import type { BodyReExecuteTaskResultParameterOverrides } from "./bodyReExecuteT
1010
export interface BodyReExecuteTaskResult {
1111
/** Optional parameter overrides: {run: {...}, input: {...}} */
1212
parameter_overrides?: BodyReExecuteTaskResultParameterOverrides;
13+
/** Update backend parameters (e.g. qubex YAML) after execution */
14+
update_params?: boolean;
15+
/** Run Configure (system_manager load + push) before executing the task */
16+
reconfigure?: boolean;
1317
}

ui/src/schemas/getTimeseriesTaskResultsParams.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export type GetTimeseriesTaskResultsParams = {
1111
* Chip ID
1212
*/
1313
chip_id: string;
14-
/**
15-
* Tag to filter by
16-
*/
17-
tag: string;
1814
/**
1915
* Parameter name
2016
*/
@@ -27,6 +23,10 @@ export type GetTimeseriesTaskResultsParams = {
2723
* End time in ISO format
2824
*/
2925
end_at: string;
26+
/**
27+
* Tag to filter by
28+
*/
29+
tag?: string | null;
3030
/**
3131
* Optional qubit ID to filter by
3232
*/

0 commit comments

Comments
 (0)