plotly / orca

Command line application for generating static images of interactive plotly charts
MIT License
294 stars 40 forks source link

525: plotly.js error #223

Closed omarshaarawi closed 4 years ago

omarshaarawi commented 5 years ago

Running my python script in a Dockerfile is giving me this error.

> /opt/conda/bin/orca: line 11:    76 Terminated              xvfb-run -a /opt/conda/bin/plotly-orca "$@"
> Traceback (most recent call last):
>   File "bot/discordBot.py", line 15, in <module>
>     import chart as c
>   File "/bot/chart.py", line 89, in <module>
>     print(get_plot("BTC"))
>   File "/bot/chart.py", line 83, in get_plot
>     pio.write_image(fig, 'fig1.png')
>   File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1512, in write_image
>     validate=validate)
>   File "/opt/conda/lib/python3.7/site-packages/plotly/io/_orca.py", line 1417, in to_image
>     raise ValueError(err_message)
> ValueError:
> The image request was rejected by the orca conversion utility
> with the following error:
>    525: plotly.js error

My script runs fine on my local machine so I don't believe it's my code. Yet replacing my code pio.write_image(fig, '/images/fig1.png',width=995, height=249) with this pio.write_image(go.Figure(data=[{'y': [1, 3, 2]}]), 'simple_fig.png') produces a file.

My Dockerfile looks like this:

FROM continuumio/miniconda3:latest
USER root

RUN     \
    apt-get update                              && \
    apt-get install -y gcc && \
    apt-get install -y poppler-utils

#    apt-get install -y libgtk2.0-0              && \
#    apt-get install -y libgconf-2-4             && \
#    apt-get install -y xvfb

#
# for Orca
#

RUN apt-get update && apt-get install -y --no-install-recommends \
        gnupg curl ca-certificates xz-utils wget libgtk2.0-0 libgconf-2-4 \
        && rm -rf /var/lib/apt/lists/* && apt-get clean

RUN apt-get install -y libgtk2.0-0              && \
    apt-get install -y libgconf-2-4             && \
    wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
    sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' && \
    apt-get update -y && \
    apt-get install -y google-chrome-stable xvfb  && \
    rm -rf /var/lib/apt/lists/* && apt-get clean

USER root

RUN \
    conda update -n base conda                  &&  \
    conda install -c plotly plotly              &&  \
    conda install -c plotly plotly-orca poppler psutil

USER root

# Set up a wrapper for orca (see https://github.com/plotly/orca) in an X11-less environment

RUN \
    mv /opt/conda/bin/orca /opt/conda/bin/plotly-orca

COPY orca /opt/conda/bin/orca

RUN chmod a+x /opt/conda/bin/plotly-orca
RUN chmod a+x /opt/conda/bin/orca

RUN orca --help

I have yet to find a working instance of orca running in a Docker container. What could be causing the errors above?

I should mention that issues arise with my code in other docker containers that have orca installed. This is the closest I've gotten it to working flawlessly and I am unsure if there is a dependency issue or if there is an extra step needed to take in a docker image.

bjodah commented 5 years ago

I was struggling with this today, I got it working by passing additional server args to xvfb-run, here's my orca script (on my $PATH):

#!/bin/bash                                                                                             
LIBGL_DEBUG=verbose xvfb-run --server-args "-screen 0 1920x1080x24" -a /home/bjorn/Downloads/orca-1.2.1-x86_64.AppImage "$@"

For reference, this answer led me to trying this: https://unix.stackexchange.com/a/283129/119480

ZilinXiang commented 5 years ago

I encountered the same problem. But the reason is weird, it maybe helps you. I changed the size of the font, some values could lead to the problem. Maybe you can set a small font size.

antoinerg commented 5 years ago

I encountered the same problem. But the reason is weird, it maybe helps you. I changed the size of the font, some values could lead to the problem. Maybe you can set a small font size.

@ZilinXiang I would like to better understand the issue you faced. Could you provide me with the JSON of the figure exhibiting this problem?

ZilinXiang commented 5 years ago

layout = { "margin": {"l": 0, "r": 0, "t": 30, "b": 0, "pad": 0}, }, "xaxis": { "autorange": True, "gridcolor": "#FFFFFF", "gridwidth": 2, "showspikes": False, "showticklabels": True, "tickfont": {"color": "#000000", "size": 18, "family": "Cousine"}, "ticks": "outside", "title": { "font": { "size": 18, "family": "Cousine", "color": "#000000" }, }, "type": "category", "zerolinecolor": "#FFFFFF" }, } when I set the size=20, the error incurs.

antoinerg commented 4 years ago

Closing this issue since it seems to be a plotly.js error. Such errors should be reported in the following repo https://github.com/plotly/plotly.js with a full JSON example.