zero-sum-seattle/python-mlb-statsapi

Issue with mlb.get_schedule() and mlb.get_scheduled_games_by_date() methods

michaelbarski opened this issue · 4 comments

Executed within a cell in Google Colab

! pip install python-mlb-statsapi==0.5.13
import mlbstatsapi
mlb = mlbstatsapi.Mlb()

mlb.get_schedule(date='2023-09-03')

#output

DEBUG:mlbstatsapi.mlb_dataadapter:url=https://statsapi.mlb.com/api/v1/schedule ,success={}, status_code={}, message={}, url={}
DEBUG:mlbstatsapi.mlb_dataadapter:url=https://statsapi.mlb.com/api/v1/schedule ,success=success, status_code=200, message=OK, url=https://statsapi.mlb.com/api/v1/schedule?date=2023-09-03&sportId=1

TypeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 mlb.get_schedule(date='2023-09-03')

6 frames
/usr/local/lib/python3.10/dist-packages/mlbstatsapi/models/schedules/attributes.py in (.0)
213
214 def post_init(self):
--> 215 self.games = [ScheduleGames(**game) for game in self.games ] if self.games else self.games
216
217 def repr(self):

TypeError: ScheduleGames.init() got an unexpected keyword argument 'gameguid'

The same output occurs with the get_scheduled_games_by_date() method.

This error goes away if you install the default version of the library. For example, this version of the lib has no issues with the schedule methods:
! pip install python-mlb-statsapi

However, the version specified in the installation instructions for this lib does not seem to have a working schedule method:
! pip install python-mlb-statsapi==0.5.13

(Since I'm using a google colab file, I wrote the code for use in code cells, not terminals). Here is the same code but for use in a terminal:

python3 -m pip install python-mlb-statsapi
python3 -m pip install python-mlb-statsapi==0.5.13

The install instructions in the docs for this lib should be updated to avoid future issues.

@michaelbarski should we just drop the version from the install?

I was having issues with pip install an old version unless I did that, so I tossed it in the docs.

@Mattsface

I haven't had any issues with the default install, so if you aren't either, I'd suggest dropping it.

Here's a link to some of the testing I just did with the Schedule obj methods.

From the code, it's clear that the issues with the methods have to do with version 0.5.13.

With version 0.5.14 (this is the current default version) the methods work. That said, I didn't dig into the code for that specific version—but I'm guessing that one of the objects being referenced is missing the gameguid attribute in the older version.

If the default pip install python-mlb-statsapi is still not working for some people (which would be a little surprising), I guess you could try specifying python-mlb-statsapi==0.5.14.

Otherwise,

For notebook/colab users:
! pip install python-mlb-statsapi

For terminal:
pip install python-mlb-statsapi

Done I've made the change to the readme

They are constantly adding new attributes are automated testing finds.

Thanks for your input @michaelbarski