From f1ef9014983f4a5e7e47a920aa78d3af5cc41c77 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Fri, 12 Jul 2019 06:26:10 -0700 Subject: [PATCH 1/3] Make spec repr generic --- distributed/deploy/spec.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/distributed/deploy/spec.py b/distributed/deploy/spec.py index bb46f81db88..445949dc200 100644 --- a/distributed/deploy/spec.py +++ b/distributed/deploy/spec.py @@ -315,7 +315,8 @@ async def scale_down(self, workers): scale_up = scale # backwards compatibility def __repr__(self): - return "SpecCluster(%r, workers=%d)" % ( + return "%s(%r, workers=%d)" % ( + type(self).__name__, self.scheduler_address, len(self.workers), ) From 70775ad6da926afa77a50f889451a6673e4b213f Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Mon, 15 Jul 2019 04:30:03 -0700 Subject: [PATCH 2/3] Add repr test --- distributed/deploy/tests/test_spec_cluster.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/distributed/deploy/tests/test_spec_cluster.py b/distributed/deploy/tests/test_spec_cluster.py index 0c062d3d3e0..fb2eee9e4e4 100644 --- a/distributed/deploy/tests/test_spec_cluster.py +++ b/distributed/deploy/tests/test_spec_cluster.py @@ -81,6 +81,15 @@ def test_loop_started(): ) +@pytest.mark.asyncio +async def test_repr(): + class MyCluster(SpecCluster): + pass + + async with MyCluster(..., asynchronous=True) as cluster: + assert "MyCluster" in str(cluster) + + @pytest.mark.asyncio async def test_scale(): worker = {"cls": Worker, "options": {"nthreads": 1}} From 9cf220477f145464b9de91b4e75ba856fbd17f12 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Mon, 15 Jul 2019 09:28:00 -0700 Subject: [PATCH 3/3] Remove bad copypasta --- distributed/deploy/tests/test_spec_cluster.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/distributed/deploy/tests/test_spec_cluster.py b/distributed/deploy/tests/test_spec_cluster.py index fb2eee9e4e4..e51e8f14260 100644 --- a/distributed/deploy/tests/test_spec_cluster.py +++ b/distributed/deploy/tests/test_spec_cluster.py @@ -83,10 +83,14 @@ def test_loop_started(): @pytest.mark.asyncio async def test_repr(): + worker = {"cls": Worker, "options": {"nthreads": 1}} + class MyCluster(SpecCluster): pass - async with MyCluster(..., asynchronous=True) as cluster: + async with MyCluster( + asynchronous=True, scheduler=scheduler, worker=worker + ) as cluster: assert "MyCluster" in str(cluster)