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

Simplest example in README doesn't work #72

Closed
datum-dpoulin opened this issue Oct 8, 2024 · 3 comments · Fixed by #73
Closed

Simplest example in README doesn't work #72

datum-dpoulin opened this issue Oct 8, 2024 · 3 comments · Fixed by #73
Assignees
Labels
bug Something isn't working

Comments

@datum-dpoulin
Copy link

Describe the bug
Ran the sample code on the home page in Python 3.11 on MacOS and got this error:

Invalid report property: [{"property": "points", "direction": "DESC"}, {"property": "gamesPlayed", "direction": "ASC"}, {"property": "playerId", "direction": "ASC"}]

    client = NHLClient(verbose=True)
    filters = [
        GameTypeQuery(game_type="2"),
        DraftQuery(year="2020", draft_round="2"),
        SeasonQuery(season_start="20202021", season_end="20232024"),
        PositionQuery(position=PositionTypes.ALL_FORWARDS)
    ]
    query_builder = QueryBuilder()
    query_context:QueryContext = query_builder.build(filters=filters)
    data = client.stats.skater_stats_with_query_context(
        report_type='summary',
        query_context=query_context,
        aggregate=True
    )

@coreyjs
Copy link
Owner

coreyjs commented Oct 9, 2024

I'll get this cleaned up today. I must not have enough test coverage when I was refactoring. Thanks for finding this.

@coreyjs coreyjs self-assigned this Oct 9, 2024
@coreyjs coreyjs added the bug Something isn't working label Oct 9, 2024
@coreyjs
Copy link
Owner

coreyjs commented Oct 9, 2024

This seems to work on my console, ver 3.10 and 3.12, but I can replicate this error in google collab. Which is 3.10. So the search continues.

@coreyjs coreyjs linked a pull request Oct 9, 2024 that will close this issue
@coreyjs
Copy link
Owner

coreyjs commented Oct 9, 2024

this is fixed in 2.11.1. Tested in google collab, local Jupyter notebook, local python console. Versions 3.9->3.12

! pip install nhl-api-py
from nhlpy.api.query.builder import QueryBuilder, QueryContext
from nhlpy.nhl_client import NHLClient
from nhlpy.api.query.filters.draft import DraftQuery
from nhlpy.api.query.filters.season import SeasonQuery
from nhlpy.api.query.filters.game_type import GameTypeQuery
from nhlpy.api.query.filters.position import PositionQuery, PositionTypes

client = NHLClient(verbose=True)

filters = [
    GameTypeQuery(game_type="2"),
    DraftQuery(year="2020", draft_round="2"),
    SeasonQuery(season_start="20202021", season_end="20232024"),
    PositionQuery(position=PositionTypes.ALL_FORWARDS)
]

query_builder = QueryBuilder()
query_context: QueryContext = query_builder.build(filters=filters)

