How runai-professional-services/runapy works
Main Components
a. Client Layer:
• Central RunaiClient class as the main entry point
• Authentication handling (both API tokens and CLIv2 token support)
• Configuration management
• Retry mechanism
b. Controllers Layer:
• Resource-specific controllers (Projects, Workloads, Assets, etc.)
• Controller factories and implementations
• Error handling
c. Models Layer:
• Data models and schema validation (using Pydantic)
• Type definitions
d. External Integration:
• Run:ai REST API connection
• CLIv2 configuration integration
┌─────────────────────────────────────────────────────────┐
• Client Applications │
• ┬─────────────────────────────────┘
• ↓
┌─────────────────────────────────────────────────────────┐
• RunaiClient │
• ┬────────────────┬────────────────┬────┤
• Authentication │ Configuration │ Retry Logic │ │
• Management │ Management │ │ │
• ┴────────────────┴────────────────┘ │
• ↓ │
┌─────────────────────────────────────────────────────┐ │
• Controllers Layer │ │
• ┬───────────┬────────────┬──────────────┐ │ │
• Projects │ Workloads │ Assets │ Users/Roles │ │ │
• Controller│ Controller│ Controller │ Controller │ │ │
• ┴───────────┴────────────┴──────────────┘ │ │
• ↓ │ │
┌─────────────────────────────────────────────────────┤ │
• Models Layer │ │
• ┤ │
• Pydantic Models & Validation │ │
• ┘ │
• ↓ │
┌─────────────────────────────────────────────────────┐ │
• Error Handling Layer │←─┘
• ┬─────────────────────────────┘
• ↓
┌─────────────────────────────────────────────────────┐
• Run:ai REST API │
• ┘
Important Details to Highlight
• Hierarchical relationship between controllers (e.g., Assets controller having sub-controllers for PVC, S3, Git, etc.)
• Authentication flow, including both standard API token and CLIv2 token paths
• Retry mechanism's integration with the error handling layer
• Validation flow from controllers through models
Implementation Notes
• The single entry point nature of the RunaiClient class
• The controller-based architecture for resource management
• The separation of concerns between authentication, business logic, and data validation
• The error handling and retry mechanism's pervasive nature
• The integration points with the Run:ai platform
This system design should provide a clear understanding of the SDK's architecture while maintaining enough detail to be useful for development and maintenance purposes.