-
Notifications
You must be signed in to change notification settings - Fork 2.3k
support global plugins file, improve plugins docs #4779
Conversation
allennlp/common/plugins.py
Outdated
if os.path.isfile(LOCAL_PLUGINS_FILENAME): | ||
with push_python_path("."): | ||
yield from discover_file_plugins(LOCAL_PLUGINS_FILENAME) | ||
elif os.path.isfile(GLOBAL_PLUGINS_FILENAME): | ||
yield from discover_file_plugins(GLOBAL_PLUGINS_FILENAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means only one of the files will be respected. Wouldn't it make more sense to load from both files if they are both present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think either way would make sense. I don't feel strongly about it, so I'm happy to make the change if you do.
allennlp/common/plugins.py
Outdated
else: | ||
yield from [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this. You can just let the function end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeup, you're right.
@@ -56,13 +55,20 @@ def discover_plugins() -> Iterable[str]: | |||
""" | |||
Returns an iterable of the plugins found. | |||
""" | |||
plugins: Set[str] = set() | |||
if os.path.isfile(LOCAL_PLUGINS_FILENAME): | |||
with push_python_path("."): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The global one doesn't need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the assumption made with global plugins is that they should be installed in your virtual environment, rather than just existing in the current directly.
Adds support for declaring a global plugins file at
~/.allennlp/plugins
and improves the documentation for plugins. This also closes #4775 by added a place to display third-party plugins.