Skip to content

Commit

Permalink
Merge pull request #12931 from RasaHQ/merge-3.6.x-main-fa00c49
Browse files Browse the repository at this point in the history
Merge 3.6.x into main
  • Loading branch information
Tawakalt committed Oct 23, 2023
2 parents a47ffb9 + 9204576 commit a3c104a
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 6 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ jobs:
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Inject setuptools into poetry's runtime environment
if: needs.changes.outputs.backend == 'true'
run: |
poetry self add setuptools
- name: Load Poetry Cached Libraries ⬇
id: cache-poetry
if: needs.changes.outputs.backend == 'true'
Expand Down Expand Up @@ -163,7 +168,7 @@ jobs:
# This is a workaround for that issue
run: |
sudo apt-get -y install libpq-dev
make install-full || make install-full || make install-full
make install-full
- name: Checkout target branch to be able to diff
if: needs.changes.outputs.backend == 'true' && github.event_name == 'pull_request'
Expand Down Expand Up @@ -277,6 +282,11 @@ jobs:
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Inject setuptools into poetry's runtime environment
if: needs.changes.outputs.backend == 'true'
run: |
poetry self add setuptools
- name: Load Poetry Cached Libraries ⬇
id: cache-poetry
if: needs.changes.outputs.backend == 'true'
Expand Down Expand Up @@ -311,7 +321,7 @@ jobs:
# This is a workaround for that issue
run: |
sudo apt-get -y install libpq-dev
make install-full | tee .output || make install-full | tee .output || make install-full | tee .output
make install-full | tee .output
if grep 'The lock file is not up to date' .output; then exit 1; fi
make prepare-tests-ubuntu
Expand All @@ -330,7 +340,7 @@ jobs:
Remove-Item -Force -Recurse $spacy_data_dir
New-Item -Path $spacy_data_dir -Type Directory
}
make install-full || make install-full || make install-full
make install-full
make prepare-tests-windows-gha
- name: Add github workflow problem matchers
Expand Down Expand Up @@ -427,6 +437,11 @@ jobs:
with:
poetry-version: ${{ env.POETRY_VERSION }}

- name: Inject setuptools into poetry's runtime environment
if: needs.changes.outputs.backend == 'true'
run: |
poetry self add setuptools
- name: Load Poetry Cached Libraries ⬇
id: cache-poetry
if: needs.changes.outputs.backend == 'true'
Expand Down
1 change: 1 addition & 0 deletions changelog/12927.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix wrong conflicts that occur when rasa validate stories is run with slots that have active_loop set to null in mapping conditions.
7 changes: 7 additions & 0 deletions data/test/test_integration/data/nlu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,10 @@ nlu:
- are you a human?
- am I talking to a bot?
- am I talking to a human?
- intent: block
examples: |
- block my [checking](account_type) account
- i want to block my [savings](account_type) account
- i need to block an account
- i need to block my [credit](account_type) card
26 changes: 26 additions & 0 deletions data/test/test_integration/data/stories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,29 @@ stories:
- action: utter_did_that_help
- intent: deny
- action: utter_goodbye

- story: block savings
steps:
- intent: block
entities:
- account_type: savings
- action: utter_block_account

- story: block checking
steps:
- intent: block
entities:
- account_type: checking
- action: utter_checking

- story: block credit
steps:
- intent: block
entities:
- account_type: credit
- action: utter_credit

- story: block no entities
steps:
- intent: block
- action: utter_nothing
30 changes: 30 additions & 0 deletions data/test/test_integration/domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ intents:
- mood_great
- mood_unhappy
- bot_challenge
- block

responses:
utter_greet:
Expand All @@ -29,6 +30,35 @@ responses:
utter_iamabot:
- text: "I am a bot, powered by Rasa."

utter_block_account:
- text: "your account has been blocked"

utter_checking:
- text: "checking account"

utter_credit:
- text: "credit account"

utter_nothing:
- text: "no account type was specified"

entities:
- account_type

slots:
account_type:
type: categorical
influence_conversation: true
values:
- savings
- checking
- credit
mappings:
- type: from_entity
entity: account_type
conditions:
- active_loop: null

session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
9 changes: 6 additions & 3 deletions rasa/shared/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
SlotMappingType,
MAPPING_TYPE,
MAPPING_CONDITIONS,
ACTIVE_LOOP,
)
from rasa.shared.exceptions import (
RasaException,
Expand Down Expand Up @@ -1408,9 +1409,11 @@ def slots_for_entities(self, entities: List[Dict[Text, Any]]) -> List[SlotSet]:
matching_entities = []

for mapping in slot.mappings:
if mapping[MAPPING_TYPE] != str(
SlotMappingType.FROM_ENTITY
) or mapping.get(MAPPING_CONDITIONS):
mapping_conditions = mapping.get(MAPPING_CONDITIONS)
if mapping[MAPPING_TYPE] != str(SlotMappingType.FROM_ENTITY) or (
mapping_conditions
and mapping_conditions[0].get(ACTIVE_LOOP) is not None
):
continue

for entity in entities:
Expand Down
33 changes: 33 additions & 0 deletions tests/integration_tests/core/test_cli_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,36 @@ def test_rasa_validate_quiet_no_errors(
"you can use `rasa telemetry disable`." in output_text
assert "To learn more, check out"
"https://rasa.com/docs/rasa/telemetry/telemetry." in output_text


def test_rasa_validate_null_active_loop_no_errors(
run: Callable[..., RunResult], request: FixtureRequest
):
# Test captures the subprocess output for the command run
# and validates that the data in 'data/test/test_integration' throws no cli errors

test_data_dir = Path(request.config.rootdir, "data", "test", "test_integration")
test_config_dir = Path(request.config.rootdir, "data", "test_config")
source_file = (test_data_dir / "data").absolute()
domain_file = (test_data_dir / "domain.yml").absolute()
config_file = (test_config_dir / "config_unique_assistant_id.yml").absolute()
result = run(
"data",
"validate",
"--data",
str(source_file),
"-d",
str(domain_file),
"-c",
str(config_file),
)
assert result.ret == 0

stderr_text = str(result.stderr)
assert "INFO" in stderr_text
assert "Validating intents..." in stderr_text
assert "Validating utterances..." in stderr_text
assert "Story structure validation..." in stderr_text
assert "Validating utterances..." in stderr_text
assert "Considering all preceding turns for conflict analysis." in stderr_text
assert "No story structure conflicts found." in stderr_text
27 changes: 27 additions & 0 deletions tests/shared/core/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,33 @@ def test_domain_slots_for_entities_with_mapping_conditions_no_slot_set():
assert len(events) == 0


def test_domain_slots_for_entities_with_mapping_conditions_no_active_loop():
domain = Domain.from_yaml(
textwrap.dedent(
f"""
version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
entities:
- city
slots:
location:
type: text
influence_conversation: false
mappings:
- type: from_entity
entity: city
conditions:
- active_loop: null
forms:
booking_form:
required_slots:
- location
"""
)
)
events = domain.slots_for_entities([{"entity": "city", "value": "Berlin"}])
assert events == [SlotSet("location", "Berlin")]


def test_domain_slots_for_entities_sets_valid_slot():
domain = Domain.from_yaml(
textwrap.dedent(
Expand Down

0 comments on commit a3c104a

Please sign in to comment.