Skip to content

Commit

Permalink
Merge pull request RasaHQ#1641 from RasaHQ/py3-only
Browse files Browse the repository at this point in the history
remove python 2 support
  • Loading branch information
tmbo authored Jan 23, 2019
2 parents 6966025 + c581b58 commit c525081
Show file tree
Hide file tree
Showing 83 changed files with 131 additions and 507 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ cache:
- $HOME/.cache/pip
- /tmp/cached/
python:
- '2.7'
- '3.5'
- '3.6'
env:
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Change Log
All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning`_ starting with version 0.7.0.

[Unreleased 0.15.0.aX] - `master`_
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Added
-----

Changed
-------

Removed
-------
- **removed python 2.7 support**

Fixed
-----

.. _v0-14-0:

[0.14.1] - 2018-01-23
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Rasa NLU
[![Join the forum at https://forum.rasa.com](https://img.shields.io/badge/forum-join%20discussions-brightgreen.svg)](https://forum.rasa.com/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![PyPI version](https://badge.fury.io/py/rasa-nlu.svg)](https://badge.fury.io/py/rasa-nlu)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/rasa_nlu.svg)](https://pypi.python.org/pypi/rasa_nlu)
[![Build Status](https://travis-ci.com/RasaHQ/rasa_nlu.svg?branch=master)](https://travis-ci.com/RasaHQ/rasa_nlu)
[![Coverage Status](https://coveralls.io/repos/github/RasaHQ/rasa_nlu/badge.svg?branch=master)](https://coveralls.io/github/RasaHQ/rasa_nlu?branch=master)
[![PyPI version](https://badge.fury.io/py/rasa-nlu.svg)](https://badge.fury.io/py/rasa-nlu)
[![Documentation Status](https://img.shields.io/badge/docs-stable-brightgreen.svg)](https://nlu.rasa.com/)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FRasaHQ%2Frasa_nlu.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FRasaHQ%2Frasa_nlu?ref=badge_shield)

Expand Down Expand Up @@ -39,6 +40,13 @@ If you are new to Rasa NLU and want to create a bot, you should start with the [

- **I would like to contribute 🤗** [How to contribute](#how-to-contribute)

### Important Note

Current github master version does NOT support python 2.7 anymore (neither
will the next major release). If you want to use Rasa NLU with python
2.7, please install the most recent version from pypi (0.14).


# Quick Install

For the full installation instructions, please head over to the documenation: [Installation](https://nlu.rasa.com/installation.html)
Expand Down
1 change: 0 additions & 1 deletion alt_requirements/requirements_bare.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ klein==17.10.0
hyperlink==17.3.1
typing==3.6.2
future==0.16.0
six==1.11.0
jsonschema==2.6.0
matplotlib==2.1.0
requests==2.20.0
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile_mitie
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2.7-slim
FROM python:3.6-slim

ENV RASA_NLU_DOCKER="YES" \
RASA_NLU_HOME=/app \
Expand Down
58 changes: 40 additions & 18 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,41 @@ Frequently Asked Questions

Which languages does the Rasa NLU support?
------------------------------------------
Rasa NLU can be used to understand any language that can be tokenized (on whitespace or using a custom tokenizer),
Rasa NLU can be used to understand any language that can be
tokenized (on whitespace or using a custom tokenizer),
but some backends are restricted to specific languages.

The ``tensorflow_embedding`` pipeline can be used for any language because it trains custom word embeddings for your domain using the data you provide in the NLU training examples.
The ``tensorflow_embedding`` pipeline can be used for any language
because it trains custom word embeddings for your domain using the
data you provide in the NLU training examples.

Other backends use pre-trained word vectors and therefore are restricted to languages which have pre-trained
vectors available.
Other backends use pre-trained word vectors and therefore are
restricted to languages which have pre-trained vectors available.

You can read more about the Rasa NLU supported languages in :ref:`section_languages`.
You can read more about the Rasa NLU supported languages in
:ref:`section_languages`.


How many training examples do I need?
-------------------------------------
Unfortunately, the answer is *it depends*.

A good starting point is to have 10 examples for each intent and build up from there.
A good starting point is to have 10 examples for each intent
and build up from there.

If you have intents that are easily confusable, you will need more training data. Accordingly, as you add more
intents, you also want to add more training examples for each intent. If you quickly write 20-30 unique expressions for
If you have intents that are easily confusable, you will need more
training data. Accordingly, as you add more
intents, you also want to add more training examples for each intent.
If you quickly write 20-30 unique expressions for
each intent, you should be good for the beginning.

The same holds true for entities. the number of training examples you will need depends on how closely related your different entity types are and how clearly
entities are distinguishable from non-entities in your use case.
The same holds true for entities. the number of training examples you
will need depends on how closely related your different entity types
are and how clearly entities are distinguishable from non-entities in
your use case.

To assess your model's performance, use the :ref:`evaluation script <section_evaluation>`.
To assess your model's performance, use the
:ref:`evaluation script <section_evaluation>`.


.. _section_faq_version:
Expand All @@ -43,26 +53,38 @@ To find out which Rasa version you are running, you can execute
python -c "import rasa_nlu; print(rasa_nlu.__version__);"
If you are using a virtual environment to run your python code, make sure you are using the correct python to execute the above code.
If you are using a virtual environment to run your python code, make sure
you are using the correct python to execute the above code.

Why am I getting an ``UndefinedMetricWarning``?
-----------------------------------------------
The complete warning is: ``UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples.``
The warning is a result of a lack of training data. During the training the dataset will be splitted multiple times, if there are to few training samples for any of the intents, the splitting might result in splits that do not contain any examples for this intent.
The complete warning is:
``UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 in labels with no predicted samples.``
The warning is a result of a lack of training data. During the training
the dataset will be splitted multiple times, if there are to few training
samples for any of the intents, the splitting might result in splits that
do not contain any examples for this intent.

Hence, the solution is to add more training samples. As this is only a warning, training will still succeed, but the resulting models predictions might be weak on the intents where you are lacking training data.  
Hence, the solution is to add more training samples. As this is only a
warning, training will still succeed, but the resulting models predictions
might be weak on the intents where you are lacking training data.  


I have an issue, can you help me?
---------------------------------
We'd love to help you. If you are unsure if your issue is related to your setup, you should state your problem in the `Rasa Community Forum <https://forum.rasa.com>`_.
If you found an issue with the framework, please file a report on `github issues <https://github.com/RasaHQ/rasa_nlu/issues>`_
We'd love to help you. If you are unsure if your issue is related to your
setup, you should state your problem in the
`Rasa Community Forum <https://forum.rasa.com>`_.
If you found an issue with the framework, please file a report on
`github issues <https://github.com/RasaHQ/rasa_nlu/issues>`_
including all the information needed to reproduce the problem.


