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

Treat list custom json facebook #9567

Closed

Conversation

ErickGiffoni
Copy link
Contributor

@ErickGiffoni ErickGiffoni commented Sep 7, 2021

Hello, I am continuing the work that was previously being done here -> #8332.
It solves #5657

Proposed changes:

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)

silvasara and others added 26 commits March 29, 2021 11:08
* Add ability to point to a certificate in endpoints.yml (RasaHQ#9118)

* Add cert file functionality to Endpoint

* Apply suggestions from code review

types

Co-authored-by: Tobias Wochinger <[email protected]>

* update changelog

Co-authored-by: Tobias Wochinger <[email protected]>

* Fix epoch override for TEDPolicy (RasaHQ#9182)

* bump rasa-sdk dep and min compat version

* fix bug add tests

* add changelog

* change test cases

* remove test cases

* prepared release of version 2.8.1 (RasaHQ#9183)

* update rasa-sdk

* prepared release of version 2.8.1

* update lock

* Make UnexpecTEDIntentPolicy compatible with E2E data (RasaHQ#9203)

* bump rasa-sdk dep and min compat version

* add test and code

* add changelog and refactor method

* add test

* more test cases

* use applied_events

* 2.8.x: Remove experimental feature warning for story validation and entity roles and groups (RasaHQ#9237)

* I removed the experimental feature designation from the docs.

* I removed the entity roles and groups experimental feature warning message from the code, and tested it using 'rasa train' on a minimal example.

* I removed the unused import: rasa.shared.utils.common

* Adding change log files for issues 8791 and 8024.

* Rewording change logs to make it clear that the behaviour of the features remains unchanged.

* prepared release of version 2.8.2 (RasaHQ#9262)

* prepared release of version 2.8.2

* Updated the date of release.

* install yarn dependency in cloned repository, in docs publication workflow

* silence yarn warning

* Fix typo in push_docs_to_branch.sh

* Generated a new poetry lock file

Co-authored-by: Joe Juzl <[email protected]>
Co-authored-by: Tobias Wochinger <[email protected]>
Co-authored-by: Daksh Varshneya <[email protected]>
Co-authored-by: m-vdb <[email protected]>
@ErickGiffoni ErickGiffoni requested a review from a team as a code owner September 7, 2021 20:58
@ErickGiffoni ErickGiffoni requested review from ancalita and removed request for a team September 7, 2021 20:58
@ErickGiffoni ErickGiffoni mentioned this pull request Sep 7, 2021
3 tasks
@ErickGiffoni
Copy link
Contributor Author

ErickGiffoni commented Sep 7, 2021

I just realised I accidentally pushed some files from another issue I was working on, sorry!
I'll make the proper adjustments later.

@ErickGiffoni
Copy link
Contributor Author

Ok, ready for review.

@ancalita ancalita linked an issue Sep 14, 2021 that may be closed by this pull request
Copy link
Member

@ancalita ancalita left a comment

Choose a reason for hiding this comment

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

Thank you for continuing work on this issue 💯

In addition to the suggestions below, I'd like to request you to rebase to target 2.8.x since this is actually a bugfix and this could be released in a minor.

Probably the easiest would be to open a new PR with only the solution specific to this bugfix (and not the README diff that shouldn't be in this PR) to avoid potential git funkiness when rebasing. If you choose this route, you can close this PR afterwards.

@@ -0,0 +1 @@
Add list handling in the `send_custom_json` method on `channels/facebook.py`.
Copy link
Member

Choose a reason for hiding this comment

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

I think this changelog entry should actually be a bugfix rather than improvement based on the original issue. It would also be great if you could give more details around the bug since it isn't very clear for me in which circumstances would the json_message be of type list rather than dict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Done in a new branch rebase-treat-custom-json-fb.
I haven't pushed it yet, but soon I will and I'll also open the new PR.

) -> None:
"""Sends custom json data to the output."""

recipient_id = json_message.pop("sender", {}).pop("id", None) or recipient_id
if isinstance(json_message, dict) and "sender" in json_message.keys():
Copy link
Member

Choose a reason for hiding this comment

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

This also needs a check if json_message is list and assigning recipient_id to the extracted id from json_message.
Potentially also json_message needs to be updated to be of dict type when being given as an argument to self.messenger_client.send(), not entirely sure since Facebook code doesn't have type annotations.
I'd advise researching a bit how to test that this works with MessengerClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, except the part regarding json_message being updated to dict.
It seams to be ok passing a list to self.messenger_client.send().

rasa/core/channels/facebook.py Outdated Show resolved Hide resolved
@@ -0,0 +1,91 @@
import logging
Copy link
Member

Choose a reason for hiding this comment

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

Could you please shift this file into the correct subdirectory: tests/core/channels?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

},
]
}
json_with_id = {
Copy link
Member

Choose a reason for hiding this comment

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

This test should also check that send_custom_json works with json_message as list.
I would also suggest using pytest.mark.parametrize for different json inputs and expected values of recipient_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ErickGiffoni
Copy link
Contributor Author

@ancalita ok, I'm on it !

@ErickGiffoni
Copy link
Contributor Author

Closing this PR. The new one is #9692, rebased to 2.8.x.

@SamuelNoB SamuelNoB deleted the treat-list-custom-json-facebook branch January 27, 2022 22:00
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.

Type error in facebook.py
7 participants