Skip to content

Commit

Permalink
load plug-ins in try..except block (#1392)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafał Jankowski <[email protected]>
  • Loading branch information
kshitij12345 and Raalsky authored Jul 28, 2023
1 parent d1f0c0e commit 76dcb5e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [UNRELEASED] neptune 1.5.0

### Fixes
- 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))


## neptune 1.4.1

### Fixes
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)

0 comments on commit 76dcb5e

Please sign in to comment.