-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] runpod #14353
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
base: master
Are you sure you want to change the base?
[Components] runpod #14353
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,182 @@ | ||||||||||||||||||
| import app from "../../runpod.app.mjs"; | ||||||||||||||||||
| import mutations from "../../common/mutations.mjs"; | ||||||||||||||||||
| import utils from "../../common/utils.mjs"; | ||||||||||||||||||
|
|
||||||||||||||||||
| export default { | ||||||||||||||||||
| key: "runpod-create-pod", | ||||||||||||||||||
| name: "Create Pod", | ||||||||||||||||||
| description: "Creates a new pod with the specified parameters. [See the documentation](https://docs.runpod.io/sdks/graphql/manage-pods#create-spot-pod)", | ||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||
| type: "action", | ||||||||||||||||||
| props: { | ||||||||||||||||||
| app, | ||||||||||||||||||
| bidPerGpu: { | ||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||
| app, | ||||||||||||||||||
| "bidPerGpu", | ||||||||||||||||||
| ], | ||||||||||||||||||
| }, | ||||||||||||||||||
| cloudType: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Cloud Type", | ||||||||||||||||||
| description: "The type of cloud to use for the pod.", | ||||||||||||||||||
| options: [ | ||||||||||||||||||
| "SECURE", | ||||||||||||||||||
| "COMMUNITY", | ||||||||||||||||||
| "ALL", | ||||||||||||||||||
| ], | ||||||||||||||||||
| }, | ||||||||||||||||||
| gpuCount: { | ||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||
| app, | ||||||||||||||||||
| "gpuCount", | ||||||||||||||||||
| ], | ||||||||||||||||||
| }, | ||||||||||||||||||
| volumeInGb: { | ||||||||||||||||||
| type: "integer", | ||||||||||||||||||
| label: "Volume In GB", | ||||||||||||||||||
| description: "The size of the volume in GB.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| containerDiskInGb: { | ||||||||||||||||||
| type: "integer", | ||||||||||||||||||
| label: "Container Disk In GB", | ||||||||||||||||||
| description: "The size of the container disk in GB.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| minVcpuCount: { | ||||||||||||||||||
| type: "integer", | ||||||||||||||||||
| label: "Minimum VCPU Count", | ||||||||||||||||||
| description: "The minimum number of VCPUs.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| minMemoryInGb: { | ||||||||||||||||||
| type: "integer", | ||||||||||||||||||
| label: "Minimum Memory In GB", | ||||||||||||||||||
| description: "The minimum memory size in GB.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| gpuTypeId: { | ||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||
| app, | ||||||||||||||||||
| "gpuTypeId", | ||||||||||||||||||
| ], | ||||||||||||||||||
| }, | ||||||||||||||||||
| name: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Name", | ||||||||||||||||||
| description: "The name of the pod.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| imageName: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Image Name", | ||||||||||||||||||
| description: "The name of the image to use for the pod.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| ports: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Ports", | ||||||||||||||||||
| description: "The ports to use for the pod.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| volumeMountPath: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Volume Mount Path", | ||||||||||||||||||
| description: "The path where the volume will be mounted.", | ||||||||||||||||||
| }, | ||||||||||||||||||
| env: { | ||||||||||||||||||
| type: "string[]", | ||||||||||||||||||
| label: "Environment Variables", | ||||||||||||||||||
| 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\"}`", | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo in description: 'formated' should be 'formatted' There's a typographical error in the description of the Environment Variables property. Please correct 'formated' to 'formatted'. Apply this diff to fix the typo: - 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\"}`",
+ description: "The environment variables to set for the pod. Each row should be formatted with a JSON string like this `{\"key\": \"ENV_NAME\", \"value\": \"ENV_VALUE\"}`",📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
|
Comment on lines
+81
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve handling of 'Environment Variables' property to avoid parsing JSON strings Currently, the Environment Variables property expects users to input JSON-formatted strings, which can be error-prone. Consider changing the property to accept key-value pairs directly, improving usability and reducing the likelihood of input errors. Apply this refactor to change the Environment Variables property: - type: "string[]",
- label: "Environment Variables",
- 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\"}`",
- optional: true,
+ type: "object[]",
+ label: "Environment Variables",
+ description: "The environment variables to set for the pod. Each item should be an object with 'key' and 'value' properties.",
+ optional: true,Then, in your - env: utils.parseArray(env),
+ env,
|
||||||||||||||||||
| dockerArgs: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Docker Args", | ||||||||||||||||||
| description: "The arguments to pass to the docker command.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| startJupyter: { | ||||||||||||||||||
| type: "boolean", | ||||||||||||||||||
| label: "Start Jupyter", | ||||||||||||||||||
| description: "Whether to start Jupyter for the pod.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| startSsh: { | ||||||||||||||||||
| type: "boolean", | ||||||||||||||||||
| label: "Start SSH", | ||||||||||||||||||
| description: "Whether to start SSH for the pod.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| stopAfter: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Stop After", | ||||||||||||||||||
| description: "The duration after which the pod will be stopped.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
|
Comment on lines
+106
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clarify the expected format for 'Stop After' property The Stop After property is of type Apply this diff to improve the description: - description: "The duration after which the pod will be stopped.",
+ description: "The duration in seconds after which the pod will be stopped (e.g., '3600' for 1 hour).",📝 Committable suggestion
Suggested change
|
||||||||||||||||||
| }, | ||||||||||||||||||
| supportPublicIp: { | ||||||||||||||||||
| type: "boolean", | ||||||||||||||||||
| label: "Support Public IP", | ||||||||||||||||||
| description: "Whether to support public IP for the pod.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| templateId: { | ||||||||||||||||||
| type: "string", | ||||||||||||||||||
| label: "Template ID", | ||||||||||||||||||
| description: "The ID of the template to use for the pod.", | ||||||||||||||||||
| optional: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| methods: { | ||||||||||||||||||
| createPod(variables) { | ||||||||||||||||||
| return this.app.makeRequest({ | ||||||||||||||||||
| query: mutations.createPod, | ||||||||||||||||||
| variables, | ||||||||||||||||||
| }); | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||
| const { | ||||||||||||||||||
| createPod, | ||||||||||||||||||
| bidPerGpu, | ||||||||||||||||||
| cloudType, | ||||||||||||||||||
| gpuCount, | ||||||||||||||||||
| volumeInGb, | ||||||||||||||||||
| containerDiskInGb, | ||||||||||||||||||
| minVcpuCount, | ||||||||||||||||||
| minMemoryInGb, | ||||||||||||||||||
| gpuTypeId, | ||||||||||||||||||
| name, | ||||||||||||||||||
| imageName, | ||||||||||||||||||
| ports, | ||||||||||||||||||
| volumeMountPath, | ||||||||||||||||||
| env, | ||||||||||||||||||
| dockerArgs, | ||||||||||||||||||
| startJupyter, | ||||||||||||||||||
| startSsh, | ||||||||||||||||||
| stopAfter, | ||||||||||||||||||
| supportPublicIp, | ||||||||||||||||||
| templateId, | ||||||||||||||||||
| } = this; | ||||||||||||||||||
|
|
||||||||||||||||||
| const response = await createPod({ | ||||||||||||||||||
| input: utils.cleanInput({ | ||||||||||||||||||
| bidPerGpu, | ||||||||||||||||||
| cloudType, | ||||||||||||||||||
| gpuCount, | ||||||||||||||||||
| volumeInGb, | ||||||||||||||||||
| containerDiskInGb, | ||||||||||||||||||
| minVcpuCount, | ||||||||||||||||||
| minMemoryInGb, | ||||||||||||||||||
| gpuTypeId, | ||||||||||||||||||
| name, | ||||||||||||||||||
| imageName, | ||||||||||||||||||
| ports, | ||||||||||||||||||
| volumeMountPath, | ||||||||||||||||||
| env: utils.parseArray(env), | ||||||||||||||||||
| dockerArgs, | ||||||||||||||||||
| startJupyter, | ||||||||||||||||||
| startSsh, | ||||||||||||||||||
| stopAfter, | ||||||||||||||||||
| supportPublicIp, | ||||||||||||||||||
| templateId, | ||||||||||||||||||
| }), | ||||||||||||||||||
| }); | ||||||||||||||||||
| $.export("$summary", `Successfully created a new pod with ID \`${response.id}\`.`); | ||||||||||||||||||
| return response; | ||||||||||||||||||
| }, | ||||||||||||||||||
| }; | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import app from "../../runpod.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import queries from "../../common/queries.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "runpod-get-pod", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Get Pod Details", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Get details of a pod by ID. [See the documentation](https://docs.runpod.io/sdks/graphql/manage-pods#get-pod-by-id).", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| podId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The ID of the pod to get details for.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "podId", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| methods: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getPodDetails(variables) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return this.app.makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| query: queries.getPod, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variables, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getPodDetails, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| podId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = this; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await getPodDetails({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| podId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", `Succesfully retrieved details for pod with ID \`${response.id}\`.`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM: The run function is well-structured and follows best practices. The async function is implemented correctly, using destructuring for improved readability. The API call and summary export provide the necessary functionality and user feedback. There's a typo in the summary message. Please apply the following fix: - $.export("$summary", `Succesfully retrieved details for pod with ID \`${response.id}\`.`);
+ $.export("$summary", `Successfully retrieved details for pod with ID \`${response.id}\`.`);📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import app from "../../runpod.app.mjs"; | ||
| import mutations from "../../common/mutations.mjs"; | ||
|
|
||
| export default { | ||
| key: "runpod-start-pod", | ||
| name: "Start Pod", | ||
| description: "Starts a stopped pod, making it available for use. [See the documentation](https://docs.runpod.io/sdks/graphql/manage-pods#start-spot-pod)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| podId: { | ||
| propDefinition: [ | ||
| app, | ||
| "podId", | ||
| ], | ||
| }, | ||
| gpuCount: { | ||
| propDefinition: [ | ||
| app, | ||
| "gpuCount", | ||
| ], | ||
| }, | ||
| bidPerGpu: { | ||
| propDefinition: [ | ||
| app, | ||
| "bidPerGpu", | ||
| ], | ||
| }, | ||
| }, | ||
| methods: { | ||
| startPod(variables) { | ||
| return this.app.makeRequest({ | ||
| query: mutations.startPod, | ||
| variables, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| startPod, | ||
| podId, | ||
| gpuCount, | ||
| bidPerGpu, | ||
| } = this; | ||
|
|
||
| const response = await startPod({ | ||
| input: { | ||
| podId, | ||
| gpuCount, | ||
| bidPerGpu: parseFloat(bidPerGpu), | ||
| }, | ||
| }); | ||
|
|
||
|
Comment on lines
+47
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for the API request The You could wrap the API call in a try-catch block: async run({ $ }) {
const {
startPod,
podId,
gpuCount,
bidPerGpu,
} = this;
+ try {
const response = await startPod({
input: {
podId,
gpuCount,
bidPerGpu: parseFloat(bidPerGpu),
},
});
$.export("$summary", `Successfully started pod with ID \`${response.id}\`.`);
return response;
+ } catch (error) {
+ $.export("$summary", "Failed to start pod.");
+ throw new Error(`Error starting pod: ${error.message}`);
+ }
},
|
||
| $.export("$summary", `Sucessfully started pod with ID \`${response.id}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import app from "../../runpod.app.mjs"; | ||
| import mutations from "../../common/mutations.mjs"; | ||
|
|
||
| export default { | ||
| key: "runpod-stop-pod", | ||
| name: "Stop Pod", | ||
| description: "Stops a running pod, freeing up resources and preventing further charges. [See the documentation](https://docs.runpod.io/sdks/graphql/manage-pods#stop-pods)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| podId: { | ||
| description: "The ID of the pod to stop.", | ||
| propDefinition: [ | ||
| app, | ||
| "podId", | ||
| ], | ||
| }, | ||
| incrementVersion: { | ||
| type: "boolean", | ||
| label: "Increment Version", | ||
| description: "Whether to increment the pod version after stopping it.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| stopPod(variables) { | ||
| return this.app.makeRequest({ | ||
| query: mutations.stopPod, | ||
| variables, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| stopPod, | ||
| podId, | ||
| incrementVersion, | ||
| } = this; | ||
|
|
||
| const response = await stopPod({ | ||
| input: { | ||
| podId, | ||
| incrementVersion, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Succesfully stopped pod with ID \`${response.id}\`.`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { gql } from "graphql-request"; | ||
|
|
||
| export default { | ||
| createPod: gql` | ||
| mutation createPod($input: PodRentInterruptableInput!) { | ||
| podRentInterruptable(input: $input) { | ||
| id | ||
| } | ||
| } | ||
| `, | ||
| startPod: gql` | ||
| mutation startPod($input: PodBidResumeInput!) { | ||
| podResume(input: $input) { | ||
| id | ||
| } | ||
| } | ||
| `, | ||
| stopPod: gql` | ||
| mutation stopPod($input: PodStopInput!) { | ||
| podStop(input: $input) { | ||
| id | ||
| } | ||
| } | ||
| `, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify the expected format for 'Ports' property
The Ports property is defined as a
string, but it's unclear how users should input the port values. Should it be a single port number, a comma-separated list, or another format? Please provide clear guidance in the description to help users enter the correct values.Apply this diff to update the description:
📝 Committable suggestion