[tune] Tweaks to Trainable and Verbosity (#2889)

This commit is contained in:
Richard Liaw
2018-10-11 23:42:13 -07:00
committed by GitHub
parent 828fe24b39
commit f9b58d7b02
17 changed files with 160 additions and 47 deletions
+10 -4
View File
@@ -8,6 +8,7 @@ import logging
import time
import tempfile
import os
from numbers import Number
import ray
from ray.tune import TuneError
@@ -33,12 +34,14 @@ class Resources(
namedtuple("Resources", ["cpu", "gpu", "extra_cpu", "extra_gpu"])):
"""Ray resources required to schedule a trial.
TODO: Custom resources.
Attributes:
cpu (int): Number of CPUs to allocate to the trial.
gpu (int): Number of GPUs to allocate to the trial.
extra_cpu (int): Extra CPUs to reserve in case the trial needs to
cpu (float): Number of CPUs to allocate to the trial.
gpu (float): Number of GPUs to allocate to the trial.
extra_cpu (float): Extra CPUs to reserve in case the trial needs to
launch additional Ray actors that use CPUs.
extra_gpu (int): Extra GPUs to reserve in case the trial needs to
extra_gpu (float): Extra GPUs to reserve in case the trial needs to
launch additional Ray actors that use GPUs.
"""
@@ -46,6 +49,9 @@ class Resources(
__slots__ = ()
def __new__(cls, cpu, gpu, extra_cpu=0, extra_gpu=0):
for entry in [cpu, gpu, extra_cpu, extra_gpu]:
assert isinstance(entry, Number), "Improper resource value."
assert entry >= 0, "Resource cannot be negative."
return super(Resources, cls).__new__(cls, cpu, gpu, extra_cpu,
extra_gpu)