Skip to content

Commit

Permalink
AUTO docusaurus 20231005
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub CI committed Oct 5, 2023
1 parent 89616cb commit d88fe0d
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 93 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ rasa/tests
rasa/scripts
data/
examples/
docker-data/*
32 changes: 25 additions & 7 deletions .github/workflows/continous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,15 @@ jobs:
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 0
- name: Install ddtrace
if: needs.changes.outputs.backend == 'true'
run: poetry run pip install -U ddtrace
- name: Install ddtrace on Linux
if: needs.changes.outputs.backend == 'true' && matrix.os == 'ubuntu-22.04'
run: poetry run pip install -U 'ddtrace<2.0.0'

- name: Install ddtrace on Windows
if: needs.changes.outputs.backend == 'true' && matrix.os == 'windows-2019'
run: |
.\.venv\Scripts\activate
py -m pip install -U 'ddtrace<2.0.0'
- name: Test Code 🔍 (multi-process)
if: needs.changes.outputs.backend == 'true'
Expand Down Expand Up @@ -492,9 +498,15 @@ jobs:
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 0
- name: Install ddtrace
if: needs.changes.outputs.backend == 'true'
run: poetry run pip install -U ddtrace
- name: Install ddtrace on Linux
if: needs.changes.outputs.backend == 'true' && matrix.os == 'ubuntu-22.04'
run: poetry run pip install -U 'ddtrace<2.0.0'

- name: Install ddtrace on Windows
if: needs.changes.outputs.backend == 'true' && matrix.os == 'windows-2019'
run: |
.\.venv\Scripts\activate
py -m pip install -U 'ddtrace<2.0.0'
- name: Test Code 🔍 (multi-process)
if: needs.changes.outputs.backend == 'true'
Expand Down Expand Up @@ -1040,8 +1052,11 @@ jobs:
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo apt clean
docker image prune -a
docker image prune -a -f
docker volume prune -f
docker container prune -f
df -h
- name: Read Poetry Version 🔢
Expand Down Expand Up @@ -1069,6 +1084,9 @@ jobs:
run: |
docker buildx bake --set *.platform=linux/amd64,linux/arm64 -f docker/docker-bake.hcl ${{ matrix.image }}
- name: Check how much space is left after Docker build
run: df -h

- name: Push image with main tag 📦
if: needs.changes.outputs.docker == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'RasaHQ/rasa'
run: |
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ https://github.com/RasaHQ/rasa/tree/main/changelog/ . -->

<!-- TOWNCRIER -->

## [3.6.11] - 2023-10-05

Rasa 3.6.11 (2023-10-05)
### Bugfixes
- [#12722](https://github.com/rasahq/rasa/issues/12722): Intent names will not be falsely abbreviated in interactive training (fixes OSS-413).

This will also fix a bug where forced user utterances (using the regex matcher) will
be reverted even though they are present in the domain.
- [#12886](https://github.com/rasahq/rasa/issues/12886): Cache `EndpointConfig` session object using `cached_property` decorator instead of recreating this object on every request.
Initialize these connection pools for action server and model server endpoints as part of the Sanic `after_server_start` listener.
Also close connection pools during Sanic `after_server_stop` listener.


## [3.6.10] - 2023-09-26

Rasa 3.6.10 (2023-09-26)
### Improvements
- [#12827](https://github.com/rasahq/rasa/issues/12827): Improved handling of last batch during DIET and TED training. The last batch is discarded if it contains less than half a batch size of data.
- [#12852](https://github.com/rasahq/rasa/issues/12852): Added `username` to the connection parameters for `RedisLockStore` and `RedisTrackerStore`
- [#1493](https://github.com/rasahq/rasa/issues/1493): Telemetry data is only send for licensed users.

### Improved Documentation
- [#12868](https://github.com/rasahq/rasa/issues/12868): Remove the Playground from docs.


## [3.6.9] - 2023-09-15

Rasa 3.6.9 (2023-09-15)
Expand Down
1 change: 1 addition & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-data/*
25 changes: 25 additions & 0 deletions docs/docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ https://github.com/RasaHQ/rasa/tree/main/changelog/ . -->

<!-- TOWNCRIER -->

## [3.6.11] - 2023-10-05

Rasa 3.6.11 (2023-10-05)
### Bugfixes
- [#12722](https://github.com/rasahq/rasa/issues/12722): Intent names will not be falsely abbreviated in interactive training (fixes OSS-413).

This will also fix a bug where forced user utterances (using the regex matcher) will
be reverted even though they are present in the domain.
- [#12886](https://github.com/rasahq/rasa/issues/12886): Cache `EndpointConfig` session object using `cached_property` decorator instead of recreating this object on every request.
Initialize these connection pools for action server and model server endpoints as part of the Sanic `after_server_start` listener.
Also close connection pools during Sanic `after_server_stop` listener.


## [3.6.10] - 2023-09-26

Rasa 3.6.10 (2023-09-26)
### Improvements
- [#12827](https://github.com/rasahq/rasa/issues/12827): Improved handling of last batch during DIET and TED training. The last batch is discarded if it contains less than half a batch size of data.
- [#12852](https://github.com/rasahq/rasa/issues/12852): Added `username` to the connection parameters for `RedisLockStore` and `RedisTrackerStore`
- [#1493](https://github.com/rasahq/rasa/issues/1493): Telemetry data is only send for licensed users.

### Improved Documentation
- [#12868](https://github.com/rasahq/rasa/issues/12868): Remove the Playground from docs.


## [3.6.9] - 2023-09-15

Rasa 3.6.9 (2023-09-15)
Expand Down
26 changes: 26 additions & 0 deletions docs/docs/reference/rasa/core/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,29 @@ Gracefully closes resources when shutting down server.
- `app` - The Sanic application.
- `_` - The current Sanic worker event loop.

#### create\_connection\_pools

```python
async def create_connection_pools(app: Sanic, _: AbstractEventLoop) -> None
```

Create connection pools for the agent&#x27;s action server and model server.

#### create\_action\_endpoint\_connection\_pool

```python
def create_action_endpoint_connection_pool(
agent: Agent) -> Optional["ClientSession"]
```

Create a connection pool for the action endpoint.

#### create\_model\_server\_connection\_pool

```python
def create_model_server_connection_pool(
agent: Agent) -> Optional["ClientSession"]
```

Create a connection pool for the model server.

11 changes: 11 additions & 0 deletions docs/docs/reference/rasa/core/training/interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ async def is_listening_for_message(conversation_id: Text,

Check if the conversation is in need for a user message.

#### intent\_names\_from\_domain

```python
def intent_names_from_domain(domain: Any) -> List[Text]
```

Get a list of the possible intents names from the domain specification.

This is its own function as intents are non-trivial to unpack and this
warrants testing.

#### record\_messages

```python
Expand Down
5 changes: 2 additions & 3 deletions docs/docs/reference/rasa/utils/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ def read_endpoint_config(filename: Text,
endpoint_type: Text) -> Optional["EndpointConfig"]
```

Read an endpoint configuration file from disk and extract one.

config.
Read an endpoint configuration file from disk and extract one config.

#### concat\_url

Expand Down Expand Up @@ -62,6 +60,7 @@ Creates an `EndpointConfig` instance.
#### session

```python
@cached_property
def session() -> aiohttp.ClientSession
```

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 @@ -39,7 +39,7 @@ options:
--conversation-id CONVERSATION_ID
Specify the id of the conversation the messages are
in. Defaults to a UUID that will be randomly
generated. (default: c7b0c8957e9b4ade97e3a6bf4d87a4dd)
generated. (default: dd7d3b2331674a919a50600e70916b57)
--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 @@ -30,7 +30,7 @@ options:
-h, --help show this help message and exit
--conversation-id CONVERSATION_ID
Set the conversation ID. (default:
d2436920ecba4b0e80992625be3a2fd8)
3b2c230cea104e8b983c892f7c201afe)
-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
96 changes: 45 additions & 51 deletions rasa/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,59 +112,53 @@ async def _pull_model_and_fingerprint(

logger.debug(f"Requesting model from server {model_server.url}...")

async with model_server.session() as session:
try:
params = model_server.combine_parameters()
async with session.request(
"GET",
model_server.url,
timeout=DEFAULT_REQUEST_TIMEOUT,
headers=headers,
params=params,
) as resp:

if resp.status in [204, 304]:
logger.debug(
"Model server returned {} status code, "
"indicating that no new model is available. "
"Current fingerprint: {}"
"".format(resp.status, fingerprint)
)
return None
elif resp.status == 404:
logger.debug(
"Model server could not find a model at the requested "
"endpoint '{}'. It's possible that no model has been "
"trained, or that the requested tag hasn't been "
"assigned.".format(model_server.url)
)
return None
elif resp.status != 200:
logger.debug(
"Tried to fetch model from server, but server response "
"status code is {}. We'll retry later..."
"".format(resp.status)
)
return None

model_path = Path(model_directory) / resp.headers.get(
"filename", "model.tar.gz"
try:
params = model_server.combine_parameters()
async with model_server.session.request(
"GET",
model_server.url,
timeout=DEFAULT_REQUEST_TIMEOUT,
headers=headers,
params=params,
) as resp:
if resp.status in [204, 304]:
logger.debug(
"Model server returned {} status code, "
"indicating that no new model is available. "
"Current fingerprint: {}"
"".format(resp.status, fingerprint)
)
with open(model_path, "wb") as file:
file.write(await resp.read())

logger.debug("Saved model to '{}'".format(os.path.abspath(model_path)))

# return the new fingerprint
return resp.headers.get("ETag")

except aiohttp.ClientError as e:
logger.debug(
"Tried to fetch model from server, but "
"couldn't reach server. We'll retry later... "
"Error: {}.".format(e)
return None
elif resp.status == 404:
logger.debug(
"Model server could not find a model at the requested "
"endpoint '{}'. It's possible that no model has been "
"trained, or that the requested tag hasn't been "
"assigned.".format(model_server.url)
)
return None
elif resp.status != 200:
logger.debug(
"Tried to fetch model from server, but server response "
"status code is {}. We'll retry later..."
"".format(resp.status)
)
return None
model_path = Path(model_directory) / resp.headers.get(
"filename", "model.tar.gz"
)
return None
with open(model_path, "wb") as file:
file.write(await resp.read())
logger.debug("Saved model to '{}'".format(os.path.abspath(model_path)))
# return the new fingerprint
return resp.headers.get("ETag")
except aiohttp.ClientError as e:
logger.debug(
"Tried to fetch model from server, but "
"couldn't reach server. We'll retry later... "
"Error: {}.".format(e)
)
return None


async def _run_model_pulling_worker(model_server: EndpointConfig, agent: Agent) -> None:
Expand Down
47 changes: 46 additions & 1 deletion rasa/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid
import os
from functools import partial
from typing import Any, List, Optional, Text, Union, Dict
from typing import Any, List, Optional, TYPE_CHECKING, Text, Union, Dict

import rasa.core.utils
from rasa.plugin import plugin_manager
Expand All @@ -23,6 +23,9 @@
from sanic import Sanic
from asyncio import AbstractEventLoop

if TYPE_CHECKING:
from aiohttp import ClientSession

logger = logging.getLogger() # get the root logger


Expand Down Expand Up @@ -214,6 +217,7 @@ def serve_application(
partial(load_agent_on_start, model_path, endpoints, remote_storage),
"before_server_start",
)
app.register_listener(create_connection_pools, "after_server_start")
app.register_listener(close_resources, "after_server_stop")

number_of_workers = rasa.core.utils.number_of_sanic_workers(
Expand Down Expand Up @@ -275,3 +279,44 @@ async def close_resources(app: Sanic, _: AbstractEventLoop) -> None:
event_broker = current_agent.tracker_store.event_broker
if event_broker:
await event_broker.close()

action_endpoint = current_agent.action_endpoint
if action_endpoint:
await action_endpoint.session.close()

model_server = current_agent.model_server
if model_server:
await model_server.session.close()


async def create_connection_pools(app: Sanic, _: AbstractEventLoop) -> None:
"""Create connection pools for the agent's action server and model server."""
current_agent = getattr(app.ctx, "agent", None)
if not current_agent:
logger.debug("No agent found after server start.")
return None

create_action_endpoint_connection_pool(current_agent)
create_model_server_connection_pool(current_agent)

return None


def create_action_endpoint_connection_pool(agent: Agent) -> Optional["ClientSession"]:
"""Create a connection pool for the action endpoint."""
action_endpoint = agent.action_endpoint
if not action_endpoint:
logger.debug("No action endpoint found after server start.")
return None

return action_endpoint.session


def create_model_server_connection_pool(agent: Agent) -> Optional["ClientSession"]:
"""Create a connection pool for the model server."""
model_server = agent.model_server
if not model_server:
logger.debug("No model server endpoint found after server start.")
return None

return model_server.session
Loading

0 comments on commit d88fe0d

Please sign in to comment.