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

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

Open
jortiz12 opened this issue Aug 10, 2022 · 18 comments
Labels

Comments

@jortiz12
Copy link

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
Copy link
Owner

@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
Copy link
Author

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
Copy link
Collaborator

pllim commented Aug 11, 2022

@pllim pllim added the question label Aug 11, 2022
@pllim pllim changed the title Start viewer server ERROR Start viewer server ERROR (Google Colab) Aug 11, 2022
@pllim pllim changed the title Start viewer server ERROR (Google Colab) Start viewer server OSError: [Errno 99] Cannot assign requested address (Google Colab) Aug 11, 2022
@jortiz12
Copy link
Author

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
Copy link
Collaborator

pllim commented Aug 12, 2022

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

@jortiz12
Copy link
Author

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
Copy link
Collaborator

pllim commented Aug 12, 2022

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Collaborator

pllim commented Aug 15, 2022

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
Copy link
Author

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

@mwcraig
Copy link
Contributor

mwcraig commented Aug 16, 2022

@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
Copy link
Owner

@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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants