-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move nucliadb_node/binding to the root [sc-6670] (#1154)
- Loading branch information
1 parent
58ce534
commit 765557c
Showing
20 changed files
with
146 additions
and
81 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
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
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
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
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.PHONY: install-dev | ||
install-dev: | ||
pip install --upgrade pip wheel | ||
cd .. && pip install \ | ||
-r test-requirements.txt \ | ||
-r code-requirements.txt | ||
pip install -e . | ||
|
||
.PHONY: test | ||
test: | ||
pytest -s --tb=native -v test.py | ||
|
||
.PHONY: build | ||
build: | ||
maturin build |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,93 @@ | ||
# Copyright (C) 2021 Bosutech XXI S.L. | ||
# | ||
# nucliadb is offered under the AGPL v3.0 and as commercial software. | ||
# For commercial licensing, contact us at [email protected]. | ||
# | ||
# AGPL: | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import asyncio | ||
import os | ||
import shutil | ||
from contextlib import contextmanager | ||
from datetime import datetime | ||
from tempfile import mkdtemp | ||
|
||
from nucliadb_protos.nodereader_pb2 import SearchRequest, SearchResponse | ||
from nucliadb_protos.noderesources_pb2 import Resource | ||
from nucliadb_protos.nodewriter_pb2 import ShardCreated, NewShardRequest | ||
from nucliadb_protos.utils_pb2 import VectorSimilarity | ||
from nucliadb_protos.nodewriter_pb2 import OpStatus | ||
|
||
from nucliadb_node_binding import NodeReader, NodeWriter | ||
|
||
|
||
@contextmanager | ||
def temp_data_path(): | ||
if "DATA_PATH" in os.environ: | ||
saved_path = os.environ["DATA_PATH"] | ||
else: | ||
saved_path = None | ||
|
||
dir = mkdtemp() | ||
try: | ||
os.environ["DATA_PATH"] = dir | ||
yield | ||
finally: | ||
shutil.rmtree(dir) | ||
if saved_path is not None: | ||
os.environ["DATA_PATH"] = saved_path | ||
else: | ||
del os.environ["DATA_PATH"] | ||
|
||
|
||
# TODO improve coverage (see what nucliadb/common/cluster/standalone/grpc_node_binding.py does) | ||
async def main(): | ||
with temp_data_path(): | ||
writer = NodeWriter() | ||
reader = NodeReader() | ||
req = NewShardRequest(kbid="test-kbid", similarity=VectorSimilarity.COSINE) | ||
|
||
req = req.SerializeToString() | ||
shard = writer.new_shard(req) | ||
|
||
pb = ShardCreated() | ||
pb.ParseFromString(bytes(shard)) | ||
assert pb.id is not None | ||
|
||
resourcepb = Resource() | ||
resourcepb.resource.uuid = "001" | ||
resourcepb.resource.shard_id = pb.id | ||
resourcepb.texts["field1"].text = "My lovely text" | ||
resourcepb.status = Resource.ResourceStatus.PROCESSED | ||
resourcepb.shard_id = pb.id | ||
resourcepb.metadata.created.FromDatetime(datetime.now()) | ||
resourcepb.metadata.modified.FromDatetime(datetime.now()) | ||
|
||
pb_bytes = writer.set_resource(resourcepb.SerializeToString()) | ||
op_status = OpStatus() | ||
op_status.ParseFromString(bytes(pb_bytes)) | ||
assert op_status.status == OpStatus.OK | ||
|
||
searchpb = SearchRequest() | ||
searchpb.shard = pb.id | ||
searchpb.body = "text" | ||
pbresult = reader.search(searchpb.SerializeToString()) | ||
pb = SearchResponse() | ||
pb.ParseFromString(bytes(pbresult)) | ||
|
||
print(pb) | ||
|
||
|
||
asyncio.run(main()) |
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
765557c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
nucliadb/search/tests/unit/search/test_fetch.py::test_highligh_error
5831.997799741431
iter/sec (stddev: 0.0000014789463488094966
)5804.479338298567
iter/sec (stddev: 1.4505330313876097e-7
)1.00
This comment was automatically generated by workflow using github-action-benchmark.
765557c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
nucliadb/tests/benchmarks/test_search.py::test_search_returns_labels
58.3817214149345
iter/sec (stddev: 0.0012175762722159737
)60.779932309336715
iter/sec (stddev: 0.0019119907918232523
)1.04
nucliadb/tests/benchmarks/test_search.py::test_search_relations
133.65791518802646
iter/sec (stddev: 0.00029830463232722936
)182.57436721258293
iter/sec (stddev: 0.0002220745559283828
)1.37
This comment was automatically generated by workflow using github-action-benchmark.