nesticot commited on
Commit
7965905
·
verified ·
1 Parent(s): 8e30408

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -278,8 +278,29 @@ def server(input, output, session):
278
 
279
  @session.download()
280
  def download():
281
- # When running in Hugging Face space, we need to use a temporary file
282
- yield cached_data().write_csv('data.csv')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
 
284
 
285
  app = App(app_ui, server)
 
278
 
279
  @session.download()
280
  def download():
281
+ year_input = int(input.year_input())
282
+ sport_id = int(input.level_input())
283
+ player_input = int(input.pitcher_id())
284
+ start_date = str(input.date_id()[0])
285
+ end_date = str(input.date_id()[1])
286
+ # Simulate an expensive data operation
287
+ game_list = scrape.get_player_games_list(sport_id = sport_id,
288
+ season = year_input,
289
+ player_id = player_input,
290
+ start_date = start_date,
291
+ end_date = end_date)
292
+
293
+ data_list = scrape.get_data(game_list_input = game_list[:])
294
+ df = (stuff_apply.stuff_apply(fe.feature_engineering(update.update(scrape.get_data_df(data_list = data_list).filter(
295
+ (pl.col("pitcher_id") == player_input)&
296
+ (pl.col("is_pitch") == True)&
297
+ (pl.col('batter_hand').is_in(split_dict_hand[input.split_id()]))
298
+
299
+ )))).with_columns(
300
+ pl.col('pitch_type').count().over('pitch_type').alias('pitch_count')
301
+ ))
302
+
303
+ yield df.write_csv('data.csv')
304
 
305
 
306
  app = App(app_ui, server)