Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions dask_mpi/cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import click

import asyncio
from mpi4py import MPI

from dask.distributed import Scheduler, Worker, Nanny
from distributed.cli.utils import check_python_3

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
from mpi4py import MPI


@click.command()
Expand Down Expand Up @@ -72,34 +71,40 @@ def main(
protocol,
):

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

if rank == 0 and scheduler:

async def run():
async def run_scheduler():
async with Scheduler(
interface=interface,
protocol=protocol,
scheduler_file=scheduler_file,
dashboard_address=dashboard_address,
port=scheduler_port,
scheduler_file=scheduler_file,
) as s:
comm.Barrier()
await s.finished()

asyncio.get_event_loop().run_until_complete(run_scheduler())

else:
comm.Barrier()

async def run():
async def run_worker():
WorkerType = Nanny if nanny else Worker
async with WorkerType(
scheduler_file=scheduler_file,
interface=interface,
protocol=protocol,
nthreads=nthreads,
memory_limit=memory_limit,
local_directory=local_directory,
name=rank,
scheduler_file=scheduler_file,
) as worker:
await worker.finished()

asyncio.get_event_loop().run_until_complete(run())
asyncio.get_event_loop().run_until_complete(run_worker())


def go():
Expand Down