You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by dm...@apache.org on 2018/02/21 18:55:49 UTC

aurora git commit: Add GPUs as resources in the Aurora CLI.

Repository: aurora
Updated Branches:
  refs/heads/master c52137e20 -> d95fc2ff9


Add GPUs as resources in the Aurora CLI.

Reviewed at https://reviews.apache.org/r/65735/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/d95fc2ff
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/d95fc2ff
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/d95fc2ff

Branch: refs/heads/master
Commit: d95fc2ff92ddb7eb2c4054c311fcfe9cc24319d2
Parents: c52137e
Author: Franck Cuny <fc...@twitter.com>
Authored: Wed Feb 21 10:55:41 2018 -0800
Committer: David McLaughlin <da...@dmclaughlin.com>
Committed: Wed Feb 21 10:55:41 2018 -0800

----------------------------------------------------------------------
 src/main/python/apache/aurora/config/resource.py       |  1 +
 src/test/python/apache/aurora/config/test_resources.py | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/d95fc2ff/src/main/python/apache/aurora/config/resource.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/config/resource.py b/src/main/python/apache/aurora/config/resource.py
index 85e1d00..b2ebd39 100644
--- a/src/main/python/apache/aurora/config/resource.py
+++ b/src/main/python/apache/aurora/config/resource.py
@@ -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

http://git-wip-us.apache.org/repos/asf/aurora/blob/d95fc2ff/src/test/python/apache/aurora/config/test_resources.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/config/test_resources.py b/src/test/python/apache/aurora/config/test_resources.py
index f43bad7..3ac5490 100644
--- a/src/test/python/apache/aurora/config/test_resources.py
+++ b/src/test/python/apache/aurora/config/test_resources.py
@@ -24,17 +24,22 @@ class TestResourceType(unittest.TestCase):
     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(