Skip to content

Add Docker in installation methods #187

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

Closed
antoinerg opened this issue Jan 11, 2019 · 20 comments · Fixed by #222
Closed

Add Docker in installation methods #187

antoinerg opened this issue Jan 11, 2019 · 20 comments · Fixed by #222

Comments

@antoinerg
Copy link
Collaborator

I think we should advertise our Docker images in the installation methods as Docker is getting more and more popular and should solve all the problems related to missing dependencies or misconfiguration.

@etpinard
Copy link
Contributor

Good idea! We could either upload a docker image for each of our releases alongside the mac/windows/linux executables:

image

or just provide a link to quay,io (are those public links?) in the README.

cc #178

@austinbutler
Copy link

Having it available in the Docker Hub would be great. I saw the somewhat convoluted possible install options in the README and at first thought those were the only options. Then I noticed there's a Dockerfile in the deployment folder in this repo, but even then since it's not documented figured it wouldn't be good to rely on it.

@etpinard
Copy link
Contributor

Good point by @antoinerg in #190

For #187, we may want to write a new Dockerfile aimed at offline use without streambed plotly.js but the public bundle.

where I'd say we should add another Dockerfile!

@antoinerg
Copy link
Collaborator Author

Having it available in the Docker Hub would be great.

@austinbutler Is there something special about Docker Hub or would any other Docker registries fit your needs? We were thinking of using quay.io instead. You can pull from it the same way you pull from Docker Hub.

@austinbutler
Copy link

Quay would be fine, too. But in terms of visibility Docker Hub is just where I default to when looking for images.

@antoinerg
Copy link
Collaborator Author

antoinerg commented Jan 16, 2019

where I'd say we should add another Dockerfile!

Ok, I'll make a new one. Can we start it from the most recent LTS version of Ubuntu (which is newer than the current https://github.com/plotly/orca/blob/master/deployment/Dockerfile)?

If so, I could reuse the ones I made many when I worked on delivering reproducible OpenGL
and published a Docker image here: https://hub.docker.com/r/antoinerg/orca-reproducible.

@etpinard
Copy link
Contributor

Can we start it from the most recent LTS version of Ubuntu

yes please.

I could reuse the ones I made many when I worked on delivering

sure.

@PedroRegisPOAR
Copy link

I would love to see Docker images to run this!

I have a question, @antoinerg I am not sure if I am in the right place, but as an user I would love to use full plotly.py functionalities, that includes orca, in an Docker image. Who may provide a way to do this? The plotly.py or the orca repository?

I guess that for most users, like me, would expect to have a way do install all plotly.py stuff, that includes orca, from a Python official base image. Is here the right place to talk about this?

I think if orca provide a way to build an image it is going to help to build a image for all plotly.py stuff.

I have been trying to do so for some time (many hours spent), but no luck. And while searching to see if someone has done a image, I could find many people trying to do that and failing too. A list of some links that I've saved:

From plotly community:
Plotly-Orca and Docker
Error to locate Orca

From stackoverflow:
Docker and Plotly
How to Build a Docker Python Image with Plotly?

From a russian guy: R plotly orca

An interesting image that I found is this for the R stuff (I am not R user so is not clear to me what that image does).

@gpernelle
Copy link

Are there already some documents that could help build a docker image than runs python plotly and orca?
Or a docker image already built?

@scjody
Copy link
Contributor

scjody commented Feb 14, 2019

I just became aware of this issue. 👋

https://quay.io/repository/plotly/image-exporter?tab=info is a public Quay repo that holds Orca images for every successful CircleCI test-and-push (one is attempted on every push to this GitHub repo). This is, and was always intended to be public.

