Skip to content

Commit 30e6196

Browse files
committedFeb 26, 2020
Poetry for Rasa
1 parent 7229a3e commit 30e6196

9 files changed

+242
-385
lines changed
 

‎Dockerfile

+53-69
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,60 @@
1-
# Create common base stage
2-
FROM python:3.6-slim as base
3-
4-
WORKDIR /build
5-
6-
# Create virtualenv to isolate builds
7-
RUN python -m venv /build
8-
9-
# Install common libraries
10-
RUN apt-get update -qq \
11-
&& apt-get install -y --no-install-recommends \
12-
# required by psycopg2 at build and runtime
13-
libpq-dev \
14-
# required for health check
15-
curl \
16-
&& apt-get autoremove -y
17-
18-
# Make sure we use the virtualenv
19-
ENV PATH="/build/bin:$PATH"
20-
21-
# Stage to build and install everything
22-
FROM base as builder
23-
24-
WORKDIR /src
25-
26-
# Install all required build libraries
27-
RUN apt-get update -qq \
28-
&& apt-get install -y --no-install-recommends \
29-
build-essential \
30-
wget \
31-
openssh-client \
32-
graphviz-dev \
33-
pkg-config \
34-
git-core \
35-
openssl \
36-
libssl-dev \
37-
libffi6 \
38-
libffi-dev \
39-
libpng-dev
40-
41-
# Copy only what we really need
42-
COPY README.md .
43-
COPY setup.py .
44-
COPY setup.cfg .
45-
COPY MANIFEST.in .
46-
COPY requirements.txt .
47-
COPY LICENSE.txt .
48-
49-
# Install dependencies
50-
RUN pip install -U pip && pip install --no-cache-dir -r requirements.txt
51-
52-
# Install Rasa as package
53-
COPY rasa ./rasa
54-
RUN pip install .[sql]
55-
56-
# Runtime stage which uses the virtualenv which we built in the previous stage
57-
FROM base AS runner
58-
59-
# Copy virtualenv from previous stage
60-
COPY --from=builder /build /build
61-
62-
WORKDIR /app
1+
FROM python:3.6-slim as python_builder
2+
RUN apt-get update -qq && \
3+
apt-get install -y --no-install-recommends \
4+
build-essential \
5+
wget \
6+
openssh-client \
7+
graphviz-dev \
8+
pkg-config \
9+
git-core \
10+
openssl \
11+
libssl-dev \
12+
libffi6 \
13+
libffi-dev \
14+
libpng-dev \
15+
# required by psycopg2 at build and runtime
16+
libpq-dev \
17+
curl
18+
19+
# install poetry
20+
ENV POETRY_VERSION 1.0.3
21+
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
22+
ENV PATH "/root/.poetry/bin:/opt/venv/bin:${PATH}"
23+
24+
# install dependencies
25+
COPY README.md poetry.lock pyproject.toml setup.cfg /opt/rasa/
26+
RUN python -m venv /opt/venv && \
27+
. /opt/venv/bin/activate && \
28+
pip install -U pip && \
29+
cd /opt/rasa && \
30+
poetry install --no-dev --no-interaction
31+
32+
# build and install rasa
33+
COPY rasa /opt/rasa/rasa
34+
RUN ls /opt/rasa
35+
RUN ls /opt/rasa/rasa
36+
RUN . /opt/venv/bin/activate && \
37+
cd /opt/rasa && \
38+
poetry install --no-dev --no-interaction
39+
40+
# start a new build stage
41+
FROM python:3.6-slim
42+
43+
# copy everything from /opt
44+
COPY --from=python_builder /opt /opt
45+
ENV PATH="/opt/venv/bin:$PATH"
46+
47+
# change user
48+
RUN chgrp -R 0 /opt/rasa && chmod -R g=u /opt/rasa
49+
USER 1001
6350

6451
# Create a volume for temporary data
6552
VOLUME /tmp
6653

