Skip to content

Conversation

jayavenkatesh19
Copy link

Closes #9106

  • Tests added / passed
  • Passes pre-commit run --all-files

Adds a client side function to check if a plugin is registered on either the scheduler, worker or nanny registries. The plugin names seem to be unique enough to ignore the edge case where two different plugin types such as a WorkerPlugin and a SchedulerPlugin have the same name. The scheduler has separate functions added for this use case but will need to add extra client functions to separate the has_plugin function into has_worker_plugin etc.

Apart from checking if a plugin is registered by passing its name, also added the functionality of passing the plugin object itself with name extraction handled by the function. This is especially useful while using built-in plugins for users who do not know about the plugin.name attribute. Also added an error check for plugins whose name is not set.

CC: @jacobtomlinson

@jayavenkatesh19 jayavenkatesh19 changed the title Plugin registration status Check plugin registration status Sep 24, 2025
Copy link
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    27 files  ±0      27 suites  ±0   9h 34m 44s ⏱️ - 4m 46s
 4 111 tests ±0   4 002 ✅  - 3    104 💤 ±0  5 ❌ +3 
51 503 runs  ±0  49 313 ✅  - 3  2 184 💤 ±0  6 ❌ +3 

For more details on these failures, see this check.

Results for commit 4e88de0. ± Comparison against base commit 8e604a0.

Copy link
Member

@jacobtomlinson jacobtomlinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to me!

If you have a look in distributed/distributed/diagnostics/tests/ you'll find test_scheduler_plugin.py, test_worker_plugin.py and test_nanny_plugin.py. Could you go through those and add/update some tests that exercise the new code here?

Copy link
Member

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

I wonder if it'd be more useful to have separate methods has_worker_plugin, has_scheduler_plugin, has_nanny_plugin. Are people interested whether some plugin is somewhere on the cluster? Or whether it's specifically on the scheduler or specifically on the worker?

In my experience, you typically don't have plugins of different types with the same name, so perhaps it's not worth worrying about.

Comment on lines +5492 to +5494
elif isinstance(plugin, (WorkerPlugin, SchedulerPlugin, NannyPlugin)):
plugin_name = getattr(plugin, "name", None)
if plugin_name is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible simplification: if we detect a single plugin here, we can assign it to

plugin = [plugin]

and then fall through to the list case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see that the return type is different in that case (bool vs. dict[str, bool]). We could add a local unbox variable to handle this, but perhaps not worth it.

)
return result[plugin_name]

elif isinstance(plugin, list):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Sequence here (and in the type signature)?

f"Plugin {funcname(type(p))} has no 'name' attribute"
)
names_to_check.append(plugin_name)
return self.sync(self._get_plugin_registration_status, names=names_to_check)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have an else case that raises rather than silently returning None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

check if a Plugin is present
3 participants