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

Validate Conversation ID #7238

Merged
merged 24 commits into from
Feb 15, 2021
Merged

Conversation

aleronupe
Copy link
Contributor

@aleronupe aleronupe commented Nov 10, 2020

Proposed changes:

  • Solves issue Check if conversation ID is valid for all server endpoints #7022
  • Create a decorator to validate that a conversation ID exists when requests are made to the following endpoints:
    • GET /conversations/<conversation_id:path>/story
    • POST /conversations/<conversation_id:path>/execute
    • POST /conversations/<conversation_id:path>/predict

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)

@sara-tagger
Copy link
Collaborator

Thanks for submitting a pull request 🚀 @JustinaPetr will take a look at it as soon as possible ✨

@wochinge wochinge requested review from wochinge and removed request for JustinaPetr November 11, 2020 09:19
@wochinge
Copy link
Contributor

@JustinaPetr I assigned myself as @aleronupe were already taking here about it

@aleronupe Will give it a review later today or tomorrow 👍

Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

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

Thanks for your PR and sorry for the late review! I really appreciate your initiative and contribution 💪

Can we please also add unit tests for the new changes?

Let me know if I can help somehow!

changelog/7022.improvement.md Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
@@ -776,6 +797,7 @@ async def trigger_intent(request: Request, conversation_id: Text) -> HTTPRespons
@app.post("/conversations/<conversation_id:path>/predict")
@requires_auth(app, auth_token)
@ensure_loaded_agent(app)
@ensure_conversation_exists(app)
async def predict(request: Request, conversation_id: Text) -> HTTPResponse:
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

out of the scope of your PR / optional: We should actually use the lockstore here as processor.predict_next persists the updated tracker.

@aleronupe
Copy link
Contributor Author

Hello @wochinge, we've just made the required changes and added the unit tests for the new functionalities. Would you please take a look at it?

Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

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

Looks great! Added a few more comments, but nothing critical 👍🏻

changelog/7022.improvement.md Outdated Show resolved Hide resolved
changelog/7022.improvement.md Outdated Show resolved Hide resolved
changelog/7022.improvement.md Outdated Show resolved Hide resolved
changelog/7022.improvement.md Outdated Show resolved Hide resolved
rasa/core/tracker_store.py Outdated Show resolved Hide resolved
rasa/core/tracker_store.py Outdated Show resolved Hide resolved
rasa/server.py Outdated Show resolved Hide resolved
async def test_predict_without_conversation_id(rasa_app: SanicASGITestClient):
_, response = await rasa_app.post("/conversations/non_existent_id/predict")

assert response.status == 404
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert response.status == 404
assert response.status == HTTPStatus.NOT_FOUND

"/conversations/non_existent_id/execute", json=data
)

assert response.status == 404
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert response.status == 404
assert response.status == HTTPStatus.NOT_FOUND


_, response = await rasa_app.get(url)

assert response.status == 404
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assert response.status == 404
assert response.status == HTTPStatus.NOT_FOUND

@RomuloSouza
Copy link
Contributor

Hi @wochinge, we've made the required changes. Can you please take a look?

rasa/core/tracker_store.py Outdated Show resolved Hide resolved
rasa/core/tracker_store.py Outdated Show resolved Hide resolved
tests/test_server.py Outdated Show resolved Hide resolved
tests/test_server.py Outdated Show resolved Hide resolved
Base automatically changed from master to main January 22, 2021 11:15
@wochinge
Copy link
Contributor

wochinge commented Feb 3, 2021

@aleronupe Can we wrap this up? Happy to help 🙌🏻

Copy link
Contributor

@wochinge wochinge left a comment

Choose a reason for hiding this comment

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

💯 thanks a lot @aleronupe

tests/test_server.py Outdated Show resolved Hide resolved
@wochinge
Copy link
Contributor

wochinge commented Feb 4, 2021

Re the failing windows tests: Windows testing is a bit flakey atm. Re-running the tests should hep 🤞🏻

Co-authored-by: Rômulo Souza <[email protected]>
@aleronupe
Copy link
Contributor Author

@wochinge we've fixed the URL error but windows tests keep failing on a different section of the code. Is there any other change we should make to fix this?

@wochinge
Copy link
Contributor

wochinge commented Feb 5, 2021

Can you please merge the latest main state into your branch? It should be just a matter of re-running / might be fixed on main already.

@aleronupe
Copy link
Contributor Author

@wochinge we’ve updated The branch and now all the testes are passing

@wochinge
Copy link
Contributor

@aleronupe It's out of date again. Can you somehow make it that I can push to your repo as well? Then i can update the branch as well for you.

@aleronupe
Copy link
Contributor Author

@wochinge Our repo is on an organization from our university, so I think it won’t be possible, but we’ve just updated the branch

@wochinge wochinge merged commit 4abc498 into RasaHQ:main Feb 15, 2021
@wochinge
Copy link
Contributor

Merged 🎉 Thanks for your patience!

@iurisevero iurisevero deleted the validate_conversation_id branch February 21, 2021 03:52
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.

4 participants