Better model bar
Browse files- app.py +39 -6
- styles.css +39 -22
    	
        app.py
    CHANGED
    
    | @@ -70,7 +70,9 @@ def get_description_text(): | |
| 70 | 
             
            def load_css():
         | 
| 71 | 
             
                try:
         | 
| 72 | 
             
                    with open("styles.css", "r") as f:
         | 
| 73 | 
            -
                         | 
|  | |
|  | |
| 74 | 
             
                except FileNotFoundError:
         | 
| 75 | 
             
                    logger.warning("styles.css not found, using minimal default styles")
         | 
| 76 | 
             
                    return "body { background: #000; color: #fff; }"
         | 
| @@ -79,6 +81,7 @@ def load_css(): | |
| 79 | 
             
            # Create the Gradio interface with sidebar and dark theme
         | 
| 80 | 
             
            with gr.Blocks(title="Model Test Results Dashboard", css=load_css()) as demo:
         | 
| 81 |  | 
|  | |
| 82 | 
             
                with gr.Row():
         | 
| 83 | 
             
                    # Sidebar for model selection
         | 
| 84 | 
             
                    with gr.Column(scale=1, elem_classes=["sidebar"]):
         | 
| @@ -96,19 +99,24 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css()) as demo: | |
| 96 | 
             
                            elem_classes=["summary-button"]
         | 
| 97 | 
             
                        )
         | 
| 98 |  | 
| 99 | 
            -
                        # Model selection header
         | 
| 100 | 
            -
                        gr. | 
|  | |
|  | |
|  | |
|  | |
| 101 |  | 
| 102 | 
            -
                        #  | 
| 103 | 
            -
                        with gr.Column( | 
| 104 | 
             
                            # Create individual buttons for each model
         | 
| 105 | 
             
                            model_buttons = []
         | 
| 106 | 
             
                            model_choices = [model.lower() for model in Ci_results.available_models] if Ci_results.available_models else ["auto", "bert", "clip", "llama"]
         | 
|  | |
|  | |
| 107 |  | 
| 108 | 
             
                            for model_name in model_choices:
         | 
| 109 | 
             
                                # Check if model has failures to determine styling
         | 
| 110 | 
             
                                has_failures = model_has_failures(model_name)
         | 
| 111 | 
            -
                                # print(f"{model_name = }, {has_failures = }")
         | 
| 112 | 
             
                                button_classes = ["model-button"]
         | 
| 113 | 
             
                                if has_failures:
         | 
| 114 | 
             
                                    button_classes.append("model-button-failed")
         | 
| @@ -177,6 +185,31 @@ with gr.Blocks(title="Model Test Results Dashboard", css=load_css()) as demo: | |
| 177 | 
             
                        outputs=[summary_display, detail_view]
         | 
| 178 | 
             
                    )
         | 
| 179 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 180 | 
             
                # Summary button click handler
         | 
| 181 | 
             
                def show_summary_and_update_links():
         | 
| 182 | 
             
                    """Show summary page and update CI links."""
         | 
|  | |
| 70 | 
             
            def load_css():
         | 
| 71 | 
             
                try:
         | 
| 72 | 
             
                    with open("styles.css", "r") as f:
         | 
| 73 | 
            +
                        css_content = f.read()
         | 
| 74 | 
            +
                    
         | 
| 75 | 
            +
                    return css_content
         | 
| 76 | 
             
                except FileNotFoundError:
         | 
| 77 | 
             
                    logger.warning("styles.css not found, using minimal default styles")
         | 
| 78 | 
             
                    return "body { background: #000; color: #fff; }"
         | 
|  | |
| 81 | 
             
            # Create the Gradio interface with sidebar and dark theme
         | 
| 82 | 
             
            with gr.Blocks(title="Model Test Results Dashboard", css=load_css()) as demo:
         | 
| 83 |  | 
| 84 | 
            +
             | 
| 85 | 
             
                with gr.Row():
         | 
| 86 | 
             
                    # Sidebar for model selection
         | 
| 87 | 
             
                    with gr.Column(scale=1, elem_classes=["sidebar"]):
         | 
|  | |
| 99 | 
             
                            elem_classes=["summary-button"]
         | 
| 100 | 
             
                        )
         | 
| 101 |  | 
| 102 | 
            +
                        # Model selection header (clickable toggle)
         | 
| 103 | 
            +
                        model_toggle_button = gr.Button(
         | 
| 104 | 
            +
                            f"▼ Select model ({len(Ci_results.available_models)})",
         | 
| 105 | 
            +
                            variant="secondary",
         | 
| 106 | 
            +
                            elem_classes=["model-header"]
         | 
| 107 | 
            +
                        )
         | 
| 108 |  | 
| 109 | 
            +
                        # Model buttons container (collapsible)
         | 
| 110 | 
            +
                        with gr.Column(elem_classes=["model-list", "model-list-visible"]) as model_list_container:
         | 
| 111 | 
             
                            # Create individual buttons for each model
         | 
| 112 | 
             
                            model_buttons = []
         | 
| 113 | 
             
                            model_choices = [model.lower() for model in Ci_results.available_models] if Ci_results.available_models else ["auto", "bert", "clip", "llama"]
         | 
| 114 | 
            +
                            
         | 
| 115 | 
            +
                            print(f"Creating {len(model_choices)} model buttons: {model_choices}")
         | 
| 116 |  | 
| 117 | 
             
                            for model_name in model_choices:
         | 
| 118 | 
             
                                # Check if model has failures to determine styling
         | 
| 119 | 
             
                                has_failures = model_has_failures(model_name)
         | 
|  | |
| 120 | 
             
                                button_classes = ["model-button"]
         | 
| 121 | 
             
                                if has_failures:
         | 
| 122 | 
             
                                    button_classes.append("model-button-failed")
         | 
|  | |
| 185 | 
             
                        outputs=[summary_display, detail_view]
         | 
| 186 | 
             
                    )
         | 
| 187 |  | 
| 188 | 
            +
                # Model toggle functionality
         | 
| 189 | 
            +
                def toggle_model_list(current_visible):
         | 
| 190 | 
            +
                    """Toggle the visibility of the model list."""
         | 
| 191 | 
            +
                    new_visible = not current_visible
         | 
| 192 | 
            +
                    arrow = "▼" if new_visible else "►"
         | 
| 193 | 
            +
                    button_text = f"{arrow} Select model ({len(Ci_results.available_models)})"
         | 
| 194 | 
            +
                    
         | 
| 195 | 
            +
                    # Use CSS classes instead of Gradio visibility
         | 
| 196 | 
            +
                    css_classes = ["model-list"]
         | 
| 197 | 
            +
                    if new_visible:
         | 
| 198 | 
            +
                        css_classes.append("model-list-visible")
         | 
| 199 | 
            +
                    else:
         | 
| 200 | 
            +
                        css_classes.append("model-list-hidden")
         | 
| 201 | 
            +
                        
         | 
| 202 | 
            +
                    return gr.update(value=button_text), gr.update(elem_classes=css_classes), new_visible
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                # Track model list visibility state
         | 
| 205 | 
            +
                model_list_visible = gr.State(True)
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                model_toggle_button.click(
         | 
| 208 | 
            +
                    fn=toggle_model_list,
         | 
| 209 | 
            +
                    inputs=[model_list_visible],
         | 
| 210 | 
            +
                    outputs=[model_toggle_button, model_list_container, model_list_visible]
         | 
| 211 | 
            +
                )
         | 
| 212 | 
            +
             | 
| 213 | 
             
                # Summary button click handler
         | 
| 214 | 
             
                def show_summary_and_update_links():
         | 
| 215 | 
             
                    """Show summary page and update CI links."""
         | 
    	
        styles.css
    CHANGED
    
    | @@ -82,18 +82,19 @@ div[data-testid="column"]:has(.sidebar) { | |
| 82 |  | 
| 83 | 
             
            .model-header {
         | 
| 84 | 
             
                margin-bottom: 10px !important;
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 85 | 
             
            }
         | 
| 86 |  | 
| 87 | 
            -
            .model- | 
| 88 | 
            -
                 | 
| 89 | 
            -
                overflow-y: auto !important;
         | 
| 90 | 
            -
                overflow-x: hidden !important;
         | 
| 91 | 
            -
                margin-bottom: 15px !important;
         | 
| 92 | 
            -
                scrollbar-width: none !important;
         | 
| 93 | 
            -
                -ms-overflow-style: none !important;
         | 
| 94 | 
            -
                border: 1px solid #333 !important;
         | 
| 95 | 
            -
                border-radius: 8px !important;
         | 
| 96 | 
            -
                padding: 5px !important;
         | 
| 97 | 
             
            }
         | 
