Skip to content

clients.runpod #

runpod

To get started




import freeflowuniverse.crystallib.clients. runpod

mut client:= runpod.get()!

client...

example heroscript

!!runpod.configure
    secret: '...'
    host: 'localhost'
    port: 8888

RunPod API Example

This script demonstrates creating, stopping, starting, and terminating RunPod pods using the RunPod API. It creates both on-demand and spot pods.

Requirements

  • Environment variable RUNPOD_API_KEY set with your RunPod API key

How to Run

  • Find out our example in: examples/develop/runpod/runpod_example.vsh

Constants #

const version = '1.14.3'

fn get #

fn get(args_ ArgsGet) !&RunPod

fn heroscript_default #

fn heroscript_default() !string

heroscript_default returns the default heroscript configuration for RunPod

fn play #

fn play(args_ PlayArgs) !

fn switch #

fn switch(name string)

switch instance to be used for runpod

struct AddOperationArgs #

@[params]
struct AddOperationArgs {
pub:
	operation OperationType
	fields    []Field
	variables map[string]string
}

struct ArgsGet #

@[params]
struct ArgsGet {
pub mut:
	name string
}

///////FACTORY

struct BuildQueryArgs #

@[params]
struct BuildQueryArgs {
pub:
	variables map[string]json2.Any
}

struct EnvironmentVariableInput #

struct EnvironmentVariableInput {
pub mut:
	key   string
	value string
}

struct Machine #

struct Machine {
pub:
	pod_host_id string @[json: 'podHostId']
}

Represents the nested machine structure in the response

struct NewFieldArgs #

@[params]
struct NewFieldArgs {
pub:
	name       string
	arguments  map[string]string
	sub_fields []Field
}

struct PlayArgs #

@[params]
struct PlayArgs {
pub mut:
	heroscript string // if filled in then plbook will be made out of it
	plbook     ?playbook.PlayBook
	reset      bool
}

struct PodBidResumeInput #

@[params]
struct PodBidResumeInput {
pub mut:
	pod_id      string @[json: 'podId'; required]
	gpu_count   int    @[json: 'gpuCount']
	bid_per_gpu f32    @[json: 'bidPerGpu']
}

fn (PodBidResumeInput) json_str #

fn (p PodBidResumeInput) json_str() string

struct PodFilter #

@[params]
struct PodFilter {
pub:
	pod_id string @[json: 'podId'; required]
}

struct PodFindAndDeployOnDemandRequest #

@[params]
struct PodFindAndDeployOnDemandRequest {
pub mut:
	cloud_type           string                     @[json: 'cloudType']
	gpu_count            int                        @[json: 'gpuCount']
	volume_in_gb         int                        @[json: 'volumeInGb']
	container_disk_in_gb int                        @[json: 'containerDiskInGb']
	min_vcpu_count       int                        @[json: 'minVcpuCount']
	min_memory_in_gb     int                        @[json: 'minMemoryInGb']
	gpu_type_id          string                     @[json: 'gpuTypeId']
	name                 string                     @[json: 'name']
	image_name           string                     @[json: 'imageName']
	docker_args          string                     @[json: 'dockerArgs']
	ports                string                     @[json: 'ports']
	volume_mount_path    string                     @[json: 'volumeMountPath']
	env                  []EnvironmentVariableInput @[json: 'env']
}

Input structure for the mutation

fn (PodFindAndDeployOnDemandRequest) json_str #

fn (p PodFindAndDeployOnDemandRequest) json_str() string

struct PodRentInterruptableInput #

