Skip to content

wraped in try except #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ved1beta
Copy link

fixes #34
i tried wrapping everything in try except for abort error handling if there is any better approach you think i should take please let me know : )

@JannikSt
Copy link
Member

Thank you for your contribution! :)
Can you rebase this PR off main and re-run formatting locally? I made some formatting adjustments as the line length of 88 was too short for a good dev-exp.

@JannikSt JannikSt requested a review from Copilot June 29, 2025 10:10
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves error handling for interactive prompts by wrapping various user input sections in try/except blocks to catch cancellation events.

  • Added a top-level try block around the pod creation logic for API error handling.
  • Introduced try/except blocks for GPU selection, provider selection, configuration selection, pod name, disk size, vCPU, memory, image, and team ID prompts.
  • Wrapped the final pod creation confirmation to handle cancellation gracefully.

Comment on lines +347 to +371
try:
# Show available GPU types
console.print("\n[bold]Available GPU Types:[/bold]")
gpu_types = sorted(
[
gpu_type
for gpu_type, gpus in availabilities.items()
if len(gpus) > 0
]
)
for idx, gpu_type_option in enumerate(gpu_types, 1):
console.print(f"{idx}. {gpu_type_option}")

gpu_type_idx = typer.prompt("Select GPU type number", type=int, default=1)
if gpu_type_idx < 1 or gpu_type_idx > len(gpu_types):
console.print("[red]Invalid GPU type selection[/red]")
raise typer.Exit(1)
gpu_type = gpu_types[gpu_type_idx - 1]
gpu_type_idx = typer.prompt(
"Select GPU type number", type=int, default=1
)
if gpu_type_idx < 1 or gpu_type_idx > len(gpu_types):
console.print("[red]Invalid GPU type selection[/red]")
raise typer.Exit(1)
gpu_type = gpu_types[gpu_type_idx - 1]
except (KeyboardInterrupt, typer.Abort):
console.print(
"\n[yellow]GPU type selection cancelled by user[/yellow]"
)
raise typer.Exit(0)
Copy link
Preview

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple similar try/except blocks for handling interactive prompt cancellations are used throughout the function. Consider extracting a helper function for prompt interactions and cancellation to reduce duplicate code and improve maintainability.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aborts currently cause ugly exceptions
2 participants