67-
# Make sure the default group has the same permissions as the owner
68-
RUN chgrp -R 0 . && chmod -R g=u .
69-
70-
# Don't run as root
71-
USER 1001
54+
# change shell
55+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7256

57+
# the entry point
7358
EXPOSE 5005
74-
7559
ENTRYPOINT ["rasa"]
76-
CMD ["--help"]
60+
CMD ["--help"]

‎MANIFEST.in

-5
This file was deleted.

‎pyproject.toml

+161-51
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,164 @@
11
[tool.black]
2-
line-length = 88
3-
target-version = ['py36', 'py37']
4-
exclude = '''
5-
(
6-
/(
7-
\.eggs
8-
| \.git
9-
| \.pytype
10-
| \.pytest_cache
11-
| build
12-
| dist
13-
)/
14-
)
15-
'''
2+
line-length = 88
3+
target-version = [ "py36", "py37",]
4+
exclude = "((.eggs | .git | .pytype | .pytest_cache | build | dist))"
5+
6+
[tool.poetry]
7+
name = "rasa"
8+
version = "1.7.0"
9+
description = "Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants"
10+
authors = [ "Rasa Technologies GmbH <hi@rasa.com>",]
11+
maintainers = [ "Tom Bocklisch <tom@rasa.com>",]
12+
homepage = "https://rasa.com"
13+
repository = "https://github.com/rasahq/rasa"
14+
documentation = "https://rasa.com/docs"
15+
classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries",]
16+
keywords = [ "nlp", "machine-learning", "machine-learning-library", "bot", "bots", "botkit", "rasa conversational-agents", "conversational-ai", "chatbot", "chatbot-framework", "bot-framework",]
17+
include = [ "LICENSE.txt", "README.md", "rasa/core/schemas/*", "rasa/core/training/visualization.html", "rasa/nlu/schemas/*", "rasa/cli/default_config.yml",]
18+
readme = "README.md"
19+
license = "Apache-2.0"
1620

