Skip to content

Commit e1abc2f

Browse files
authored
Merge pull request #17 from opensource-observer/carl/ddp-fix-repo-rank-stale-window
fix(ethereum-repo-rank): anchor rolling window to data max to survive stale UDM
2 parents 3c5c816 + f2c7f92 commit e1abc2f

1 file changed

Lines changed: 28 additions & 20 deletions

File tree

notebooks/insights/ethereum-repo-rank.py

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,27 @@ def _(df_trending, eth_dev_set, df_engagement_raw, mo):
2626
_panel_size = len(eth_dev_set)
2727
_active_eth = int(df_engagement_raw[df_engagement_raw["username_lower"].isin(eth_dev_set)]["username_lower"].nunique())
2828

29-
_top_eth = df_trending.sort_values("eth_devs_30d", ascending=False).iloc[0]
30-
_top_eth_repo = _top_eth["repo_name"].split("/")[-1]
31-
_top_eth_devs = int(_top_eth["eth_devs_30d"])
32-
33-
_top_all = df_trending.sort_values("global_engagers_30d", ascending=False).iloc[0]
34-
_top_all_repo = _top_all["repo_name"].split("/")[-1]
35-
_top_all_devs = int(_top_all["global_engagers_30d"])
36-
37-
mo.hstack(
38-
[
39-
mo.stat(value=f"{_panel_size:,}", label="Ethereum Builders Tracked", bordered=True, caption="≥12 months commit activity"),
40-
mo.stat(value=f"{_active_eth}", label="Active on Trending Repos", bordered=True, caption=f"{_active_eth/_panel_size*100:.1f}% of panel"),
41-
mo.stat(value=_top_eth_repo, label="#1 by Eth Builder Attention", bordered=True, caption=f"{_top_eth_devs} distinct eth builders"),
42-
mo.stat(value=_top_all_repo, label="#1 by All Builder Attention", bordered=True, caption=f"{_top_all_devs:,} distinct builders"),
43-
],
44-
widths="equal",
45-
gap=1,
46-
)
29+
if df_trending.empty:
30+
mo.md("**Ethereum builder engagement data is temporarily unavailable.** The upstream engagement dataset has no repos in the latest window; check that the `ethereum.dev_engagement_models` pipeline has refreshed.")
31+
else:
32+
_top_eth = df_trending.sort_values("eth_devs_30d", ascending=False).iloc[0]
33+
_top_eth_repo = _top_eth["repo_name"].split("/")[-1]
34+
_top_eth_devs = int(_top_eth["eth_devs_30d"])
35+
36+
_top_all = df_trending.sort_values("global_engagers_30d", ascending=False).iloc[0]
37+
_top_all_repo = _top_all["repo_name"].split("/")[-1]
38+
_top_all_devs = int(_top_all["global_engagers_30d"])
39+
40+
mo.hstack(
41+
[
42+
mo.stat(value=f"{_panel_size:,}", label="Ethereum Builders Tracked", bordered=True, caption="≥12 months commit activity"),
43+
mo.stat(value=f"{_active_eth}", label="Active on Trending Repos", bordered=True, caption=f"{_active_eth/_panel_size*100:.1f}% of panel"),
44+
mo.stat(value=_top_eth_repo, label="#1 by Eth Builder Attention", bordered=True, caption=f"{_top_eth_devs} distinct eth builders"),
45+
mo.stat(value=_top_all_repo, label="#1 by All Builder Attention", bordered=True, caption=f"{_top_all_devs:,} distinct builders"),
46+
],
47+
widths="equal",
48+
gap=1,
49+
)
4750
return
4851

4952

@@ -797,8 +800,13 @@ def _(df_repo_engagement, df_engagement_raw, eth_dev_set, pd, REPO_CATEGORIES, R
797800
_active_lower = {k.lower() for k in REPO_CATEGORIES.keys()}
798801
df_trending = df_trending[df_trending["repo_name"].isin(_active_lower)].copy()
799802

800-
# Recompute eth dev counts from raw CSV data (more reliable than UDM precomputed)
801-
_now = pd.Timestamp.now()
803+
# Recompute eth dev counts from raw CSV data (more reliable than UDM precomputed).
804+
# Anchor the rolling window to the latest event in the data, not wall-clock now(),
805+
# so the notebook always shows the most recent available 30-day window even when the
806+
# upstream UDM lags. (A now()-relative window empties df_trending once the UDM is >30d stale.)
807+
_now = df_engagement_raw["ts"].max()
808+
if pd.isna(_now):
809+
_now = pd.Timestamp.now()
802810
_raw = df_engagement_raw.copy()
803811
_raw["_is_eth"] = _raw["username_lower"].isin(eth_dev_set)
804812
_eth_only = _raw[_raw["_is_eth"]]

0 commit comments

Comments
 (0)