CoolFace
Apppublic

lvwerra/bigcode_planning

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
app.py131 linesDownload Raw Back to root
1from github import Github2import os 3import streamlit as st4import datetime5import plotly.figure_factory as ff6import plotly.graph_objects as go7import pandas as pd8import math9import copy10 11st.set_page_config(layout="wide")12name2repo = [("Training", "bigcode-project/Megatron-LM"),13             ("Dataset", "bigcode-project/bigcode-dataset"),14             ("Evaluation", "bigcode-project/bigcode-evaluation-harness"),15             ("Inference", "bigcode-project/bigcode-inference-benchmark"),16             ("Legal", "bigcode-project/admin")17            ]18 19name2num_milestones = dict()20g = Github(os.environ.get('github'))21df = list()22all_status = list()23 24for name, repo_name in name2repo:25    repo = g.get_repo(repo_name)26    num_milestones = 027    for milestone in repo.get_milestones():28        num_milestones += 129        desc = dict()30        for line in milestone.description.split('\n'):31            tmp = line.split(":")32            if len(tmp) > 1:33                key = tmp[0].lower()34                value = tmp[1].strip()35                if key == 'status':36                    value = value.lower()37                desc[key] = value38        task_name = f"""<a href="https://www.github.com/{repo_name}/milestone/{milestone.number}", target="_black">{milestone.title}</a>"""39        if desc['status'] not in all_status:40            all_status.append(desc['status'])41        df.append(dict(Task=task_name, 42                       Start=desc['start date'], 43                       Finish=milestone.due_on.strftime('%Y-%m-%d'), 44                       Resource=desc['status'], 45                       Description=desc['leader']))46    name2num_milestones[name] = num_milestones47 48copy_df = copy.deepcopy(df)49colors = {'not started': 'rgb(217, 217, 217)',50          'in progress': 'rgb(147, 196, 125)',51          'high priority - on track': 'rgb(234, 153, 153)',52          'high priority - help needed': 'rgb(255, 0, 0)',53          'completed': 'rgb(56, 118, 29)'}54 55if len(all_status) == 0:56    task_name = "None"57 58for key in colors.keys():59    if key not in all_status:60        copy_df.append(dict(Task=task_name, 61                   Start='2023-04-02', 62                   Finish='2023-04-02', 63                   Resource=key))64 65fig = ff.create_gantt(copy_df, colors=colors, 66                      index_col='Resource', 67                      show_colorbar=True, 68                      show_hover_fill=True,69                      group_tasks=True,70                      title="BigCode planning")71 72fig.update_xaxes(ticks= "outside",73                 ticklabelmode= "period", 74                 tickformat="%b",75                 tickcolor= "black", 76                 ticklen=10, 77                 range=[datetime.datetime(2022, 12, 30),78                        datetime.datetime(2023, 4, 2)],79                 minor=dict(80                     ticklen=4,  81                     dtick=7*24*60*60*1000,  82                     tick0="2023-01-01", 83                     griddash='dot', 84                     gridcolor='white')85                )86 87fig.update_layout(margin=go.layout.Margin(l=250))88fig.layout.xaxis.rangeselector = None # remove range selector on top89 90# Add today line91fig.add_vline(x=datetime.datetime.now().strftime('%Y-%m-%d'), line_width=3, line_dash="dash", line_color="black")92fig.add_annotation({93            "x": datetime.datetime.now().strftime('%Y-%m-%d'),94            "y": fig.layout.yaxis['range'][1],95            "yshift": 10,96            "text": "Today",97            "showarrow": False,98        })99 100# Add point of contacts101fig.add_annotation({102            "x": "2023-01-01",103            "y": fig.layout.yaxis['range'][1],104            "yshift": 10,105            "xanchor": "left",106            "text": "Contact",107            "showarrow": False})108for i, entry in enumerate(df[::-1]):109    fig.add_annotation(x='2023-01-01', y=i,110                text=entry['Description'],111                showarrow=False,112                xanchor="left",113                xref="x")114 115# Add working group annotations116fig.add_hline(y=-0.5, line_width=1, line_color="grey")117height = -0.5118for name, _ in name2repo[::-1]:119    if name2num_milestones[name] > 0:120        fig.add_annotation(x='2023-03-31', y=height + name2num_milestones[name]/2,121                text=name,122                showarrow=False,123                align="center",124                textangle=-90)125        height += name2num_milestones[name]126        fig.add_hline(y=height, line_width=1, line_color="grey")127 128st.plotly_chart(fig, use_container_width=True)129 130if st.button("Refresh"):131    st.experimental_rerun()