It was fantastic to create an image for ApiLogicServer. ApiLogicServer creates an API server, instantly. To experience it, opening a browser is a must-have (see Open API).
Here is what I have tried:
Looking for any approach to launching a browser on the created server, either from the console, a “webloc” file, from a cell, etc.
Locally, it ilocalhost:5000.
For making this Binder-ready, I think you’d want to run your steps in the notebook and not deal with venv. In other words add a cell with the following and remove source venv/bin/activate
and add a cell with the following:
%%bash
ApiLogicServer run
Then for launching the API interface, equivalent of http://localhost:5000
, I believe you’d use Jupyter Server Proxy. Something like https://notebooks.gesis.org/binder/jupyter/user/valhuber-apilogicservertutorial-6easlb4a/proxy/5000/
should switch to the API interface when you get the pieces in place.
“Jupyter Server Proxy lets you run arbitrary external processes (such as RStudio, Shiny Server, syncthing, PostgreSQL, etc) alongside your notebook, and provide authenticated web access to them.”
This implementation of using it to make a package, may help you understand it more. It is also what RStudio is using to run on Binder, see here. I’ve used it access hugo which normally runs a server accessible on http://localhost:1313
. Go here, click on launch binder
and then in the notebook that comes up when the session spins up, run the cells up to above ‘Click following link to open & preview content on development server’. The link below ‘Click following link to open & preview content on development server’ opens the proxy window.
Thanks so much for the quick response. But I had no luck.
I did remove the venv stuff (you were right, it’s not required). I can start the server with no problem, either from a terminal window, or with a cell containing !ApiLogicServer run —db_url=
But for this to be of any value, I need to get to the Browser (also to curl, but that works in terminal using localhost:
curl -vX PATCH "http://localhost:5000/Customer/ALFKI/“…
This got “not found”: https://notebooks.gesis.org/binder/jupyter/user/valhuber-apilogicservertutorial-mxxyzccd/proxy/5000
This got “forbidden”: https://notebooks.gesis.org/binder/jupyter/user/valhuber-apilogicservertutorial-mxxyzccd:5000
I look at your binder. It did run, but it appears you are using: the running development server - it did not seem to do anything when I tried it in my notebook.
I also experimented with trying to install Chrome using apt.txt, but I have no clue about that.
I also did hostname -I, and pasted that into my browser, with and without /proxy - it hangs:
http://10.244.95.170/proxy/5000
http://10.244.95.170:5000
It’s super ironic that I was able to deploy and run this complex environment on my first try, but fail on browser access. But it’s a must-have, so any help is greatly appreciated. I am available for zoom if that works for you (I live in California).
I read a bit about ServerProxy - it appears to be about servers known in advance. The whole point of this project is that it can create and run an API Server given a database. So the server does not exist beforehand.
If you are running things via Binder, you are already in a browser, right? You just need to get the service from the session to appear in a window on the browser. That is what the proxy allows.
If you start up the development server by running all the cells above (first 11 cells in the notebook), when you click on the link in the markdown just below where you started the development server while the development server is running, it opens the page served via the development server in another tab on my local Chrome browser. The basic HTML only works because the css and javascript files aren’t found correctly due to relative paths; however, it illustrates the remote server being proxied to your local browser from the session. (It doesn’t matter for your case, but to explain why I don’t care about the css and js, I’m actually planning to use a different way to let users access the hugo-built pages now based on jupyter-http-server because it works more easily and will be more in line with how the built pages will ultimately be served; I just haven’t changed the rest of tutorial to actually use it yet).
I updated the thread you referenced with a new post and now the directions should get you launching Firefox with webbrowser.open()
commands in an ipython console. I don’t think that works from Jupyter because I feel there you should use the proxy.
Maybe looking at this other example will help it click more for you. Pay close attention to the ‘Setup: start the desktop’ part. Or this one is nice because it clearly illustrates how the proxy is used to open streamlit in the launch binder
link. If you go here and click on the launch binder badge you can see how the SpyderIDE is run in a desktop in the browser via Jupyter to for demonstration/tour.
Again, thanks for getting back.
I think I misled you with installing (remote) Browser in notebook. I agree that I am already in a (local) browser, and just need a new tab/window to connect to the proxy. So let’s focus on the proxy.
I am certain my remote server (ApiLogicServer) is running I it responds to curl commands issued in the notebook, using remote’s localhost:
curl -vX PATCH "http://localhost:5000/Customer/ALFKI/“…
So we are back to how to get from my local browser to the remote ApiLogicServer via the proxy. I have tried 2 ways:
- Get the IP from from
hostname -I
. It hangs when I try
http://10.244.95.170/proxy/5000
http://10.244.95.170:5000
-
Use the URL that accesses the binder notebook. This was trying to follow your suggestion, which I do agree looks like the best path:
I have updated my `requirements.txt’ to:
ApiLogicServer
jupyterlab==3.0.7
jupyter-offlinenotebook
jupyter-server-proxy
so I am presuming the proxy is there.
So, in conclusion, I agree that approach 2 is most promising, but I failing when I try to make your suggestion work.
Zoom?
Did any of the examples you’ve found where jupyter-server-proxy
runs include JupyterLab 3? I see given the ‘Bump extension to 2.1.2: jupyterlab 3 support’ comment text of this commit that they’ve done it; however, given that commit was last month and JupyterLab release candidate only very recently was shown to be Binder-ready I’d like to find a working example via Binder before switching from JupyterLab 2 to 3. Seen any?
Did you try putting a trailing /
after 5000
? It used to be very important, see the bottom of GitHub - chekos/testing-streamlit-mybinder: A repo tryna see if you could run a streamlit app in mybinder . I think though it was adjusted to not be required because I seem to have a mix.
Just so you know, if it helps in testing, with jupyter-desktop-server, you can run Firefox. It was in the links above.
My fork is currently ALMOST working. Or at least seems promising. It is an all white page but says Swagger UI at top and has HTML. And the server in the terminal reacts with an HTTP 200 response every time I hit the page. See https://notebooks.gesis.org/binder/jupyter/user/fomightez-apilogicservertutorial-vldtyrjr/proxy/5000/?token=uNVPWiQpTjmocnoA4Y9Xcw in the next 10 minutes and view the page source.
The HTML I see I pasted here.
I started it with ApiLogicServer run
in the terminal and maybe that is why it is otherwise a white page?
Yes, I see the White Page. Syracuse gets a lot of snow, does it?
I do appreciate your help here. Let’s continue to work the problem, but I will begin to transition the page to rely more on curl than swagger. Not my preference, but I am making peace with it.
Thanks,
Val
Yes, sorry, I don’t know enough about what is behind those choices to be much help on how to better implement. Also, I’m not yet aware of the what is behind the proxy service working to offer much advice on how to better integrate your needs. I will say that maybe now that you have it closer to working and know some more of what is involved in making your situation play along with MyBinder more, you may ultimately want to craft a new post here asking for advice. You may attract more interest than the current topic/title. I think the category of Binder (/ Jupyterhub?) would be more appropriate for that unless I am missing something. I don’t think you even need JupyterLab per se? I think there is a ‘repo help needed’ sub-topic although I don’t know if that would catch the eye of those well-versed in the server proxy.
Plus, there is a Jupyter Community Call in a couple of weeks. Even if you aren’t comfortable making it a topic of discussion, sometimes there’s some time for a bit of technical talk before or after with others that know a lot and can help you that last mile.
Yes, we are one of the snowiest cities of our size.