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

load plug-ins in try..except block #1392

Merged
merged 7 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Fixes
Raalsky marked this conversation as resolved.
Show resolved Hide resolved
- Fixed operation processor bug if current working directory is different from the script directory ([#1391](https://github.com/neptune-ai/neptune-client/pull/1391))
- Retry request when ChunkedEncodingError occurred. ([#1402](https://github.com/neptune-ai/neptune-client/pull/1402))
- Load CLI plug-ins in try..except block to avoid a failure in loading a plug-in to crash entire CLI ([#1392](https://github.com/neptune-ai/neptune-client/pull/1392))

### Features
- Added support for `tensorboard` integration ([#1368](https://github.com/neptune-ai/neptune-client/pull/1368))
Expand Down
11 changes: 10 additions & 1 deletion src/neptune/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# limitations under the License.
#

import warnings

import click
import pkg_resources

Expand All @@ -36,4 +38,11 @@ def main():
plugins = {entry_point.name: entry_point for entry_point in pkg_resources.iter_entry_points("neptune.plugins")}

for name, entry_point in plugins.items():
main.add_command(entry_point.load(), name)
# loading an entry_point may fail and this
# will cause all CLI commands to fail.
# So, we load the plug-ins in try and except block.
try:
loaded_plugin = entry_point.load()
except Exception as e:
warnings.warn(f"Failed loading neptune plug-in `{name}` with exception: {e}")
main.add_command(loaded_plugin, name)