[tune] move jenkins tests to travis (#9609)

Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
Co-authored-by: Kai Fricke <kai@anyscale.com>
This commit is contained in:
krfricke
2020-07-24 21:22:54 -07:00
committed by GitHub
co-authored by Richard Liaw Kai Fricke
parent 0d67602051
commit 9f3570828a
9 changed files with 749 additions and 55 deletions
+350 -39
View File
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------
# Tests from the python/ray/tune/tests directory.
# Covers all tests starting with `test_`.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "test_actor_reuse",
size = "medium",
@@ -6,6 +11,14 @@ py_test(
deps = [":tune_lib"],
)
py_test(
name = "test_api",
size = "large",
srcs = ["tests/test_api.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_automl_searcher",
size = "small",
@@ -25,7 +38,7 @@ py_test(
size = "large",
srcs = ["tests/test_cluster.py"],
deps = [":tune_lib"],
tags = ["jenkins_only", "exclusive"],
tags = ["flaky", "jenkins_only", "exclusive"],
)
py_test(
@@ -51,6 +64,13 @@ py_test(
deps = [":tune_lib"],
)
py_test(
name = "test_experiment",
size = "small",
srcs = ["tests/test_experiment.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_experiment_analysis",
size = "medium",
@@ -66,10 +86,11 @@ py_test(
)
py_test(
name = "test_experiment",
size = "small",
srcs = ["tests/test_experiment.py"],
name = "test_function_api",
size = "medium",
srcs = ["tests/test_function_api.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
@@ -94,6 +115,22 @@ py_test(
deps = [":tune_lib"],
)
py_test(
name = "test_run_experiment",
size = "medium",
srcs = ["tests/test_run_experiment.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_sync",
size = "medium",
srcs = ["tests/test_sync.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_track",
size = "small",
@@ -102,11 +139,10 @@ py_test(
)
py_test(
name = "test_run_experiment",
size = "medium",
srcs = ["tests/test_run_experiment.py"],
name = "test_trainable_util",
size = "small",
srcs = ["tests/test_trainable_util.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
@@ -141,37 +177,6 @@ py_test(
tags = ["exclusive"],
)
py_test(
name = "test_api",
size = "large",
srcs = ["tests/test_api.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_function_api",
size = "medium",
srcs = ["tests/test_function_api.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_sync",
size = "medium",
srcs = ["tests/test_sync.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_trainable_util",
size = "small",
srcs = ["tests/test_trainable_util.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_trial_scheduler",
size = "medium",
@@ -212,6 +217,312 @@ py_test(
tags = ["exclusive"],
)
# --------------------------------------------------------------------
# Tests from the python/ray/tune/tests directory.
# Covers all remaining tests that do not start with `test_`.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "example",
size = "small",
srcs = ["tests/example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
)
# Todo: Ensure MPLBACKEND=Agg
py_test(
name = "tutorial",
size = "medium",
srcs = ["tests/tutorial.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
)
# --------------------------------------------------------------------
# Examples from the python/ray/tune/examples directory.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "async_hyperband_example",
size = "small",
srcs = ["examples/async_hyperband_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "ax_example",
size = "medium",
srcs = ["examples/ax_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "py37"],
args = ["--smoke-test"]
)
py_test(
name = "bayesopt_example",
size = "medium",
srcs = ["examples/bayesopt_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "bohb_example",
size = "small",
srcs = ["examples/bohb_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"]
)
py_test(
name = "cifar10_pytorch",
size = "medium",
srcs = ["examples/cifar10_pytorch.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "pytorch"],
args = ["--smoke-test"]
)
py_test(
name = "dragonfly_example",
size = "medium",
srcs = ["examples/dragonfly_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
# Does not work without awscli tool installed. Check if can be mocked.
# py_test(
# name = "durable_trainable_example",
# size = "medium",
# srcs = ["examples/durable_trainable_example.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"],
# args = ["--local", "--mock-storage"]
# )
py_test(
name = "genetic_example",
size = "small",
srcs = ["examples/genetic_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "hyperband_example",
size = "medium",
srcs = ["examples/hyperband_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"]
)
py_test(
name = "hyperband_function_example",
size = "medium",
srcs = ["examples/hyperband_function_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "hyperopt_example",
size = "medium",
srcs = ["examples/hyperopt_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "lightgbm_example",
size = "medium",
srcs = ["examples/lightgbm_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"]
)
py_test(
name = "logging_example",
size = "medium",
srcs = ["examples/logging_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
# Commenting out for now because it is not idempotent
# py_test(
# name = "mlflow_example",
# size = "medium",
# srcs = ["examples/mlflow_example.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"]
# )
py_test(
name = "mnist_pytorch",
size = "small",
srcs = ["examples/mnist_pytorch.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "pytorch"],
args = ["--smoke-test"]
)
py_test(
name = "mnist_pytorch_lightning",
size = "medium",
srcs = ["examples/mnist_pytorch_lightning.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "pytorch"],
args = ["--smoke-test"]
)
py_test(
name = "mnist_pytorch_trainable",
size = "small",
srcs = ["examples/mnist_pytorch_trainable.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "pytorch"],
args = ["--smoke-test"]
)
py_test(
name = "nevergrad_example",
size = "medium",
srcs = ["examples/nevergrad_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "pbt_convnet_example",
size = "medium",
srcs = ["examples/pbt_convnet_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "pbt_example",
size = "medium",
srcs = ["examples/pbt_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "pbt_function",
size = "medium",
srcs = ["examples/pbt_function.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "pbt_memnn_example",
size = "medium",
srcs = ["examples/pbt_memnn_example.py"],
deps = [":tune_lib"],
tags = ["flaky", "exclusive", "example"],
args = ["--smoke-test"]
)
# Requires GPUs. Add smoke test?
# py_test(
# name = "pbt_ppo_example",
# size = "medium",
# srcs = ["examples/pbt_ppo_example.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"],
# args = ["--smoke-test"]
# )
# Requires GPUs. Add smoke test?
# py_test(
# name = "pbt_tune_cifar10_with_keras",
# size = "medium",
# srcs = ["examples/pbt_tune_cifar10_with_keras.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"],
# args = ["--smoke-test"]
# )
# Needs SigOpt API key.
# py_test(
# name = "sigopt_example",
# size = "medium",
# srcs = ["examples/sigopt_example.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"],
# args = ["--smoke-test"]
# )
py_test(
name = "skopt_example",
size = "medium",
srcs = ["examples/skopt_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "tf_mnist_example",
size = "medium",
srcs = ["examples/tf_mnist_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example", "tf"],
args = ["--smoke-test"]
)
# Downloads too much data.
# py_test(
# name = "tune_cifar10_gluon",
# size = "medium",
# srcs = ["examples/tune_cifar10_gluon.py"],
# deps = [":tune_lib"],
# tags = ["exclusive", "example"],
# args = ["--model SqueezeNet1.0", "--smoke-test"]
# )
py_test(
name = "tune_mnist_keras",
size = "medium",
srcs = ["examples/tune_mnist_keras.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
py_test(
name = "xgboost_example",
size = "small",
srcs = ["examples/xgboost_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"]
)
py_test(
name = "zoopt_example",
size = "small",
srcs = ["examples/zoopt_example.py"],
deps = [":tune_lib"],
tags = ["exclusive", "example"],
args = ["--smoke-test"]
)
# This is a dummy test dependency that causes the above tests to be
# re-run if any of these files changes.
py_library(
+15 -11
View File
@@ -22,7 +22,7 @@ import tarfile
import numpy as np
import re
from ray.tune import Trainable
from ray import tune
def tokenize(sent):
@@ -94,7 +94,7 @@ def vectorize_stories(word_idx, story_maxlen, query_maxlen, data):
pad_sequences(queries, maxlen=query_maxlen), np.array(answers))
def read_data():
def read_data(finish_fast=False):
# Get the file
try:
path = get_file(
@@ -125,11 +125,13 @@ def read_data():
with tarfile.open(path) as tar:
train_stories = get_stories(tar.extractfile(challenge.format("train")))
test_stories = get_stories(tar.extractfile(challenge.format("test")))
if finish_fast:
train_stories = train_stories[:64]
test_stories = test_stories[:64]
return train_stories, test_stories
class MemNNModel(Trainable):
class MemNNModel(tune.Trainable):
def build_model(self):
"""Helper method for creating the model"""
vocab = set()
@@ -216,7 +218,8 @@ class MemNNModel(Trainable):
def setup(self, config):
with FileLock(os.path.expanduser("~/.tune.lock")):
self.train_stories, self.test_stories = read_data()
self.train_stories, self.test_stories = read_data(
config["finish_fast"])
model = self.build_model()
rmsprop = RMSprop(
lr=self.config.get("lr", 1e-3), rho=self.config.get("rho", 0.9))
@@ -255,33 +258,34 @@ class MemNNModel(Trainable):
if __name__ == "__main__":
import ray
from ray.tune import Trainable, run
from ray.tune.schedulers import PopulationBasedTraining
parser = argparse.ArgumentParser()
parser.add_argument(
"--smoke-test", action="store_true", help="Finish quickly for testing")
args, _ = parser.parse_known_args()
ray.init()
ray.init(num_cpus=2)
read_data()
pbt = PopulationBasedTraining(
time_attr="training_iteration",
metric="mean_accuracy",
mode="max",
perturbation_interval=5,
perturbation_interval=2,
hyperparam_mutations={
"dropout": lambda: np.random.uniform(0, 1),
"lr": lambda: 10**np.random.randint(-10, 0),
"rho": lambda: np.random.uniform(0, 1)
})
results = run(
results = tune.run(
MemNNModel,
name="pbt_babi_memnn",
scheduler=pbt,
stop={"training_iteration": 10 if args.smoke_test else 100},
num_samples=4,
stop={"training_iteration": 4 if args.smoke_test else 100},
num_samples=2,
config={
"finish_fast": args.smoke_test,
"batch_size": 32,
"epochs": 1,
"dropout": 0.3,
+1 -1
View File
@@ -6,7 +6,7 @@ to run concurrently, otherwise PBT will round-robin train the trials which
is less efficient (or you can set {"gpu": 0} to use CPUs for SGD instead).
Note that Tune in general does not need 8 GPUs, and this is just a more
computationally demainding example.
computationally demanding example.
"""
import random
+213
View File
@@ -0,0 +1,213 @@
# --------------------------------------------------------------------
# Tests from the python/ray/util/sgd/tests directory.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "test_tensorflow",
size = "small",
srcs = ["tests/test_tensorflow.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
)
py_test(
name = "test_torch",
size = "large",
srcs = ["tests/test_torch.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
)
py_test(
name = "test_torch_runner",
size = "small",
srcs = ["tests/test_torch_runner.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
)
# --------------------------------------------------------------------
# Tests from the python/ray/util/sgd/tf/examples directory.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "cifar_tf_example_1",
size = "medium",
main = "tf/examples/cifar_tf_example.py",
srcs = ["tf/examples/cifar_tf_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-replicas=1"]
)
py_test(
name = "cifar_tf_example_2",
size = "medium",
main = "tf/examples/cifar_tf_example.py",
srcs = ["tf/examples/cifar_tf_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-replicas=2"]
)
py_test(
name = "cifar_tf_example_2b",
size = "small",
main = "tf/examples/cifar_tf_example.py",
srcs = ["tf/examples/cifar_tf_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-replicas=2", "--augment-data"]
)
py_test(
name = "tensorflow_train_example_1",
size = "small",
main = "tf/examples/tensorflow_train_example.py",
srcs = ["tf/examples/tensorflow_train_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--num-replicas=1"]
)
py_test(
name = "tensorflow_train_example_2",
size = "small",
main = "tf/examples/tensorflow_train_example.py",
srcs = ["tf/examples/tensorflow_train_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--num-replicas=2"]
)
py_test(
name = "tensorflow_train_example_tune",
size = "small",
main = "tf/examples/tensorflow_train_example.py",
srcs = ["tf/examples/tensorflow_train_example.py"],
tags = ["exclusive", "tf"],
deps = [":sgd_lib"],
args = ["--tune"]
)
# --------------------------------------------------------------------
# Tests from the python/ray/util/sgd/torch/examples directory.
# Does not include subdirectories.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "cifar_pytorch_example_1",
size = "medium",
main = "torch/examples/cifar_pytorch_example.py",
srcs = ["torch/examples/cifar_pytorch_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-workers=1"]
)
py_test(
name = "cifar_pytorch_example_2",
size = "medium",
main = "torch/examples/cifar_pytorch_example.py",
srcs = ["torch/examples/cifar_pytorch_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-workers=2"]
)
py_test(
name = "cifar_pytorch_pbt",
size = "medium",
srcs = ["torch/examples/cifar_pytorch_pbt.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--smoke-test"]
)
py_test(
name = "dcgan",
size = "small",
srcs = ["torch/examples/dcgan.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--smoke-test", "--num-workers=2"]
)
py_test(
name = "raysgd_torch_signatures",
size = "small",
srcs = ["torch/examples/raysgd_torch_signatures.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"]
)
py_test(
name = "train_example_1",
size = "small",
main = "torch/examples/train_example.py",
srcs = ["torch/examples/train_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--num-workers=1"]
)
py_test(
name = "train_example_2",
size = "small",
main = "torch/examples/train_example.py",
srcs = ["torch/examples/train_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--num-workers=2"]
)
py_test(
name = "tune_example_1",
size = "small",
main = "torch/examples/tune_example.py",
srcs = ["torch/examples/tune_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--num-workers=1"]
)
py_test(
name = "tune_example_2",
size = "small",
main = "torch/examples/tune_example.py",
srcs = ["torch/examples/tune_example.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--num-workers=2"]
)
# --------------------------------------------------------------------
# Tests from the python/ray/util/sgd/torch/examples/* directories.
# Only covers subdirectories.
# Please keep these sorted alphabetically.
# --------------------------------------------------------------------
py_test(
name = "benchmark",
size = "small",
srcs = ["torch/examples/benchmarks/benchmark.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--smoke-test"]
)
py_test(
name = "image_models",
size = "small",
main = "torch/examples/image_models/train.py",
srcs = ["torch/examples/image_models/train.py"],
tags = ["exclusive", "pytorch"],
deps = [":sgd_lib"],
args = ["--no-gpu", "--mock-data", "--smoke-test", "--ray-num-workers=2", "--model=mobilenetv3_small_075", "data"]
)
# This is a dummy test dependency that causes the above tests to be
# re-run if any of these files changes.
py_library(
name = "sgd_lib",
srcs = glob(["**/*.py"], exclude=["tests/*.py"]),
)