Onur Solmaz commited on
Commit
7eb84bb
·
1 Parent(s): 1f6f77d

fix: compact variant and tooltip rendering

Browse files
leaderboard_core.py CHANGED
@@ -1734,6 +1734,7 @@ def render_html(payload: dict[str, Any]) -> str:
1734
  if more_count
1735
  else ""
1736
  )
 
1737
  artifact_extra = f'<span class="artifact-extra" hidden>{extra_artifacts}</span>' if more_count else ""
1738
  row_attrs = {
1739
  "data-class": group["candidate_class"],
@@ -1759,14 +1760,13 @@ def render_html(payload: dict[str, Any]) -> str:
1759
  <td class="rank" data-label="Rank">{group['rank']}</td>
1760
  <td class="model-cell" data-label="Model">
1761
  <a class="model-link" href="{html.escape(model_url(str(group['representative_id'])))}" target="_blank" rel="noreferrer">{html.escape(str(group['group_key']))}</a>
1762
- <div class="model-sub">{html.escape(str(group['representative_id']))}</div>
1763
  </td>
1764
- <td class="num metric has-tooltip" data-label="Avg Downloads / Month" data-metric="downloads_per_month" data-tooltip="{attr(group_downloads_tooltip)}" title="{attr(group_downloads_tooltip)}"><span class="metric-value">{group_downloads_label}</span></td>
1765
- <td class="num metric has-tooltip" data-label="Avg Likes / month" data-metric="likes_per_month" data-tooltip="{attr(group_likes_tooltip)}" title="{attr(group_likes_tooltip)}"><span class="metric-value">{group_likes_label}</span></td>
1766
  <td data-label="Params">{format_params(group['parameter_count_b'])}</td>
1767
  <td class="date-cell" data-label="Created">{render_created(group.get('created_at'), generated_at_dt)}</td>
1768
  <td class="artifacts" data-label="Related repos">
1769
- <span class="artifact-list">{visible_artifact}{artifact_toggle}{artifact_extra}</span>
1770
  </td>
1771
  </tr>
1772
  """
@@ -2011,10 +2011,8 @@ def render_html(payload: dict[str, Any]) -> str:
2011
  .model-cell {{ min-width: 260px; }}
2012
  .model-link {{ display: block; color: var(--ink); font-weight: 800; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }}
2013
  .model-link:hover {{ color: var(--accent); }}
2014
- .model-sub {{ margin-top: 4px; color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }}
2015
  .num {{ text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }}
2016
  .metric {{ position: relative; }}
2017
- .metric.has-tooltip {{ cursor: help; }}
2018
  .metric.has-tooltip:hover::after,
2019
  .metric.has-tooltip:focus-within::after {{
2020
  content: attr(data-tooltip);
@@ -2053,35 +2051,40 @@ def render_html(payload: dict[str, Any]) -> str:
2053
  }}
2054
  .artifacts {{ min-width: 280px; color: var(--muted); }}
2055
  .artifact-list {{
2056
- display: flex;
2057
- align-items: center;
2058
- gap: 5px 10px;
2059
  min-width: 0;
2060
  overflow: hidden;
2061
- white-space: nowrap;
2062
  }}
2063
  .artifact-list.is-expanded {{
2064
- align-items: flex-start;
2065
- flex-wrap: wrap;
2066
  overflow: visible;
2067
- white-space: normal;
2068
  }}
2069
- .artifact-list > a {{
 
 
 
 
 
 
 
 
 
 
2070
  min-width: 0;
2071
- max-width: 170px;
2072
  overflow: hidden;
2073
  text-overflow: ellipsis;
2074
  white-space: nowrap;
2075
- flex: 0 1 auto;
2076
  }}
2077
- .artifact-list.is-expanded > a,
2078
  .artifact-list.is-expanded .artifact-extra a {{
2079
  max-width: none;
2080
  white-space: normal;
2081
  overflow-wrap: anywhere;
2082
  }}
2083
  .artifact-extra {{
2084
- display: contents;
 
 
 
2085
  }}
2086
  .artifact-toggle {{
2087
  flex: 0 0 auto;
@@ -2142,7 +2145,6 @@ def render_html(payload: dict[str, Any]) -> str:
2142
  th {{ font-size: 11px; }}
2143
  th:nth-child(7),
2144
  td:nth-child(7) {{ display: none; }}
2145
- .model-sub {{ font-size: 13px; }}
2146
  .metric small,
2147
  .age-stamp {{ font-size: 12px; }}
2148
  .method {{ padding: 18px 16px; }}
@@ -2167,7 +2169,7 @@ def render_html(payload: dict[str, Any]) -> str:
2167
  <span aria-hidden="true"></span>
2168
  <span aria-hidden="true"></span>
2169
  </button>
2170
- <h1 aria-label="Open LLM Distribution Leaderboard"><img class="hf-logo" src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="" /><span class="title-text"><span>Open LLM Distribution </span><span class="title-tail">Leaderboard<a class="info-link" href="#method" aria-label="How this is calculated" title="How this is calculated"><svg class="lucide lucide-info info-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 16v-4"></path><path d="M12 8h.01"></path></svg></a></span></span></h1>
2171
  </div>
2172
  <nav id="filters-panel" class="controls" aria-label="Leaderboard filters">
2173
  <div class="control search-control">
 
1734
  if more_count
1735
  else ""
1736
  )
1737
+ artifact_more = f'<span class="artifact-more">{artifact_toggle}</span>' if more_count else ""
1738
  artifact_extra = f'<span class="artifact-extra" hidden>{extra_artifacts}</span>' if more_count else ""
1739
  row_attrs = {
1740
  "data-class": group["candidate_class"],
 
1760
  <td class="rank" data-label="Rank">{group['rank']}</td>
1761
  <td class="model-cell" data-label="Model">
1762
  <a class="model-link" href="{html.escape(model_url(str(group['representative_id'])))}" target="_blank" rel="noreferrer">{html.escape(str(group['group_key']))}</a>
 
1763
  </td>
1764
+ <td class="num metric has-tooltip" data-label="Avg Downloads / Month" data-metric="downloads_per_month" data-tooltip="{attr(group_downloads_tooltip)}"><span class="metric-value">{group_downloads_label}</span></td>
1765
+ <td class="num metric has-tooltip" data-label="Avg Likes / month" data-metric="likes_per_month" data-tooltip="{attr(group_likes_tooltip)}"><span class="metric-value">{group_likes_label}</span></td>
1766
  <td data-label="Params">{format_params(group['parameter_count_b'])}</td>
1767
  <td class="date-cell" data-label="Created">{render_created(group.get('created_at'), generated_at_dt)}</td>
1768
  <td class="artifacts" data-label="Related repos">
1769
+ <span class="artifact-list"><span class="artifact-primary">{visible_artifact}</span>{artifact_more}{artifact_extra}</span>
1770
  </td>
1771
  </tr>
1772
  """
 
2011
  .model-cell {{ min-width: 260px; }}
2012
  .model-link {{ display: block; color: var(--ink); font-weight: 800; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }}
2013
  .model-link:hover {{ color: var(--accent); }}
 
2014
  .num {{ text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }}
2015
  .metric {{ position: relative; }}
 
2016
  .metric.has-tooltip:hover::after,
2017
  .metric.has-tooltip:focus-within::after {{
2018
  content: attr(data-tooltip);
 
2051
  }}
2052
  .artifacts {{ min-width: 280px; color: var(--muted); }}
2053
  .artifact-list {{
2054
+ display: block;
 
 
2055
  min-width: 0;
2056
  overflow: hidden;
 
2057
  }}
2058
  .artifact-list.is-expanded {{
 
 
2059
  overflow: visible;
 
2060
  }}
2061
+ .artifact-primary,
2062
+ .artifact-more {{
2063
+ display: block;
2064
+ min-width: 0;
2065
+ }}
2066
+ .artifact-more {{
2067
+ margin-top: 3px;
2068
+ line-height: 1.2;
2069
+ }}
2070
+ .artifact-primary > a {{
2071
+ display: block;
2072
  min-width: 0;
 
2073
  overflow: hidden;
2074
  text-overflow: ellipsis;
2075
  white-space: nowrap;
 
2076
  }}
2077
+ .artifact-list.is-expanded .artifact-primary > a,
2078
  .artifact-list.is-expanded .artifact-extra a {{
2079
  max-width: none;
2080
  white-space: normal;
2081
  overflow-wrap: anywhere;
2082
  }}
2083
  .artifact-extra {{
2084
+ display: flex;
2085
+ flex-wrap: wrap;
2086
+ gap: 5px 10px;
2087
+ margin-top: 6px;
2088
  }}
2089
  .artifact-toggle {{
2090
  flex: 0 0 auto;
 
2145
  th {{ font-size: 11px; }}
2146
  th:nth-child(7),
2147
  td:nth-child(7) {{ display: none; }}
 
2148
  .metric small,
2149
  .age-stamp {{ font-size: 12px; }}
2150
  .method {{ padding: 18px 16px; }}
 
2169
  <span aria-hidden="true"></span>
2170
  <span aria-hidden="true"></span>
2171
  </button>
2172
+ <h1 aria-label="Open LLM Distribution Leaderboard"><img class="hf-logo" src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="" /><span class="title-text"><span>Open LLM Distribution </span><span class="title-tail">Leaderboard<a class="info-link" href="#method" aria-label="How this is calculated"><svg class="lucide lucide-info info-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><path d="M12 16v-4"></path><path d="M12 8h.01"></path></svg></a></span></span></h1>
2173
  </div>
2174
  <nav id="filters-panel" class="controls" aria-label="Leaderboard filters">
2175
  <div class="control search-control">
tests/test_leaderboard_core.py CHANGED
@@ -706,9 +706,12 @@ class RenderTests(unittest.TestCase):
706
  self.assertIn("data-group-downloads-tooltip=", text)
707
  self.assertIn("data-group-likes-tooltip=", text)
708
  self.assertIn("class=\"num metric has-tooltip\"", text)
 
 
709
  self.assertNotIn("class=\"metric-detail\"", text)
710
  self.assertNotIn("<small class=\"metric-detail\"", text)
711
  self.assertIn(">Model<", text)
 
712
  self.assertNotIn("Model group", text)
713
  self.assertNotIn("visibleCount", text)
714
  self.assertIn("How This Is Calculated", text)
@@ -723,6 +726,9 @@ class RenderTests(unittest.TestCase):
723
  self.assertIn("123.5K recent HF downloads", text)
724
  self.assertIn("1.2K likes across 3 repos", text)
725
  self.assertIn("class=\"artifact-list\"", text)
 
 
 
726
  self.assertIn("class=\"artifact-toggle\"", text)
727
  self.assertIn("+ 2 more variants", text)
728
  self.assertIn("class=\"artifact-extra\" hidden", text)
 
706
  self.assertIn("data-group-downloads-tooltip=", text)
707
  self.assertIn("data-group-likes-tooltip=", text)
708
  self.assertIn("class=\"num metric has-tooltip\"", text)
709
+ self.assertNotIn("title=", text)
710
+ self.assertNotIn("cursor: help", text)
711
  self.assertNotIn("class=\"metric-detail\"", text)
712
  self.assertNotIn("<small class=\"metric-detail\"", text)
713
  self.assertIn(">Model<", text)
714
+ self.assertNotIn("class=\"model-sub\"", text)
715
  self.assertNotIn("Model group", text)
716
  self.assertNotIn("visibleCount", text)
717
  self.assertIn("How This Is Calculated", text)
 
726
  self.assertIn("123.5K recent HF downloads", text)
727
  self.assertIn("1.2K likes across 3 repos", text)
728
  self.assertIn("class=\"artifact-list\"", text)
729
+ self.assertIn("class=\"artifact-primary\"", text)
730
+ self.assertIn("class=\"artifact-more\"", text)
731
+ self.assertIn(".artifact-more {\n margin-top: 3px;", text)
732
  self.assertIn("class=\"artifact-toggle\"", text)
733
  self.assertIn("+ 2 more variants", text)
734
  self.assertIn("class=\"artifact-extra\" hidden", text)