-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: rewrite the service completely
BREAKING CHANGE: Instead of using protobuf definitions from arg-services, the package now contains code generated via betterproto. We also added a library that can be used in other Python projects without needing to start a server. Lastly, a proper CLI has been integrated that (besides starting the server) allows to perform semantic retrieval in the local file system.
- Loading branch information
Showing
15 changed files
with
1,823 additions
and
985 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 |
---|---|---|
|
@@ -226,7 +226,8 @@ data/ | |
|
||
# nix | ||
.envrc | ||
.direnv/ | ||
.devenv/ | ||
.direnv | ||
.devenv | ||
/result | ||
.venv | ||
.direnv |
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,83 @@ | ||
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/betterproto/default.nix | ||
{ | ||
fetchFromGitHub, | ||
lib, | ||
python, | ||
buildPythonPackage, | ||
poetry-core, | ||
grpclib, | ||
python-dateutil, | ||
typing-extensions, | ||
black, | ||
jinja2, | ||
isort, | ||
pytestCheckHook, | ||
pytest-asyncio, | ||
pytest-cov, | ||
pytest-mock, | ||
pydantic, | ||
protobuf, | ||
cachelib, | ||
tomlkit, | ||
grpcio-tools, | ||
}: | ||
buildPythonPackage rec { | ||
pname = "betterproto"; | ||
version = "master"; | ||
format = "pyproject"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "danielgtaylor"; | ||
repo = "python-betterproto"; | ||
rev = "bd7de203e16e949666b2844b3dec1eb7c4ed523c"; | ||
hash = "sha256-ppVS8dfVSXBm7KGv1/um6ePK4pBln+RrizR9EXz40qo="; | ||
}; | ||
|
||
nativeBuildInputs = [poetry-core]; | ||
|
||
propagatedBuildInputs = [ | ||
grpclib | ||
python-dateutil | ||
typing-extensions | ||
]; | ||
|
||
passthru.optional-dependencies.compiler = [ | ||
black | ||
jinja2 | ||
isort | ||
]; | ||
|
||
nativeCheckInputs = | ||
[ | ||
pytestCheckHook | ||
pytest-asyncio | ||
pytest-cov | ||
pytest-mock | ||
pydantic | ||
protobuf | ||
cachelib | ||
tomlkit | ||
grpcio-tools | ||
] | ||
++ passthru.optional-dependencies.compiler; | ||
|
||
# The tests require the generation of code before execution. This requires | ||
# the protoc-gen-python_betterproto script from the package to be on PATH. | ||
preCheck = '' | ||
export PATH=$PATH:$out/bin | ||
${python.interpreter} -m tests.generate | ||
''; | ||
|
||
pythonImportsCheck = ["betterproto"]; | ||
|
||
meta = { | ||
description = "Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC"; | ||
longDescription = '' | ||
This project aims to provide an improved experience when using Protobuf / | ||
gRPC in a modern Python environment by making use of modern language | ||
features and generating readable, understandable, idiomatic Python code. | ||
''; | ||
homepage = "https://github.com/danielgtaylor/python-betterproto"; | ||
license = lib.licenses.mit; | ||
}; | ||
} |
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,6 @@ | ||
version: v1 | ||
managed: | ||
enabled: true | ||
plugins: | ||
- name: python_betterproto | ||
out: ./gen |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,9 +1,24 @@ | ||
import logging | ||
|
||
from . import client as client | ||
from . import similarity as similarity | ||
from . import typing as typing | ||
from . import client, sim_funcs, typing | ||
from .lib import doc, docs, similarities, similarity, vector, vectors | ||
from .nlp_pb import EmbeddingModel, EmbeddingType, NlpConfig, Pooling, SimilarityMethod | ||
|
||
__all__ = ("client", "similarity", "typing") | ||
__all__ = ( | ||
"client", | ||
"sim_funcs", | ||
"typing", | ||
"docs", | ||
"doc", | ||
"vectors", | ||
"vector", | ||
"similarities", | ||
"similarity", | ||
"NlpConfig", | ||
"EmbeddingModel", | ||
"SimilarityMethod", | ||
"EmbeddingType", | ||
"Pooling", | ||
) | ||
|
||
logging.getLogger(__name__).addHandler(logging.NullHandler()) |
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 @@ | ||
from nlp_service.server import app | ||
from nlp_service.cli import app | ||
|
||
app() |
Oops, something went wrong.