1721
[tool.towncrier]
18-
package = "rasa"
19-
package_dir = "rasa"
20-
filename = "CHANGELOG.rst"
21-
directory = "./changelog"
22-
underlines = "^-_"
23-
title_format = "[{version}] - {project_date}"
24-
template = "./changelog/_template.jinja2"
25-
26-
[[tool.towncrier.type]]
27-
directory = "removal"
28-
name = "Deprecations and Removals"
29-
showcontent = true
30-
31-
[[tool.towncrier.type]]
32-
directory = "feature"
33-
name = "Features"
34-
showcontent = true
35-
36-
[[tool.towncrier.type]]
37-
directory = "improvement"
38-
name = "Improvements"
39-
showcontent = true
40-
41-
[[tool.towncrier.type]]
42-
directory = "bugfix"
43-
name = "Bugfixes"
44-
showcontent = true
45-
46-
[[tool.towncrier.type]]
47-
directory = "doc"
48-
name = "Improved Documentation"
49-
showcontent = true
50-
51-
[[tool.towncrier.type]]
52-
directory = "misc"
53-
name = "Miscellaneous internal changes"
54-
showcontent = false
22+
package = "rasa"
23+
package_dir = "rasa"
24+
filename = "CHANGELOG.rst"
25+
directory = "./changelog"
26+
underlines = "^-_"
27+
title_format = "[{version}] - {project_date}"
28+
template = "./changelog/_template.jinja2"
29+
[[tool.towncrier.type]]
30+
directory = "removal"
31+
name = "Deprecations and Removals"
32+
showcontent = true
33+
34+
[[tool.towncrier.type]]
35+
directory = "feature"
36+
name = "Features"
37+
showcontent = true
38+
39+
[[tool.towncrier.type]]
40+
directory = "improvement"
41+
name = "Improvements"
42+
showcontent = true
43+
44+
[[tool.towncrier.type]]
45+
directory = "bugfix"
46+
name = "Bugfixes"
47+
showcontent = true
48+
49+
[[tool.towncrier.type]]
50+
directory = "doc"
51+
name = "Improved Documentation"
52+
showcontent = true
53+
54+
[[tool.towncrier.type]]
55+
directory = "misc"
56+
name = "Miscellaneous internal changes"
57+
showcontent = false
58+
59+
[tool.poetry.dependencies]
60+
python = "^3.6"
61+
boto3 = "==1.9.146"
62+
requests = "==2.22.0"
63+
matplotlib = "==3.0.3"
64+
attrs = "==19.1.0"
65+
jsonpickle = "==1.1"
66+
redis = "==3.3.5"
67+
numpy = "==1.16.3"
68+
scipy = "==1.4.1"
69+
absl-py = ">=0.8.0"
70+
setuptools = "^45.1.0"
71+
tensor2tensor = "==1.14.0"
72+
apscheduler = "==3.6.0"
73+
tqdm = "==4.31.0"
74+
networkx = "==2.4.0"
75+
fbmessenger = "==6.0.0"
76+
pykwalify = "==1.7.0"
77+
coloredlogs = "==10.0"
78+
"ruamel.yaml" = "^0.15"
79+
scikit-learn = "==0.20.2"
80+
slackclient = "==1.3.1"
81+
python-telegram-bot = "==11.1.0"
82+
twilio = "==6.26.3"
83+
webexteamssdk = "==1.1.1"
84+
mattermostwrapper = "==2.1"
85+
rocketchat_API = "==0.6.31"
86+
colorhash = "==1.0.2"
87+
pika = "==1.0.1"
88+
jsonschema = "==3.0.2"
89+
packaging = "==19.0"
90+
gevent = "==1.4.0"
91+
pytz = "==2019.1"
92+
colorclass = "==2.2.0"
93+
terminaltables = "==3.1.0"
94+
sanic = "==19.9.0"
95+
sanic-cors = "==0.9.9.post1"
96+
sanic-jwt = "==1.3.2"
97+
sanic-plugins-framework = "==0.8.2"
98+
multidict = "==4.6.1"
99+
aiohttp = "==3.5.4"
100+
questionary = "==1.1.1"
101+
prompt-toolkit = "==2.0.10"
102+
python-socketio = "==4.3.1"
103+
python-engineio = "==3.9.3"
104+
pydot = "==1.4.1"
105+
async_generator = "==1.10"
106+
SQLAlchemy = "==1.3.3"
107+
kafka-python = "==1.4.7"
108+
sklearn-crfsuite = "==0.3.6"
109+
psycopg2-binary = "==2.8.2"
110+
PyJWT = "==1.7.1"
111+
python-dateutil = "==2.8.0"
112+
tensorflow = "==2.1.0"
113+
tensorflow_hub = "==0.7.0"
114+
tensorflow-addons = "==0.7.0"
115+
tensorflow-probability = "==0.7.0"
116+
117+
[tool.poetry.dev-dependencies]
118+
pytest-cov = "^2.8.1"
119+
pytest-localserver = "^0.5.0"
120+
pytest-sanic = "^1.1.2"
121+
pytest-asyncio = "^0.10.0"
122+
pytest-xdist = "^1.31.0"
123+
pytest = "^5.3.4"
124+
freezegun = "^0.3.14"
125+
responses = "^0.10.9"
126+
nbsphinx = "==0.3.2"
127+
aioresponses = "^0.6.2"
128+
moto = "==1.3.8"
129+
fakeredis = "^1.1.0"
130+
mongomock = "^3.18.0"
131+
black = "^19.10b0"
132+
flake8 = "^3.7.9"
133+
pytype = "^2020.1.24"
134+
google-cloud-storage = "^1.25.0"
135+
azure-storage-blob = "^12.1.0"
136+
coveralls = "^1.10.0"
137+
towncrier = "^19.2.0"
138+
toml = "^0.10.0"
139+
semantic_version = "^2.8.4"
140+
sphinx = "==1.8.2"
141+
sphinx-autobuild = "==0.7.1"
142+
sphinxcontrib-programoutput = "==0.11"
143+
pygments = "==2.2.0"
144+
sphinxcontrib-httpdomain = "==1.6.1"
145+
sphinxcontrib-websupport = "==1.1.0"
146+
sphinxcontrib-trio = "==1.0.2"
147+
sphinx-tabs = "==1.1.11"
148+
sphinx-autodoc-typehints = "==1.6.0"
149+
150+
[tool.poetry.scripts]
151+
rasa = "rasa.__main__:main"
152+
153+
[tool.poetry.dependencies.pymongo]
154+
version = "==3.8.0"
155+
extras = [ "tls", "srv",]
156+
157+
[tool.poetry.dev-dependencies.rasabaster]
158+
url = "https://storage.googleapis.com/docs-theme/rasabaster-0.7.23.tar.gz"
159+
160+
[tool.poetry.dev-dependencies.sphinxcontrib-versioning]
161+
git = "https://github.com/RasaHQ/sphinxcontrib-versioning.git"
162+
163+
[tool.poetry.dev-dependencies.sphinx_rtd_theme]
164+
git = "https://github.com/RasaHQ/sphinx_rtd_theme.git"