data = client.stats.skater_stats_with_query_context(
    report_type='summary',
    query_context=query_context,
    aggregate=True
)
data
{'data': [{'assists': 42,
   'evGoals': 35,
   'evPoints': 70,
   'faceoffWinPct': 0.33333,
   'gameWinningGoals': 6,
   'gamesPlayed': 161,
   'goals': 40,
   'lastName': 'Peterka',
   'otGoals': 0,
   'penaltyMinutes': 54,
   'playerId': 8482175,
   'plusMinus': -5,
   'points': 82,
   'pointsPerGame': 0.50931,
   'positionCode': 'R',
   'ppGoals': 5,
   'ppPoints': 12,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.11299,
   'shootsCatches': 'L',
   'shots': 354,
   'skaterFullName': 'JJ Peterka',
   'timeOnIcePerGame': 904.5714},
  {'assists': 31,
   'evGoals': 20,
   'evPoints': 42,
   'faceoffWinPct': 0.25,
   'gameWinningGoals': 2,
   'gamesPlayed': 104,
   'goals': 23,
   'lastName': 'Evangelista',
   'otGoals': 0,
   'penaltyMinutes': 24,
   'playerId': 8482146,
   'plusMinus': 7,
   'points': 54,
   'pointsPerGame': 0.51923,
   'positionCode': 'R',
   'ppGoals': 3,
   'ppPoints': 12,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.10176,
   'shootsCatches': 'R',
   'shots': 226,
   'skaterFullName': 'Luke Evangelista',
   'timeOnIcePerGame': 873.5673},
  {'assists': 8,
   'evGoals': 12,
   'evPoints': 19,
   'faceoffWinPct': 0.16666,
   'gameWinningGoals': 2,
   'gamesPlayed': 85,
   'goals': 13,
   'lastName': 'Cuylle',
   'otGoals': 0,
   'penaltyMinutes': 66,
   'playerId': 8482157,
   'plusMinus': -5,
   'points': 21,
   'pointsPerGame': 0.24705,
   'positionCode': 'L',
   'ppGoals': 1,
   'ppPoints': 2,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.10833,
   'shootsCatches': 'L',
   'shots': 120,
   'skaterFullName': 'Will Cuylle',
   'timeOnIcePerGame': 655.7647},
  {'assists': 12,
   'evGoals': 2,
   'evPoints': 10,
   'faceoffWinPct': 0.48648,
   'gameWinningGoals': 1,
   'gamesPlayed': 43,
   'goals': 6,
   'lastName': 'Bordeleau',
   'otGoals': 0,
   'penaltyMinutes': 18,
   'playerId': 8482133,
   'plusMinus': -22,
   'points': 18,
   'pointsPerGame': 0.4186,
   'positionCode': 'C',
   'ppGoals': 4,
   'ppPoints': 8,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.08571,
   'shootsCatches': 'L',
   'shots': 70,
   'skaterFullName': 'Thomas Bordeleau',
   'timeOnIcePerGame': 910.093},
  {'assists': 3,
   'evGoals': 0,
   'evPoints': 3,
   'faceoffWinPct': 0.47572,
   'gameWinningGoals': 0,
   'gamesPlayed': 16,
   'goals': 1,
   'lastName': 'Khusnutdinov',
   'otGoals': 0,
   'penaltyMinutes': 6,
   'playerId': 8482177,
   'plusMinus': -3,
   'points': 4,
   'pointsPerGame': 0.25,
   'positionCode': 'C',
   'ppGoals': 1,
   'ppPoints': 1,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.16666,
   'shootsCatches': 'L',
   'shots': 6,
   'skaterFullName': 'Marat Khusnutdinov',
   'timeOnIcePerGame': 786.625},
  {'assists': 1,
   'evGoals': 1,
   'evPoints': 2,
   'faceoffWinPct': 0.55555,
   'gameWinningGoals': 0,
   'gamesPlayed': 2,
   'goals': 1,
   'lastName': 'Ponomarev',
   'otGoals': 0,
   'penaltyMinutes': 0,
   'playerId': 8482102,
   'plusMinus': 1,
   'points': 2,
   'pointsPerGame': 1.0,
   'positionCode': 'C',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 1.0,
   'shootsCatches': 'L',
   'shots': 1,
   'skaterFullName': 'Vasily Ponomarev',
   'timeOnIcePerGame': 580.5},
  {'assists': 1,
   'evGoals': 1,
   'evPoints': 2,
   'faceoffWinPct': None,
   'gameWinningGoals': 1,
   'gamesPlayed': 13,
   'goals': 1,
   'lastName': 'Sokolov',
   'otGoals': 0,
   'penaltyMinutes': 4,
   'playerId': 8481102,
   'plusMinus': -4,
   'points': 2,
   'pointsPerGame': 0.15384,
   'positionCode': 'L',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.07692,
   'shootsCatches': 'R',
   'shots': 13,
   'skaterFullName': 'Egor Sokolov',
   'timeOnIcePerGame': 545.3846},
  {'assists': 0,
   'evGoals': 1,
   'evPoints': 1,
   'faceoffWinPct': None,
   'gameWinningGoals': 0,
   'gamesPlayed': 3,
   'goals': 1,
   'lastName': 'Colangelo',
   'otGoals': 0,
   'penaltyMinutes': 2,
   'playerId': 8482118,
   'plusMinus': 0,
   'points': 1,
   'pointsPerGame': 0.33333,
   'positionCode': 'R',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.14285,
   'shootsCatches': 'R',
   'shots': 7,
   'skaterFullName': 'Sam Colangelo',
   'timeOnIcePerGame': 753.3333},
  {'assists': 1,
   'evGoals': 0,
   'evPoints': 1,
   'faceoffWinPct': 0.31428,
   'gameWinningGoals': 0,
   'gamesPlayed': 7,
   'goals': 0,
   'lastName': 'Jarventie',
   'otGoals': 0,
   'penaltyMinutes': 4,
   'playerId': 8482162,
   'plusMinus': -5,
   'points': 1,
   'pointsPerGame': 0.14285,
   'positionCode': 'L',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.0,
   'shootsCatches': 'L',
   'shots': 5,
   'skaterFullName': 'Roby Jarventie',
   'timeOnIcePerGame': 451.2857},
  {'assists': 0,
   'evGoals': 0,
   'evPoints': 0,
   'faceoffWinPct': 0.0,
   'gameWinningGoals': 0,
   'gamesPlayed': 2,
   'goals': 0,
   'lastName': 'Goncalves',
   'otGoals': 0,
   'penaltyMinutes': 6,
   'playerId': 8482201,
   'plusMinus': 0,
   'points': 0,
   'pointsPerGame': 0.0,
   'positionCode': 'C',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': None,
   'shootsCatches': 'L',
   'shots': 0,
   'skaterFullName': 'Gage Goncalves',
   'timeOnIcePerGame': 597.5},
  {'assists': 0,
   'evGoals': 0,
   'evPoints': 0,
   'faceoffWinPct': 0.43333,
   'gameWinningGoals': 0,
   'gamesPlayed': 3,
   'goals': 0,
   'lastName': 'Robins',
   'otGoals': 0,
   'penaltyMinutes': 0,
   'playerId': 8482181,
   'plusMinus': -1,
   'points': 0,
   'pointsPerGame': 0.0,
   'positionCode': 'C',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': 0.0,
   'shootsCatches': 'R',
   'shots': 2,
   'skaterFullName': 'Tristen Robins',
   'timeOnIcePerGame': 822.6666},
  {'assists': 0,
   'evGoals': 0,
   'evPoints': 0,
   'faceoffWinPct': 0.0,
   'gameWinningGoals': 0,
   'gamesPlayed': 4,
   'goals': 0,
   'lastName': 'Heineman',
   'otGoals': 0,
   'penaltyMinutes': 0,
   'playerId': 8482476,
   'plusMinus': 2,
   'points': 0,
   'pointsPerGame': 0.0,
   'positionCode': 'L',
   'ppGoals': 0,
   'ppPoints': 0,
   'shGoals': 0,
   'shPoints': 0,
   'shootingPct': None,
   'shootsCatches': 'L',
   'shots': 0,
   'skaterFullName': 'Emil Heineman',
   'timeOnIcePerGame': 597.25}],
 'total': 12}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants