Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,11 +34,13 @@ def init_conn():
|
|
| 34 |
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40model-sheets-connect.iam.gserviceaccount.com"
|
| 35 |
}
|
| 36 |
|
| 37 |
-
uri = "mongodb+srv://multichem:
|
|
|
|
|
|
|
| 38 |
|
| 39 |
gc_con = gspread.service_account_from_dict(credentials, scope)
|
| 40 |
|
| 41 |
-
return gc_con,
|
| 42 |
|
| 43 |
gcservice_account, uri = init_conn()
|
| 44 |
|
|
@@ -46,11 +48,6 @@ percentages_format = {'PG': '{:.2%}', 'SG': '{:.2%}', 'SF': '{:.2%}', 'PF': '{:.
|
|
| 46 |
|
| 47 |
@st.cache_resource(ttl = 599)
|
| 48 |
def init_baselines():
|
| 49 |
-
|
| 50 |
-
# Create a new client and connect to the server
|
| 51 |
-
client = MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
| 52 |
-
db = client['testing_db']
|
| 53 |
-
|
| 54 |
collection = db["MLB_Hitters_DB"]
|
| 55 |
cursor = collection.find() # Finds all documents in the collection
|
| 56 |
|
|
@@ -86,8 +83,6 @@ def init_baselines():
|
|
| 86 |
'FB%', 'HR/FB', 'Hard%', 'Barrels', 'Barrel%', 'xERA', 'vFA', 'vFT', 'vFC', 'vFS', 'vFO', 'vSI',
|
| 87 |
'vSL', 'vCU', 'vKC', 'vEP', 'vCH', 'vSC', 'vKN'], axis=1)
|
| 88 |
|
| 89 |
-
client.close()
|
| 90 |
-
|
| 91 |
timestamp = pitcher_gamelog_table['Date'].max()
|
| 92 |
|
| 93 |
return hitter_gamelog_table, pitcher_gamelog_table, timestamp
|
|
|
|
| 34 |
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40model-sheets-connect.iam.gserviceaccount.com"
|
| 35 |
}
|
| 36 |
|
| 37 |
+
uri = "mongodb+srv://multichem:Xr1q5wZdXPbxdUmJ@testcluster.lgwtp5i.mongodb.net/?retryWrites=true&w=majority&appName=TestCluster"
|
| 38 |
+
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
| 39 |
+
db = client["testing_db"]
|
| 40 |
|
| 41 |
gc_con = gspread.service_account_from_dict(credentials, scope)
|
| 42 |
|
| 43 |
+
return gc_con, client, db
|
| 44 |
|
| 45 |
gcservice_account, uri = init_conn()
|
| 46 |
|
|
|
|
| 48 |
|
| 49 |
@st.cache_resource(ttl = 599)
|
| 50 |
def init_baselines():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
collection = db["MLB_Hitters_DB"]
|
| 52 |
cursor = collection.find() # Finds all documents in the collection
|
| 53 |
|
|
|
|
| 83 |
'FB%', 'HR/FB', 'Hard%', 'Barrels', 'Barrel%', 'xERA', 'vFA', 'vFT', 'vFC', 'vFS', 'vFO', 'vSI',
|
| 84 |
'vSL', 'vCU', 'vKC', 'vEP', 'vCH', 'vSC', 'vKN'], axis=1)
|
| 85 |
|
|
|
|
|
|
|
| 86 |
timestamp = pitcher_gamelog_table['Date'].max()
|
| 87 |
|
| 88 |
return hitter_gamelog_table, pitcher_gamelog_table, timestamp
|