JuliaGizmos / Blink.jl

Web-based GUIs for Julia
Other
360 stars 75 forks source link

ssh to remote server #76

Closed udion closed 5 years ago

udion commented 7 years ago

when ssh'd to some remote server and using julia the plot can not be saved using the savefig() function, there is some error related to electron not being invoked, although after the blink installation Atomshell installation does not show any problem. How to save/ plot the graph in such case using plotlyJS??

sglyon commented 7 years ago

Hi @udion. In order to call savefig and use any format besides json or html, PlotlyJS.jl needs to open up an active Blink window. If you are using ssh, this will fail by default because when you ssh there is no display active in which the Blink window can be opened.

There is, however, a trick to get around that problem. If you start Julia with xvfb-run julia it will trick Julia into thinking there is an active display and everything should work without a problem.

Good luck

stugorf commented 7 years ago

I am trying to run Blink.jl inside a Docker container as part of a service running PlotlyJS.jl. The goal is to generate either a png/svg and convert to base64 or to use PlotlyJS's png_data output. Installation works. When I send a request to the service I get connect: connection refused (ECONNREFUSED). I have tried checking ports inside the container and get the same error when sending a request to the port that was randomly assigned to Blink. Can you explain the xvfb-run solution? Installing xvfb and using it to install Blink did not seem to work: # RUN xvfb-run julia -e 'using Blink; Blink.AtomShell.install();'

Thank you for any insights!

stugorf commented 7 years ago

@sglyon Do you know if there is a way to use a PlotlyJS.SyncPlot{PlotlyJS.ElectronDisplay} generate by calling p = plot(data, layout) and sending output to cairosvg to save a chart image? If I could create an image without using Blink.jl then I can create a base64 output using Julia's base64encode function.

sglyon commented 7 years ago

hi @stugorf unfortunately while the PlotlyJS.SyncPlot is in Julia land it is just a dict-like Julia data structure. Right now, the only way we can display it or convert it to an image format like png/svg/pdf... is to hand our Julia data structure over to the plotly.js javascript library and ask it to give us the image format. I use Blink.jl as the javascript engine to process the plotly figure and have it return either the base64 encoded data or the raw svg string.

It is entirely possible that you can find another solution for doing this step on a "remote" machine like a server or from within a docker container. I think the key would be to be able to run a javascript file from the command line.

Hopefully that makes sense?

What happened when you tried the xvfb-run command? what that should be doing is creating a virtual display on whatever server is running your script. This virtual display tricks things like web browsers (e.g. blink) into thinking there is a proper display in which to open their windows.

stugorf commented 7 years ago

Hi @sglyon Spencer,

THank you for the quick reply! I tried using xvfb but may not have it set up correctly. I installed it using ubuntu apt-get and then started Julia with RUN xvfb-run julia but still received the connection refused error. Do you have an example of the xvfb solution that I can review?

Thank you!

sglyon commented 7 years ago

I think the best example is the .travis.yml file in this repo.

See these two lines: https://github.com/JunoLab/Blink.jl/blob/master/.travis.yml#L8 and https://github.com/JunoLab/Blink.jl/blob/master/.travis.yml#L20

stugorf commented 7 years ago

Thank you @sglyon. I'll try these in my Dockerfile.

stugorf commented 7 years ago

Hi @sglyon I am hitting a wall with getting Blink.jl to run headless in a container. Have you ever been successful running PlotlyJS.jl and Blink.jl in a headless environment? I wonder if using something like this https://github.com/JunoLab/Media.jl could be a solution?

sglyon commented 7 years ago

I don't think Media.jl will help you. That is just used to instruct Julia on which display to use for certain types -- it doesn't set up remote displays.

I'm sorry, but I haven't done this before and don't know what would or wouldn't' work. If you do figure something out will you please report back so we know for the next time someone has this issue?

stugorf commented 7 years ago

