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

Skip multiple version of plugin warning if the metadata is equal #380

Merged
merged 2 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#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"),
}
)
Comment on lines +61 to +69
Copy link
Collaborator

Choose a reason for hiding this comment

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

Define this metadata dictionary once as a variable? Here it is introduced two times (more work to maintain)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest just leaving the duplication for now. My upcoming and revised #377 ends up rewriting/moving this code so the duplication can removed then.


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

Expand Down