Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Make plugin dependencies explicit in configuration #117

Closed
tsv1 opened this issue Jan 5, 2025 · 0 comments · Fixed by #118
Closed

[Feature]: Make plugin dependencies explicit in configuration #117

tsv1 opened this issue Jan 5, 2025 · 0 comments · Fixed by #118

Comments

@tsv1
Copy link
Member

tsv1 commented Jan 5, 2025

Summary

Enhance the plugin configuration to explicitly define plugin dependencies using a depends_on attribute. The framework will automatically order plugins based on these dependencies, ensuring correct load sequences and eliminating ambiguity in plugin relationships.

Problem

Currently, plugins are loaded in the order they are declared within the Config.Plugins. However, there is no explicit indication of whether a plugin depends on another plugin or whether the order is chosen arbitrarily. This can lead to confusion for developers and potential errors when reordering plugins or introducing new ones. For instance, plugin X might depend on plugin Y, but the lack of an explicit declaration makes it unclear why X must follow Y.

Proposal

Detailed Description

  1. Introduce a depends_on Attribute:

    • Each plugin class in Config.Plugins can include a depends_on attribute, listing the other plugins it depends on.
    • Example:
      class Config(vedro.Config):
         class Plugins(vedro.Config.Plugins):
            class PluginA(plugin_a.PluginA):
               enabled = True
      
            class PluginB(plugin_b.PluginB):
               enabled = True
      
               @computed
               def depends_on(cls):
                  return [Config.Plugins.PluginA]
  2. Automatic Ordering of Plugins:

    • The framework will analyze the depends_on attributes and automatically reorder plugins to satisfy the dependency graph.
    • If a circular dependency is detected, the framework will log an error and halt execution.
  3. Validation and Error Logging:

    • The framework will validate that all dependencies declared in depends_on are present and enabled.
    • If a required plugin is disabled or missing, the framework will raise a clear error.

Backward Compatibility Notes

  • If no depends_on attribute is defined, plugins will be loaded in the order they are declared, preserving current behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant