Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#2
Fix SignalsAPI.stake_get (KeyError on removed totalStake field)#2lingster wants to merge 1 commit into
Conversation
stake_get read `data['totalStake']` from public_user_profile, but that field was dropped from the profile query during the v2SignalsProfile/v3UserProfile refactors (commits c4451ec/6a9819f added it; later refactors removed it). `totalStake` no longer exists on the V3UserProfile type at all, so stake_get raised KeyError for every call. Query `stakeValue` (type Nmr) directly within the signals tournament and parse it to Decimal, returning None when the model has no stake. Verified against the live API: stake_get("uuazed") now returns the real stake value instead of raising. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb6d6c21c7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| v3UserProfile(model_name: $model_name | ||
| tournament: $tournament) { |
There was a problem hiding this comment.
Query the Signals profile endpoint
In a SignalsAPI call, the username identifies a Signals model; this class and the changelog map Signals profiles to v2SignalsProfile, while v3UserProfile is the Classic profile endpoint. For Signals-only model names this call will not find the model, and for names shared across tournaments it can return the Classic stake instead, so SignalsAPI().stake_get(...) still gives users the wrong result. Use the Signals profile stake field (nmrStaked) instead.
Useful? React with 👍 / 👎.
|
Superseded by upstream PR numerai#129. |
Problem
SignalsAPI.stake_getraisedKeyError: 'totalStake'on every call:totalStakewas once part of the profile query (added in c4451ec / 6a9819f)but was dropped when the query was migrated to
v2SignalsProfileand thenv3UserProfile. The field no longer exists on theV3UserProfiletype at all,so the lookup always failed.
Fix
Query the current stake field,
stakeValue(typeNmr), directly within thesignals tournament and parse it to
Decimal, returningNonefor models withno stake (instead of raising):
Testing (red/green TDD)
test_stake_get(assertsstakeValueis queried,totalStakeis not,and the request is scoped to tournament 11) and
test_stake_get_no_stake(null stake →
None). Written failing first.44 passed(live-API tests deselected);pyflakesclean.SignalsAPI().stake_get("uuazed")now returns a realDecimalinstead of raising; an unstaked model returnsNone.🤖 Generated with Claude Code