Add external module as a node scaler. (#1703)

* WIP: add external module as a node scaler.

* Fix style.

* Add tests, fix style issues.

* Fix typos.

* Fix test error.

* Fix node provider path.

* Add function to spli pkg from class.

* Add doc.

* Correct documentation.

* Debugging....

* Debugging....

* Add __init__.py to tests.

* add more output for debugging

* Add more test, fix error with import.

* Add a small detail to the documentation.

* Update autoscaler.py
This commit is contained in:
Christian Barra
2018-03-17 16:59:13 -07:00
committed by Eric Liang
parent e3685fca5e
commit 070e27ea7a
5 changed files with 77 additions and 2 deletions
View File
+35
View File
@@ -507,6 +507,41 @@ class AutoscalingTest(unittest.TestCase):
autoscaler.update()
self.waitFor(lambda: len(runner.calls) > num_calls)
def testExternalNodeScaler(self):
config = SMALL_CLUSTER.copy()
config["provider"] = {
"type": "external",
"module": "ray.autoscaler.node_provider.NodeProvider",
}
config_path = self.write_config(config)
autoscaler = StandardAutoscaler(
config_path, LoadMetrics(), max_failures=0, update_interval_s=0)
self.assertIsInstance(autoscaler.provider, NodeProvider)
def testExternalNodeScalerWrongImport(self):
config = SMALL_CLUSTER.copy()
config["provider"] = {
"type": "external",
"module": "mymodule.provider_class",
}
invalid_provider = self.write_config(config)
self.assertRaises(
ImportError,
lambda: StandardAutoscaler(
invalid_provider, LoadMetrics(), update_interval_s=0))
def testExternalNodeScalerWrongModuleFormat(self):
config = SMALL_CLUSTER.copy()
config["provider"] = {
"type": "external",
"module": "does-not-exist",
}
invalid_provider = self.write_config(config)
self.assertRaises(
ValueError,
lambda: StandardAutoscaler(
invalid_provider, LoadMetrics(), update_interval_s=0))
if __name__ == "__main__":
unittest.main(verbosity=2)