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

Add Starlette (and thus FastAPI) support #47

Closed

Conversation

twalcari
Copy link

@twalcari twalcari commented Jun 2, 2021

This pull request adds support for Starlette, which underlies FastAPI (the same way Werkzeug underlies Flask).

This way, we add support for the most populair ASGI web frameworks.

For testing purposes, I've also adapted the Flask example to FastAPI and published it here: https://github.com/twalcari/pylti1.3-fastapi-example. I've tested this on https://lti-ri.imsglobal.org/ to verify the implementation.

@dmitry-viskov
Copy link
Owner

dmitry-viskov commented Jun 2, 2021

Hi @twalcari .

First off, thank you for the PR!
There are few blocker reasons why this feature can't be merged at the current moment:

  1. Current library still supports Python 2.7 and 3.5 but Starlette requires Python 3.6+. I'm going to remove support of these versions in some future.

  2. At the current moment I don't consider FastAPI as a suitable framework for the LTI interaction within the current implementation on the library engine. I understand that FastAPI supports async and non-async operations (and as i see from your example you've used it in non-async way) but in my opinion the main advantages of the FastAPI usage in async views. For now the current library contains some http calls (using requests library) + non-async cache usage so it can't be used in case of asynchronous views. So in my opinion first of all this library should be refactored to support usage from the async functions.

  3. FastAPI usually is used in case on JSON requests/responses. But LTI uses form data. That's the other reason why i think that FastAPI is not suitable library for the LTI. In my opinion the library python-multipart should be used in case of FastAPI but it looks like additional non-required dependency that is out of the library scope. I see that you've used form_data = loop.run_until_complete(self._request.form()) but it looks like a workaround instead of using built-in approach.

Because of all this i don't consider FastAPI as additional adapter for the current moment but we may probably return to this feature in the future at least after drop python 2.7/3.5 support.

@twalcari
Copy link
Author

twalcari commented Jun 2, 2021

Hi @dmitry-viskov . Thank you for the quick and careful consideration of this PR. I'll review your remarks and will do some extra work to see how these blocking issues can be resolved.

@orlovmyk
Copy link

@twalcari I am currently working on FastAPI + LTI 1.3 integration too
Have you succeeded in launching your tool? Do you have any advice how to do it easily maybe?

@twalcari
Copy link
Author

In the end I just implemented the part of the LTI advantage spec that I needed myself. I'll attach the relevant code as a tar to this comment.

The project has never progressed beyond a PoC stage, so I cannot vouch for its correctness/performance.

lti_advantage.tar.gz

@orlovmyk
Copy link

@twalcari Thank you, I will take a look. Anyways your PR already helped me a lot to figure out what to do next!

@orlovmyk
Copy link

orlovmyk commented Mar 17, 2023

@twalcari It looks like slightly different implementation for asynchronous applications.

I haven't tested it yet, but I would like to see this project it in PyPi.org, so don't you mind if I will add some packaging and will publish it?

@orlovmyk orlovmyk mentioned this pull request Mar 17, 2023
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.

3 participants