rasa
rasa copied to clipboard
Upgrade prompt-toolkit to 3.0
Proposed changes:
Upgrades prompt-toolkit and make some edits to the use of questionary
which has prompt-toolkit
as dependency:
- replace sync method
questionary.ask()
withask_async()
, otherwise this breaksrasa shell
by raisingRuntimeError: This event loop is already running
. - use
concurrent.futures.ThreadPoolExecutor
to execute async code in synchronous function_get_user_input()
, otherwise trying to make this function async would have resulted in breaking two tests (althoughrasa shell
worked fine):
-
test_console_input
fails withTypeError: object str can't be used in 'await' expression
-
test_record_messages
fails withOSError: [Errno 9] Bad file descriptor
.
! The ThreadPoolExecutor
approach still fails test_record_messages
with RuntimeErrors or OSErrors, more investigation required.
Status (please check what you already did):
@losterloh This is now ready for review after a great troubleshooting round with @tmbo 🥳
@ancalita do you mind linking the ticket you created on the prompt-toolkit repo here so that we have a reference to it if / when we need to get back to this pr in the future?
@ancalita do you mind linking the ticket you created on the prompt-toolkit repo here so that we have a reference to it if / when we need to get back to this pr in the future?
@tmbo I've just linked to it in the PR description. I also just noticed that prompt-toolkit
version is still at 3.0.3
in poetry.lock
, I'll update now and push the change.
@tmbo I just ran a sanity check with rasa interactive
on a rasa init
project and everything works fine up until a point 😅
I tried this conversation:
- Hi # correct prediction
- Hey! How are you? # correct action
- fANTASTIC # here i have to correct intent to `mood_great`
- Great, carry on! # correct predicted action
After the last predicted action action_listen
, I get an error, with this stacktrace:
ERROR rasa.core.training.interactive - An exception occurred while recording messages.
Traceback (most recent call last):
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 1504, in record_messages
await _predict_till_next_listen(
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 978, in _predict_till_next_listen
await _print_history(conversation_id, endpoint)
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 483, in _print_history
print(table)
BlockingIOError: [Errno 35] write could not complete without blocking
2022-08-11 10:34:33 ERROR asyncio - Task exception was never retrieved
future: <Task finished name='Task-6' coro=<SignalRouter._dispatch() done, defined at /Users/ancalita/rasa-projects/oss-0908-3.2.x/lib/python3.9/site-packages/sanic/signals.py:121> exception=BlockingIOError(35, 'write could not complete without blocking', 0)>
Traceback (most recent call last):
File "/Users/ancalita/rasa-projects/oss-0908-3.2.x/lib/python3.9/site-packages/sanic/signals.py", line 161, in _dispatch
retval = await maybe_coroutine
File "/Users/ancalita/rasa-projects/oss-0908-3.2.x/lib/python3.9/site-packages/sanic/app.py", line 1581, in run_delayed_task
await prepped
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 1596, in run_interactive_io
await record_messages(
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 1504, in record_messages
await _predict_till_next_listen(
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 978, in _predict_till_next_listen
await _print_history(conversation_id, endpoint)
File "/Users/ancalita/rasa-projects/rasa/rasa/core/training/interactive.py", line 483, in _print_history
print(table)
BlockingIOError: [Errno 35] write could not complete without blocking
I've tried amending print(table, flush=True)
, but it didn't help.
I also double-checked this is not an error dating before this PR, so I tested with rasa 3.2.5
on 3.2.x
branch and no errors were triggered. Any ideas? 🆘
🚀 A preview of the docs have been deployed at the following URL: https://11426--rasahq-docs-rasa-v2.netlify.app/docs/rasa