From c833e7bba894ce15e050866b92d40537b0e572fb Mon Sep 17 00:00:00 2001 From: Evan Pete Walsh Date: Mon, 4 May 2020 08:59:25 -0700 Subject: [PATCH] get rid of plugin mechanism (#40) --- .github/workflows/release.yml | 16 ++++++++++++++-- allennlp_plugins/__init__.py | 0 allennlp_plugins/allennlp_models/__init__.py | 8 -------- scripts/ensure_models_found.py | 12 ++++++++++++ scripts/ensure_versions_match.py | 11 +++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) delete mode 100644 allennlp_plugins/__init__.py delete mode 100644 allennlp_plugins/allennlp_models/__init__.py create mode 100755 scripts/ensure_models_found.py create mode 100755 scripts/ensure_versions_match.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 343d493a9..cdf8e4a59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,6 +79,14 @@ jobs: python: ['3.6', '3.7'] steps: + - uses: actions/checkout@v2 + + - name: Cleanup directory + run: | + # Remove the source code so that it doesn't conflict with the wheel + # installation. + rm -rf allennlp_models/ + - name: Setup Python uses: actions/setup-python@v1 with: @@ -98,9 +106,13 @@ jobs: run: | pip install $(ls dist/*.whl) - - name: Ensure models plugin found + - name: Ensure models automatically loaded + run: | + ./scripts/ensure_models_found.py + + - name: Ensure versions match run: | - python -c 'from allennlp.common.plugins import discover_plugins; assert "allennlp_plugins.allennlp_models" in list(discover_plugins())' + ./scripts/ensure_versions_match.py publish: name: PyPI diff --git a/allennlp_plugins/__init__.py b/allennlp_plugins/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/allennlp_plugins/allennlp_models/__init__.py b/allennlp_plugins/allennlp_models/__init__.py deleted file mode 100644 index 77ecf217d..000000000 --- a/allennlp_plugins/allennlp_models/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -import allennlp_models.coref -import allennlp_models.lm -import allennlp_models.ner -import allennlp_models.nli -import allennlp_models.rc -import allennlp_models.sentiment -import allennlp_models.seq2seq -import allennlp_models.syntax diff --git a/scripts/ensure_models_found.py b/scripts/ensure_models_found.py new file mode 100755 index 000000000..1e0fd4b59 --- /dev/null +++ b/scripts/ensure_models_found.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +""" +Ensures models are automatically found by allennlp. +""" + +from allennlp.common.plugins import import_plugins +from allennlp.models import Model + + +import_plugins() +Model.by_name("copynet_seq2seq") diff --git a/scripts/ensure_versions_match.py b/scripts/ensure_versions_match.py new file mode 100755 index 000000000..c76ec78b9 --- /dev/null +++ b/scripts/ensure_versions_match.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +""" +Ensures allennlp and models versions are the same. +""" + +from allennlp.version import VERSION as CORE_VERSION +from allennlp_models.version import VERSION as MODELS_VERSION + + +assert CORE_VERSION == MODELS_VERSION, f"core: {CORE_VERSION}, models: {MODELS_VERSION}"