-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #591 from deeppavlov/dev
Release
- Loading branch information
Showing
161 changed files
with
3,149 additions
and
695 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python test.py | ||
python tests/test.py |
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,46 @@ | ||
import json | ||
|
||
import pytest | ||
|
||
from os import getenv | ||
|
||
INTENT_PHRASES_PATH = getenv("INTENT_PHRASES_PATH") | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--uri", action="store", default="http://0.0.0.0") | ||
parser.addoption("--port", action="store", default="8014") | ||
parser.addoption("--handle", action="store", default="detect") | ||
|
||
|
||
@pytest.fixture | ||
def uri(request) -> str: | ||
return request.config.getoption("--uri") | ||
|
||
|
||
@pytest.fixture | ||
def port(request) -> str: | ||
return request.config.getoption("--port") | ||
|
||
|
||
@pytest.fixture | ||
def handle(request) -> str: | ||
return request.config.getoption("--handle") | ||
|
||
|
||
@pytest.fixture | ||
def url(uri, port, handle) -> str: | ||
return f"{uri}:{port}/{handle}" | ||
|
||
|
||
@pytest.fixture | ||
def tests(): | ||
if "RU" in INTENT_PHRASES_PATH and "commands" in INTENT_PHRASES_PATH: | ||
tests = json.load(open("tests_commands_RU.json")) | ||
elif "RU" in INTENT_PHRASES_PATH: | ||
tests = json.load(open("tests_RU.json")) | ||
elif "commands" in INTENT_PHRASES_PATH: | ||
tests = json.load(open("tests_commands.json")) | ||
else: | ||
tests = json.load(open("tests.json")) | ||
return tests |
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,27 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--uri", action="store", default="http://proxy.deeppavlov.ai") | ||
parser.addoption("--port", action="store", default=8021) | ||
parser.addoption("--handle", action="store", default="/ner") | ||
|
||
|
||
@pytest.fixture | ||
def uri(request) -> str: | ||
return request.config.getoption("--uri") | ||
|
||
|
||
@pytest.fixture | ||
def port(request) -> int: | ||
return request.config.getoption("--port") | ||
|
||
|
||
@pytest.fixture | ||
def handle(request) -> str: | ||
return request.config.getoption("--handle") | ||
|
||
|
||
@pytest.fixture | ||
def url(uri, port, handle) -> str: | ||
return f"{uri}:{port}/{handle}" |
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,41 @@ | ||
import json | ||
|
||
import pytest | ||
|
||
import sys | ||
from os import path | ||
|
||
import requests | ||
|
||
PARENT_DIR = path.dirname(path.dirname(path.abspath(__file__))) | ||
sys.path.append(PARENT_DIR) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"sentences, gold_result", | ||
[ | ||
( | ||
{ | ||
"last_utterances": [ | ||
["john peterson is my brother.", "he lives in New York."], | ||
["my laptop was broken.", "could you show me the nearest store in Moscow where i can fix it."], | ||
] | ||
}, | ||
[ | ||
[ | ||
[{"confidence": 1, "end_pos": 2, "start_pos": 0, "text": "john peterson", "type": "PER"}], | ||
[{"confidence": 1, "end_pos": 5, "start_pos": 3, "text": "New York", "type": "LOC"}], | ||
], | ||
[ | ||
[], | ||
[{"confidence": 1, "end_pos": 9, "start_pos": 8, "text": "Moscow", "type": "LOC"}], | ||
], | ||
], | ||
) | ||
], | ||
) | ||
def test_ner(url: str, sentences: dict, gold_result: list): | ||
response = requests.post(url, json=sentences, headers={"Content-Type": "application/json"}) | ||
result = json.loads(response.text) | ||
assert response.status_code == 200 | ||
assert result == gold_result |
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,20 @@ | ||
FROM deeppavlov/deeppavlov:1.2.0-gpu | ||
|
||
ARG CONFIG | ||
ARG SERVICE_PORT | ||
ARG SRC_DIR | ||
ARG SED_ARG=" | " | ||
|
||
ENV CONFIG=$CONFIG | ||
ENV SERVICE_PORT=$SERVICE_PORT | ||
|
||
COPY ./annotators/NER_deeppavlov/tests/requirements.txt /src/requirements.txt | ||
|
||
RUN pip install --upgrade pip && \ | ||
pip install -r /src/requirements.txt | ||
|
||
COPY $SRC_DIR /src | ||
|
||
WORKDIR /src | ||
|
||
CMD gunicorn --workers=1 --timeout 800 server:app -b 0.0.0.0:8021 |
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,4 @@ | ||
#!/bin/bash | ||
|
||
|
||
python test_server.py | ||
python -m pytest tests/test_server.py |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--uri", action="store", default="http://0.0.0.0") | ||
parser.addoption("--port", action="store", default=8021) | ||
parser.addoption("--handle", action="store", default="/ner") | ||
|
||
|
||
@pytest.fixture | ||
def uri(request) -> str: | ||
return request.config.getoption("--uri") | ||
|
||
|
||
@pytest.fixture | ||
def port(request) -> int: | ||
return request.config.getoption("--port") | ||
|
||
|
||
@pytest.fixture | ||
def handle(request) -> str: | ||
return request.config.getoption("--handle") | ||
|
||
|
||
@pytest.fixture | ||
def url(uri, port, handle) -> str: | ||
return f"{uri}:{port}/{handle}" |
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,11 @@ | ||
sentry-sdk[flask]==0.14.1 | ||
flask==1.1.1 | ||
gunicorn==19.9.0 | ||
itsdangerous==2.0.1 | ||
jinja2<=3.0.3 | ||
Werkzeug<=2.0.3 | ||
transformers==4.6.0 | ||
datasets==1.11.0 | ||
huggingface-hub==0.0.8 | ||
pytest==7.4.2 | ||
allure-pytest==2.13.2 |
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,56 @@ | ||
import allure | ||
import pytest | ||
import requests | ||
|
||
|
||
@allure.description("""Test NER""") | ||
@pytest.mark.parametrize( | ||
"request_data, gold_results", | ||
[ | ||
( | ||
{ | ||
"last_utterances": [ | ||
["я видела ивана в москве"], | ||
["Я видела Ивана в Москве"], | ||
["i have heard about justin. he is in sahara desert"], | ||
["I have heard about Justin. He is in Sahara Desert"], | ||
[ | ||
"can john smith move forward for 15 meters, then for \ | ||
fifteen meters, and get back to las vegas then" | ||
], | ||
["я бы проехала на 30 метров вперед, а потом повернула на сорок пять градусов по часовой стрелке"], | ||
[""], | ||
] | ||
}, | ||
[ | ||
[[]], | ||
[[]], | ||
[ | ||
[ | ||
{"start_pos": 4, "end_pos": 5, "type": "PER", "text": "justin", "confidence": 1}, | ||
{"start_pos": 9, "end_pos": 11, "type": "LOC", "text": "sahara desert", "confidence": 1}, | ||
] | ||
], | ||
[ | ||
[ | ||
{"start_pos": 4, "end_pos": 5, "type": "PER", "text": "Justin", "confidence": 1}, | ||
{"start_pos": 9, "end_pos": 11, "type": "LOC", "text": "Sahara Desert", "confidence": 1}, | ||
] | ||
], | ||
[ | ||
[ | ||
{"start_pos": 1, "end_pos": 3, "type": "PER", "text": "john smith", "confidence": 1}, | ||
{"start_pos": 6, "end_pos": 8, "type": "QUANTITY", "text": "15 meters", "confidence": 1}, | ||
{"start_pos": 11, "end_pos": 13, "type": "QUANTITY", "text": "fifteen meters", "confidence": 1}, | ||
{"start_pos": 18, "end_pos": 20, "type": "LOC", "text": "las vegas", "confidence": 1}, | ||
] | ||
], | ||
[[]], | ||
[[]], | ||
], | ||
) | ||
], | ||
) | ||
def test_ner(url: str, request_data: dict, gold_results: list): | ||
result = requests.post(url, json=request_data).json() | ||
assert result == gold_results |
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,28 @@ | ||
FROM python:3.7-slim | ||
|
||
ARG DATA_URL=files.deeppavlov.ai/alexaprize_data/sentseg/elmo2.tar.gz | ||
ARG MODEL_META_URL=files.deeppavlov.ai/alexaprize_data/sentseg/model.meta | ||
ARG MODEL_DATA_URL=files.deeppavlov.ai/alexaprize_data/sentseg/model.data-00000-of-00001 | ||
|
||
WORKDIR /src | ||
RUN mkdir /data /elmo2 tfhub_cache_dir | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y curl && \ | ||
curl -L $DATA_URL --output /tmp/elmo2.tar.gz && \ | ||
tar -xf /tmp/elmo2.tar.gz -C /elmo2 && \ | ||
rm /tmp/elmo2.tar.gz && \ | ||
curl -L $MODEL_META_URL --output /data/model.meta && \ | ||
curl -L $MODEL_DATA_URL --output /data/model.data-00000-of-00001 | ||
|
||
ENV TFHUB_CACHE_DIR tfhub_cache_dir | ||
|
||
COPY tests/requirements.txt . | ||
RUN pip install --upgrade pip && \ | ||
pip install -r requirements.txt && \ | ||
python -c "import nltk; nltk.download('punkt')" | ||
|
||
COPY . . | ||
COPY model.index /data/ | ||
|
||
CMD gunicorn --workers=1 server:app |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python test.py | ||
python -m pytest tests/test.py |
Oops, something went wrong.