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
Remi behind jupyter server proxy #475
Conversation
gbrault
commented
Nov 22, 2021
- Designed with minimal remi change in mind (see diff files to estimate the level of change)
- For both remi core and remi apps (minimal change)
- Fully tested with jupyter-server-proxy
- Jupyter notebooks provided
- works only with 3.6+ (f"" string interpolation)
- If proxy not used, legacy remi app are working
- adding proxy feature need some remi app rework (to calculate url for the front-end)
@gbrault this is an extraordinary work! The work that can be done only by an experienced man. Please EXCUSE ME for the late reply. Fstrings are fine for performances and readability, but it prevents the use on older python versions. Just to make you an example, I'm using remi on a plc (beckhoff softplc) that runs only python 3.4. Unfortunately this happens. Proxy seems a bit invasive, I'm not sure to understand why it is required. Can you please explain it simply to me? |
@dddomodossola I understand your point! I am interested by remi as a gui component for Jupyter based applications. I use Jupyter for processing data from production and sales for a medium company and time to time, I need some UI to enter data or browse sql database. Remi seems a good candidate for that. |
Of course, I need a proxy to have both, the notebook and the UI interoperating seemlessly. The user see it as a single application. Starting the UI from a notebook enable to share the same python machine. |
I'm really interested in your changes, lots of people uses jupyter and of course it is wonderful to get remi usable from it. Maybe this is feasible without affecting remi server. I have to study your changes in detail.
Maybe the Proxy class can be avoided (not sure). I'm thinking about solving the resource problem directly in remi server:
If this solution could be feasible, the remi library could get untouched, and all gets solved by a template App, with a special _get_static_file function. import remi.gui as gui
from remi import start, App
import os
class MyApp(App):
def _get_static_file(self, filename):
#here the magic should be done
...
def idle(self):
...
def main(self):
...
if __name__ == "__main__":
start(MyApp) Do you think this could be feasible? Thank you a lot for the collaboration. |
This is a good idea! import remi.gui as gui
from remi import start, App
import os
class MyApp(App):
def _get_static_file(self, filename):
#here the magic should be done
...
def idle(self):
...
def main(self):
...
if __name__ == "__main__":
start(MyApp) This solve all the cases where the client ask for a file and in _get_static_file, we have a chance to tweak all content where you have patterns like "/:" where res can be in ['res', "editor_resource', etc...] I can give a try to write "#here the magic should be done"... (it should be mainly based on some code I wrote already) I let you know. |
BugFix #469 Now clicking on a leaf MenuItem makes the menu to be hidden.
@dddomodossola, I used your recommendation, it comes to only modifying server.py
I don't think I have used coding rules which cannot be used in earlier version of Python in server.py. I calling code, it can be post 3.6+ version (no influence on your code) If you want we can make a video call to show you it works and see if we can even simplify again! Let me know! |
I have also created all_paths to get all the /res: like tokens |
One drawback of this method might be performance:
|
@gbrault you did the magic! I gave a rapid look at the code and seems:
I will analyze it better this late evening and merge. Thank you so much! |
remi/server.py
Outdated
self._log.debug('get: %s' % func) | ||
if 'overload' not in kwargs: |
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.
Why is it required to pass the overload function as arguments? The App class is inherited, so the function _overload is already overloaded. Doesn't it?
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 are perfectly right, this is not needed, we just need to use self._overload to call the function (it is a scorie which need to be cleaned-up: I make the correction and send new a new version.
Why you preferred to replace/correct paths instead of resolving them by overloading the _get_static_file function? I supposed that overloading that _get_static_file function you can interpret the path inside it. Isn't this possible? |
From the reverse proxy perspective (Jupyter-Server-Proxy), an url targeting the remi server, in the client (browser) needs to be http(s)://<the server domain>:{jlabport}/proxy/{remiport}/<original path to remi server> When the 'original' remi generates url, the /proxy/{remiport}/ part does not exists and it would rather send to the client http(s)://<the server domain>:{remiport}/<original path to remi server> From my understanding _get_static_file function would be usefull to find the os disk path if given /proxy/{remiport}/<original path to remi server> But this never happens, as the reverse proxy when called by the client with http(s)://<the server domain>:{jlabport}/proxy/{remiport}/<original path to remi server> calls back remi server with http://localhost:{remiport}/<original path to remi server> Do you agree, or am I missing something? |
Yes, thank you for the clarification. |
Thank you ;-) |
The extra code in _process_all is cleaned |
Merged, thank you 😊 |
You welcome! |
Now remi can be executed from Jupyter, this is cool |
With this feature, when you have target platform able to support Jupyter Lab (I used it on a raspberry PI 3 A+ with success), you have a complete web access with:
|