| 
 | 1 | +import app from "../../runpod.app.mjs";  | 
 | 2 | +import mutations from "../../common/mutations.mjs";  | 
 | 3 | +import utils from "../../common/utils.mjs";  | 
 | 4 | + | 
 | 5 | +export default {  | 
 | 6 | +  key: "runpod-create-pod",  | 
 | 7 | +  name: "Create Pod",  | 
 | 8 | +  description: "Creates a new pod with the specified parameters. [See the documentation](https://docs.runpod.io/sdks/graphql/manage-pods#create-spot-pod)",  | 
 | 9 | +  version: "0.0.1",  | 
 | 10 | +  type: "action",  | 
 | 11 | +  props: {  | 
 | 12 | +    app,  | 
 | 13 | +    bidPerGpu: {  | 
 | 14 | +      propDefinition: [  | 
 | 15 | +        app,  | 
 | 16 | +        "bidPerGpu",  | 
 | 17 | +      ],  | 
 | 18 | +    },  | 
 | 19 | +    cloudType: {  | 
 | 20 | +      type: "string",  | 
 | 21 | +      label: "Cloud Type",  | 
 | 22 | +      description: "The type of cloud to use for the pod.",  | 
 | 23 | +      options: [  | 
 | 24 | +        "SECURE",  | 
 | 25 | +        "COMMUNITY",  | 
 | 26 | +        "ALL",  | 
 | 27 | +      ],  | 
 | 28 | +    },  | 
 | 29 | +    gpuCount: {  | 
 | 30 | +      propDefinition: [  | 
 | 31 | +        app,  | 
 | 32 | +        "gpuCount",  | 
 | 33 | +      ],  | 
 | 34 | +    },  | 
 | 35 | +    volumeInGb: {  | 
 | 36 | +      type: "integer",  | 
 | 37 | +      label: "Volume In GB",  | 
 | 38 | +      description: "The size of the volume in GB.",  | 
 | 39 | +    },  | 
 | 40 | +    containerDiskInGb: {  | 
 | 41 | +      type: "integer",  | 
 | 42 | +      label: "Container Disk In GB",  | 
 | 43 | +      description: "The size of the container disk in GB.",  | 
 | 44 | +    },  | 
 | 45 | +    minVcpuCount: {  | 
 | 46 | +      type: "integer",  | 
 | 47 | +      label: "Minimum VCPU Count",  | 
 | 48 | +      description: "The minimum number of VCPUs.",  | 
 | 49 | +    },  | 
 | 50 | +    minMemoryInGb: {  | 
 | 51 | +      type: "integer",  | 
 | 52 | +      label: "Minimum Memory In GB",  | 
 | 53 | +      description: "The minimum memory size in GB.",  | 
 | 54 | +    },  | 
 | 55 | +    gpuTypeId: {  | 
 | 56 | +      propDefinition: [  | 
 | 57 | +        app,  | 
 | 58 | +        "gpuTypeId",  | 
 | 59 | +      ],  | 
 | 60 | +    },  | 
 | 61 | +    name: {  | 
 | 62 | +      type: "string",  | 
 | 63 | +      label: "Name",  | 
 | 64 | +      description: "The name of the pod.",  | 
 | 65 | +    },  | 
 | 66 | +    imageName: {  | 
 | 67 | +      type: "string",  | 
 | 68 | +      label: "Image Name",  | 
 | 69 | +      description: "The name of the image to use for the pod.",  | 
 | 70 | +    },  | 
 | 71 | +    ports: {  | 
 | 72 | +      type: "string",  | 
 | 73 | +      label: "Ports",  | 
 | 74 | +      description: "The ports to use for the pod.",  | 
 | 75 | +    },  | 
 | 76 | +    volumeMountPath: {  | 
 | 77 | +      type: "string",  | 
 | 78 | +      label: "Volume Mount Path",  | 
 | 79 | +      description: "The path where the volume will be mounted.",  | 
 | 80 | +    },  | 
 | 81 | +    env: {  | 
 | 82 | +      type: "string[]",  | 
 | 83 | +      label: "Environment Variables",  | 
 | 84 | +      description: "The environment variables to set for the pod. Each row should be formated with JSON string like this `{\"key\": \"ENV_NAME\", \"value\": \"ENV_VALUE\"}`",  | 
 | 85 | +      optional: true,  | 
 | 86 | +    },  | 
 | 87 | +    dockerArgs: {  | 
 | 88 | +      type: "string",  | 
 | 89 | +      label: "Docker Args",  | 
 | 90 | +      description: "The arguments to pass to the docker command.",  | 
 | 91 | +      optional: true,  | 
 | 92 | +    },  | 
 | 93 | +    startJupyter: {  | 
 | 94 | +      type: "boolean",  | 
 | 95 | +      label: "Start Jupyter",  | 
 | 96 | +      description: "Whether to start Jupyter for the pod.",  | 
 | 97 | +      optional: true,  | 
 | 98 | +    },  | 
 | 99 | +    startSsh: {  | 
 | 100 | +      type: "boolean",  | 
 | 101 | +      label: "Start SSH",  | 
 | 102 | +      description: "Whether to start SSH for the pod.",  | 
 | 103 | +      optional: true,  | 
 | 104 | +    },  | 
 | 105 | +    stopAfter: {  | 
 | 106 | +      type: "string",  | 
 | 107 | +      label: "Stop After",  | 
 | 108 | +      description: "The duration after which the pod will be stopped.",  | 
 | 109 | +      optional: true,  | 
 | 110 | +    },  | 
 | 111 | +    supportPublicIp: {  | 
 | 112 | +      type: "boolean",  | 
 | 113 | +      label: "Support Public IP",  | 
 | 114 | +      description: "Whether to support public IP for the pod.",  | 
 | 115 | +      optional: true,  | 
 | 116 | +    },  | 
 | 117 | +    templateId: {  | 
 | 118 | +      type: "string",  | 
 | 119 | +      label: "Template ID",  | 
 | 120 | +      description: "The ID of the template to use for the pod.",  | 
 | 121 | +      optional: true,  | 
 | 122 | +    },  | 
 | 123 | +  },  | 
 | 124 | +  methods: {  | 
 | 125 | +    createPod(variables) {  | 
 | 126 | +      return this.app.makeRequest({  | 
 | 127 | +        query: mutations.createPod,  | 
 | 128 | +        variables,  | 
 | 129 | +      });  | 
 | 130 | +    },  | 
 | 131 | +  },  | 
 | 132 | +  async run({ $ }) {  | 
 | 133 | +    const {  | 
 | 134 | +      createPod,  | 
 | 135 | +      bidPerGpu,  | 
 | 136 | +      cloudType,  | 
 | 137 | +      gpuCount,  | 
 | 138 | +      volumeInGb,  | 
 | 139 | +      containerDiskInGb,  | 
 | 140 | +      minVcpuCount,  | 
 | 141 | +      minMemoryInGb,  | 
 | 142 | +      gpuTypeId,  | 
 | 143 | +      name,  | 
 | 144 | +      imageName,  | 
 | 145 | +      ports,  | 
 | 146 | +      volumeMountPath,  | 
 | 147 | +      env,  | 
 | 148 | +      dockerArgs,  | 
 | 149 | +      startJupyter,  | 
 | 150 | +      startSsh,  | 
 | 151 | +      stopAfter,  | 
 | 152 | +      supportPublicIp,  | 
 | 153 | +      templateId,  | 
 | 154 | +    } = this;  | 
 | 155 | + | 
 | 156 | +    const response = await createPod({  | 
 | 157 | +      input: utils.cleanInput({  | 
 | 158 | +        bidPerGpu,  | 
 | 159 | +        cloudType,  | 
 | 160 | +        gpuCount,  | 
 | 161 | +        volumeInGb,  | 
 | 162 | +        containerDiskInGb,  | 
 | 163 | +        minVcpuCount,  | 
 | 164 | +        minMemoryInGb,  | 
 | 165 | +        gpuTypeId,  | 
 | 166 | +        name,  | 
 | 167 | +        imageName,  | 
 | 168 | +        ports,  | 
 | 169 | +        volumeMountPath,  | 
 | 170 | +        env: utils.parseArray(env),  | 
 | 171 | +        dockerArgs,  | 
 | 172 | +        startJupyter,  | 
 | 173 | +        startSsh,  | 
 | 174 | +        stopAfter,  | 
 | 175 | +        supportPublicIp,  | 
 | 176 | +        templateId,  | 
 | 177 | +      }),  | 
 | 178 | +    });  | 
 | 179 | +    $.export("$summary", `Successfully created a new pod with ID \`${response.id}\`.`);  | 
 | 180 | +    return response;  | 
 | 181 | +  },  | 
 | 182 | +};  | 
0 commit comments