Skip to content

Commit 889ffd9

Browse files
committed
remove multi select
1 parent 38c4758 commit 889ffd9

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

eval_protocol/cli_commands/create_rft.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -380,27 +380,15 @@ def _resolve_evaluator(
380380
selected_tests = _discover_and_select_tests(project_root, non_interactive=non_interactive)
381381
if not selected_tests:
382382
return None, None, None, None
383+
383384
if len(selected_tests) != 1:
384385
if non_interactive and len(selected_tests) > 1:
385386
print("Error: Multiple evaluation tests found in --yes (non-interactive) mode.")
386387
print(" Please pass --evaluator or --entry to disambiguate.")
387-
try:
388-
# Offer candidate evaluator ids for convenience
389-
tests = _discover_tests(project_root)
390-
if tests:
391-
print(" Candidate evaluator ids:")
392-
for t in tests:
393-
func = t.qualname.split(".")[-1]
394-
stem = os.path.splitext(os.path.basename(t.file_path))[0]
395-
cand = _normalize_evaluator_id(f"{stem}-{func}")
396-
print(f" - {cand}")
397-
except Exception:
398-
pass
399388
else:
400389
print("Error: Please select exactly one evaluation test for 'create rft'.")
401390
return None, None, None, None
402391

403-
# Derive evaluator_id from user's single selection
404392
chosen = selected_tests[0]
405393
func_name = chosen.qualname.split(".")[-1]
406394
source_file_name = os.path.splitext(os.path.basename(chosen.file_path))[0]

eval_protocol/cli_commands/utils.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def _format_test_choice(test: DiscoveredTest, idx: int) -> str:
278278

279279

280280
def _prompt_select_interactive(tests: list[DiscoveredTest]) -> list[DiscoveredTest]:
281-
"""Interactive selection with arrow keys using questionary."""
281+
"""Interactive single selection with arrow keys using questionary (Enter selects highlighted)."""
282282
try:
283283
import questionary
284284

@@ -289,35 +289,32 @@ def _prompt_select_interactive(tests: list[DiscoveredTest]) -> list[DiscoveredTe
289289
print(f"\nFound 1 test: {_format_test_choice(tests[0], 1)}")
290290
confirm = questionary.confirm("Select this test?", default=True, style=custom_style).ask()
291291
if confirm:
292-
return tests
292+
return [tests[0]]
293293
else:
294294
return []
295295

296-
# Build checkbox choices
296+
# Build single-select choices
297297
choices = []
298298
for idx, t in enumerate(tests, 1):
299299
choice_text = _format_test_choice(t, idx)
300-
choices.append(questionary.Choice(title=choice_text, value=idx - 1, checked=False))
300+
choices.append(questionary.Choice(title=choice_text, value=idx - 1))
301301

302302
print()
303-
selected_indices = questionary.checkbox(
304-
"Select evaluation tests to upload:",
303+
selected_index = questionary.select(
304+
"Select an evaluation test:",
305305
choices=choices,
306306
style=custom_style,
307307
pointer=">",
308-
instruction="(↑↓ move, space select, enter confirm)",
308+
instruction="(↑↓ move, enter confirm)",
309309
).ask()
310310

311-
if selected_indices is None: # Ctrl+C
311+
if selected_index is None: # Ctrl+C / Esc
312312
print("\nUpload cancelled.")
313313
return []
314314

315-
if not selected_indices:
316-
return []
317-
318-
selected_tests = [tests[i] for i in selected_indices]
319-
print(f"\n✓ Selected {len(selected_tests)} test(s)")
320-
return selected_tests
315+
chosen = tests[int(selected_index)]
316+
print("\n✓ Selected 1 test")
317+
return [chosen]
321318

322319
except ImportError:
323320
# Fallback to simpler implementation
@@ -372,9 +369,10 @@ def _prompt_select_fallback(tests: list[DiscoveredTest]) -> list[DiscoveredTest]
372369

373370

374371
def _prompt_select(tests: list[DiscoveredTest], non_interactive: bool) -> list[DiscoveredTest]:
375-
"""Prompt user to select tests to upload."""
372+
"""Prompt user to select exactly one test."""
376373
if non_interactive:
377-
return tests
374+
# In non-interactive mode, only proceed if unambiguous.
375+
return [tests[0]] if len(tests) == 1 else []
378376

379377
return _prompt_select_interactive(tests)
380378

@@ -401,7 +399,16 @@ def _discover_and_select_tests(project_root: str, non_interactive: bool) -> Opti
401399
return None
402400

403401
if not selected_tests:
404-
print("No tests selected.")
402+
if non_interactive and len(tests) > 1:
403+
print("Error: Multiple evaluation tests found in --yes (non-interactive) mode.")
404+
print(" Please pass --evaluator or --entry to disambiguate.")
405+
else:
406+
print("No test selected.")
407+
return None
408+
409+
# Enforce single-select at the helper level.
410+
if len(selected_tests) != 1:
411+
print("Error: Please select exactly one evaluation test.")
405412
return None
406413

407414
return selected_tests

0 commit comments

Comments
 (0)