Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performances dump player_stats KeyError #69

Open
j-krl opened this issue Apr 15, 2024 · 1 comment
Open

Performances dump player_stats KeyError #69

j-krl opened this issue Apr 15, 2024 · 1 comment

Comments

@j-krl
Copy link

j-krl commented Apr 15, 2024

I am running the command yahoofantasy dump -g nhl -s 2023 -o ./data/nhl-2023-performances.csv performances for my recently completed NHL league. All other dump commands are working fine, but this one raises

WARN: Failed to fetch week 1 stats for Aleksander Barkov (427.p.5981), trying again in 2 minutes

I thought it might some kind of ratelimit, but when I throw a breakpoint in, the traceback is as follows:

Traceback (most recent call last):
  File ".../venv/lib/python3.11/site-packages/yahoofantasy/cli/dump.py", line 54, in _player_out
    for stat in player.get_stats(week_num):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/yahoofantasy/resources/player.py", line 23, in get_stats
    stats_data = self._fetch_stats(week_num)["player_stats"]
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'player_stats'

I believe the error is happening inside the player.get_stats(week_num) call inside _player_out. I didn't dig any further but can give a hand if needed.

@mattdodge
Copy link
Owner

I'm not a part of an NHL fantasy league so it's a bit hard for me to test. But it looks like your suspicion is correct, this is likely not due to rate limiting but is indeed some kind of bug. I wonder if the stat data comes back differently for NHL leagues? A bit surprised this wouldn't have been reported before though.

Try this snippet and see if you can see what the stats data object looks like for a player, this might lead to some hints

league = ctx.get_leagues('nhl', 2023)[0]
players = league.players()
player_1 = players[0]
stats = player_1._fetch_stats(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants