Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

support global plugins file, improve plugins docs #4779

Merged
merged 8 commits into from
Nov 11, 2020
Merged

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented Nov 10, 2020

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.

@epwalsh epwalsh requested review from dirkgr and AkshitaB November 10, 2020 19:22
Comment on lines 59 to 63
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)
Copy link
Member

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?

Copy link
Member Author

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.

Comment on lines 64 to 65
else:
yield from []
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeup, you're right.

@epwalsh epwalsh requested a review from dirkgr November 10, 2020 22:38
@@ -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("."):
Copy link
Member

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?

Copy link
Member Author

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.

@epwalsh epwalsh merged commit 04247fa into master Nov 11, 2020
@epwalsh epwalsh deleted the document-plugins branch November 11, 2020 00:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ask for further integration with Optuna
2 participants