serve ez/dz/de bee via FastAPI rest
Project description
dezbee-rest
Serve ezbee via FastAPI port 5555 ([de|dz]bee may be supported later)
Install it (Python 3.8 only)
pip install dezrest
# pip install git+https://github.com/ffreemt/dezbee-rest
# poetry add git+https://github.com/ffreemt/dezbee-rest
# git clone https://github.com/ffreemt/dezbee-rest && cd dezbee-rest
Python virutal environment (Optional)
You may wish to create a python virutal environment first, e.g.,
mkdir temp-dir && cd temp-dir
py -3.8 -m venv .venv
call .venv\Scripts\activate
pip install dezrest
Post- or Pre-install (same as for ezbee)
pip install fastext
pip install pyicu==2.8 pycld2
pip install https://github.com/ffreemt/ezbee/raw/main/data/artifects/polyglot-16.7.4.tar.gz
In linux/macos, you may need to run (if the required packages are not already present in the system) something similar to
apt install libicu-dev
# or for macos
brew install icu4c
brew link icu4c --force
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/icu4c/lib"
export CPPFLAGS="-I/usr/local/opt/icu4c/include"
Refer to the pre-install part in workflow file routine-tests.yml
Use it
# sart the server at port 5555 via `uvicorn` with 2 workers
python -m dezrest
# or
dezrest
# or run at external IP
python -m dezrest --host 0.0.0.0
# or dezrest --host 0.0.0.0
# cli help
python -m dezrest --help
# or
dezrest --help
# REST docs (Swagger UI)
http://127.0.0.1:5555/docs
Sample run:
$ dezrest
[D 221220 10:48:21 fastlid:34] fetching lid.176.ftz (once only)
[I 221220 10:48:22 fastlid:44] Downloading https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.ftz (need to do this just once)
[I 221220 10:48:27 __main__:204] pid: C:\mat-dir\playground\venv-python
INFO: Uvicorn running on http://127.0.0.1:5555 (Press CTRL+C to quit)
INFO: Started parent process [486952]
INFO: Started server process [548488]
INFOINFO: Started server process [: Waiting for application startup.
547296]
INFOINFO: Application startup complete.
: Waiting for application startup.
INFO: Application startup complete.
INFO: 127.0.0.1:7114 - "POST /post/ HTTP/1.1" 200 OK
INFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Application shutdown complete.
INFO: Finished server process [547296]
To kill the server in Windows, kill the parent process (CTRL+C does not quite work in Windows at least), e.g.
taskkill /f /pid 486952
Test the REST API:
import httpx
res = httpx.post("http://127.0.0.1:5555/post/", json=["test\nlove", "没有\n测试\n其他\n爱"]).json()
print(res)
# [['', '没有', ''], ['test', '测试', '0.75'], ['', '其他', ''], ['love', '爱', '0.87']]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dezrest-0.1.0.tar.gz.
File metadata
- Download URL: dezrest-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cb85ff3d8ac8b587c8fcaa833c1b6634aadfe7b54263992c828f18238c2ca60
|
|
| MD5 |
341c2b2cc337143590c5cf2292338fb8
|
|
| BLAKE2b-256 |
ac2197fc5fcb84ab0233eeeb0f480c274b27acf29c486f035fc729f740f05c66
|
File details
Details for the file dezrest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dezrest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.1 CPython/3.8.10 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73555be258eef116279a93cf6a505eb735aa2937a953264a92ff1fe11f5f11f9
|
|
| MD5 |
fb156c4b84d1144ebc9f7658b5c98b20
|
|
| BLAKE2b-256 |
c500dbc29d58958a17a8fe5af17bf3043d5f82dc6569caff9618cfc7590b3b86
|