patrickramos commited on
Commit
332152c
·
1 Parent(s): ba07c8b

Rearrange app tabs, edit to-do

Browse files
Files changed (5) hide show
  1. app.py +23 -18
  2. data.py +18 -7
  3. pitch_leaderboard.py +2 -2
  4. pitcher_overview.py +1 -10
  5. player_team_leaderboard.py +0 -4
app.py CHANGED
@@ -20,6 +20,7 @@ with open('updated.txt') as f:
20
  limitations = '''**General Limitations**
21
  - As new players make their debut, some names may be missing or not translated/transliterated correctly.
22
  - IP is underestimated (does not count outs via caught stealing)
 
23
  '''
24
 
25
  with open('acknowledgements.md', 'r') as f:
@@ -28,25 +29,29 @@ with open('acknowledgements.md', 'r') as f:
28
  if __name__ == '__main__':
29
  with gr.Blocks(title='NPB Data App', css=css) as app:
30
  with gr.Tab('Pitching'):
31
- with gr.Tab('Pitcher Overview'):
32
- create_pitcher_overview(data_df)
33
- with gr.Tab('Pitcher Leaderboard'):
34
- create_pitcher_leaderboard()
35
- with gr.Tab('Pitch Leaderboard'):
36
- create_pitcher_pitch_leaderboard()
37
- with gr.Tab('Team Pitching Leaderboard'):
38
- create_team_pitching_leaderboard()
39
- with gr.Tab('Team Pitching Pitch Leaderboard'):
40
- create_team_pitching_pitch_leaderboard()
 
 
41
  with gr.Tab('Batting'):
42
- with gr.Tab('Batter Leaderboard'):
43
- create_batter_leaderboard()
44
- with gr.Tab('Team Batting Leaderboard'):
45
- create_team_batting_leaderboard()
46
- with gr.Tab('Batter Pitch Leaderboard'):
47
- create_batter_pitch_leaderboard()
48
- with gr.Tab('Team Batting Pitch Leaderboard'):
49
- create_team_batting_pitch_leaderboard()
 
 
50
  with gr.Tab('Daily/Weekly Leaderboard'):
51
  create_daily_weekly_leaderboard_app(data_df)
52
  with gr.Tab('Acknowledgements'):
 
20
  limitations = '''**General Limitations**
21
  - As new players make their debut, some names may be missing or not translated/transliterated correctly.
22
  - IP is underestimated (does not count outs via caught stealing)
23
+ - Data is only from regular season
24
  '''
25
 
26
  with open('acknowledgements.md', 'r') as f:
 
29
  if __name__ == '__main__':
30
  with gr.Blocks(title='NPB Data App', css=css) as app:
31
  with gr.Tab('Pitching'):
32
+ with gr.Tab('Pitcher'):
33
+ with gr.Tab('Pitcher Overview'):
34
+ create_pitcher_overview(data_df)
35
+ with gr.Tab('Pitcher Leaderboard'):
36
+ create_pitcher_leaderboard()
37
+ with gr.Tab('Pitch Leaderboard'):
38
+ create_pitcher_pitch_leaderboard()
39
+ with gr.Tab('Team Pitching'):
40
+ with gr.Tab('Team Pitching Leaderboard'):
41
+ create_team_pitching_leaderboard()
42
+ with gr.Tab('Team Pitching Pitch Leaderboard'):
43
+ create_team_pitching_pitch_leaderboard()
44
  with gr.Tab('Batting'):
45
+ with gr.Tab('Batter'):
46
+ with gr.Tab('Batter Leaderboard'):
47
+ create_batter_leaderboard()
48
+ with gr.Tab('Batter Pitch Leaderboard'):
49
+ create_batter_pitch_leaderboard()
50
+ with gr.Tab('Team Batting'):
51
+ with gr.Tab('Team Batting Leaderboard'):
52
+ create_team_batting_leaderboard()
53
+ with gr.Tab('Team Batting Pitch Leaderboard'):
54
+ create_team_batting_pitch_leaderboard()
55
  with gr.Tab('Daily/Weekly Leaderboard'):
56
  create_daily_weekly_leaderboard_app(data_df)
57
  with gr.Tab('Acknowledgements'):
data.py CHANGED
@@ -8,6 +8,8 @@ import numpy as np
8
  from string import ascii_letters
9
  from itertools import product
10
 
 
 
