Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Reverted new file addition, added another make test cmd
Browse files Browse the repository at this point in the history
This reverts commit ef0a2f3.
  • Loading branch information
Maneesh Tewani committed Aug 7, 2018
1 parent 72baf4d commit 56134e1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 22 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test_prepare: test_requirements.txt $(ACTIVATE)

test: test_prepare $(ACTIVATE) dev
@. $(ACTIVATE); spacy download en
@. $(ACTIVATE); python -c 'from nlp_architect.api.ner_api import NerApi; NerApi(prompt=False)'
@. $(ACTIVATE); py.test -rs -vv tests

flake: test_prepare
Expand Down
4 changes: 1 addition & 3 deletions doc/source/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ The server code is split into two pieces:
1. :py:class:`Service <server.service>` which is a representation of each model's API
2. :py:mod:`Server <server.serve>` which handles processing of HTTP requests

To run the server, from the root directory simply run ``hug -p 8080 --fetch -f server/serve.py``, the server will run on `http://localhost:8080`.
Note: the ``--fetch`` allows you to prefetch the models, requiring you to respond to the prompt for each model.

To run the server, from the root directory simply run ``hug -p 8080 -f server/serve.py``, the server will run on `http://localhost:8080`.

If you wish to use the server's visualization - enter `http://localhost:8080`

Expand Down
4 changes: 2 additions & 2 deletions nlp_architect/api/ner_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class NerApi(AbstractApi):
pretrained_model = path.join(dir, 'ner-pretrained', 'model.h5')
pretrained_model_info = path.join(dir, 'ner-pretrained', 'model_info.dat')

def __init__(self, prompt=True):
def __init__(self, ner_model=None, prompt=True):
self.model = None
self.model_info = None
self.model_path = NerApi.pretrained_model
Expand Down Expand Up @@ -81,7 +81,7 @@ def _prompt(self):
def _download_pretrained_model(self, prompt=True):
"""Downloads the pre-trained BIST model if non-existent."""
dir_path = path.join(self.dir, 'ner-pretrained')
if not path.isfile(self.model_path) or not path.isfile(self.model_info_path):
if not path.isfile(path.join(dir_path, 'model.h5')):
print('The pre-trained models to be downloaded for the NER dataset'
'are licensed under Apache 2.0. By downloading, you accept the terms'
'and conditions provided by the license')
Expand Down
9 changes: 1 addition & 8 deletions server/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@
import json
from falcon import status_codes
from server.service import format_response
from argparse import ArgumentParser
from server.service import Service, parse_headers
services = {}

parser = ArgumentParser()
parser.add_argument('--fetch', action='store_true')
args = parser.parse_known_args()
prefetch_val = args[0].fetch

api = hug.API(__name__)


Expand Down Expand Up @@ -84,5 +78,4 @@ def static():
return [os.path.realpath(os.path.join('./', 'server/web_service/static'))]


if prefetch_val is True:
prefetchModels()
prefetchModels()
5 changes: 0 additions & 5 deletions tests/download_ner.py

This file was deleted.

6 changes: 2 additions & 4 deletions tests/test_server_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import os
from os.path import dirname
import pytest
from tests.download_ner import download
import server.serve
from nlp_architect.utils.text import is_spacy_model_installed
from server.serve import api
if not is_spacy_model_installed('en'):
Expand All @@ -40,8 +40,6 @@
"IS-HTML": "False"}
server_data_rel_path = 'fixtures/data/server/'

download()


def load_test_data(service_name):
"""
Expand Down Expand Up @@ -153,7 +151,7 @@ def test_json_file_request(service_name):
myHeaders = headers.copy()
myHeaders["Content-Type"] = "application/json"
myHeaders["RESPONSE-FORMAT"] = "json"
response = hug.test.post(api, '/inference', body=doc, headers=myHeaders)
response = hug.test.post(server.serve, '/inference', body=doc, headers=myHeaders)
assert_response_struct(response.data, json.loads(expected_result))
assert response.status == hug.HTTP_OK

Expand Down

0 comments on commit 56134e1

Please sign in to comment.