Allow tasks to be used with placement groups (#9738)

This commit is contained in:
Eric Liang
2020-07-31 10:51:37 -07:00
committed by GitHub
parent 78995d085f
commit b73080c85f
11 changed files with 177 additions and 120 deletions
+8 -1
View File
@@ -4,7 +4,7 @@ from typing import (List, Dict)
def placement_group(bundles: List[Dict[str, float]],
strategy: str = "PACK",
name: str = None):
name: str = "unnamed_group"):
"""
Create a placement group.
@@ -21,6 +21,13 @@ def placement_group(bundles: List[Dict[str, float]],
name: The name of the placement group.
"""
worker = ray.worker.global_worker
worker.check_connected()
if not isinstance(bundles, list):
raise ValueError(
"The type of bundles must be list, got {}".format(bundles))
placement_group_id = worker.core_worker.create_placement_group(
name, bundles, strategy)
return placement_group_id