mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
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:
committed by
Eric Liang
parent
e3685fca5e
commit
070e27ea7a
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user