Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import pandas as pd | |
| import plotly.express as px | |
| merged_df = pd.read_csv("data/merged_cloud_data.csv") | |
| tdp_fig = px.scatter( | |
| merged_df, | |
| x="Total TDP (W)", | |
| y="$/Hour", | |
| color="provider", | |
| log_x=True, | |
| log_y=True, | |
| trendline="ols", | |
| trendline_options=dict(log_y=True, log_x=True), | |
| trendline_scope="overall", | |
| ) | |
| cost_fig = px.scatter( | |
| merged_df, | |
| x="GPU Total Cost", | |
| y="$/Hour", | |
| color="GPU Type", | |
| log_y=True, | |
| log_x=True, | |
| trendline="ols", | |
| trendline_options=dict(log_x=True, log_y=True), | |
| trendline_scope="overall", | |
| ) | |
| def generate_figure(org_name): | |
| org_data = data[data["Organization"] == org_name] | |
| model_counts = ( | |
| org_data.groupby("Year")[["Model", "Environmental Transparency"]] | |
| .value_counts() | |
| .reset_index() | |
| ) | |
| model_counts.columns = ["Year", "Model", "Environmental Transparency", "Count"] | |
| fig = px.bar( | |
| model_counts, | |
| x="Year", | |
| y="Count", | |
| color="Environmental Transparency", | |
| color_discrete_map=color_discrete_map, | |
| hover_data=["Model"], | |
| ) | |
| fig.update_layout(xaxis_type="category") | |
| fig.update_xaxes(categoryorder="category ascending") | |
| return fig | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Cloud Compute ☁️, Energy ⚡ and Cost 💲 - Explorer Tool") | |
| gr.Markdown( | |
| "## Explore the data from 'When we pay for cloud compute, what are we really paying for?'" | |
| ) | |
| with gr.Accordion("Methodology", open=False): | |
| gr.Markdown("TODO") | |
| with gr.Row(): | |
| with gr.Column(): | |
| gr.Markdown("### TDP Data") | |
| plt1 = gr.Plot(tdp_fig) | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| org_choice = gr.Dropdown( | |
| organizations, | |
| value="", | |
| label="Organizations", | |
| info="Pick a characteristic to regenerate plot", | |
| interactive=True, | |
| ) | |
| with gr.Column(scale=4): | |
| gr.Markdown("### Cost Data") | |
| fig = generate_figure(org_choice) | |
| plt = gr.Plot(cost_fig) | |
| # org_choice.select(generate_figure, inputs=[org_choice], outputs=[plt]) | |
| demo.launch() | |