Multichem commited on
Commit
e35cf54
·
verified ·
1 Parent(s): 9d203ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -23,14 +23,16 @@ def init_conn():
23
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40model-sheets-connect.iam.gserviceaccount.com"
24
  }
25
  uri = "mongodb+srv://multichem:[email protected]/?retryWrites=true&w=majority&appName=TestCluster"
 
 
26
 
27
  MLB_Data = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=340831852'
28
 
29
  gc_con = gspread.service_account_from_dict(credentials, scope)
30
 
31
- return gc_con, uri, MLB_Data
32
 
33
- gcservice_account, uri, MLB_Data = init_conn()
34
 
35
  percentages_format = {'Exposure': '{:.2%}'}
36
  freq_format = {'Exposure': '{:.2%}', 'Proj Own': '{:.2%}', 'Edge': '{:.2%}'}
@@ -38,9 +40,7 @@ dk_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 's
38
  fd_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count']
39
 
40
  @st.cache_data(ttl = 599)
41
- def init_seed_frames(uri):
42
- client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
43
- db = client["testing_db"]
44
 
45
  collection = db["DK_MLB_seed_frame"]
46
  cursor = collection.find()
@@ -56,8 +56,6 @@ def init_seed_frames(uri):
56
  raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count']]
57
  FD_seed = raw_display.to_numpy()
58
 
59
- client.close()
60
-
61
  return DK_Seed, FD_Seed
62
 
63
  @st.cache_data(ttl = 599)
@@ -131,7 +129,7 @@ def sim_contest(Sim_size, seed_frame, maps_dict, sharp_split, Contest_Size):
131
 
132
  return Sim_Winners
133
 
134
- DK_Seed, FD_Seed = init_seed_frames(uri)
135
  dk_raw, fd_raw = init_baselines()
136
 
137
  tab1, tab2 = st.tabs(['Data Export', 'Contest Sims'])
@@ -142,7 +140,7 @@ with tab1:
142
  st.cache_data.clear()
143
  for key in st.session_state.keys():
144
  del st.session_state[key]
145
- DK_Seed, FD_Seed = init_seed_frames(db)
146
  dk_raw, fd_raw = init_baselines()
147
 
148
  slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Other Main Slate'))
@@ -228,7 +226,7 @@ with tab2:
228
  st.cache_data.clear()
229
  for key in st.session_state.keys():
230
  del st.session_state[key]
231
- DK_Seed, FD_Seed = init_seed_frames(db)
232
  dk_raw, fd_raw = init_baselines()
233
  sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Other Main Slate'), key='sim_slate_var1')
234
  sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')
 
23
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40model-sheets-connect.iam.gserviceaccount.com"
24
  }
25
  uri = "mongodb+srv://multichem:[email protected]/?retryWrites=true&w=majority&appName=TestCluster"
26
+ client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
27
+ db = client["testing_db"]
28
 
29
  MLB_Data = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=340831852'
30
 
31
  gc_con = gspread.service_account_from_dict(credentials, scope)
32
 
33
+ return gc_con, db, MLB_Data
34
 
35
+ gcservice_account, db, MLB_Data = init_conn()
36
 
37
  percentages_format = {'Exposure': '{:.2%}'}
38
  freq_format = {'Exposure': '{:.2%}', 'Proj Own': '{:.2%}', 'Edge': '{:.2%}'}
 
40
  fd_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count']
41
 
42
  @st.cache_data(ttl = 599)
43
+ def init_seed_frames():
 
 
44
 
45
  collection = db["DK_MLB_seed_frame"]
46
  cursor = collection.find()
 
56
  raw_display = raw_display[['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count']]
57
  FD_seed = raw_display.to_numpy()
58
 
 
 
59
  return DK_Seed, FD_Seed
60
 
61
  @st.cache_data(ttl = 599)
 
129
 
130
  return Sim_Winners
131
 
132
+ DK_Seed, FD_Seed = init_seed_frames()
133
  dk_raw, fd_raw = init_baselines()
134
 
135
  tab1, tab2 = st.tabs(['Data Export', 'Contest Sims'])
 
140
  st.cache_data.clear()
141
  for key in st.session_state.keys():
142
  del st.session_state[key]
143
+ DK_Seed, FD_Seed = init_seed_frames()
144
  dk_raw, fd_raw = init_baselines()
145
 
146
  slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Other Main Slate'))
 
226
  st.cache_data.clear()
227
  for key in st.session_state.keys():
228
  del st.session_state[key]
229
+ DK_Seed, FD_Seed = init_seed_frames()
230
  dk_raw, fd_raw = init_baselines()
231
  sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Other Main Slate'), key='sim_slate_var1')
232
  sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')