Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

Commit 3e11584

Browse files
author
Neel Kamath
authored
Allow for a multi-model architecture (#16)
1 parent 4236377 commit 3e11584

File tree

13 files changed

+152
-399
lines changed

13 files changed

+152
-399
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,14 @@ download-vectors:
2323
test-server:
2424
stage: test
2525
image: docker/compose
26-
script: docker-compose -f docker-compose.yml -f docker-compose.test.yml
26+
script: SPACY_MODEL=en_core_web_sm docker-compose -f docker-compose.yml -f docker-compose.test.yml
2727
up --build --abort-on-container-exit --exit-code-from app
2828

2929
test-spec:
3030
stage: test
3131
image: node
3232
script: npx @stoplight/spectral lint docs/openapi.yaml
3333

34-
build-image:
35-
stage: build
36-
image: docker:dind
37-
script:
38-
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
39-
- version=$(grep version docs/openapi.yaml -m 1)
40-
- 'version=${version#*: }'
41-
- version=$(echo $version | cut -d "'" -f 2)
42-
- echo v$version > version.txt
43-
- docker build -t $CI_REGISTRY_IMAGE -t $CI_REGISTRY_IMAGE:$(cat version.txt) .
44-
- docker push $CI_REGISTRY_IMAGE
45-
- docker push $CI_REGISTRY_IMAGE:$(cat version.txt)
46-
artifacts:
47-
paths: [version.txt]
48-
only: [master]
49-
5034
build-docs:
5135
stage: build
5236
image: node
@@ -58,14 +42,7 @@ build-docs:
5842
docker-hub:
5943
stage: deploy
6044
image: docker:dind
61-
script:
62-
- echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USER --password-stdin https://index.docker.io/v1/
63-
- docker pull $CI_REGISTRY_IMAGE
64-
- docker pull $CI_REGISTRY_IMAGE:$(cat version.txt)
65-
- docker tag $CI_REGISTRY_IMAGE $DOCKER_HUB_USER/spacy-server
66-
- docker tag $CI_REGISTRY_IMAGE:$(cat version.txt) $DOCKER_HUB_USER/spacy-server:$(cat version.txt)
67-
- docker push $DOCKER_HUB_USER/spacy-server
68-
- docker push $DOCKER_HUB_USER/spacy-server:$(cat version.txt)
45+
script: sh deploy.sh
6946
only: [master]
7047

7148
pages:

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ WORKDIR /app
33
ENV PYTHONUNBUFFERED 1
44
COPY requirements.txt .
55
RUN pip install --no-cache-dir -r requirements.txt
6+
ARG SPACY_MODEL
7+
RUN python -m spacy download $SPACY_MODEL
68
COPY main.py .
79
COPY s2v_old/ s2v_old/
810
EXPOSE 8000

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
[![Built with spaCy](https://img.shields.io/badge/built%20with-spaCy-09a3d5.svg)](https://spacy.io)
44

5-
This project provides industrial-strength NLP via [spaCy](https://spacy.io/) and [sense2vec](https://github.com/explosion/sense2vec) over a containerized HTTP API.
5+
This project provides industrial-strength NLP for multiple languages via [spaCy](https://spacy.io/) and [sense2vec](https://github.com/explosion/sense2vec) over a containerized HTTP API.
66

77
## Installation
88

99
### Server
1010

1111
Install [Docker](https://hub.docker.com/search/?type=edition&offering=community).
1212

13-
The container `EXPOSE`s port `8000`. To serve at `http://localhost:8000`, run `docker run --rm -p 8000:8000 neelkamath/spacy-server`.
13+
You can find specific tags (say for example, a French model) on the [Docker Hub repository](https://hub.docker.com/repository/docker/neelkamath/spacy-server/tags?page=1).
1414

15-
You can find specific versions on the [Docker Hub repository](https://hub.docker.com/repository/docker/neelkamath/spacy-server/tags?page=1).
15+
For example, to run an English model at `http://localhost:8000`, run:
16+
```
17+
docker run --rm -e SPACY_MODEL=en_core_web_sm -p 8000:8000 neelkamath/spacy-server:v1-en_core_web_sm
18+
```
1619

1720
### Generating an SDK
1821

19-
You can generate a wrapper for the HTTP API using [OpenAPI Generator](https://openapi-generator.tech/) on the file `https://raw.githubusercontent.com/neelkamath/spacy-server/master/docs/openapi.yaml`.
22+
You can generate a wrapper for the HTTP API using [OpenAPI Generator](https://openapi-generator.tech/) on the file [`https://raw.githubusercontent.com/neelkamath/spacy-server/master/docs/openapi.yaml`](https://raw.githubusercontent.com/neelkamath/spacy-server/master/docs/openapi.yaml).
2023

2124
## [Usage](https://neelkamath.gitlab.io/spacy-server/)
2225

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: '3.7'
22
services:
33
app:
4-
command: sh setup.sh 'uvicorn main:app --host 0.0.0.0 --reload'
4+
command: sh scripts/setup.sh 'uvicorn main:app --host 0.0.0.0 --reload'
55
ports: ['8000:8000']

docker-compose.test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version: '3.7'
22
services:
33
app:
4-
command: sh setup.sh pytest
4+
command: sh scripts/setup.sh pytest

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ services:
77
app:
88
image: python:3.8
99
working_dir: /app
10+
environment:
11+
SPACY_MODEL:
1012
volumes:
1113
- type: bind
1214
source: .

docs/developing.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,33 @@
22

33
## Server
44

5+
Replace `<MODEL>` with the name of the [spaCy model](https://spacy.io/models) (e.g., `en_core_web_sm`, `fr_core_news_md`). The model must be compatible with the spaCy version specified in [requirements.txt](../requirements.txt).
6+
57
### Development
68

79
```
8-
docker-compose -p dev up --build
10+
SPACY_MODEL=<MODEL> docker-compose -p dev up --build
911
```
1012

1113
The server will be running on `http://localhost:8000`, and has automatic reload enabled.
1214

1315
### Testing
1416

17+
Since any model will do, tests have been written only for the `en_core_web_sm` model for its combination of speed, features, and accuracy.
18+
1519
```
16-
docker-compose -p test -f docker-compose.yml -f docker-compose.test.yml \
20+
SPACY_MODEL=en_core_web_sm docker-compose -p test -f docker-compose.yml -f docker-compose.test.yml \
1721
up --build --abort-on-container-exit --exit-code-from app
1822
```
1923

2024
### Production
2125

2226
```
23-
docker build -t spacy-server .
27+
docker build --build-arg SPACY_MODEL=<MODEL> -t spacy-server .
28+
docker run --rm -e SPACY_MODEL=<MODEL> -p 8000:8000 spacy-server
2429
```
2530

26-
The container `EXPOSE`s port `8000`. To serve at `http://localhost:8080`, run `docker run --rm -p 8000:8000 spacy-server`.
31+
The container `EXPOSE`s port `8000`.
2732

2833
## Specification
2934

0 commit comments

Comments
 (0)