Skip to content

Commit 7582e7d

Browse files
committed
check FIREWORKS_API_KEY in upload flow
1 parent cf55313 commit 7582e7d

File tree

1 file changed

+58
-17
lines changed

1 file changed

+58
-17
lines changed

eval_protocol/cli_commands/upload.py

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from typing import Any, Callable, Iterable, Optional
1313

1414
import pytest
15+
from eval_protocol.auth import get_fireworks_account_id, get_fireworks_api_key
16+
from eval_protocol.platform_api import create_or_update_fireworks_secret
1517

1618
from eval_protocol.evaluation import create_evaluation
1719

@@ -343,28 +345,45 @@ def _prompt_select_interactive(tests: list[DiscoveredTest]) -> list[DiscoveredTe
343345
else:
344346
return []
345347

346-
# Create choices with nice formatting
347-
choices = []
348-
for idx, test in enumerate(tests, 1):
349-
choice_text = _format_test_choice(test, idx)
350-
choices.append({"name": choice_text, "value": idx - 1, "checked": False})
348+
# Enter-only selection UX with optional multi-select via repeat
349+
remaining_indices = list(range(len(tests)))
350+
selected_indices: list[int] = []
351351

352352
print("\n")
353-
print("💡 Tip: Use ↑/↓ arrows to navigate, SPACE to select/deselect, ENTER when done")
354-
print(" You can select multiple tests!\n")
355-
selected_indices = questionary.checkbox(
356-
"Select evaluation tests to upload:",
357-
choices=choices,
358-
style=custom_style,
359-
).ask()
360-
361-
if selected_indices is None: # User pressed Ctrl+C
362-
print("\nUpload cancelled.")
363-
return []
353+
print("Tip: Use ↑/↓ arrows to navigate and press ENTER to select.")
354+
print(" After selecting one, you can choose to add more.\n")
355+
356+
while remaining_indices:
357+
# Build choices from remaining
358+
choices = []
359+
for idx, test_idx in enumerate(remaining_indices, 1):
360+
t = tests[test_idx]
361+
choice_text = _format_test_choice(t, idx)
362+
choices.append({"name": choice_text, "value": test_idx})
363+
364+
selected = questionary.select(
365+
"Select an evaluation test to upload:", choices=choices, style=custom_style
366+
).ask()
367+
368+
if selected is None: # Ctrl+C
369+
print("\nUpload cancelled.")
370+
return []
371+
372+
if isinstance(selected, int):
373+
selected_indices.append(selected)
374+
# Remove from remaining
375+
if selected in remaining_indices:
376+
remaining_indices.remove(selected)
377+
378+
# Ask whether to add another (ENTER to finish)
379+
add_more = questionary.confirm("Add another?", default=False, style=custom_style).ask()
380+
if not add_more:
381+
break
382+
else:
383+
break
364384

365385
if not selected_indices:
366386
print("\n⚠️ No tests were selected.")
367-
print(" Remember: Use SPACE bar to select tests, then press ENTER to confirm.")
368387
return []
369388

370389
print(f"\n✓ Selected {len(selected_indices)} test(s)")
@@ -474,6 +493,28 @@ def upload_command(args: argparse.Namespace) -> int:
474493
description = getattr(args, "description", None)
475494
force = bool(getattr(args, "force", False))
476495

496+
# Ensure FIREWORKS_API_KEY is available to the remote by storing it as a Fireworks secret
497+
try:
498+
fw_account_id = get_fireworks_account_id()
499+
fw_api_key_value = get_fireworks_api_key()
500+
if fw_account_id and fw_api_key_value:
501+
print("Ensuring FIREWORKS_API_KEY is registered as a secret on Fireworks for rollout...")
502+
if create_or_update_fireworks_secret(
503+
account_id=fw_account_id,
504+
key_name="FIREWORKS_API_KEY",
505+
secret_value=fw_api_key_value,
506+
):
507+
print("✓ FIREWORKS_API_KEY secret created/updated on Fireworks.")
508+
else:
509+
print("Warning: Failed to create/update FIREWORKS_API_KEY secret on Fireworks.")
510+
else:
511+
if not fw_account_id:
512+
print("Warning: FIREWORKS_ACCOUNT_ID not found; cannot register FIREWORKS_API_KEY secret.")
513+
if not fw_api_key_value:
514+
print("Warning: FIREWORKS_API_KEY not found locally; cannot register secret.")
515+
except Exception as e:
516+
print(f"Warning: Skipped Fireworks secret registration due to error: {e}")
517+
477518
exit_code = 0
478519
for i, (code, file_name, qualname, source_file_path) in enumerate(selected_specs):
479520
# Use ts_mode to upload evaluator

0 commit comments

Comments
 (0)