equinor / webviz-config

Make Dash applications from a user-friendly config file :book: :snake:
https://github.com/orgs/equinor/projects/24
MIT License
54 stars 38 forks source link

Calling `plugin_layout` fails if your plugin is not an installed package #603

Open oysteinequinor opened 2 years ago

oysteinequinor commented 2 years ago

Describe the bug Subclassing the WebvizPluginABC and calling plugin_layout crashes unless the plugin you are writing is installed as a package in your python environment.

How to reproduce

import webviz_config
class MyPlugin(webviz_config.WebvizPluginABC):
    def layout(self):
        return ""
MyPlugin().plugin_layout()

... webviz-config/webviz_config/_plugin_abc.py", line 185, in _make_extended_deprecation_warnings dist_name = PLUGIN_METADATA[plugin_name]["dist_name"] KeyError: 'MyPlugin'

Expected behavior I expect plugin_layout to return the layout.

Additional context We are using our webviz plugin by importing it (without installing it) and adding it to a dash app manually.

Suggested fix I think iterating through installed packages in _make_extended_deprecation_warnings is a bit shady. Maybe find another way of doing something similar. A minimal fix is to silently skip if it fails?

anders-kiaer commented 1 year ago

I agree with this - thanks for the report @oysteinequinor. 👍