Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async Tracker Store Support #10696

Merged
merged 77 commits into from
Mar 22, 2022

Conversation

danielenricocahall
Copy link
Contributor

@danielenricocahall danielenricocahall commented Jan 18, 2022

This is an effort to make tracker stores asynchronous, based off of the work initially done in this PR and it should address [this issue] (#8774). I've tried to account for the comments made in the original PR and reduce the surface area/object wrapping from the original implementation, but that comes at a trade-off - specifically making the other tracker store methods async.

Also, should we convert some of the tracker store implementations to use async APIs (i.e; AIORedis for AioRedis, Motor for Mongo)?

. First PR, so entirely open to feedback!

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@danielenricocahall danielenricocahall requested a review from a team as a code owner January 18, 2022 00:47
@danielenricocahall danielenricocahall requested review from jupyterjazz and removed request for a team January 18, 2022 00:47
@CLAassistant
Copy link

CLAassistant commented Jan 18, 2022

CLA assistant check
All committers have signed the CLA.

@joejuzl
Copy link
Contributor

joejuzl commented Mar 21, 2022

Hey @wochinge @joejuzl could someone possibly retrigger the CI at earliest convenience? Sorry to be a bother, just really excited to get this in :)

Hey @danielenricocahall sorry I was on holiday :) - have re-run it now.
Also, in-case you weren't aware, you can use make to run the various checks locally, e.g. make lint (check the Makefile for the full list). This may make it easier to get all issues fixed locally.

@danielenricocahall
Copy link
Contributor Author

Hey @wochinge @joejuzl could someone possibly retrigger the CI at earliest convenience? Sorry to be a bother, just really excited to get this in :)

Hey @danielenricocahall sorry I was on holiday :) - have re-run it now. Also, in-case you weren't aware, you can use make to run the various checks locally, e.g. make lint (check the Makefile for the full list). This may make it easier to get all issues fixed locally.

Hey @joejuzl no worries and thank you!!! And ah yes good to know - I was running a few commands manually based on what I saw in CI but the make commands are definitely easier. Let me resolve this other linting problem...

@joejuzl joejuzl mentioned this pull request Mar 21, 2022
4 tasks
@danielenricocahall
Copy link
Contributor Author

Hey @joejuzl I've corrected most of the linting errors after running make lint-docstring. However, there are a few errors I don't understand:

make lint-docstrings
git diff main...HEAD -- rasa | poetry run flake8 --select D --diff
/usr/local/lib/python3.8/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
rasa/core/tracker_store.py:277:1: D205 1 blank line required between summary line and description
rasa/core/tracker_store.py:277:1: D415 First line should end with a period, question mark, or exclamation point
rasa/core/tracker_store.py:1253:1: D102 Missing docstring in public method
rasa/core/tracker_store.py:1260:1: D102 Missing docstring in public method
rasa/core/tracker_store.py:1267:1: D102 Missing docstring in public method
make: *** [Makefile:95: lint-docstrings] Error 1

When I navigate to these lines, they are methods which have not had any docstring modifications in this PR - only the signatures have changed (to add async). Should I still make changes to those docstrings?

@joejuzl
Copy link
Contributor

joejuzl commented Mar 21, 2022

When I navigate to these lines, they are methods which have not had any docstring modifications in this PR - only the signatures have changed (to add async). Should I still make changes to those docstrings?

The check uses rather broad strokes to determine what needs to be checked, and since it has not been around since the start it often requires small changes to existing docstrings. Let me know if you need a hand with any of them (it should be fine to keep them fairly succinct and simple.)

@danielenricocahall
Copy link
Contributor Author

When I navigate to these lines, they are methods which have not had any docstring modifications in this PR - only the signatures have changed (to add async). Should I still make changes to those docstrings?

The check uses rather broad strokes to determine what needs to be checked, and since it has not been around since the start it often requires small changes to existing docstrings. Let me know if you need a hand with any of them (it should be fine to keep them fairly succinct and simple.)

Done! :)

@danielenricocahall
Copy link
Contributor Author

When I navigate to these lines, they are methods which have not had any docstring modifications in this PR - only the signatures have changed (to add async). Should I still make changes to those docstrings?

The check uses rather broad strokes to determine what needs to be checked, and since it has not been around since the start it often requires small changes to existing docstrings. Let me know if you need a hand with any of them (it should be fine to keep them fairly succinct and simple.)

Done! :)

Oof, then those changes caused Flake8 to complain about line length errors 😵 . Just addressed and pushed up.

@danielenricocahall
Copy link
Contributor Author

danielenricocahall commented Mar 21, 2022

Just corrected the typing errors. With the two AwaitableTrackerStore methods (retrieve and keys), I added ignore[return-value] since the alternative would be to change the type signature for those methods for all TrackerStore subclasses, which I thought was less clean (especially if the idea is that AwaitableTrackerStore would be removed in 4.0 since all tracker store implementations should be asynchronous by then and there would be no need for the wrapper).

