mirror of https://github.com/gsi-upm/senpy
Deployment changes
* Docker all the things! * Make all the things! * Fixed version.shpull/8/merge
parent
9f6a6f5ecd
commit
ba2e18125c
@ -1 +0,0 @@
|
|||||||
Dockerfile-3.5
|
|
@ -1,21 +0,0 @@
|
|||||||
from python:2.7
|
|
||||||
|
|
||||||
RUN mkdir /cache/
|
|
||||||
ENV PIP_CACHE_DIR=/cache/
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
ADD requirements.txt /usr/src/app/
|
|
||||||
RUN pip install --use-wheel -r requirements.txt
|
|
||||||
ADD . /usr/src/app/
|
|
||||||
RUN pip install .
|
|
||||||
|
|
||||||
|
|
||||||
VOLUME /data/
|
|
||||||
|
|
||||||
RUN mkdir /senpy-plugins/
|
|
||||||
|
|
||||||
WORKDIR /senpy-plugins/
|
|
||||||
ONBUILD ADD . /senpy-plugins/
|
|
||||||
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
|
@ -1,21 +0,0 @@
|
|||||||
from python:3.4
|
|
||||||
|
|
||||||
RUN mkdir /cache/
|
|
||||||
ENV PIP_CACHE_DIR=/cache/
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
ADD requirements.txt /usr/src/app/
|
|
||||||
RUN pip install --use-wheel -r requirements.txt
|
|
||||||
ADD . /usr/src/app/
|
|
||||||
RUN pip install .
|
|
||||||
|
|
||||||
|
|
||||||
VOLUME /data/
|
|
||||||
|
|
||||||
RUN mkdir /senpy-plugins/
|
|
||||||
|
|
||||||
WORKDIR /senpy-plugins/
|
|
||||||
ONBUILD ADD . /senpy-plugins/
|
|
||||||
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
|
@ -1,21 +0,0 @@
|
|||||||
FROM python:3.5
|
|
||||||
|
|
||||||
RUN mkdir /cache/
|
|
||||||
ENV PIP_CACHE_DIR=/cache/
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
ADD requirements.txt /usr/src/app/
|
|
||||||
RUN pip install --use-wheel -r requirements.txt
|
|
||||||
ADD . /usr/src/app/
|
|
||||||
RUN pip install .
|
|
||||||
|
|
||||||
|
|
||||||
VOLUME /data/
|
|
||||||
|
|
||||||
RUN mkdir /senpy-plugins/
|
|
||||||
|
|
||||||
WORKDIR /senpy-plugins/
|
|
||||||
ONBUILD ADD . /senpy-plugins/
|
|
||||||
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
|
@ -1,33 +0,0 @@
|
|||||||
from python:2.7
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get -y install git
|
|
||||||
RUN mkdir -p /senpy-plugins
|
|
||||||
|
|
||||||
RUN apt-get -y install python-numpy
|
|
||||||
RUN apt-get -y install python-scipy
|
|
||||||
RUN apt-get -y install python-sklearn
|
|
||||||
RUN apt-get -y install python-gevent
|
|
||||||
RUN apt-get -y install libopenblas-dev
|
|
||||||
RUN apt-get -y install gfortran
|
|
||||||
RUN apt-get -y install libxml2-dev libxslt1-dev python-dev
|
|
||||||
|
|
||||||
#RUN pip install --upgrade pip
|
|
||||||
|
|
||||||
ADD id_rsa /root/.ssh/id_rsa
|
|
||||||
RUN chmod 700 /root/.ssh/id_rsa
|
|
||||||
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
|
|
||||||
|
|
||||||
RUN git clone https://github.com/gsi-upm/senpy /usr/src/app/
|
|
||||||
RUN git clone git@github.com:gsi-upm/senpy-plugins-enterprise /senpy-plugins/enterprise
|
|
||||||
RUN git clone https://github.com/gsi-upm/senpy-plugins-community /senpy-plugins/community
|
|
||||||
|
|
||||||
RUN pip install /usr/src/app
|
|
||||||
RUN pip install --no-use-wheel -r /senpy-plugins/enterprise/requirements.txt
|
|
||||||
RUN python -m nltk.downloader stopwords
|
|
||||||
RUN python -m nltk.downloader punkt
|
|
||||||
RUN python -m nltk.downloader maxent_treebank_pos_tagger
|
|
||||||
RUN python -m nltk.downloader wordnet
|
|
||||||
|
|
||||||
WORKDIR /senpy-plugins
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", ".", "--host", "0.0.0.0"]
|
|
@ -1,21 +1,22 @@
|
|||||||
from python:{{PYVERSION}}
|
from python:{{PYVERSION}}
|
||||||
|
|
||||||
RUN mkdir /cache/
|
MAINTAINER J. Fernando Sánchez <jf.sanchez@upm.es>
|
||||||
ENV PIP_CACHE_DIR=/cache/
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
ADD requirements.txt /usr/src/app/
|
|
||||||
RUN pip install --use-wheel -r requirements.txt
|
|
||||||
ADD . /usr/src/app/
|
|
||||||
RUN pip install .
|
|
||||||
|
|
||||||
|
RUN mkdir /cache/ /senpy-plugins /data/
|
||||||
|
|
||||||
VOLUME /data/
|
VOLUME /data/
|
||||||
|
|
||||||
RUN mkdir /senpy-plugins/
|
ENV PIP_CACHE_DIR=/cache/
|
||||||
|
|
||||||
WORKDIR /senpy-plugins/
|
ONBUILD COPY . /senpy-plugins/
|
||||||
ONBUILD ADD . /senpy-plugins/
|
|
||||||
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
ONBUILD RUN python -m senpy --only-install -f /senpy-plugins
|
||||||
|
ONBUILD WORKDIR /senpy-plugins/
|
||||||
|
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
COPY test-requirements.txt requirements.txt /usr/src/app/
|
||||||
|
RUN pip install --use-wheel -r test-requirements.txt -r requirements.txt
|
||||||
|
COPY . /usr/src/app/
|
||||||
|
RUN pip install --no-deps --no-index .
|
||||||
|
|
||||||
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
ENTRYPOINT ["python", "-m", "senpy", "-f", "/senpy-plugins/", "--host", "0.0.0.0"]
|
@ -1,3 +1,3 @@
|
|||||||
pytest
|
|
||||||
mock
|
mock
|
||||||
pytest-cov
|
pytest-cov
|
||||||
|
pytest
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
from senpy.api import parse_params, API_PARAMS, NIF_PARAMS, WEB_PARAMS
|
||||||
|
from senpy.models import Error
|
||||||
|
|
||||||
|
|
||||||
|
class APITest(TestCase):
|
||||||
|
|
||||||
|
def test_api_params(self):
|
||||||
|
"""The API should not define any required parameters without a default"""
|
||||||
|
parse_params({}, spec=API_PARAMS)
|
||||||
|
|
||||||
|
def test_web_params(self):
|
||||||
|
"""The WEB should not define any required parameters without a default"""
|
||||||
|
parse_params({}, spec=WEB_PARAMS)
|
||||||
|
|
||||||
|
def test_basic(self):
|
||||||
|
a = {}
|
||||||
|
try:
|
||||||
|
parse_params(a, spec=NIF_PARAMS)
|
||||||
|
raise AssertionError()
|
||||||
|
except Error:
|
||||||
|
pass
|
||||||
|
a = {'input': 'hello'}
|
||||||
|
p = parse_params(a, spec=NIF_PARAMS)
|
||||||
|
assert 'input' in p
|
||||||
|
b = {'i': 'hello'}
|
||||||
|
p = parse_params(b, spec=NIF_PARAMS)
|
||||||
|
assert 'input' in p
|
||||||
|
|
||||||
|
def test_plugin(self):
|
||||||
|
query = {}
|
||||||
|
plug_params = {
|
||||||
|
'hello': {
|
||||||
|
'aliases': ['hello', 'hiya'],
|
||||||
|
'required': True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
parse_params(query, spec=plug_params)
|
||||||
|
raise AssertionError()
|
||||||
|
except Error:
|
||||||
|
pass
|
||||||
|
query['hello'] = 'world'
|
||||||
|
p = parse_params(query, spec=plug_params)
|
||||||
|
assert 'hello' in p
|
||||||
|
assert p['hello'] == 'world'
|
||||||
|
del query['hello']
|
||||||
|
|
||||||
|
query['hiya'] = 'dlrow'
|
||||||
|
p = parse_params(query, spec=plug_params)
|
||||||
|
assert 'hello' in p
|
||||||
|
assert 'hiya' in p
|
||||||
|
assert p['hello'] == 'dlrow'
|
||||||
|
|
||||||
|
def test_default(self):
|
||||||
|
spec = {
|
||||||
|
'hello': {
|
||||||
|
'required': True,
|
||||||
|
'default': 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p = parse_params({}, spec=spec)
|
||||||
|
assert 'hello' in p
|
||||||
|
assert p['hello'] == 1
|
@ -1,2 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
VERSION=$(git describe --long --tags --dirty)
|
|
Loading…
Reference in New Issue