Does it run with python 3?
--------------------------
Yes it does, Rasa NLU supports python 2.7 as well as python 3.5 and 3.6. If there are any issues with a specific python version, feel free to create an issue or directly provide a fix.
Yes it does, Rasa NLU supports python 3.5 and 3.6 (supported for python 2.7
up until version 0.14). If there are any issues with a specific python version,
feel free to create an issue or directly provide a fix.


.. include:: feedback.inc
Expand Down
5 changes: 0 additions & 5 deletions rasa_nlu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

import rasa_nlu.version
Expand Down
5 changes: 0 additions & 5 deletions rasa_nlu/classifiers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

# How many intents are at max put into the output intent
# ranking, everything else will be cut off
INTENT_RANKING_LENGTH = 10
5 changes: 0 additions & 5 deletions rasa_nlu/classifiers/embedding_intent_classifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import io
import copy
import logging
Expand Down
4 changes: 0 additions & 4 deletions rasa_nlu/classifiers/keyword_intent_classifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from builtins import map
from typing import Any
from typing import Dict
Expand Down
5 changes: 0 additions & 5 deletions rasa_nlu/classifiers/mitie_intent_classifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import typing
Expand Down
11 changes: 3 additions & 8 deletions rasa_nlu/classifiers/sklearn_intent_classifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import

import logging
import typing
from builtins import zip
Expand Down Expand Up @@ -124,9 +119,9 @@ def train(self, training_data, cfg, **kwargs):
for e in training_data.intent_examples]

if len(set(labels)) < 2:
logger.warn("Can not train an intent classifier. "
"Need at least 2 different classes. "
"Skipping training of intent classifier.")
logger.warning("Can not train an intent classifier. "
"Need at least 2 different classes. "
"Skipping training of intent classifier.")
else:
y = self.transform_labels_str2num(labels)
X = np.stack([example.get("text_features")
Expand Down
11 changes: 2 additions & 9 deletions rasa_nlu/components.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

import typing
Expand Down Expand Up @@ -43,7 +38,7 @@ def find_unavailable_packages(package_names):


def validate_requirements(component_names):
# type: (List[Text], Text) -> None
# type: (List[Text]) -> None
"""Ensures that all required python packages are installed to
instantiate and used the passed components."""
from rasa_nlu import registry
Expand Down Expand Up @@ -206,7 +201,7 @@ def load(cls,
model_dir=None, # type: Optional[Text]
model_metadata=None, # type: Optional[Metadata]
cached_component=None, # type: Optional[Component]
**kwargs # type: **Any
**kwargs # type: Any
):
# type: (...) -> Component
"""Load this component from file.
Expand Down Expand Up @@ -370,7 +365,6 @@ def __get_cached_component(self, component_name, model_metadata):
Returns the component, if found, and the cache key."""
from rasa_nlu import registry
from rasa_nlu.model import Metadata

component_class = registry.get_component_class(component_name)
cache_key = component_class.cache_key(model_metadata)
Expand Down Expand Up @@ -409,7 +403,6 @@ def load_component(self,
Component: the loaded component.
"""
from rasa_nlu import registry
from rasa_nlu.model import Metadata

try:
cached_component, cache_key = self.__get_cached_component(
Expand Down
13 changes: 4 additions & 9 deletions rasa_nlu/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import copy
import logging
import os

import six
import ruamel.yaml as yaml
from builtins import object
# Describes where to search for the config file if no location is specified
Expand Down Expand Up @@ -118,7 +112,7 @@ def __init__(self, configuration_values=None):
self.override(DEFAULT_CONFIG)
self.override(configuration_values)

if isinstance(self.__dict__['pipeline'], six.string_types):
if isinstance(self.__dict__['pipeline'], str):
from rasa_nlu import registry

template_name = self.__dict__['pipeline']
Expand Down Expand Up @@ -188,8 +182,9 @@ def set_component_attr(self, name, **kwargs):
if c.get("name") == name:
c.update(kwargs)
else:
logger.warn("Tried to set configuration value for component '{}' "
"which is not part of the pipeline.".format(name))
logger.warning("Tried to set configuration value for component "
"'{}' which is not part of the pipeline."
"".format(name))

def override(self, config):
if config:
Expand Down
5 changes: 0 additions & 5 deletions rasa_nlu/convert.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import argparse

from rasa_nlu import training_data
Expand Down
Loading

0 comments on commit c525081

Please sign in to comment.