Skip to content

Commit

Permalink
Merge pull request #6453 from RasaHQ/remove-deprecation-warnings
Browse files Browse the repository at this point in the history
Cleanup deprecation warnings
  • Loading branch information
rasabot authored Aug 26, 2020
2 parents 9571963 + f04ec88 commit dbd3e94
Show file tree
Hide file tree
Showing 36 changed files with 316 additions and 379 deletions.
34 changes: 34 additions & 0 deletions changelog/6453.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Removed support for `queue` argument in `PikaEventBroker` (use `queues` instead).

Domain file:
- Removed support for `templates` key (use `responses` instead).
- Removed support for string `responses` (use dictionaries instead).

NLU `Component`:
- Removed support for `provides` attribute, it's not needed anymore.
- Removed support for `requires` attribute (use `required_components()` instead).

Removed `_guess_format()` utils method from `rasa.nlu.training_data.loading` (use `guess_format` instead).

Removed several config options for [TED Policy](./policies#ted-policy), [DIETClassifier](./components/intent-classifiers#dietclassifier) and [ResponseSelector](./components/selectors#responseselector):
- `hidden_layers_sizes_pre_dial`
- `hidden_layers_sizes_bot`
- `droprate`
- `droprate_a`
- `droprate_b`
- `hidden_layers_sizes_a`
- `hidden_layers_sizes_b`
- `num_transformer_layers`
- `num_heads`
- `dense_dim`
- `embed_dim`
- `num_neg`
- `mu_pos`
- `mu_neg`
- `use_max_sim_neg`
- `C2`
- `C_emb`
- `evaluate_every_num_epochs`
- `evaluate_on_num_examples`

Please check the documentation for more information.
26 changes: 0 additions & 26 deletions data/test_domains/default_deprecated_templates.yml

This file was deleted.

6 changes: 3 additions & 3 deletions data/test_domains/default_unfeaturized_entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ entities:

responses:
utter_greet:
- hey there!
- text: hey there!
utter_goodbye:
- goodbye :(
- text: goodbye :(
utter_default:
- default message
- text: default message
25 changes: 25 additions & 0 deletions data/test_domains/empty_response_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
intents:
- greet
- default
- goodbye

slots:
cuisine:
type: text
location:
type: text

entities:
- name

responses:
utter_greet:
utter_goodbye:
- text: goodbye :(
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
26 changes: 26 additions & 0 deletions data/test_domains/wrong_custom_response_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
intents:
- greet
- default
- goodbye

slots:
cuisine:
type: text
location:
type: text

entities:
- name

responses:
utter_greet:
- super: cool
utter_goodbye:
- text: goodbye :(
utter_default:
- text: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
26 changes: 26 additions & 0 deletions data/test_domains/wrong_response_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
intents:
- greet
- default
- goodbye

slots:
cuisine:
type: text
location:
type: text

entities:
- name

responses:
utter_greet:
- hey there!
utter_goodbye:
- goodbye :(
utter_default:
- stuff: default message

actions:
- utter_default
- utter_greet
- utter_goodbye
2 changes: 0 additions & 2 deletions docs/docs/policies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ in your policy configuration. The functionality of the policy stayed the same.

:::

<a aria-hidden="true" tabIndex="-1" className="anchor enhancedAnchor" id="ted-policy"></a>

## TED Policy

The Transformer Embedding Dialogue (TED) Policy is described in
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repository = "https://github.com/rasahq/rasa"
documentation = "https://rasa.com/docs"
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", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Libraries",]
keywords = [ "nlp", "machine-learning", "machine-learning-library", "bot", "bots", "botkit", "rasa conversational-agents", "conversational-ai", "chatbot", "chatbot-framework", "bot-framework",]
include = [ "LICENSE.txt", "README.md", "rasa/core/schemas/*", "rasa/core/training/visualization.html", "rasa/nlu/schemas/*", "rasa/cli/default_config.yml", "rasa/importers/*",]
include = [ "LICENSE.txt", "README.md", "rasa/core/schemas/*", "rasa/core/training/visualization.html", "rasa/nlu/schemas/*", "rasa/cli/default_config.yml", "rasa/importers/*", "rasa/utils/schemas.yml",]
readme = "README.md"
license = "Apache-2.0"
[[tool.poetry.source]]
Expand Down
4 changes: 4 additions & 0 deletions rasa/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

CONFIG_SCHEMA_FILE = "nlu/schemas/config.yml"
DOMAIN_SCHEMA_FILE = "core/schemas/domain.yml"
SCHEMA_UTILS_FILE = "utils/schemas.yml"
SCHEMA_EXTENSIONS_FILE = "utils/pykwalify_extensions.py"
YAML_VERSION = (1, 2)

DEFAULT_RASA_X_PORT = 5002
Expand Down Expand Up @@ -62,6 +64,8 @@

MINIMUM_COMPATIBLE_VERSION = "1.11.0a3"

NEXT_MAJOR_VERSION_FOR_DEPRECATIONS = "3.0.0"

LATEST_TRAINING_DATA_FORMAT_VERSION = "2.0"

GLOBAL_USER_CONFIG_PATH = os.path.expanduser("~/.config/rasa/global.yml")
Expand Down
29 changes: 5 additions & 24 deletions rasa/core/brokers/pika.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def __init__(
self.password = password
self.port = port
self.channel: Optional["Channel"] = None
self.queues = self._get_queues_from_args(queues, kwargs)
self.queues = self._get_queues_from_args(queues)
self.should_keep_unpublished_messages = should_keep_unpublished_messages
self.raise_on_failure = raise_on_failure

Expand All @@ -315,37 +315,24 @@ def rasa_environment(self) -> Optional[Text]:

@staticmethod
def _get_queues_from_args(
queues_arg: Union[List[Text], Tuple[Text], Text, None], kwargs: Any
queues_arg: Union[List[Text], Tuple[Text], Text, None]
) -> Union[List[Text], Tuple[Text]]:
"""Get queues for this event broker.
The preferred argument defining the RabbitMQ queues the `PikaEventBroker` should
publish to is `queues` (as of Rasa Open Source version 1.8.2). This function
ensures backwards compatibility with the old `queue` argument. This method
publish to is `queues` (as of Rasa Open Source version 1.8.2). This method
can be removed in the future, and `self.queues` should just receive the value of
the `queues` kwarg in the constructor.
Args:
queues_arg: Value of the supplied `queues` argument.
kwargs: Additional kwargs supplied to the `PikaEventBroker` constructor.
If `queues_arg` is not supplied, the `queue` kwarg will be used instead.
Returns:
Queues this event broker publishes to.
Raises:
`ValueError` if no valid `queue` or `queues` argument was found.
`ValueError` if no valid `queues` argument was found.
"""
queue_arg = kwargs.pop("queue", None)

if queue_arg:
raise_warning(
"Your Pika event broker config contains the deprecated `queue` key. "
"Please use the `queues` key instead.",
FutureWarning,
docs=DOCS_URL_PIKA_EVENT_BROKER,
)

if queues_arg and isinstance(queues_arg, (list, tuple)):
return queues_arg

Expand All @@ -357,14 +344,8 @@ def _get_queues_from_args(
)
return [queues_arg]

if queue_arg and isinstance(queue_arg, str):
return [queue_arg]

if queue_arg:
return queue_arg # pytype: disable=bad-return-type

raise_warning(
f"No `queues` or `queue` argument provided. It is suggested to "
f"No `queues` argument provided. It is suggested to "
f"explicitly specify a queue as described in "
f"{DOCS_URL_PIKA_EVENT_BROKER}. "
f"Using the default queue '{DEFAULT_QUEUE_NAME}' for now."
Expand Down
5 changes: 2 additions & 3 deletions rasa/core/channels/mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rasa.core.channels.channel import UserMessage, OutputChannel, InputChannel
from sanic.response import HTTPResponse

from rasa.utils.common import raise_warning
from rasa.utils import common as common_utils

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -132,12 +132,11 @@ def from_credentials(cls, credentials: Optional[Dict[Text, Any]]) -> InputChanne

# pytype: disable=attribute-error
if credentials.get("pw") is not None or credentials.get("user") is not None:
raise_warning(
common_utils.raise_deprecation_warning(
"Mattermost recently switched to bot accounts. 'user' and 'pw' "
"should not be used anymore, you should rather convert your "
"account to a bot account and use a token. Password based "
"authentication will be removed in a future Rasa Open Source version.",
FutureWarning,
docs=DOCS_URL_CONNECTORS + "mattermost/",
)
token = MattermostBot.token_from_login(
Expand Down
53 changes: 1 addition & 52 deletions rasa/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,7 @@ def from_yaml(cls, yaml: Text, original_filename: Text = "") -> "Domain":

@classmethod
def from_dict(cls, data: Dict) -> "Domain":
utter_templates = cls.collect_templates(data.get(KEY_RESPONSES, {}))
if "templates" in data:
raise_warning(
"Your domain file contains the key: 'templates'. This has been "
"deprecated and renamed to 'responses'. The 'templates' key will "
"no longer work in future versions of Rasa. Please replace "
"'templates' with 'responses'",
FutureWarning,
docs=DOCS_URL_DOMAINS,
)
utter_templates = cls.collect_templates(data.get("templates", {}))

utter_templates = data.get(KEY_RESPONSES, {})
slots = cls.collect_slots(data.get(KEY_SLOTS, {}))
additional_arguments = data.get("config", {})
session_config = cls._get_session_config(data.get(SESSION_CONFIG_KEY, {}))
Expand Down Expand Up @@ -418,46 +407,6 @@ def _add_default_intents(
_, properties = cls._intent_properties(intent_name, entities)
intent_properties.update(properties)

@staticmethod
def collect_templates(
yml_templates: Dict[Text, List[Any]]
) -> Dict[Text, List[Dict[Text, Any]]]:
"""Go through the templates and make sure they are all in dict format."""
templates = {}
for template_key, template_variations in yml_templates.items():
validated_variations = []
if template_variations is None:
raise InvalidDomain(
"Response '{}' does not have any defined variations.".format(
template_key
)
)

for t in template_variations:

# responses should be a dict with options
if isinstance(t, str):
raise_warning(
f"Responses should not be strings anymore. "
f"Response '{template_key}' should contain "
f"either a '- text: ' or a '- custom: ' "
f"attribute to be a proper response.",
FutureWarning,
docs=DOCS_URL_DOMAINS + "#responses",
)
validated_variations.append({"text": t})
elif "text" not in t and "custom" not in t:
raise InvalidDomain(
f"Response '{template_key}' needs to contain either "
f"'- text: ' or '- custom: ' attribute to be a proper "
f"response."
)
else:
validated_variations.append(t)

templates[template_key] = validated_variations
return templates

def __init__(
self,
intents: Union[Set[Text], List[Union[Text, Dict[Text, Any]]]],
Expand Down
3 changes: 1 addition & 2 deletions rasa/core/policies/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ def __init__(
self.core_threshold = core_threshold
self.fallback_action_name = fallback_action_name

common_utils.raise_warning(
common_utils.raise_deprecation_warning(
f"'{self.__class__.__name__}' is deprecated and will be removed "
"in the future. It is recommended to use the 'RulePolicy' instead.",
category=FutureWarning,
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
3 changes: 1 addition & 2 deletions rasa/core/policies/form_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ def __init__(
featurizer=featurizer, priority=priority, max_history=2, lookup=lookup
)

common_utils.raise_warning(
common_utils.raise_deprecation_warning(
f"'{FormPolicy.__name__}' is deprecated and will be removed in "
"in the future. It is recommended to use the 'RulePolicy' instead.",
category=FutureWarning,
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
3 changes: 1 addition & 2 deletions rasa/core/policies/mapping_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ def __init__(self, priority: int = MAPPING_POLICY_PRIORITY) -> None:

super().__init__(priority=priority)

common_utils.raise_warning(
common_utils.raise_deprecation_warning(
f"'{MappingPolicy.__name__}' is deprecated and will be removed in "
"the future. It is recommended to use the 'RulePolicy' instead.",
category=FutureWarning,
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
5 changes: 3 additions & 2 deletions rasa/core/schemas/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ mapping:
- type: "str"
required: True
responses:
type: "map"
allowempty: True
# see rasa/utils/schemas.yml
include: responses

slots:
type: "map"
allowempty: True
Expand Down
Loading

0 comments on commit dbd3e94

Please sign in to comment.