-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(language): better structure (#365)
- Loading branch information
Showing
18 changed files
with
1,643 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,29 +2,15 @@ | |
|
||
## Prerequisites | ||
|
||
Install [NVM](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating). | ||
|
||
Install [Node.js](https://nodejs.org/) 20.x with NVM and set it as default: | ||
|
||
```shell | ||
nvm install lts/iron | ||
``` | ||
|
||
```shell | ||
nvm alias default lts/iron | ||
``` | ||
Install [Bun](https://bun.sh). | ||
|
||
Install [Go](https://go.dev) for your platform. | ||
|
||
Install [Rust](https://www.rust-lang.org) for your platform. | ||
|
||
Install [PDM](https://pdm-project.org). | ||
|
||
Install Python 3.12 with PDM: | ||
Install [Poetry](https://python-poetry.org/docs/#installation). | ||
|
||
```shell | ||
pdm py install [email protected] | ||
``` | ||
Install [Python](https://www.python.org) 3.12 with [pyenv](https://github.com/pyenv/pyenv). | ||
|
||
## Run Infrastructure Services | ||
|
||
|
@@ -171,3 +157,4 @@ Start each microservice separately in a new terminal as described here: | |
- [Voltaserve Conversion](conversion/README.md) | ||
- [Voltaserve Mosaic](mosaic/README.md) | ||
- [Voltaserve Language](mosaic/README.md) | ||
- [Voltaserve Console](console/README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
[tool.poetry] | ||
name = "voltaserve-console" | ||
version = "0.0.1" | ||
version = "3.0.0" | ||
license = "BUSL-1.1" | ||
description = "Asynchronous API for voltaserve-console microservice" | ||
authors = ["Piotr Łoboda <[email protected]>"] | ||
maintainers = ["Piotr Łoboda <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
[flake8] | ||
exclude = .git,.venv,.dockerignore,.pdm-python,Dockerfile | ||
extend-ignore = E203 | ||
max-line-length = 88 | ||
exclude = .git,.venv,.dockerignore,.pdm-python,Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/__pycache__ | ||
__pycache__ | ||
/.venv | ||
/.pdm-python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,45 +2,30 @@ | |
|
||
## Getting Started | ||
|
||
Use Python 3.12: | ||
|
||
```shell | ||
pdm use [email protected] | ||
``` | ||
|
||
Install dependencies: | ||
|
||
```shell | ||
pdm install | ||
``` | ||
|
||
Activate the virtual environment created by PDM: | ||
|
||
```shell | ||
source .venv/bin/activate | ||
poetry install | ||
``` | ||
|
||
Make sure PIP is available: | ||
|
||
Run: | ||
```shell | ||
python3 -m ensurepip | ||
poetry run flask run --host=0.0.0.0 --port=8084 | ||
``` | ||
|
||
Run for development: | ||
Add `--debug` flag for development: | ||
|
||
```shell | ||
flask run --host=0.0.0.0 --port=8084 --debug | ||
poetry run flask run --host=0.0.0.0 --port=8084 --debug | ||
``` | ||
|
||
You can omit the `--debug` flag when not developing. | ||
|
||
Lint code: | ||
|
||
```shell | ||
flake8 . | ||
poetry run flake8 . | ||
``` | ||
|
||
Format code: | ||
```shell | ||
black . | ||
poetry run black . | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. | ||
|
||
from flask import Blueprint, request, jsonify | ||
import spacy.cli | ||
from ..services.entities import EntityExtractor | ||
|
||
bp = Blueprint("entities", __name__) | ||
|
||
multi_language_model = "xx_ent_wiki_sm" | ||
spacy.cli.download(multi_language_model) | ||
|
||
nlp = spacy.load(multi_language_model) | ||
nlp.add_pipe("sentencizer") | ||
|
||
|
||
@bp.route("/v3/entities", methods=["POST"]) | ||
def get_entities(): | ||
global nlp | ||
|
||
content = request.json | ||
text = content["text"] | ||
|
||
entity_extractor = EntityExtractor(nlp) | ||
dtos = entity_extractor.run(text) | ||
|
||
return jsonify(dtos) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. | ||
|
||
from flask import Blueprint | ||
|
||
bp = Blueprint("health", __name__) | ||
|
||
|
||
@bp.route("/v3/health", methods=["GET"]) | ||
def get_health(): | ||
return "OK", 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. | ||
|
||
from flask import Blueprint | ||
|
||
bp = Blueprint("version", __name__) | ||
|
||
|
||
@bp.route("/version", methods=["GET"]) | ||
def get_version(): | ||
return {"version": "3.0.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright 2023 Anass Bouassaba. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.txt. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the GNU Affero General Public License v3.0 only, included in the file | ||
# licenses/AGPL.txt. |
Oops, something went wrong.