From 6110dc7e922416ffe8bf7f64ebdf90d662a70cbb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 4 Nov 2025 23:24:56 +0000 Subject: [PATCH] Fix search dialog ValueError by using string values for direction select The search dialog was failing to open with "ValueError: Invalid value: -1" because NiceGUI's select component has validation issues when using numeric values with dict-based options and emit-value/map-options props. Changed the direction select to use string values ('desc', 'asc') instead of integers (-1, 1) and updated _perform_search to convert the string back to the integer value expected by the HuggingFace service API. Fixes the issue where clicking "Search Models" or "Search Datasets" in the configure view would crash instead of opening the search dialog. --- src/msquant/app/components/hf_search_dialog.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/msquant/app/components/hf_search_dialog.py b/src/msquant/app/components/hf_search_dialog.py index ded5593..be86684 100644 --- a/src/msquant/app/components/hf_search_dialog.py +++ b/src/msquant/app/components/hf_search_dialog.py @@ -76,10 +76,10 @@ def show(self): self.direction_select = ui.select( options=[ - {'label': 'Descending', 'value': -1}, - {'label': 'Ascending', 'value': 1} + {'label': 'Descending', 'value': 'desc'}, + {'label': 'Ascending', 'value': 'asc'} ], - value=-1, + value='desc', label='Direction' ).classes('w-48').props('emit-value map-options') @@ -105,7 +105,9 @@ def _perform_search(self) -> None: """Perform the search based on current input.""" query = self.search_input.value.strip() if self.search_input.value else "" sort = str(self.sort_select.value) if self.sort_select.value else 'downloads' - direction = int(self.direction_select.value) if self.direction_select.value is not None else -1 + # Convert string direction to integer: 'desc' -> -1, 'asc' -> 1 + direction_str = str(self.direction_select.value) if self.direction_select.value else 'desc' + direction = -1 if direction_str == 'desc' else 1 # Clear previous results and errors self.results_container.clear()