Unverified Commit 2cb8d483 authored by Neel Kamath's avatar Neel Kamath Committed by GitHub

Bug fixes (#23)

* Fix /health_check endpoint

* Update examples to be more intuitive
parent 5106f041
......@@ -4,7 +4,6 @@ services:
command: sh -c '. scripts/setup.sh && pytest'
environment:
SENSE2VEC: 1
# Since any model will do, tests have been written only for the en_core_web_sm model because of its combination of
# speed, features, and accuracy.
SPACY_MODEL: en_core_web_sm
\ No newline at end of file
# A virtual environment caches dependencies instead of a Docker volume because the volume randomly gets corrupted.
version: '3.7'
services:
app:
......
......@@ -2,7 +2,7 @@
## Server
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). Replace `<ENABLED>` with `1` or `0` to enable to disable sense2vec respectively.
Replace `<MODEL>` with the name of the [spaCy model](https://spacy.io/models) (e.g., `en_core_web_sm`). The model must be compatible with the spaCy version specified in [requirements.txt](../requirements.txt). Replace `<ENABLED>` with `1` or `0` to enable to disable sense2vec respectively.
### Development
......@@ -41,13 +41,7 @@ The container `EXPOSE`s port `8000`. Run using `docker run --rm -p 8000:8000 spa
## Specification
`docs/openapi.yaml` is the [OpenAPI specification](https://swagger.io/specification/) for the HTTP API. Use `$ref` instead of inlining `schema`s so that OpenAPI Generator will name give usable names to the models.
### Testing
```
npx @stoplight/spectral lint docs/openapi.yaml
```
`docs/openapi.yaml` is the [OpenAPI specification](https://swagger.io/specification/) for the HTTP API. Use `$ref` instead of inlining `schema`s so that OpenAPI Generator will name give usable names to the models. Validate the schema by running `npx @stoplight/spectral lint docs/openapi.yaml`.
## Documentation
......@@ -57,9 +51,7 @@ npx @stoplight/spectral lint docs/openapi.yaml
npx redoc-cli serve docs/openapi.yaml -w
```
Open `http://127.0.0.1:8080` in your browser.
The documentation will automatically rebuild whenever you save a change to `docs/openapi.yaml`. Refresh the page whenever you want to view the updated documentation.
Open `http://127.0.0.1:8080` in your browser. The documentation will automatically rebuild whenever you save a change to `docs/openapi.yaml`. Refresh the page whenever you want to view the updated documentation.
### Production
......
This diff is collapsed.
# We must specify a particular version for spaCy and sense2vec because pretrained models are only compatible with
# particular versions.
# Specify fixed versions for spaCy and sense2vec because pretrained models are only compatible with certain versions.
spacy==2.2.3
sense2vec==1.0.2
......
......@@ -7,12 +7,13 @@ import fastapi
import pydantic
import sense2vec
import spacy
import starlette.responses
import starlette.status
app = fastapi.FastAPI()
model = os.getenv('SPACY_MODEL')
pipeline_error = 'The pretrained model ({})'.format(model) \
+ " doesn't support {}."
pipeline_error = ("The pretrained model ({}) does't support ".format(model)
+ '{}.')
nlp = spacy.load(model)
if os.getenv('SENSE2VEC') == '1':
nlp.add_pipe(
......@@ -154,6 +155,8 @@ async def sentencize(request: TextModel):
return {'sentences': [sent.text for sent in doc.sents]}
@app.get('/health_check', status_code=starlette.status.HTTP_204_NO_CONTENT)
@app.get('/health_check')
async def check_health():
pass
return starlette.responses.Response(
status_code=starlette.status.HTTP_204_NO_CONTENT
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment