Pip install pybaseball differs from code on master branch
I ran pip install pybaseball and was attempting to use the season_game_logs function in the retrosheets.py file and realized it wasn't working. I dove into the code and fixed some stuff with the intention of submitting a pull request. Here is the function season_game_logs that was pip installed:
def season_game_logs(season):
"""
Pull Retrosheet game logs for a given season
"""
GH_TOKEN=os.getenv('GH_TOKEN', '')
# validate input
g = Github(GH_TOKEN)
repo = g.get_repo('chadwickbureau/retrosheet')
gamelogs = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents('gamelog')]
file_name = f'GL{season}.TXT'
if file_name not in gamelogs:
raise ValueError(f'Season game logs not available for {season}')
s = get_text_file(gamelog_url.format(season))
data = pd.read_csv(StringIO(s), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data
After "fixing" the code and following the contribution markdown, I realized that the problem had already been fixed on the master branch. So I deleted the pip installed pybaseball code and ran pip install git+ssh://[email protected]/jldbc/pybaseball.git. The code for season_game_logs is:
def season_game_logs(season):
"""
Pull Retrosheet game logs for a given season
"""
GH_TOKEN=os.getenv('GH_TOKEN', '')
# validate input
g = Github(GH_TOKEN)
repo = g.get_repo('chadwickbureau/retrosheet')
season_folder = [f.path[f.path.rfind('/')+1:] for f in repo.get_contents(f'seasons/{season}')]
gamelog_file_name = f'GL{season}.TXT'
if gamelog_file_name not in season_folder:
raise ValueError(f'Season game logs not available for {season}')
s = get_text_file(season_gamelog_url.format(season, season))
data = pd.read_csv(StringIO(s), header=None, sep=',', quotechar='"')
data.columns = gamelog_columns
return data
The above seems to be the correct code but this code doesn't get installed when you run pip install pybaseball. I assume this has something to do with the setup.py file, but I'm not exactly sure what needs to change in it.
The current version on PYPI is 2.2.7 which was released on 2023/09/08. Might need to wait the maintainer to release the latest version of the code.
ref: https://github.com/jldbc/pybaseball/releases
I think the temporary solution is using pip install git+ssh://[email protected]/jldbc/pybaseball.git to install first