@[params]
struct PodRentInterruptableInput {
pub mut:
	port                  int                        @[json: 'port']
	network_volume_id     string                     @[json: 'networkVolumeId'; omitempty]
	start_jupyter         bool                       @[json: 'startJupyter']
	start_ssh             bool                       @[json: 'startSsh']
	bid_per_gpu           f32                        @[json: 'bidPerGpu']
	cloud_type            string                     @[json: 'cloudType']
	container_disk_in_gb  int                        @[json: 'containerDiskInGb']
	country_code          string                     @[json: 'countryCode'; omitempty]
	docker_args           string                     @[json: 'dockerArgs'; omitempty]
	env                   []EnvironmentVariableInput @[json: 'env']
	gpu_count             int                        @[json: 'gpuCount']
	gpu_type_id           string                     @[json: 'gpuTypeId'; omitempty]
	image_name            string                     @[json: 'imageName'; omitempty]
	min_disk              int                        @[json: 'minDisk']
	min_download          int                        @[json: 'minDownload']
	min_memory_in_gb      int                        @[json: 'minMemoryInGb']
	min_upload            int                        @[json: 'minUpload']
	min_vcpu_count        int                        @[json: 'minVcpuCount']
	name                  string                     @[json: 'name'; omitempty]
	ports                 string                     @[json: 'ports'; omitempty]
	stop_after            string                     @[json: 'stopAfter'; omitempty]
	support_public_ip     bool                       @[json: 'supportPublicIp']
	template_id           string                     @[json: 'templateId'; omitempty]
	terminate_after       string                     @[json: 'terminateAfter'; omitempty]
	volume_in_gb          int                        @[json: 'volumeInGb']
	volume_key            string                     @[json: 'volumeKey'; omitempty]
	volume_mount_path     string                     @[json: 'volumeMountPath'; omitempty]
	data_center_id        string                     @[json: 'dataCenterId'; omitempty]
	cuda_version          string                     @[json: 'cudeVersion'; omitempty]
	allowed_cuda_versions []string                   @[json: 'allowedCudaVersions']
}

fn (PodRentInterruptableInput) json_str #

fn (p PodRentInterruptableInput) json_str() string

struct PodResult #

struct PodResult {
pub:
	id             string   @[json: 'id']
	image_name     string   @[json: 'imageName']
	env            []string @[json: 'env']
	machine_id     int      @[json: 'machineId']
	machine        Machine  @[json: 'machine']
	desired_status string   @[json: 'desiredStatus']
}

Response structure for the mutation

struct PodResumeInput #

@[params]
struct PodResumeInput {
pub mut:
	pod_id       string @[json: 'podId'; required]
	gpu_count    int    @[json: 'gpuCount']
	sync_machine bool   @[json: 'syncMachine']
	compute_type string @[json: 'computeType'; omitempty]
}

fn (PodResumeInput) json_str #

fn (p PodResumeInput) json_str() string

struct PodStopInput #

@[params]
struct PodStopInput {
pub:
	pod_id            string @[json: 'podId']
	increment_version bool   @[json: 'incrementVersion']
}

fn (PodStopInput) json_str #

fn (p PodStopInput) json_str() string

struct PodTerminateInput #

@[params]
struct PodTerminateInput {
pub:
	pod_id string @[json: 'podId']
}

struct RunPod #

@[heap]
struct RunPod {
pub mut:
	name     string = 'default'
	api_key  string
	base_url string = 'https://api.runpod.io/'
}

RunPod represents a RunPod client instance

fn (RunPod) create_on_demand_pod #

fn (mut rp RunPod) create_on_demand_pod(input PodFindAndDeployOnDemandRequest) !PodResult

Create On-Demand Pod

fn (RunPod) create_spot_pod #

fn (mut rp RunPod) create_spot_pod(input PodRentInterruptableInput) !PodResult

Create Spot Pod

fn (RunPod) get_pod #

fn (mut rp RunPod) get_pod(input PodFilter) !PodResult

fn (RunPod) start_on_demand_pod #

fn (mut rp RunPod) start_on_demand_pod(input PodResumeInput) !PodResult

Start On-Demand Pod

fn (RunPod) start_spot_pod #

fn (mut rp RunPod) start_spot_pod(input PodBidResumeInput) !PodResult

Start Spot Pod

fn (RunPod) stop_pod #

fn (mut rp RunPod) stop_pod(input PodStopInput) !PodResult

Stop Pod

fn (RunPod) terminate_pod #

fn (mut rp RunPod) terminate_pod(input PodTerminateInput) !