File size: 951 Bytes
fd2274b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a9d8ad
 
 
 
 
 
 
fd2274b
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio
import gradio as gr
import plotly.graph_objects as go
from datasets import load_dataset
from huggingface_hub import list_datasets

pipelines = [d.id[20:-21] for d in list_datasets(author='open-source-metrics') if 'checkpoint-downloads' in d.id]


def plot(library: str, stacked: bool):
    dataset = load_dataset(f"open-source-metrics/{library}-checkpoint-downloads")['train']

    dates = dataset['dates']
    axis = dataset.column_names
    axis.remove('dates')

    fig = go.Figure()
    for i in axis:
        fig.add_trace(
            go.Scatter(x=dates, y=dataset[i], mode='lines+markers', name=i, stackgroup='one' if stacked else None)
        )

    fig.show()
    return fig


with gr.Blocks() as demo:
    inputs = [gr.Dropdown(pipelines), gr.Checkbox(label='Stacked')]
    with gr.Row():
        outputs = [gr.Plot()]

    submit = gr.Button('Submit')
    submit.click(fn=plot, inputs=inputs, outputs=outputs)

demo.launch()