11
  from convert import (
12
  aux_global_id_to_code, presult,
13
  team_name_short,
@@ -18,14 +20,23 @@ from convert import (
18
  game_kind
19
  )
20
 
 
21
 
22
- DATA_PATH = snapshot_download(
23
- repo_id='Ramos-Ramos/npb_data_app',
24
- repo_type='dataset',
25
- local_dir='./files',
26
- cache_dir='./.cache',
27
- allow_patterns=['*/pbp_data.parquet', '*/pbp_text.parquet', '*/pbp_aux.parquet', '*/schedule.parquet', '*/aux_schedule.parquet', 'players.parquet', 'players_translated.parquet', 'players_translated_manual.parquet']
28
- )
 
 
 
 
 
 
 
 
29
 
30
  SEASONS = [2021, 2022, 2023, 2024, 2025]
31
 
 
8
  from string import ascii_letters
9
  from itertools import product
10
 
11
+ import os
12
+
13
  from convert import (
14
  aux_global_id_to_code, presult,
15
  team_name_short,
 
20
  game_kind
21
  )
22
 
23
+ DATA_PATH = './files'
24
 
25
+ assert (PULL_NPB_DATA := os.getenv('PULL_NPB_DATA', 'True')) in ('True', 'False')
26
+ if PULL_NPB_DATA == 'True':
27
+ print('Pulling NPB data...')
28
+ DATA_PATH = snapshot_download(
29
+ repo_id='Ramos-Ramos/npb_data_app',
30
+ repo_type='dataset',
31
+ local_dir=DATA_PATH,
32
+ cache_dir='./.cache',
33
+ allow_patterns=['*/pbp_data.parquet', '*/pbp_text.parquet', '*/pbp_aux.parquet', '*/schedule.parquet', '*/aux_schedule.parquet', 'players.parquet', 'players_translated.parquet', 'players_translated_manual.parquet']
34
+ )
35
+ print('Done')
36
+ else:
37
+ DATA_PATH = os.path.abspath(DATA_PATH)
38
+
39
+ print(DATA_PATH)
40
 
41
  SEASONS = [2021, 2022, 2023, 2024, 2025]
42
 
pitch_leaderboard.py CHANGED
@@ -24,9 +24,9 @@ PITCH_TYPES = [pitch_type for pitch_type in ball_kind.values() if pitch_type !=
24
  notes = '''**Limitations**
25
  - [Column widths get messed up when filtering](https://github.com/gradio-app/gradio/issues/11564)
26
 
27
- **To-do**
28
- - Add post-season
29
  '''
 
30
  def create_pitch_leaderboard(player_team_type):
31
  '''Creates entire pitch leaderboard Gradio app given a player/team type'''
32
 
 
24
  notes = '''**Limitations**
25
  - [Column widths get messed up when filtering](https://github.com/gradio-app/gradio/issues/11564)
26
 
27
+ [**To-do**](https://docs.google.com/document/d/1fS-lba94FjczcNI1AXRwtfJMytBQY3jGeQCT_B4tQZ8)
 
28
  '''
29
+
30
  def create_pitch_leaderboard(player_team_type):
31
  '''Creates entire pitch leaderboard Gradio app given a player/team type'''
32
 
pitcher_overview.py CHANGED
@@ -6,16 +6,7 @@ from data import SEASONS, data_df
6
 
7
  from plotting import create_pitcher_overview_card
8
 
9
- notes = '''**Limitations**
10
- - Only supports regular season data
11
-
12
- **To-do**
13
- - Add teams insignias
14
- - Measure percentiles per pitcher handedness
15
- - Allow for arbitrary date ranges
16
- - Improve readability of pitch velocities
17
- - Add post-season
18
- '''
19
 
20
  def dummy(*inputs):
21
  return inputs
 
6
 
7
  from plotting import create_pitcher_overview_card
8
 
9
+ notes = ''''''
 
 
 
 
 
 
 
 
 
10
 
11
  def dummy(*inputs):
12
  return inputs
player_team_leaderboard.py CHANGED
@@ -16,10 +16,6 @@ from utils import get_col_width
16
 
17
  notes = '''**Limitations**
18
  - [Column widths get messed up when filtering](https://github.com/gradio-app/gradio/issues/11564)
19
-
20
- **To-do**
21
- - Fix IP calculation
22
- - Add post-season
23
  '''
24
 
25
 
 
16
 
17
  notes = '''**Limitations**
18
  - [Column widths get messed up when filtering](https://github.com/gradio-app/gradio/issues/11564)
 
 
 
 
19
  '''
20
 
21