We should probably rename the repo to avoid confusion (this project wasn't always called "orca"), but other than that is there anything else needed here?

@antoinerg
Copy link
Collaborator Author

antoinerg commented Mar 8, 2019

We should probably rename the repo to avoid confusion (this project wasn't always called "orca"),

I agree

, but other than that is there anything else needed here?

As of right now, our Docker images quay.io/plotly/image-exporter:master have an entrypoing that starts an Orca server that can be queried using a simple HTTP API. That's very cool and we should advertise that this feature is available today.

However, I think we should also support running Orca as a command-line tool as it does in a normal desktop installation. For example, a user should be able to bind-mount a folder and run the equivalent of orca graph:

$ docker run -i -v $(pwd):$(pwd) -w $(pwd) \
      antoinerg/orca-reproducible graph --verbose myfigure.json
exported myfigure, in 1158.483293 ms

or pipe the figure to the STDIN of the process

cat myfigure.json | docker run -i antoinerg/orca-reproducible graph --verbose > myfigure.png

To make this happen, we would need to slightly modify the Dockerfile's ENTRYPOINT to enable both use cases.

cc @scjody

@cedricyau
Copy link

@antoinerg Thanks for uploading the antoinerg/orca-reproducible Docker Image to DockerHub. By any chance, have you published the DockerFile anywhere? I found it really useful to get around all my Ubuntu Server installation issues and would like to see if I could use it load JSON and publish images to S3 with AWS Batch.

@antoinerg
Copy link
Collaborator Author

Thank you @cedricyau for your interest in plotly!

@antoinerg Thanks for uploading the antoinerg/orca-reproducible Docker Image to DockerHub. By any chance, have you published the DockerFile anywhere?

Not yet, sorry!

I found it really useful to get around all my Ubuntu Server installation issues

Great to hear this! The plan is to have an official Docker image for Orca very soon! (WIP in branch docker-release)

and would like to see if I could use it load JSON and publish images to S3 with AWS Batch.

I am not familiar with AWS Batch. Do you need to run Orca as command-line tool or can you run it as a HTTP API server?

@cedricyau
Copy link

I would need to run orca as a command-line tool. My goal is to have this run serverless. So we can leave the system "off" most of the time and only run it when we need it.

@antoinerg
Copy link
Collaborator Author

@cedricyau I opened a PR #222 which may be of interest to you.

Please note that antoinerg/orca-reproducible was meant to achieve reproducible output from machine to machine down to every pixel. This is not something most people care about since the differences can be tiny. The downside is that it uses a software implementation of OpenGL to achieve this and it is rather slow. The upside of course is that an input can only be associated to one output regardless of the hardware you're using. This is actually a bold claim so it needs to be tested further. I hope to roll in a --reproducible or --softwareRendering flag into the offical Docker image but that will have to wait a little bit.

@slfan2013
Copy link

slfan2013 commented Jul 26, 2019

As of right now, our Docker images quay.io/plotly/image-exporter:master have an entrypoing that starts an Orca server that can be queried using a simple HTTP API.

Hello @antoinerg , I found using HTTP API to call orca really useful for me. I wonder can you please illustrate how to use HTTP API to export svg plots?

Suppose I have a port with url running the orca http://metda_plotly:9091. What would be the corresponding command (or code) for $ orca graph '{ "data": [{"y": [1,2,1]}] }' -o fig.png? Is it $ docker run -i quay.io/plotly/orca graph '{ "data": [{"y": [1,2,1]}] }' -o fig.png?

Or what is the correct endpoint to call?

@antoinerg
Copy link
Collaborator Author

@slfan2013 glad to know it is useful for you!

Instead of POSTing a JSON of your figure directy to your endpoint, wrap it in another object with:

{
  "format": "svg",
  "figure": "... your figure"
}

as described there:

/** plotly-graph parse
*
* @param {object} body : JSON-parsed request body
* - figure
* - format
* - scale (only for plotly.js v.1.31.0 and up)
* - width
* - height
* - encoded
* - fid (figure id)
* 0r:
* - data
* - layout
* @param {object} req: HTTP request
* @param {object} _opts : component options
* - format
* - scale (only for plotly.js v.1.31.0 and up)
* - width
* - height
* - safeMode
* @param {function} sendToRenderer
* - errorCode
* - result
*/

@antoinerg
Copy link
Collaborator Author

antoinerg commented Jul 26, 2019

@slfan2013 I should probably also mention that the latest docker Image on quay.io now supports HTTP content-negotiation. You can specify the format you want in an HTTP Accept header as shown below without having to modify the JSON payload:

$ docker pull quay.io/plotly/orca
$ docker run -it -d -p 9091:9091 quay.io/plotly/orca
$ curl -d @14.json -H "accept: image/svg+xml" localhost:9091
... return SVG ...

The supported accept types are given by the values in the object below:

contentFormat: {
png: 'image/png',
jpeg: 'image/jpeg',
webp: 'image/webp',
svg: 'image/svg+xml',
pdf: 'application/pdf',
eps: 'application/postscript',
emf: 'image/emf'
},

@slfan2013
Copy link

Thank you @antoinerg . It helped a lot!

Now I am able to generate the plot. How can I export it (possibly using a correct endpoint)?

What I have done using R is as follows,

pacman::p_load(plotly, httr, jsonlite)
plot = plot_ly(z = ~volcano) %>% add_surface()
bod = list(
  figure = plotly_build(plot)$x[c("data","layout")],
  format = 'svg'
)
POST(url = "http://localhost:9091", body = plotly:::to_JSON(bod), encode = "json")

It successfully generated the plot giving an output of

Response [http://localhost:9091/]
  Date: 2019-07-26 18:21
  Status: 200
  Content-Type: image/svg+xml
  Size: 309 kB
<BINARY BODY>

I wonder how am I suppose to download this? Something like http://localhost:9091/xxx.svg?

@slfan2013
Copy link

Oh, got it!


res <- httr::POST(
        paste0("http://127.0.0.1:", port), 
        body = to_JSON(bod)
      )
      httr::stop_for_status(res)
      httr::warn_for_status(res)
      con <- httr::content(res, as = "raw")
      writeBin(con, file)

Perfect. This plotly + orca whole thing is perfect. Thank you @antoinerg

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

Successfully merging a pull request may close this issue.

8 participants