Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Add GPUs as resources in the Aurora CLI.
  • Loading branch information
fcuny authored and DavidMcLaughlin committed Feb 21, 2018
1 parent c52137e commit d95fc2ff92ddb7eb2c4054c311fcfe9cc24319d2
Showing 2 changed files with 9 additions and 3 deletions.
@@ -29,6 +29,7 @@ class ResourceType(Enum):
RAM_MB = ('ramMb', 'RAM', ' MB', int, 2)
DISK_MB = ('diskMb', 'Disk', ' MB', int, 3)
PORTS = ('namedPort', 'Port', '', str, 4)
GPUS = ('numGpus', 'GPU', ' GPU(s)', int, 5)

def __init__(self, field, display_name, display_unit, value_type, display_position):
self._field = field
@@ -24,17 +24,22 @@ def test_from_resource(self):
assert ResourceType.from_resource(Resource(ramMb=1)) is ResourceType.RAM_MB
assert ResourceType.from_resource(Resource(diskMb=0)) is ResourceType.DISK_MB
assert ResourceType.from_resource(Resource(namedPort='http')) is ResourceType.PORTS
assert ResourceType.from_resource(Resource(numGpus=1)) is ResourceType.GPUS

def test_resource_value(self):
assert ResourceType.CPUS.resource_value(Resource(numCpus=1.0)) == 1.0
assert ResourceType.GPUS.resource_value(Resource(numGpus=1)) == 1


class TestResourceManager(unittest.TestCase):
def test_resource_details(self):
details = ResourceManager.resource_details([Resource(ramMb=2), Resource(numCpus=1.0)])
assert len(details) == 2
assert details[0] == ResourceDetails(ResourceType.CPUS, 1.0)
details = ResourceManager.resource_details([
Resource(ramMb=2), Resource(numCpus=1.0), Resource(numGpus=1.0)
])
assert len(details) == 3
assert details[1] == ResourceDetails(ResourceType.RAM_MB, 2)
assert details[0] == ResourceDetails(ResourceType.CPUS, 1.0)
assert details[2] == ResourceDetails(ResourceType.GPUS, 1)

def test_quantity_of(self):
quantity = ResourceManager.quantity_of(

0 comments on commit d95fc2f

Please sign in to comment.