From 65ccef63f1f76eeea71720183cab5858dff929be Mon Sep 17 00:00:00 2001 From: Jason Munro Date: Wed, 26 Jan 2022 14:50:03 -0800 Subject: [PATCH] Fix and test num_chunks and num_workers error --- src/maggma/cli/distributed.py | 2 +- tests/cli/test_distributed.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/maggma/cli/distributed.py b/src/maggma/cli/distributed.py index d29fbe72d..79a94d3b1 100644 --- a/src/maggma/cli/distributed.py +++ b/src/maggma/cli/distributed.py @@ -33,7 +33,7 @@ async def manager( """ logger = getLogger("Manager") - if not num_chunks and num_workers: + if not (num_chunks and num_workers): raise ValueError("Both num_chunks and num_workers must be non-zero") logger.info(f"Binding to Manager URL {url}:{port}") diff --git a/tests/cli/test_distributed.py b/tests/cli/test_distributed.py index 26b9bfb51..89b9a7ba6 100644 --- a/tests/cli/test_distributed.py +++ b/tests/cli/test_distributed.py @@ -56,6 +56,24 @@ def process_items(self, items): SERVER_PORT = 8234 +@pytest.mark.xfail(raises=ValueError) +@pytest.mark.asyncio +async def test_wrong_worker_input(log_to_stdout): + + manager_server = asyncio.create_task( + manager( + SERVER_URL, + SERVER_PORT, + [DummyBuilder(dummy_prechunk=False)], + num_chunks=2, + num_workers=0, + ) + ) + + await asyncio.sleep(1) + manager_server.result() + + @pytest.mark.asyncio async def test_manager_give_out_chunks(log_to_stdout):