Пример #1
0
async def mars_cluster():
    mo.setup_cluster(address_to_resources=TEST_ADDRESS_TO_RESOURCES)
    main_pool_handles = []  # Hold actor_handle to avoid actor being freed.
    for index, bundle_spec in enumerate(TEST_PLACEMENT_GROUP_BUNDLES):
        address = node_placement_to_address(TEST_PLACEMENT_GROUP_NAME, index)
        actor_handle = await mo.create_actor_pool(address, bundle_spec["CPU"])
        main_pool_handles.append(actor_handle)

    yield

    RayActorDriver.stop_cluster()
Пример #2
0
async def test_task_manager_creation(ray_start_regular):
    mo.setup_cluster(address_to_resources=placement_group_info_to_addresses('test_cluster', [{'CPU': 2}]))
    # the pool is an ActorHandle, it does not have an async context.
    pool = await mo.create_actor_pool('ray://test_cluster/0/0', n_process=2,
                                      labels=[None] + ['numa-0'] * 2)
    assert pool

    # create configuration
    await mo.create_actor(TaskConfigurationActor, dict(),
                          uid=TaskConfigurationActor.default_uid(),
                          address='ray://test_cluster/0/0')

    configuration_ref = await mo.actor_ref(
            TaskConfigurationActor.default_uid(),
            address='ray://test_cluster/0/0')
    await configuration_ref.get_config()
Пример #3
0
def ray_cluster():
    try:
        from ray.cluster_utils import Cluster
    except ModuleNotFoundError:
        from ray._private.cluster_utils import Cluster
    cluster = Cluster()
    remote_nodes = []
    num_nodes = 3
    for i in range(num_nodes):
        remote_nodes.append(cluster.add_node(num_cpus=10))
        if len(remote_nodes) == 1:
            ray.init(address=cluster.address)
    mo.setup_cluster(address_to_resources=TEST_ADDRESS_TO_RESOURCES)

    yield

    RayActorDriver.stop_cluster()
    ray.shutdown()
    cluster.shutdown()