Skip to content

Commit

Permalink
new version: fixing spacy warning on version check.
Browse files Browse the repository at this point in the history
This addresses #11 #8 #5. SpaCy wants the version specification to match the major.minor.

Also added docker example
  • Loading branch information
MartinoMensio committed Nov 16, 2020
1 parent c4d6691 commit d0d3c97
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"python.pythonPath": "venv/bin/python3.7"
"python.pythonPath": "venv/bin/python"
}
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ Or you can install the following pre-packaged models with pip:

| model name | source | pip package |
|------------|--------|---|
| en_use_md | https://tfhub.dev/google/universal-sentence-encoder | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.2/en_use_md-0.3.2.tar.gz#en_use_md-0.3.2` |
| en_use_lg | https://tfhub.dev/google/universal-sentence-encoder-large | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.2/en_use_lg-0.3.2.tar.gz#en_use_lg-0.3.2` |
| xx_use_md | https://tfhub.dev/google/universal-sentence-encoder-multilingual | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.2/xx_use_md-0.3.2.tar.gz#xx_use_md-0.3.2` |
| xx_use_lg | https://tfhub.dev/google/universal-sentence-encoder-multilingual-large | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.2/xx_use_lg-0.3.2.tar.gz#xx_use_lg-0.3.2` |
| en_use_md | https://tfhub.dev/google/universal-sentence-encoder | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.3/en_use_md-0.3.3.tar.gz#en_use_md-0.3.3` |
| en_use_lg | https://tfhub.dev/google/universal-sentence-encoder-large | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.3/en_use_lg-0.3.3.tar.gz#en_use_lg-0.3.3` |
| xx_use_md | https://tfhub.dev/google/universal-sentence-encoder-multilingual | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.3/xx_use_md-0.3.3.tar.gz#xx_use_md-0.3.3` |
| xx_use_lg | https://tfhub.dev/google/universal-sentence-encoder-multilingual-large | `pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.3/xx_use_lg-0.3.3.tar.gz#xx_use_lg-0.3.3` |


## Usage
Expand Down Expand Up @@ -117,11 +117,16 @@ The solutions are:

To build and upload
```bash
VERSION=0.3.2
# change version
VERSION=0.3.3
# change version references everywhere
# update locally installed package
pip install -r requirements.txt
# build the standalone models (17)
./build_models.sh
# build the archive at dist/spacy_universal_sentence_encoder-${VERSION}.tar.gz
python setup.py sdist
# upload to pypi
twine upload dist/spacy_universal_sentence_encoder-${VERSION}.tar.gz
# upload language packages to github
```
2 changes: 1 addition & 1 deletion build_models.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set -e

VERSION=0.3.2
VERSION=0.3.3

# for every model
for MODEL_NAME in en_use_md en_use_lg xx_use_md xx_use_lg
Expand Down
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from python

RUN pip install https://github.com/MartinoMensio/spacy-universal-sentence-encoder/releases/download/v0.3.3/en_use_lg-0.3.3.tar.gz#en_use_lg-0.3.3

CMD bash
15 changes: 15 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Docker instructions

## Build the image
```bash
docker build -t use .
```

## Create the container

You can use pre-downloaded models from [TFHub](https://tfhub.dev/google/collections/universal-sentence-encoder/1) by using volume mapping.
If you want to do so, at the same time you need to provide the environment variable `TFHUB_CACHE_DIR` which will be used by the library to find the downloaded models.

```bash
docker run -it --rm -v `pwd`/models/universal_sentence_encoder:/SOME_SIMPLE_PATH_HERE -e TFHUB_CACHE_DIR=/SOME_SIMPLE_PATH_HERE --entrypoint /bin/bash nlp
```
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[metadata]
version = 0.3.2
version = 0.3.3
description = SpaCy models for using Universal Sentence Encoder from TensorFlow Hub
description-file = README.md
url = https://github.com/MartinoMensio/spacy-universal-sentence-encoder
Expand Down
6 changes: 3 additions & 3 deletions spacy_universal_sentence_encoder/meta/en_use_lg.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"lang": "en",
"name": "use_lg",
"version": "0.3.2",
"spacy_version": ">=2.1,<2.4",
"version": "0.3.3",
"spacy_version": ">=2.3,<2.4",
"description": "TensorFlow Hub wrapper for Universal Sentence Encoder",
"author": "Martino Mensio",
"email": "[email protected]",
"url": "https://github.com/MartinoMensio/spacy-universal-sentence-encoder",
"license": "MIT",
"requirements": [
"spacy_universal_sentence_encoder==0.3.2"
"spacy_universal_sentence_encoder==0.3.3"
],
"sources": [{
"name": "Universal Sentence Encoder - Large",
Expand Down
6 changes: 3 additions & 3 deletions spacy_universal_sentence_encoder/meta/en_use_md.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"lang": "en",
"name": "use_md",
"version": "0.3.2",
"spacy_version": ">=2.1,<2.4",
"version": "0.3.3",
"spacy_version": ">=2.3,<2.4",
"description": "TensorFlow Hub wrapper for Universal Sentence Encoder",
"author": "Martino Mensio",
"email": "[email protected]",
"url": "https://github.com/MartinoMensio/spacy-universal-sentence-encoder",
"license": "MIT",
"requirements": [
"spacy_universal_sentence_encoder==0.3.2"
"spacy_universal_sentence_encoder==0.3.3"
],
"sources": [{
"name": "Universal Sentence Encoder",
Expand Down
6 changes: 3 additions & 3 deletions spacy_universal_sentence_encoder/meta/xx_use_lg.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"lang": "xx",
"name": "use_lg",
"version": "0.3.2",
"spacy_version": ">=2.1,<2.4",
"version": "0.3.3",
"spacy_version": ">=2.3,<2.4",
"description": "TensorFlow Hub wrapper for Universal Sentence Encoder",
"author": "Martino Mensio",
"email": "[email protected]",
"url": "https://github.com/MartinoMensio/spacy-universal-sentence-encoder",
"license": "MIT",
"requirements": [
"spacy_universal_sentence_encoder==0.3.2"
"spacy_universal_sentence_encoder==0.3.3"
],
"sources": [{
"name": "Universal Sentence Encoder Multilingual - Large",
Expand Down
6 changes: 3 additions & 3 deletions spacy_universal_sentence_encoder/meta/xx_use_md.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"lang": "xx",
"name": "use_md",
"version": "0.3.2",
"spacy_version": ">=2.1,<2.4",
"version": "0.3.3",
"spacy_version": ">=2.3,<2.4",
"description": "TensorFlow Hub wrapper for Universal Sentence Encoder",
"author": "Martino Mensio",
"email": "[email protected]",
"url": "https://github.com/MartinoMensio/spacy-universal-sentence-encoder",
"license": "MIT",
"requirements": [
"spacy_universal_sentence_encoder==0.3.2"
"spacy_universal_sentence_encoder==0.3.3"
],
"sources": [{
"name": "Universal Sentence Encoder Multilingual",
Expand Down

0 comments on commit d0d3c97

Please sign in to comment.