Skip to content

Commit

Permalink
AUTO docusaurus 20220304
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub CI committed Mar 4, 2022
1 parent 92a3c52 commit 2299d3f
Show file tree
Hide file tree
Showing 62 changed files with 237 additions and 110 deletions.
1 change: 1 addition & 0 deletions changelog/9094.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable `mypy` `var-annotated` check and fix any resulting errors.
17 changes: 17 additions & 0 deletions docs/docs/reference/rasa/core/channels/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,23 @@ Output channel that collects send messages in a list

(doesn't send them anywhere, just collects them).

#### \_\_init\_\_

```python
| __init__() -> None
```

Initialise list to collect messages.

#### name

```python
| @classmethod
| name(cls) -> Text
```

Name of the channel.

#### send\_image\_url

```python
Expand Down
32 changes: 32 additions & 0 deletions docs/docs/reference/rasa/core/lock_store.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,35 @@ class InMemoryLockStore(LockStore)

In-memory store for ticket locks.

#### \_\_init\_\_

```python
| __init__() -> None
```

Initialise dictionary of locks.

#### get\_lock

```python
| get_lock(conversation_id: Text) -> Optional[TicketLock]
```

Get lock for conversation if it exists.

#### delete\_lock

```python
| delete_lock(conversation_id: Text) -> None
```

Delete lock for conversation.

#### save\_lock

```python
| save_lock(lock: TicketLock) -> None
```

Save lock in store.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Retrieves metadata from archive (see parent class for full docstring).

```python
| @contextmanager
| write_to(resource: Resource) -> ContextManager[Path]
| write_to(resource: Resource) -> Generator[Path, None, None]
```

Persists data for a resource (see parent class for full docstring).
Expand All @@ -58,7 +58,7 @@ Persists data for a resource (see parent class for full docstring).

```python
| @contextmanager
| read_from(resource: Resource) -> ContextManager[Path]
| read_from(resource: Resource) -> Generator[Path, None, None]
```

Provides the data of a `Resource` (see parent class for full docstring).
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/reference/rasa/engine/storage/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Retrieves metadata from archive.
```python
| @contextmanager
| @abc.abstractmethod
| write_to(resource: Resource) -> ContextManager[Path]
| write_to(resource: Resource) -> Generator[Path, None, None]
```

Persists data for a given resource.
Expand All @@ -101,7 +101,7 @@ This `Resource` can then be accessed in dependent graph nodes via
```python
| @contextmanager
| @abc.abstractmethod
| read_from(resource: Resource) -> ContextManager[Path]
| read_from(resource: Resource) -> Generator[Path, None, None]
```

Provides the data of a persisted `Resource`.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/reference/rasa/nlu/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ extraction.
#### compare\_nlu

```python
async compare_nlu(configs: List[Text], data: TrainingData, exclusion_percentages: List[int], f_score_results: Dict[Text, Any], model_names: List[Text], output: Text, runs: int) -> List[int]
async compare_nlu(configs: List[Text], data: TrainingData, exclusion_percentages: List[int], f_score_results: Dict[Text, List[List[float]]], model_names: List[Text], output: Text, runs: int) -> List[int]
```

Trains and compares multiple NLU models.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ title: rasa.shared.core.training_data.story_reader.story_step_builder
class StoryStepBuilder()
```

#### add\_checkpoint

```python
| add_checkpoint(name: Text, conditions: Optional[Dict[Text, Any]]) -> None
```

Add a checkpoint to story steps.

#### add\_user\_messages

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ serialized as YAML.

`OrderedDict` containing all training data.

#### process\_synonyms

```python
| @classmethod
| process_synonyms(cls, training_data: "TrainingData") -> List[OrderedDict]
```

Serializes the synonyms.

#### process\_regexes

```python
| @classmethod
| process_regexes(cls, training_data: "TrainingData") -> List[OrderedDict]
```

Serializes the regexes.

#### process\_lookup\_tables

```python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Turns TrainingData into a string.

```python
| @staticmethod
| prepare_training_examples(training_data: "TrainingData") -> OrderedDict
| prepare_training_examples(training_data: "TrainingData") -> Dict[Text, List[Union[Dict, Text]]]
```

Pre-processes training data examples by removing not trainable entities.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sources/rasa_interactive___help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ optional arguments:
--conversation-id CONVERSATION_ID
Specify the id of the conversation the messages are
in. Defaults to a UUID that will be randomly
generated. (default: af00641d2a27433d97d9767b4f8c8c2c)
generated. (default: d7e60459f37947e281263a9fd41dd2f1)
--endpoints ENDPOINTS
Configuration file for the model server and the
connectors as a yml file. (default: endpoints.yml)
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sources/rasa_shell___help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ optional arguments:
-h, --help show this help message and exit
--conversation-id CONVERSATION_ID
Set the conversation ID. (default:
02116ebc67354343a457fde5d2d5f6da)
dadd5d7cfe404553a191b3e219e0697b)
-m MODEL, --model MODEL
Path to a trained Rasa model. If a directory is
specified, it will use the latest model in this
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ async def run(
) -> List[Event]:
"""Runs action. Please see parent class for the full docstring."""
slot_events: List[Event] = []
executed_custom_actions = set()
executed_custom_actions: Set[Text] = set()

user_slots = [
slot for slot in domain.slots if slot.name not in DEFAULT_SLOT_NAMES
Expand Down
6 changes: 3 additions & 3 deletions rasa/core/actions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def _create_unique_entity_mappings(self, domain: Domain) -> Set[Text]:
Returns:
A set of json dumps of unique mappings of type `from_entity`.
"""
unique_entity_slot_mappings = set()
duplicate_entity_slot_mappings = set()
unique_entity_slot_mappings: Set[Text] = set()
duplicate_entity_slot_mappings: Set[Text] = set()
domain_slots = domain.as_dict().get(KEY_SLOTS, {})
for slot in domain.required_slots_for_form(self.name()):
for slot_mapping in domain_slots.get(slot, {}).get(SLOT_MAPPINGS, []):
Expand Down Expand Up @@ -360,7 +360,7 @@ def _get_slot_extractions(
events_since_last_user_uttered = FormAction._get_events_since_last_user_uttered(
tracker
)
slot_values = {}
slot_values: Dict[Text, Any] = {}

required_slots = self._add_dynamic_slots_requested_by_dynamic_forms(
tracker, domain
Expand Down
4 changes: 3 additions & 1 deletion rasa/core/channels/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,12 @@ class CollectingOutputChannel(OutputChannel):
(doesn't send them anywhere, just collects them)."""

def __init__(self) -> None:
self.messages = []
"""Initialise list to collect messages."""
self.messages: List[Dict[Text, Any]] = []

@classmethod
def name(cls) -> Text:
"""Name of the channel."""
return "collector"

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/channels/hangouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def name(cls) -> Text:

def __init__(self) -> None:
"""Starts messages as empty dictionary."""
self.messages = {}
self.messages: Dict[Text, Any] = {}

@staticmethod
def _text_card(message: Dict[Text, Any]) -> Dict:
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/channels/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def stream_response(
metadata: Optional[Dict[Text, Any]],
) -> Callable[[Any], Awaitable[None]]:
async def stream(resp: Any) -> None:
q = Queue()
q: Queue = Queue()
task = asyncio.ensure_future(
self.on_message_wrapper(
on_new_message, text, q, sender_id, input_channel, metadata
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/evaluation/marker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def _collect_yaml_files_from_path(path: Union[Text, Path]) -> List[Text]:

@staticmethod
def _collect_configs_from_yaml_files(yaml_files: List[Text]) -> Dict[Text, Dict]:
marker_names = set()
marker_names: Set[Text] = set()
loaded_configs: Dict[Text, Dict] = {}
for yaml_file in yaml_files:
loaded_config = rasa.shared.utils.io.read_yaml_file(yaml_file)
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/evaluation/marker_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _add_num_user_turns_str_to(stat_name: Text) -> Text:
def __init__(self) -> None:
"""Creates a new marker statistics object."""
# to ensure consistency of processed rows
self._marker_names = []
self._marker_names: List[Text] = []

# (1) For collecting the per-session analysis:
# NOTE: we could stream / compute them later instead of collecting them...
Expand Down
6 changes: 3 additions & 3 deletions rasa/core/featurizers/single_state_featurizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class SingleStateFeaturizer:

def __init__(self) -> None:
"""Initialize the single state featurizer."""
self._default_feature_states = {}
self.action_texts = []
self.entity_tag_specs = []
self._default_feature_states: Dict[Text, Any] = {}
self.action_texts: List[Text] = []
self.entity_tag_specs: List[EntityTagSpec] = []

def _create_entity_tag_specs(
self, bilou_tagging: bool = False
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/featurizers/tracker_featurizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ def _extract_examples(
tracker_states[:label_index], self.max_history
)
label = [event.intent_name or event.text]
entities = [{}]
entities: List[Dict[Text, Any]] = [{}]

yield sliced_states, label, entities

Expand Down
8 changes: 6 additions & 2 deletions rasa/core/lock_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

from async_generator import asynccontextmanager
from typing import Text, Union, Optional, AsyncGenerator
from typing import AsyncGenerator, Dict, Optional, Text, Union

from rasa.shared.exceptions import RasaException, ConnectionException
import rasa.shared.utils.common
Expand Down Expand Up @@ -274,19 +274,23 @@ class InMemoryLockStore(LockStore):
"""In-memory store for ticket locks."""

def __init__(self) -> None:
self.conversation_locks = {}
"""Initialise dictionary of locks."""
self.conversation_locks: Dict[Text, TicketLock] = {}
super().__init__()

def get_lock(self, conversation_id: Text) -> Optional[TicketLock]:
"""Get lock for conversation if it exists."""
return self.conversation_locks.get(conversation_id)

def delete_lock(self, conversation_id: Text) -> None:
"""Delete lock for conversation."""
deleted_lock = self.conversation_locks.pop(conversation_id, None)
self._log_deletion(
conversation_id, deletion_successful=deleted_lock is not None
)

def save_lock(self, lock: TicketLock) -> None:
"""Save lock in store."""
self.conversation_locks[lock.conversation_id] = lock


Expand Down
8 changes: 4 additions & 4 deletions rasa/core/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def _migrate_domain_files(
backup_location: where to backup all domain files
out_path: location where to store the migrated files
"""
slots = {}
forms = {}
entities = []
slots: Dict[Text, Any] = {}
forms: Dict[Text, Any] = {}
entities: List[Any] = []

domain_files = [
file for file in domain_path.iterdir() if Domain.is_domain_file(file)
Expand Down Expand Up @@ -264,7 +264,7 @@ def _migrate_domain_files(

slots.update(original_content.get(KEY_SLOTS, {}))
forms.update(original_content.get(KEY_FORMS, {}))
entities.extend(original_content.get(KEY_ENTITIES, {}))
entities.extend(original_content.get(KEY_ENTITIES, []))

if not slots or not forms:
raise RasaException(
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/policies/memoization.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _create_lookup_from_states(
Returns:
lookup dictionary
"""
lookup = {}
lookup: Dict[Text, Text] = {}

if not trackers_as_states:
return lookup
Expand Down
Loading

0 comments on commit 2299d3f

Please sign in to comment.