Skip to content

Commit

Permalink
Merge pull request #9168 from RasaHQ/8869-dialoguestatetracker-deprec…
Browse files Browse the repository at this point in the history
…ations

Remove `DialogueStateTracker` deprecated methods
  • Loading branch information
ancalita authored Jul 21, 2021
2 parents 1d54baf + 3e9bfea commit b0ce90d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 39 deletions.
1 change: 1 addition & 0 deletions changelog/8869.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove deprecated `change_form_to` and `set_form_validation` methods from `DialogueStateTracker`.
22 changes: 2 additions & 20 deletions rasa/shared/core/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,34 +334,16 @@ def change_loop_to(self, loop_name: Optional[Text]) -> None:
else:
self.active_loop = {}

def change_form_to(self, form_name: Text) -> None:
rasa.shared.utils.io.raise_warning(
"`change_form_to` is deprecated and will be removed "
"in future versions. Please use `change_loop_to` "
"instead.",
category=DeprecationWarning,
)
self.change_loop_to(form_name)

def interrupt_loop(self, is_interrupted: bool) -> None:
"""Interrupt loop and mark that we entered an unhappy path in the conversation.
Args:
is_interrupted: `True` if the loop was run after an unhappy path.
"""
self.active_loop[LOOP_INTERRUPTED] = is_interrupted

def set_form_validation(self, validate: bool) -> None:
rasa.shared.utils.io.raise_warning(
"`set_form_validation` is deprecated and will be removed "
"in future versions. Please use `interrupt_loop` "
"instead.",
category=DeprecationWarning,
)
# `validate = True` means `is_interrupted = False`
self.interrupt_loop(not validate)

def reject_action(self, action_name: Text) -> None:
"""Notify active loop that it was rejected"""
"""Notify active loop that it was rejected."""
if action_name == self.active_loop_name:
self.active_loop[LOOP_REJECTED] = True

Expand Down
19 changes: 0 additions & 19 deletions tests/shared/core/test_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,15 +1198,6 @@ def test_writing_trackers_with_legacy_form_events():
assert event["event"] == ActiveLoop.type_name


def test_change_form_to_deprecation_warning():
tracker = DialogueStateTracker.from_events("conversation", evts=[])
new_form = "new form"
with pytest.warns(DeprecationWarning):
tracker.change_form_to(new_form)

assert tracker.active_loop_name == new_form


def test_reading_of_trackers_with_legacy_form_validation_events():
tracker = DialogueStateTracker.from_dict(
"sender",
Expand Down Expand Up @@ -1239,16 +1230,6 @@ def test_writing_trackers_with_legacy_for_validation_events():
assert events_as_dict[1][LOOP_INTERRUPTED]


@pytest.mark.parametrize("validate", [True, False])
def test_set_form_validation_deprecation_warning(validate: bool):
tracker = DialogueStateTracker.from_events("conversation", evts=[])

with pytest.warns(DeprecationWarning):
tracker.set_form_validation(validate)

assert tracker.active_loop[LOOP_INTERRUPTED] == (not validate)


@pytest.mark.parametrize(
"conversation_events,n_subtrackers",
[
Expand Down

0 comments on commit b0ce90d

Please sign in to comment.