Skip to content

feat: Add CLI command and Python API to check provider availability #22

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

Merged

Conversation

codegen-sh[bot]
Copy link
Contributor

@codegen-sh codegen-sh bot commented Jun 4, 2025

🎯 Overview

Implements a comprehensive solution for checking provider availability and configuration status in Grainchain, addressing the need for users to easily see which sandbox providers are available and how to configure them.

✨ Features

CLI Command

  • grainchain providers - Shows all providers with availability status
  • --verbose - Detailed information including descriptions and setup instructions
  • --check <provider> - Check specific provider status
  • --available-only - Show only ready-to-use providers

Python API

  • get_providers_info() - Get status of all providers
  • get_available_providers() - List only available providers
  • check_provider(name) - Check specific provider
  • ProviderInfo dataclass for structured provider information

Provider Support

Supports all 5 providers with specific dependency and configuration checks:

  • Local: No dependencies or configuration needed
  • E2B: Requires E2B_API_KEY environment variable
  • Modal: Requires MODAL_TOKEN_ID and MODAL_TOKEN_SECRET
  • Daytona: Requires DAYTONA_API_KEY
  • Morph: Requires MORPH_API_KEY

🚀 Usage Examples

CLI Usage

# Basic provider status
grainchain providers

# Detailed information
grainchain providers --verbose

# Check specific provider
grainchain providers --check e2b

# Show only available providers
grainchain providers --available-only

Python API Usage

from grainchain import get_providers_info, get_available_providers, check_provider

# Get all provider information
providers = get_providers_info()

# Get only available providers
available = get_available_providers()

# Check specific provider
e2b_info = check_provider("e2b")
print(f"E2B available: {e2b_info.available}")

📁 Files Added/Modified

  • grainchain/core/providers_info.py - Core provider discovery functionality
  • grainchain/cli/main.py - Added providers CLI command
  • grainchain/__init__.py - Exposed public API functions
  • examples/provider_status_example.py - Usage examples
  • tests/test_providers_info.py - Comprehensive tests for provider discovery
  • tests/test_cli_providers.py - CLI command tests

🧪 Testing

  • ✅ 16/16 provider discovery tests passing
  • ✅ CLI functionality verified manually
  • ✅ Python API functions working correctly
  • ✅ All linting and formatting checks pass

🔧 Implementation Details

  • Lazy imports: Providers are only imported when checking dependencies to handle missing optional packages gracefully
  • Environment variable validation: Checks for required API keys and configuration
  • Helpful error messages: Provides clear setup instructions for missing dependencies
  • Structured data: Uses dataclasses for clean, typed provider information

Resolves CG-18638


💻 View my workAbout Codegen

- Add ProviderDiscovery class to check provider dependencies and configuration
- Add 'grainchain providers' CLI command with verbose, check, and available-only options
- Add Python API functions: get_providers_info(), get_available_providers(), check_provider()
- Include setup instructions for missing dependencies and configuration
- Add comprehensive tests and example usage
- Support for all 5 providers: local, e2b, modal, daytona, morph

Resolves CG-18638
@jayhack jayhack marked this pull request as ready for review June 4, 2025 03:11
@jayhack
Copy link
Contributor

jayhack commented Jun 4, 2025

@codegen can you add something to the README that explains this command, and update other relevant docs?

I'll update the README and relevant docs! 📝

💻 View my work

- Add new section in README explaining grainchain providers command
- Include CLI usage examples and Python API documentation
- Add provider requirements table with dependencies and env vars
- Update CLI commands section to include providers command
- Add provider availability check to BENCHMARKING.md prerequisites
- Update example files to mention checking provider availability
- Provide clear setup instructions for all 5 providers
Copy link
Contributor Author

codegen-sh bot commented Jun 4, 2025

📚 Documentation updated! I've added comprehensive documentation for the new grainchain providers command:

README.md Updates

  • New section: "🔍 Check Provider Availability" with CLI and Python API examples
  • Provider requirements table showing dependencies and environment variables for all 5 providers
  • Updated CLI commands section to include the providers command
  • Example output showing what users will see when running the command

BENCHMARKING.md Updates

  • Added prerequisite step to check provider availability before running benchmarks
  • Clear instructions on using grainchain providers --verbose to identify setup needs

Example Files Updates

  • Updated basic_usage.py and data_analysis.py with comments about checking provider availability
  • Helpful guidance on which providers work best for different use cases

The documentation now provides a complete guide for users to:

  1. 🔍 Check which providers are available
  2. 📋 See exactly what's needed to set up missing providers
  3. ⚡ Get started quickly with available providers
  4. 🎯 Choose the right provider for their use case

Users can now easily discover and configure sandbox providers before diving into Grainchain! 🚀

🔗 View Updated PR #22

💻 View my work • React 👍 or 👎

@jayhack
Copy link
Contributor

jayhack commented Jun 4, 2025

@codegen resolve the conflicts, you and another agent are fighting over it right now

I'll dive in and sort out those conflicts! 🤺

💻 View my work

…w Quick Start section

- Merged provider availability CLI documentation with new Quick Start structure
- Added provider availability check section to BENCHMARKING.md
- Preserved both new Quick Start examples and comprehensive provider documentation
- All conflicts resolved while maintaining both feature sets
@jayhack jayhack merged commit f2e3537 into main Jun 4, 2025
Copy link
Contributor Author

codegen-sh bot commented Jun 4, 2025

Conflicts resolved successfully! 🎯

I've successfully merged the changes and resolved all conflicts between the provider availability feature and the new Quick Start section that another agent added. Here's what was integrated:

🔧 What's Now Available:

CLI Command for Provider Availability

# Check all providers
grainchain providers

# Show detailed setup instructions  
grainchain providers --verbose

# Check specific provider
grainchain providers --check e2b

# Show only available providers
grainchain providers --available-only

Python API Functions

from grainchain import get_providers_info, get_available_providers, check_provider

# Get all provider information
providers = get_providers_info()

# Get only available providers  
available = get_available_providers()

# Check specific provider
e2b_info = check_provider("e2b")

📚 Documentation Updated:

  • README.md: Provider availability section integrated with new Quick Start flow
  • BENCHMARKING.md: Added provider check instructions before running benchmarks
  • Provider Requirements Table: Complete setup instructions for all 5 providers

🚀 Ready to Use:

The PR is now updated with all conflicts resolved. Users can immediately:

  1. Check which providers are available on their system
  2. Get specific setup instructions for missing providers
  3. See exactly which environment variables are needed
  4. Follow the integrated Quick Start guide

🔗 View Updated PR #22

The feature is fully functional and the documentation provides clear guidance on checking provider availability and configuring missing providers! 🎉

💻 View my work • React 👍 or 👎

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.

1 participant