55
66from typing import Optional
77from .queries import gpus
8+ from .queries import pods as pod_queries
89from .graphql import run_graphql_query
9- from .mutations import pods
10+ from .mutations import pods as pod_mutations
1011
1112
1213def get_gpus () -> dict :
@@ -28,6 +29,13 @@ def get_gpu(gpu_id : str):
2829 cleaned_return = raw_return ["data" ]["gpuTypes" ][0 ]
2930 return cleaned_return
3031
32+ def get_pods () -> dict :
33+ '''
34+ Get all pods
35+ '''
36+ raw_return = run_graphql_query (pod_queries .QUERY_POD )
37+ cleaned_return = raw_return ["data" ]["myself" ]["pods" ]
38+ return cleaned_return
3139
3240def create_pod (name : str , image_name : str , gpu_type_id : str , cloud_type : str = "ALL" ,
3341 data_center_id : Optional [str ]= None , country_code :Optional [str ]= None ,
@@ -58,7 +66,7 @@ def create_pod(name : str, image_name : str, gpu_type_id : str, cloud_type : str
5866 '''
5967
6068 raw_response = run_graphql_query (
61- pods .generate_pod_deployment_mutation (
69+ pod_mutations .generate_pod_deployment_mutation (
6270 name , image_name , gpu_type_id , cloud_type , data_center_id , country_code , gpu_count ,
6371 volume_in_gb , container_disk_in_gb , min_vcpu_count , min_memory_in_gb , docker_args ,
6472 ports , volume_mount_path , env )
@@ -80,7 +88,7 @@ def stop_pod(pod_id: str):
8088 >>> runpod.stop_pod(pod_id)
8189 '''
8290 raw_response = run_graphql_query (
83- pods .generate_pod_stop_mutation (pod_id )
91+ pod_mutations .generate_pod_stop_mutation (pod_id )
8492 )
8593
8694 cleaned_response = raw_response ["data" ]["podStop" ]
@@ -101,7 +109,7 @@ def resume_pod(pod_id: str, gpu_count: int):
101109 >>> runpod.resume_pod(pod_id)
102110 '''
103111 raw_response = run_graphql_query (
104- pods .generate_pod_resume_mutation (pod_id , gpu_count )
112+ pod_mutations .generate_pod_resume_mutation (pod_id , gpu_count )
105113 )
106114
107115 cleaned_response = raw_response ["data" ]["podResume" ]
@@ -120,5 +128,5 @@ def terminate_pod(pod_id: str):
120128 >>> runpod.terminate_pod(pod_id)
121129 '''
122130 run_graphql_query (
123- pods .generate_pod_terminate_mutation (pod_id )
131+ pod_mutations .generate_pod_terminate_mutation (pod_id )
124132 )
0 commit comments