Skip to content

Commit

Permalink
Add support for instance type gpu details in pipe common (#3343)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcibinan authored Aug 24, 2023
1 parent 1a5b769 commit 03c0374
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions workflows/pipe-common/pipeline/hpc/instance/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,47 @@
# limitations under the License.


class InstanceGpu:

def __init__(self, name, manufacturer, cores):
self.name = name
self.manufacturer = manufacturer
self.cores = cores

@staticmethod
def from_cp_response(instance_gpu):
return InstanceGpu(name=instance_gpu.get('name'),
manufacturer=instance_gpu.get('manufacturer'),
cores=int(instance_gpu.get('cores', 0)) or None)

def __eq__(self, other):
return self.__dict__ == other.__dict__

def __repr__(self):
return str(self.__dict__)


class Instance:

def __init__(self, name, price_type, cpu, gpu, mem):
def __init__(self, name, price_type, cpu, mem, gpu, gpu_device=None):
"""
Execution instance.
"""
self.name = name
self.price_type = price_type
self.cpu = cpu
self.gpu = gpu
self.mem = mem
self.gpu = gpu
self.gpu_device = gpu_device

@staticmethod
def from_cp_response(instance):
return Instance(name=instance['name'],
price_type=instance['termType'],
cpu=int(instance['vcpu']),
mem=int(instance['memory']),
gpu=int(instance['gpu']),
mem=int(instance['memory']))
gpu_device=InstanceGpu.from_cp_response(instance.get('gpuDevice', {})))

def __eq__(self, other):
return self.__dict__ == other.__dict__
Expand Down

0 comments on commit 03c0374

Please sign in to comment.