Skip to content

Commit

Permalink
Skip multiple version of plugin warning if the metadata is equal (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
asnyv authored Jan 26, 2021
1 parent 693fd6b commit 8dc0a12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Authorization Code flow support for Azure AD applications.
- [#374](https://github.com/equinor/webviz-config/pull/374) - Removed Webviz
SSL certificate generation and forcing of HTTPS connections.

### Fixed
- [#380](https://github.com/equinor/webviz-config/pull/380) - Don't write warning
for multiple versions of same plugin if the metadata is equal.

## [0.2.7] - 2021-01-14

### Changed
Expand Down
28 changes: 21 additions & 7 deletions webviz_config/plugins/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,34 @@ def load_webviz_plugins_with_metadata(
}

if entry_point.name in metadata:
if metadata[entry_point.name] == PluginDistInfo(
{
"dist_name": dist.metadata["name"],
"dist_version": dist.version,
"documentation_url": project_urls.get("Documentation"),
"download_url": project_urls.get("Download"),
"tracker_url": project_urls.get("Tracker"),
}
):
# May occur if folders in virtual environment are symlinked.
continue

warnings.warn(
f"Multiple versions of plugin with name {entry_point.name}. "
f"Already loaded from project {metadata[entry_point.name]['dist_name']}. "
f"Overwriting using plugin with from project {dist.metadata['name']}",
RuntimeWarning,
)

metadata[entry_point.name] = {
"dist_name": dist.metadata["name"],
"dist_version": dist.version,
"documentation_url": project_urls.get("Documentation"),
"download_url": project_urls.get("Download"),
"tracker_url": project_urls.get("Tracker"),
}
metadata[entry_point.name] = PluginDistInfo(
{
"dist_name": dist.metadata["name"],
"dist_version": dist.version,
"documentation_url": project_urls.get("Documentation"),
"download_url": project_urls.get("Download"),
"tracker_url": project_urls.get("Tracker"),
}
)

loaded_plugins[entry_point.name] = entry_point.load()

Expand Down

0 comments on commit 8dc0a12

Please sign in to comment.