Progress! I now have Blink responding to request and recognizing a virtual X window in a docker container. I can verify this by running ps auxwww inside the container and seeing the xvfb process.. I am using xvfb-run and calling savefig in PlotlyJS. The error I am now getting seems like something @tbreloffhttps://github.com/tbreloff has likely encountered:

WARNING: the no op transpose fallback is deprecated, and no more specific transpose method for ArgumentError exists. Consider permutedims(x, [2, 1]) or writing a specific transpose(x::ArgumentError) method if appropriate.

I’ll let you know if there is any further progress.

Thank you for your guidance!

From: Spencer Lyon notifications@github.com Reply-To: "JunoLab/Blink.jl" reply@reply.github.com Date: Friday, February 17, 2017 at 11:27 AM To: "JunoLab/Blink.jl" Blink.jl@noreply.github.com Cc: David Hughes david@froguts.com, Mention mention@noreply.github.com Subject: Re: [JunoLab/Blink.jl] ssh to remote server (#76)

I don't think Media.jl will help you. That is just used to instruct Julia on which display to use for certain types -- it doesn't set up remote displays.

I'm sorry, but I haven't done this before and don't know what would or wouldn't' work. If you do figure something out will you please report back so we know for the next time someone has this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/JunoLab/Blink.jl/issues/76#issuecomment-280743516, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFQ5eb3AhxkEsmNhQZgB8KFBruibZKWFks5rdfSUgaJpZM4LI4iF.

Confidentiality Notice

This communication may contain privileged and confidential information intended for the addressee. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of this information (including reliance thereon) is strictly prohibited. If you have received this communication in error, please notify us immediately and then destroy all copies of the communication. To view our complete Notice of Privacy Practices, visit our website at www.seattlecca.org.

sglyon commented 7 years ago

hi @stugorf that's great news -- good work.

What you posed there was just a warning about what happens when you do try to apply the ' operator to an array of strings. Given that it was just a warning, things should have worked out ok for that example.

Hopefully you can figure it out and get PlotlyJS.jl to save figures from inside docker!

ferrolho commented 5 years ago

Slightly similar issue: I am accessing a Jupyter server at work from my laptop at home. When I try to open a Blink window I get the following error:

IOError: connect: connection refused (ECONNREFUSED)

Stacktrace:
 [1] try_yieldto(::typeof(Base.ensure_rescheduled), ::Base.RefValue{Task}) at ./event.jl:196
 [2] wait() at ./event.jl:255
 [3] wait(::Condition) at ./event.jl:46
 [4] stream_wait(::Sockets.TCPSocket, ::Condition) at ./stream.jl:47
 [5] wait_connected(::Sockets.TCPSocket) at ./stream.jl:330
 [6] connect(::Sockets.TCPSocket, ::Sockets.IPv4, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Sockets/src/Sockets.jl:456
 [7] connect(::Sockets.IPv4, ::Int64) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Sockets/src/Sockets.jl:440
 [8] #try_connect#9(::Float64, ::Int64, ::Function, ::Sockets.IPv4, ::Vararg{Any,N} where N) at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/process.jl:71
 [9] try_connect at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/process.jl:69 [inlined]
 [10] #init#10(::Bool, ::Function) at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/process.jl:85
 [11] #init at ./none:0 [inlined]
 [12] #shell#13(::Bool, ::Function) at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/process.jl:123
 [13] shell at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/process.jl:121 [inlined]
 [14] #Window#16(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Type) at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/window.jl:70
 [15] Window() at /home/henrique/.julia/packages/Blink/1QOOi/src/AtomShell/window.jl:70
 [16] top-level scope at In[148]:2

I read an old issue somewhere here on GitHub saying this is still something not supported. Is this still the case, or should it work and I just missed something? Thanks!

twavv commented 5 years ago

Opening a window on a remote Jupyter isn't supported for the same reason that websites can't open up arbitrary applications on your computer. It might be possible to set up some level of X11 forwarding if you're SSHing into the server, but, in general, when you try to open a window, it will be opened on the computer where the Julia process is running (i.e. the server hosting the Jupyter instance).