‎requirements-dev.txt

-34
This file was deleted.

‎requirements-docs.txt

-13
This file was deleted.

‎requirements.txt

-63
This file was deleted.

‎scripts/release.py

+28
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
VERSION_FILE_PATH = "rasa/version.py"
2020

21+
PYPROJECT_FILE_PATH = "pyproject.toml"
22+
2123
REPO_BASE_URL = "https://github.com/RasaHQ/rasa"
2224

2325
RELEASE_BRANCH_PREFIX = "prepare-release-"
@@ -46,6 +48,11 @@ def version_file_path() -> Path:
4648
return project_root() / VERSION_FILE_PATH
4749

4850

51+
def pyproject_file_path() -> Path:
52+
"""Path to the pyproject.toml."""
53+
return project_root() / PYPROJECT_FILE_PATH
54+
55+
4956
def write_version_file(version: Text) -> None:
5057
"""Dump a new version into the python version file."""
5158

@@ -58,6 +65,26 @@ def write_version_file(version: Text) -> None:
5865
check_call(["git", "add", str(version_file_path().absolute())])
5966

6067

68+
def write_version_to_pyproject(version: Text) -> None:
69+
"""Dump a new version into the pyproject.toml."""
70+
71+
import toml
72+
73+
pyproject_file = pyproject_file_path()
74+
75+
try:
76+
data = toml.load(pyproject_file)
77+
data['tool']['poetry']['version'] = version
78+
with pyproject_file.open("w") as f:
79+
toml.dump(data, f)
80+
except (FileNotFoundError, TypeError):
81+
print(f"Unable to update {pyproject_file}: file not found.")
82+
sys.exit(1)
83+
except toml.TomlDecodeError:
84+
print(f"Unable to parse {pyproject_file}: incorrect TOML file.")
85+
sys.exit(1)
86+
87+
6188
def get_current_version() -> Text:
6289
"""Return the current library version."""
6390

@@ -249,6 +276,7 @@ def main(args: argparse.Namespace) -> None:
249276
validate_code_is_release_ready(version)
250277

251278
write_version_file(version)
279+
write_version_to_pyproject(version)
252280

253281
generate_changelog(version)
254282
base = git_current_branch()

‎setup.cfg

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ filterwarnings =
1818
log_cli = true
1919
log_cli_level = WARNING
2020

21-
[metadata]
22-
description-file = README.md
23-
license_file = LICENSE.txt
24-
2521
[flake8]
2622
max-line-length = 88
2723
ignore = W503, E121, E126, E211, E225, E501, E203, E402, F401, F811, E231

‎setup.py

-146
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.