| 98 |  | 
| 99 | 
             
            .sidebar-links {
         | 
| @@ -142,24 +143,37 @@ div[data-testid="column"]:has(.sidebar) { | |
| 142 | 
             
                background-color: #555555 !important;
         | 
| 143 | 
             
            }
         | 
| 144 |  | 
| 145 | 
            -
            /*  | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
                overflow-y: auto !important;
         | 
| 149 | 
            -
                overflow-x: hidden !important;
         | 
| 150 | 
            -
                max-height: calc(100vh - 350px) !important;
         | 
| 151 | 
            -
            }
         | 
| 152 | 
            -
             | 
| 153 | 
            -
            /* Force button containers to single column in model container */
         | 
| 154 | 
            -
            .model-container .gr-button,
         | 
| 155 | 
            -
            .model-container button {
         | 
| 156 | 
             
                display: block !important;
         | 
| 157 | 
             
                width: 100% !important;
         | 
| 158 | 
             
                max-width: 100% !important;
         | 
| 159 | 
            -
                margin:  | 
| 160 | 
             
                flex: none !important;
         | 
| 161 | 
             
            }
         | 
| 162 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 163 | 
             
            /* Model button styling */
         | 
| 164 | 
             
            .model-button {
         | 
| 165 | 
             
                background: linear-gradient(135deg, #2a2a2a, #1e1e1e) !important;
         | 
| @@ -178,6 +192,8 @@ div[data-testid="column"]:has(.model-container) { | |
| 178 | 
             
                display: block !important;
         | 
| 179 | 
             
                cursor: pointer !important;
         | 
| 180 | 
             
                transition: all 0.3s ease !important;
         | 
|  | |
|  | |
| 181 | 
             
            }
         | 
| 182 |  | 
| 183 | 
             
            .model-button:hover {
         | 
| @@ -650,3 +666,4 @@ h1, h2, h3, p, .markdown { | |
| 650 | 
             
                0% { scroll-behavior: auto; }
         | 
| 651 | 
             
                100% { scroll-behavior: auto; }
         | 
| 652 | 
             
            }
         | 
|  | 
|  | |
| 82 |  | 
| 83 | 
             
            .model-header {
         | 
| 84 | 
             
                margin-bottom: 10px !important;
         | 
| 85 | 
            +
                background: linear-gradient(135deg, #2a2a2a, #1e1e1e) !important;
         | 
| 86 | 
            +
                color: white !important;
         | 
| 87 | 
            +
                border: 1px solid #333 !important;
         | 
| 88 | 
            +
                border-radius: 5px !important;
         | 
| 89 | 
            +
                font-weight: 600 !important;
         | 
| 90 | 
            +
                font-size: 14px !important;
         | 
| 91 | 
            +
                font-family: monospace !important;
         | 
| 92 | 
            +
                text-align: left !important;
         | 
| 93 | 
            +
                width: 100% !important;
         | 
| 94 | 
             
            }
         | 
| 95 |  | 
| 96 | 
            +
            .model-header:hover {
         | 
| 97 | 
            +
                background: linear-gradient(135deg, #3a3a3a, #2e2e2e) !important;
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 98 | 
             
            }
         | 
| 99 |  | 
| 100 | 
             
            .sidebar-links {
         | 
|  | |
| 143 | 
             
                background-color: #555555 !important;
         | 
| 144 | 
             
            }
         | 
| 145 |  | 
| 146 | 
            +
            /* Force button containers to single column in model list */
         | 
| 147 | 
            +
            .model-list .gr-button,
         | 
| 148 | 
            +
            .model-list button {
         | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 149 | 
             
                display: block !important;
         | 
| 150 | 
             
                width: 100% !important;
         | 
| 151 | 
             
                max-width: 100% !important;
         | 
| 152 | 
            +
                margin: 4px 0 !important;
         | 
| 153 | 
             
                flex: none !important;
         | 
| 154 | 
             
            }
         | 
| 155 |  | 
| 156 | 
            +
            /* Simple unfolding menu with invisible scrollbar */
         | 
| 157 | 
            +
            .model-list-visible {
         | 
| 158 | 
            +
                max-height: 200px !important;
         | 
| 159 | 
            +
                overflow-y: auto !important;
         | 
| 160 | 
            +
                transition: max-height 0.3s ease !important;
         | 
| 161 | 
            +
                scrollbar-width: none !important;
         | 
| 162 | 
            +
                -ms-overflow-style: none !important;
         | 
| 163 | 
            +
            }
         | 
| 164 | 
            +
             | 
| 165 | 
            +
            .model-list-visible::-webkit-scrollbar {
         | 
| 166 | 
            +
                width: 0px !important;
         | 
| 167 | 
            +
                background: transparent !important;
         | 
| 168 | 
            +
            }
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            .model-list-hidden {
         | 
| 171 | 
            +
                max-height: 0 !important;
         | 
| 172 | 
            +
                overflow: hidden !important;
         | 
| 173 | 
            +
                transition: max-height 0.3s ease !important;
         | 
| 174 | 
            +
            }
         | 
| 175 | 
            +
             | 
| 176 | 
            +
             | 
| 177 | 
             
            /* Model button styling */
         | 
| 178 | 
             
            .model-button {
         | 
| 179 | 
             
                background: linear-gradient(135deg, #2a2a2a, #1e1e1e) !important;
         | 
|  | |
| 192 | 
             
                display: block !important;
         | 
| 193 | 
             
                cursor: pointer !important;
         | 
| 194 | 
             
                transition: all 0.3s ease !important;
         | 
| 195 | 
            +
                border: 1px solid #333 !important;
         | 
| 196 | 
            +
                border-radius: 5px !important;
         | 
| 197 | 
             
            }
         | 
| 198 |  | 
| 199 | 
             
            .model-button:hover {
         | 
|  | |
| 666 | 
             
                0% { scroll-behavior: auto; }
         | 
| 667 | 
             
                100% { scroll-behavior: auto; }
         | 
| 668 | 
             
            }
         | 
| 669 | 
            +
             | 

