-
Notifications
You must be signed in to change notification settings - Fork 248
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
Add Falcon (ASGI) adapter #614
Add Falcon (ASGI) adapter #614
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great addition! We are happy to have this enhancement but could you check my comments and update your branch?
Additionally only check it a single time
Thanks for the quick review @seratch! I've updated the PR with your requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update a few comments in the example apps?
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
@sarayourfriend Thanks for quick updates on the feedback! My last request is to update the examples a bit. Once the builds pass, we can merge this PR and release a new version by the end of this week. |
Hmm, it seems like there's an issue with the fact that there are tests that expect Falcon 2 instead of 3... is there some way to exclude the async Falcon tests when the falcon version is I suppose the module level skip could do it? https://docs.pytest.org/en/latest/how-to/skipping.html#skipping-test-functions |
# pip install -r requirements.txt | ||
# export SLACK_SIGNING_SECRET=*** | ||
# export SLACK_BOT_TOKEN=xoxb-*** | ||
# uvicorn --reload -h 0.0.0.0 -p 3000 async_app:api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarayourfriend Can you add unvicorn to requirements.txt in the same directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. I'm not sure what version range to pin it to. The project is still <1. Should I just use uvicorn>=0.17.6
(the currently released version)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do the same with fastapi examples
@sarayourfriend You can change this line to use |
@seratch should I also remove the conditional in the existing Falcon adapter tests? I've never worked with It could make this function unnecessary: https://github.com/sarayourfriend/bolt-python/blob/78b64878b692039e39530888a012bf738ca74058/tests/adapter_tests/falcon/test_falcon.py#L23 |
@sarayourfriend Ah, sorry - never mind my above comment. I totally forget what I did in the past 🤦 No need to modify Can you modify https://github.com/slackapi/bolt-python/blob/v1.11.6/.github/workflows/tests.yml#L73 to have |
@seratch just wanted to make sure, because I don't see any other explicit dependency installations in that workflow... would it make sense to add the This is the patch I would apply if that makes sense, but I don't know if "conflicting" arguments like this would cause diff --git a/setup.py b/setup.py
index 6543529..9c92d94 100755
--- a/setup.py
+++ b/setup.py
@@ -68,6 +68,8 @@ setuptools.setup(
"aiohttp>=3,<4",
# Socket Mode 3rd party implementation
"websockets>=8,<10",
+ # Falcon introduced ASGI support in v3
+ "falcon>=3,<4",
],
# pip install -e ".[adapter]"
# NOTE: any of async ones requires pip install -e ".[async]" too
@@ -79,7 +81,7 @@ setuptools.setup(
"click>=7,<8", # for chalice
"CherryPy>=18,<19",
"Django>=3,<5",
- "falcon>=3,<4",
+ "falcon>=2,<4",
"fastapi>=0.70.0,<1",
"Flask>=1,<3",
"Werkzeug>=2,<3", If this doesn't work for some reason or you still prefer the explicit installation in the |
@sarayourfriend this line manually installs v2: https://github.com/slackapi/bolt-python/blob/v1.11.6/.github/workflows/tests.yml#L56 this is necessary for v2 tests but it causes errors in the async tests you added. |
Ah, I see. Makes sense, thanks for explaining. Pushed the update! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarayourfriend I found that your unit test properly detects a bug in your code. Can you check my comments?
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Co-authored-by: Kazuhiro Sera <seratch@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #614 +/- ##
==========================================
- Coverage 91.52% 91.46% -0.06%
==========================================
Files 169 170 +1
Lines 5723 5766 +43
==========================================
+ Hits 5238 5274 +36
- Misses 485 492 +7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR adds an ASGI Falcon App adapter to complement the existing Falcon adapter for WSGI apps.
I wrote this code originally based on the existing adapter for https://git.sr.ht/~sara/openverse-slack-reaction.
The code I wrote there is copied almost directly here with some modifications to raise errors when an incompatible Falcon version is being used. You can see the original code here: https://git.sr.ht/~sara/openverse-slack-reaction/tree/main/item/falcon_adapter.py
It's deployed to production with https://openverse-slack.sarayourfriend.pictures.
Hope it's okay I didn't open an issue for this first, but I needed it for my own app one way or another and copying the file and adding tests was trivial so I didn't spend too much extra time on this compared to just writing a helpful issue describing the feature 🙂
Category (place an
x
in each of the[ ]
)slack_bolt.App
and/or its core componentsslack_bolt.async_app.AsyncApp
and/or its core componentsslack_bolt.adapter
/docs
Requirements (place an
x
in each[ ]
)Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
./scripts/install_all_and_run_tests.sh
after making the changes.