Bazelify tune tests in travis (#6219)

This commit is contained in:
Eric Liang
2019-11-22 13:58:50 -08:00
committed by GitHub
parent 68ac08332b
commit b052bcf1fc
9 changed files with 162 additions and 9 deletions
+123
View File
@@ -0,0 +1,123 @@
py_test(
name = "test_actor_reuse",
size = "medium",
srcs = ["tests/test_actor_reuse.py"],
tags = ["jenkins_only"],
)
py_test(
name = "test_automl_searcher",
size = "small",
srcs = ["tests/test_automl_searcher.py"],
)
py_test(
name = "test_checkpoint_manager",
size = "small",
srcs = ["tests/test_checkpoint_manager.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_cluster",
size = "large",
srcs = ["tests/test_cluster.py"],
deps = [":tune_lib"],
tags = ["jenkins_only", "exclusive"],
)
py_test(
name = "test_commands",
size = "medium",
srcs = ["tests/test_commands.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_dependency",
size = "small",
srcs = ["tests/test_dependency.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_experiment_analysis",
size = "medium",
srcs = ["tests/test_experiment_analysis.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_experiment",
size = "small",
srcs = ["tests/test_experiment.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_logger",
size = "small",
srcs = ["tests/test_logger.py"],
deps = [":tune_lib"],
tags = ["jenkins_only"],
)
py_test(
name = "test_ray_trial_executor",
size = "medium",
srcs = ["tests/test_ray_trial_executor.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_track",
size = "small",
srcs = ["tests/test_track.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_trial_runner",
size = "large",
srcs = ["tests/test_trial_runner.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_trial_scheduler",
size = "medium",
srcs = ["tests/test_trial_scheduler.py"],
deps = [":tune_lib"],
)
py_test(
name = "test_tune_restore",
size = "large",
srcs = ["tests/test_tune_restore.py"],
deps = [":tune_lib"],
tags = ["jenkins_only", "exclusive"],
)
py_test(
name = "test_tune_save_restore",
size = "large",
srcs = ["tests/test_tune_save_restore.py"],
deps = [":tune_lib"],
tags = ["exclusive"],
)
py_test(
name = "test_tune_server",
size = "medium",
srcs = ["tests/test_tune_server.py"],
deps = [":tune_lib"],
)
# This is a dummy test dependency that causes the above tests to be
# re-run if any of these files changes.
py_library(
name="tune_lib",
srcs = glob(["**/*.py"], exclude=["tests/*.py"]),
)
+2 -1
View File
@@ -70,7 +70,8 @@ DEFAULT_RESULT_KEYS = (TRAINING_ITERATION, TIME_TOTAL_S, TIMESTEPS_TOTAL,
RESULT_DUPLICATE = "__duplicate__"
# Where Tune writes result files by default
DEFAULT_RESULTS_DIR = (os.environ.get("TUNE_RESULT_DIR")
DEFAULT_RESULTS_DIR = (os.environ.get("TEST_TMPDIR")
or os.environ.get("TUNE_RESULT_DIR")
or os.path.expanduser("~/ray_results"))
# Meta file about status under each experiment directory, can be
@@ -67,3 +67,7 @@ class AutoMLSearcherTest(unittest.TestCase):
best_trial = searcher.get_best_trial()
self.assertEqual(best_trial, trials[-1])
self.assertEqual(best_trial.best_result["reward"], 3 + 10 - 1)
if __name__ == "__main__":
unittest.main(verbosity=2)
@@ -104,3 +104,9 @@ class CheckpointManagerTest(unittest.TestCase):
log_error_mock.assert_called_once()
# The newest checkpoint should still be set despite this error.
assert checkpoint_manager.newest_checkpoint == no_attr_checkpoint
if __name__ == "__main__":
import pytest
import sys
sys.exit(pytest.main(["-v", "-s", __file__]))
+6
View File
@@ -593,3 +593,9 @@ tune.run(
assert {t.trial_id for t in trials2} == {t.trial_id for t in trials}
ray.shutdown()
cluster.shutdown()
if __name__ == "__main__":
import pytest
import sys
sys.exit(pytest.main(["-v", "-s", __file__]))
+7
View File
@@ -156,3 +156,10 @@ def test_lsx(start_ray, tmpdir):
lines = output.captured
assert sum("1" in line for line in lines) >= num_experiments
assert len(lines) == 3 + num_experiments + 1
if __name__ == "__main__":
# Make click happy in bazel.
os.environ["LC_ALL"] = "en_US.UTF-8"
os.environ["LANG"] = "en_US.UTF-8"
sys.exit(pytest.main([__file__]))
+4
View File
@@ -59,3 +59,7 @@ class ExperimentTest(unittest.TestCase):
def testConvertExperimentIncorrect(self):
self.assertRaises(TuneError, lambda: convert_to_experiment_list("hi"))
if __name__ == "__main__":
unittest.main(verbosity=2)
+4
View File
@@ -82,3 +82,7 @@ class TrackApiTest(unittest.TestCase):
self.assertTrue(_check_json_val(result_path, "test", 1))
track.log(iteration=1, test=2)
self.assertTrue(_check_json_val(result_path, "test", 2))
if __name__ == "__main__":
unittest.main(verbosity=2)