@danielenricocahall
Copy link
Contributor Author

danielenricocahall commented Mar 22, 2022

Hey @joejuzl it looks like all but one test are passing 🥳 - test_train_status_is_not_blocked_by_training in test-other-unit-tests when doing multi-process tests. Do you have any suggestions on mitigating that issue?

Copy link
Contributor

@joejuzl joejuzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 Fantastic job! Thanks for this 🚀 🚀 🚀

@joejuzl
Copy link
Contributor

joejuzl commented Mar 22, 2022

Hey @joejuzl it looks like all but one test are passing 🥳 - test_train_status_is_not_blocked_by_training in test-other-unit-tests when doing multi-process tests. Do you have any suggestions on mitigating that issue?

Looks like it's a random failure - re-running it now.

@danielenricocahall
Copy link
Contributor Author

danielenricocahall commented Mar 22, 2022

Hey @joejuzl it looks like all but one test are passing 🥳 - test_train_status_is_not_blocked_by_training in test-other-unit-tests when doing multi-process tests. Do you have any suggestions on mitigating that issue?

Looks like it's a random failure - re-running it now.

Thank you!

@danielenricocahall
Copy link
Contributor Author

Hey @joejuzl it looks like all but one test are passing 🥳 - test_train_status_is_not_blocked_by_training in test-other-unit-tests when doing multi-process tests. Do you have any suggestions on mitigating that issue?

Looks like it's a random failure - re-running it now.

Thank you!

Looks like everything passed now but the codeclimate report update failed.

@joejuzl
Copy link
Contributor

joejuzl commented Mar 22, 2022

Looks like everything passed now but the codeclimate report update failed.

Don't worry about that job.
Do you have the privileges to merge?
If so make sure to squash, you can then either keep the default squashed message or write something more succinct.
If not, I can merge for you.

@danielenricocahall
Copy link
Contributor Author

Looks like everything passed now but the codeclimate report update failed.

Don't worry about that job. Do you have the privileges to merge? If so make sure to squash, you can then either keep the default squashed message or write something more succinct. If not, I can merge for you.

Okay great! Unfortunately, I do not have privileges to merge.

@joejuzl joejuzl merged commit ca316fc into RasaHQ:main Mar 22, 2022
@danielenricocahall
Copy link
Contributor Author

Hey @joejuzl would the next step be to migrate some of the existing tracker stores to using async lib equivalents e.g; MongoTrackerStore -> motor, etc.? I wouldn't mind doing that in the future.

@danielenricocahall danielenricocahall deleted the async-trackerstore-support branch March 22, 2022 16:46
indam23 pushed a commit that referenced this pull request Jul 27, 2022
Make `TrackerStore` interface methods asynchronous and supply an `AwaitableTrackerstore` wrapper for custom tracker stores which do not implement the methods as asynchronous.


Squashed commits:

* refactor tracker store and tests to be async

* update core modules with async tracker store calls

* update server with async tracker store calls

* await tracker store call in twilio voice

* add await in test rasa export

* add awaits to test_agent for tracker store

* add awaits to tracker store functions in processor tests

* refactor exporter tests for async tracker store

* use asyncmock from unittest instead of custom

* add async in test_rasa_export

* fixture update for async tracker store

* update marker logic to handle async tracker store

* fix mark tracker loader tests for async tracker store

* add awaits to server and server tests

* add await to dialogue test with tracker store

* add await to tracker test

* formatting in tracker store

* more formatting fixes

* more formatting fixes

* address formatting changes

* change return type and remove awaitable tracker store wrapper in create

* make stream_events async

* address comments (remove redundant methods in awaitable tracker store + raise exception)

* make _run_markers and _run_markers_cli sync to ensure CLI can be run

* add warning and test for creating async tracker store from endpoint config

* add changelog entry

* use TrackerStore instead of "TrackerStore" in typehint

Co-authored-by: Joe Juzl <joejuzl@gmail.com>

* use TrackerStore instead of "TrackerStore" in typehint

Co-authored-by: Joe Juzl <joejuzl@gmail.com>

* change user warning to deprecation warning

* fix typo in comment

* have fallback_tracker_store return in memory tracker store without awaitable wrapper

* import async mock from conftest instead of unittest to suport Python 3.7

* delete unused imports in marker_tracker_loader

* apply black to modules which failed ci linter

* resolve line length linting in tracker_store.py

* refer to request.app.ctx.agent object instead of request.app.agent

* resolve ci failures from not adding async/await

* applied black to reformat three modules failing code quality

* correct most docstring linting errors

* fix docstring linting errors

* fix flake8 line length errors

* fix mypy type checking errors

* linting corrections after adding type ignores to methods

* delete extra periods in docstring

Co-authored-by: Joe Juzl <joejuzl@gmail.com>
@indam23 indam23 mentioned this pull request Aug 1, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants