ejeschke / ginga

The Ginga astronomical FITS file viewer
BSD 3-Clause "New" or "Revised" License
121 stars 77 forks source link

Start viewer server OSError: [Errno 99] Cannot assign requested address (Google Colab) #1014

Open jortiz12 opened 2 years ago

jortiz12 commented 2 years ago

Dear community,

I´m trying to replicate the example ginga_ipython_demo.ipynb in a Google Collab Notebook. However, when executing the code line ``, I get the following error.

imagen

Any assitance would be highly appreciated. It may be due to the fact that I'm running the notebook in Google's platform as opposed to in a "local" (ie in my computer) Jupyter server.

Kind Regards Jose

ejeschke commented 2 years ago

@jortiz12, I just tested the notebook locally, and it is still valid. I suspect the collab environment may restrict opening ports in some way? In any case, the port number can be changed in the second cell of the notebook. Try changing it from the default of 9914 and let us know the result.

jortiz12 commented 2 years ago

First, thanks for your time and attention.

The issue doesn´t lie in the port number line of code server = ipg.make_server(host='localhost', port=8888, use_opencv=use_opencv), as I changed it from 9914 to 8888 (Jupyter default).

The error continus to appear when running server.start(no_ioloop=True).

pllim commented 2 years ago

I don't think this is Ginga's problem. See https://stackoverflow.com/questions/69880285/receive-oserror-errno-99-cannot-assign-requested-address-on-google-colab

jortiz12 commented 2 years ago

Thanks pllim,

Indeed, indeed. That's also my opinion. The issue is that as I'm working with very large IFS MUSE datacubes , my local machine hasn´t enough RAM. Hence, I've to make use of Google Cloud Platfrom.

I was simpy trying to use GINGA in such notebook in Google Colab as although I've the DS9 viewer opened, Google Colab doesn't "know" of its existance. Nor does of Ginga it seems.

Thxs again. jose

pllim commented 2 years ago

@jortiz12 , just to make sure, did the StackOverflow solution work for you?

jortiz12 commented 2 years ago

No bcse that solution applies to a Jupyter-based notebook, not to a notebook in Google Colab. I can also confirm tat GINGA is wking perfctly well in my "local" Jupyter. The issue is when you use Google Colab notebooks.

Txs again for the attention.

pllim commented 2 years ago

I am not sure what can be done in the Colab world. It seems to still be stuck in Python 3.7 while packages have moved on. @ejeschke , any ideas?

ejeschke commented 2 years ago

Thinking about this a little more deeply, I think there are two issues. The first is that probably we need to replace "localhost" with the hostname or IP of the google collab host where the notebook is actually running. For that, I think you might want to look at this video. That is simple enough. @jortiz12, please try that first and then report back here.

The second potential issue is whether you are allowed to open a port on the collab server that is open to your browser on your laptop (or wherever). You may need to tunnel the connection. I've seen a couple links on that, but let's see about the first issue before going there.

ejeschke commented 2 years ago

So I tried running this notebook on Google Collab. Using the following, it does not give me an error trying to start the server:

import socket
hostname = socket.gethostname()
ipaddr = socket.gethostbyname(hostname)

then replace "localhost" with ipaddr.

However, there is then (I think) the second issue of how to tunnel to that connection, because I think it is walled off. I'm looking that that now. It seems to be a known issue with no real support from google. However, a lot of tutorials related to this issue seem to be using a package called pyngrok. Looking into that now...

ejeschke commented 2 years ago

Just a note for the sake of completeness, I tried the Ginga Jupyter Widgets backend. It displays in Google Colab, but since ipyevents does not seem to be supported there, I could not get any interactivity with the widget. @mwcraig, do you have any experience getting ipyevents working in Google Colab?

jortiz12 commented 2 years ago

Hello @ejeschke @pllim,

Your first advice, changing the hostname, indeed has worked for me!!. It was just a matter of replacing the line server = ipg.make_server(host='localhost', port=8888, use_opencv=use_opencv) to server = ipg.make_server(host=hostname, port=8888, use_opencv=use_opencv), where hostname can be found with:

import socket hostname = socket.gethostname() IPAddress = socket.gethostbyname(hostname) print("my host computer name is " + hostname) print("my host computer IP Address is " + IPAddress)

Thks so much. Much appreciated. Kind Rgds Jose

jortiz12 commented 2 years ago

Hello again, Well, I was too quick in saying that the problem had been solved. Though by changing the localhost to Google's server hostname, as noted above, the line of code v1 = server.get_viewer('v1') didn´t resulted in any error, when I copy the URL from the output of v1.url and copy it into my browser, it can´t be found ...

ejeschke commented 2 years ago

Yes, that mirrors my result above. I think Collab doesn't want to open any ports to the world unless it can be tunneled somehow.

pllim commented 2 years ago

Instead of Collab, let's step back and maybe you should ask the data provider if they have a proper science platform you can use...

jortiz12 commented 2 years ago

Thxs @ejeschke and @pllim Indeed, and I'll continue to work with the less "heavy" data in my local Jupyter. Best rgds Jose

mwcraig commented 2 years ago

@mwcraig, do you have any experience getting ipyevents working in Google Colab?

I haven't tried -- my experience with colab was mixed the last time I looked at it so I've never really tried. ipyevents only uses the standard widget communications channel but I have no idea how how google modified that channel to get widgets working.

ejeschke commented 2 years ago

@mwcraig, do you have any experience getting ipyevents working in Google Colab?

I haven't tried -- my experience with colab was mixed the last time I looked at it so I've never really tried. ipyevents only uses the standard widget communications channel but I have no idea how how google modified that channel to get widgets working.

It seems like they have modified something, because ipyevents still works fine in a local notebook, but I can't get any events coming through running it on Colab: mouse, keyboard, scrolling...anything

ejeschke commented 2 years ago

It's too bad, because that would be the way to go, IMHO--no need to tunnel anything.