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

Pip install pybaseball differs from code on master branch #440

Open
jtracy3 opened this issue Jul 11, 2024 · 1 comment
Open

Pip install pybaseball differs from code on master branch #440

jtracy3 opened this issue Jul 11, 2024 · 1 comment

Comments

@jtracy3
Copy link

jtracy3 commented Jul 11, 2024

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.

@ss77995ss
Copy link

ss77995ss commented Jul 12, 2024

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

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