Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup deprecation warnings #6453

Merged
merged 25 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b3ba78f
remove deprecations from 1.x
m-vdb Aug 19, 2020
67de788
raise_deprecation_warning() utils requires warn_until_version
m-vdb Aug 19, 2020
b488e69
remove another deprecation warning in rasa.core.domain
m-vdb Aug 19, 2020
552e122
raise deprecation warning for Mattermost channel until 3.0.0
m-vdb Aug 19, 2020
b42d12e
use raise_deprecation_warning() in tracker_store.py
m-vdb Aug 21, 2020
aebd37a
Merge branch 'master' into remove-deprecation-warnings
m-vdb Aug 21, 2020
9dd4046
use FutureWarning and the correct stacklevel
m-vdb Aug 21, 2020
50477f5
add unit tests + a better comment
m-vdb Aug 21, 2020
ea72154
add changelog fragment for removals
m-vdb Aug 21, 2020
4d18f08
more cleanup in PikaEventBroker
m-vdb Aug 21, 2020
2f8483d
_replace_deprecated_option() uses raise_deprecation_warning()
m-vdb Aug 21, 2020
cd9088d
fix tests
m-vdb Aug 21, 2020
08b8bfb
fix validator and tracker store tests
m-vdb Aug 21, 2020
de97ed5
Merge branch 'master' into remove-deprecation-warnings
m-vdb Aug 21, 2020
a487fa2
do responses validation using yaml schema
m-vdb Aug 24, 2020
76b4376
Merge branch 'master' into remove-deprecation-warnings
m-vdb Aug 25, 2020
a546cd9
provide nice defaults for raise_deprecation_warning()
m-vdb Aug 25, 2020
6dda8c4
fix schema definitions
m-vdb Aug 25, 2020
f3c942f
reset nlu schema, no need to have the full response definition
m-vdb Aug 25, 2020
d938060
implement custom validation of response keys
m-vdb Aug 25, 2020
4aafccc
Merge branch 'master' into remove-deprecation-warnings
m-vdb Aug 25, 2020
f8d370a
remove support for custom keys
m-vdb Aug 25, 2020
4ab94c7
define responses schema in schemas/nlu.yml
m-vdb Aug 26, 2020
f9ea0f3
Merge branch 'master' into remove-deprecation-warnings
m-vdb Aug 26, 2020
f04ec88
update changelog fragment to reference documentation pages
m-vdb Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
- `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.
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
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
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
6 changes: 3 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,12 @@ 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,
warn_until_version="3.0.0",
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -415,46 +404,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
4 changes: 2 additions & 2 deletions rasa/core/policies/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ 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,
warn_until_version="3.0.0",
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
4 changes: 2 additions & 2 deletions rasa/core/policies/form_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ 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,
warn_until_version="3.0.0",
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
4 changes: 2 additions & 2 deletions rasa/core/policies/mapping_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ 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,
warn_until_version="3.0.0",
docs=DOCS_URL_MIGRATION_GUIDE,
)

Expand Down
27 changes: 27 additions & 0 deletions rasa/core/schemas/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@ mapping:
responses:
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
type: "map"
allowempty: True
matching-rule: 'any'
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
mapping:
regex;(.+):
type: "seq"
required: True
sequence:
- type: "map"
allowempty: True
matching-rule: 'any'
mapping:
regex;(^text$):
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
type: "str"
regex;(^image$):
type: "str"
regex;(^custom$):
type: "map"
allowempty: True
regex;(^buttons$):
type: "seq"
sequence:
- type: "map"
mapping:
title:
type: "str"
payload:
type: "str"

m-vdb marked this conversation as resolved.
Show resolved Hide resolved
slots:
type: "map"
allowempty: True
Expand Down
Loading