From 2428fafa1995cf0daf79d7d8d20e172378aa62f6 Mon Sep 17 00:00:00 2001 From: James Bourbeau Date: Fri, 30 Jul 2021 10:59:34 -0500 Subject: [PATCH] Deprecate worker plugin overwrite policy --- distributed/diagnostics/tests/test_worker_plugin.py | 3 ++- distributed/worker.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/distributed/diagnostics/tests/test_worker_plugin.py b/distributed/diagnostics/tests/test_worker_plugin.py index f3aa8cc6daf..7ae01f09227 100644 --- a/distributed/diagnostics/tests/test_worker_plugin.py +++ b/distributed/diagnostics/tests/test_worker_plugin.py @@ -198,7 +198,8 @@ def setup(self, worker): assert list(responses.values()) == [{"status": "OK"}] async with Worker(s.address, loop=s.loop): - responses = await c.register_worker_plugin(FooWorkerPlugin(), name="foo") + with pytest.warns(FutureWarning, match="worker plugin will be overwritten"): + responses = await c.register_worker_plugin(FooWorkerPlugin(), name="foo") assert list(responses.values()) == [{"status": "repeat"}] * 2 diff --git a/distributed/worker.py b/distributed/worker.py index c182a84249d..13c5c12ff88 100644 --- a/distributed/worker.py +++ b/distributed/worker.py @@ -2722,6 +2722,13 @@ async def plugin_add(self, comm=None, plugin=None, name=None): assert name if name in self.plugins: + warnings.warn( + "Attempting to add a worker plugin with the same name as an already registered " + f"plugin ({name}). Currently this results in no change and the previously registered " + "plugin is not overwritten. This behavior is deprecated and in a future release " + f"the previously registered {name} worker plugin will be overwritten.", + category=FutureWarning, + ) return {"status": "repeat"} else: self.plugins[name] = plugin