plotly / Kaleido

Fast static image export for web-based visualization libraries with zero dependencies
Other
358 stars 35 forks source link

OOME Kaleido #188

Open zN3utr4l opened 1 year ago

zN3utr4l commented 1 year ago

I have a linux debian 11 pc with docker and various containers. It freezes every time you operate on docker and restart. Online I found this thing: image Container Process image

The container in question has a celery scheduler that performs tasks in parallel, including the creation of svg with plotly.


......
import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=2, specs=[[{'type': 'domain'}, {'type': 'domain'}]])

fig.update_layout(
    annotations=[
        dict(
            text='Duration',
            x=0.85,
            y=0.5,
            # font_size=40,
            showarrow=False,
            font=dict(
                family='Arial',
                size=28.5,
                color='grey'
            )
        ),
        # COUNT
        dict(
            text='Count',
            x=0.17,
            y=0.5,
            # font_size=40,
            showarrow=False,
            font=dict(
                family='Arial',
                size=28.5,
                color='grey'
            )
        ),
    ]
)

labels_counts = [1, 2, 3]
labels_duration = [1, 2, 3]

fig.add_trace(
    go.Pie(
        labels=labels_counts,
        values=[1, 2, 3],
        texttemplate='%{percent}<br>(%{value})',
    ), 1, 1)

fig.add_trace(
    go.Pie(
        labels=labels_duration,
        values=[1, 2, 3],
        customdata=[1, 2, 3],
        texttemplate='%{percent}<br>(%{customdata})'
    ), 1, 2)

fig.update_traces(
    hole=0.7,
    textinfo='percent',
    textposition='outside',
    textfont_size=12,
    marker=dict(colors=['red', 'blu'],
                line=dict(color='#FFFFFF',
                            width=5)
                ),
    textfont=dict(
        family='Arial',
        size=18,
        color='grey'
    )
)

# Legend
fig.update_layout(
    legend=dict(
        yanchor='top',
        y=0.99,
        xanchor='left',
        x=-0.33,
        bgcolor='rgba(0,0,0,0)',
    )
)

# Size of img
fig.update_layout(
    autosize=False,
    width=1250,
    height=455,
)

fig.update_layout(
    font=dict(
        family='Calibri Light',
        size=22,
        color='black'
    )
)

fig.write_image('pie_chart.svg')

fig = go.Figure(layout=go.Layout(autosize=False,width=1850,height=750))

x = [date.today(), date.today() + timedelta(days=12)]

fig.add_traces(go.Scatter(x=[], y=[[1, 2, 3], [1, 2, 3]], showlegend=False, mode='markers', marker=dict(color='rgba(255, 245, 135, 0)')))
fig.add_traces(go.Scatter(x=x, y=[5, 5], mode='lines', line=dict(color='#FFB775', width=3), name='High'))
fig.add_traces(go.Scatter(x=x, y=[1, 1], mode='lines', line=dict(color='#FFB775', width=3), name='Low'))
fig.add_traces(go.Scatter(x=x,y=[1, 10],mode='lines',line=dict(color='#FFA3A6', width=6, dash='dash'),name='trend'))

fig.add_traces(go.Scatter(x=[date.today()], y=[4], name='this period',mode='lines', line=dict(color='#E7E6F0', width=6), line_shape='spline', showlegend=False))

fig.add_traces(go.Scatter(x=[date.today()], y=[0.1], name='Last period',mode='markers', marker=dict(color='#A3A1A8', size=11)))

fig.add_traces(go.Scatter(x=[date.today()], y=[5], showlegend=False, name='5% low', mode='lines', line=dict(color='#A3A1A8', width=1), line_shape='spline'))
fig.add_traces(go.Scatter(x=[date.today()], y=[6], name='90% range', mode='lines', line=dict(color='#A3A1A8', width=1), line_shape='spline', fill='tonexty', fillcolor='rgba(231, 230, 240,0.3)'))

text_date = ['1/1/2001']

fig.add_traces(go.Scatter(x=[date.today()], y=[1], name='this period', mode='markers+text', textposition='top center', textfont_size=10, text=text_date, marker=dict(color='#7D6B7D', size=11)))

fig.add_traces(go.Scatter(
    x=list([date.today()]),
    y=[1],
    mode='markers',
    marker=dict(
        color='#FF665A',
        size=19),
    name='warnings'
))

fig.update_layout({
    'plot_bgcolor': 'rgba(0, 0, 0, 0)',
    'paper_bgcolor': 'rgba(0, 0, 0, 0)',
    }, font=dict(size=32))

fig.update_xaxes(
    showgrid=True,
    gridwidth=1,
    gridcolor='rgba(0, 0, 0, 0.1)'
    )

fig.update_yaxes(
    showgrid=True,
    gridwidth=1,
    gridcolor='rgba(0, 0, 0, 0.1)',
    ticksuffix='A'
    )

fig.write_image('tempo.svg')```
Elsper01 commented 1 year ago

Which kaleido version are you using? I had similiar problems and fix it by using the following kaleido version: kaleido==0.1.0.post1

zN3utr4l commented 1 year ago

Installed with conda

Elsper01 commented 1 year ago

ok, than maybe try to run the python script again with kaleido version 0.1.0.post1

gvwilson commented 1 month ago

Thanks for your interest in Kaleido. We are currently working on an overhaul that might address your issue - we hope to have news in a few weeks and will post an update then. Thanks - @gvwilson