feat: Add VastAI client
- Add a new VastAI client to the project. - This client allows users to search for and create GPU instances on VastAI. - It uses the VastAI API to interact with the platform. - Includes functionality for searching offers, getting top offers, and creating instances. Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com>
This commit is contained in:
24
examples/develop/vastai/vastai_example.vsh
Executable file
24
examples/develop/vastai/vastai_example.vsh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.clients.vastai
|
||||
import json
|
||||
import x.json2
|
||||
|
||||
// Create client with direct API key
|
||||
// This uses VASTAI_API_KEY from environment
|
||||
mut va := vastai.get()!
|
||||
|
||||
offers := va.search_offers()!
|
||||
println('offers: ${offers}')
|
||||
|
||||
top_offers := va.get_top_offers(5)!
|
||||
println('top offers: ${top_offers}')
|
||||
|
||||
create_instance_res := va.create_instance(
|
||||
id: top_offers[0].id
|
||||
config: vastai.CreateInstanceConfig{
|
||||
image: 'pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime'
|
||||
disk: 10
|
||||
}
|
||||
)!
|
||||
println('create instance res: ${create_instance_res}')
|
||||
Reference in New Issue
Block a user