James McCool commited on
Commit
7545b49
·
1 Parent(s): c138732

Initial commit loading app.py, app.yaml, and requirements.txt

Browse files
Files changed (3) hide show
  1. app.py +36 -0
  2. app.yaml +10 -0
  3. requirements.txt +9 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ st.set_page_config(layout="wide")
3
+ import numpy as np
4
+ import pandas as pd
5
+ import pymongo
6
+ import time
7
+
8
+ @st.cache_resource
9
+ def init_conn():
10
+
11
+ uri = st.secrets['mongo_uri']
12
+ client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
13
+ db = client["League_of_Legends_Database"]
14
+
15
+ collection = db["gamelogs"]
16
+ team_names = collection.distinct("teamname")
17
+ player_names = collection.distinct("playername")
18
+
19
+ return db, team_names, player_names
20
+
21
+ db, team_names, player_names = init_conn()
22
+
23
+ @st.cache_data(ttl = 60)
24
+ def init_team_data(team):
25
+
26
+ collection = db["gamelogs"]
27
+ cursor = collection.find({"teamname": team})
28
+
29
+ raw_display = pd.DataFrame(list(cursor))
30
+ raw_display = raw_display[['playername', 'teamname', 'playername_avg_kill_share_win', 'playername_avg_death_share_win', 'playername_avg_assist_share_win', 'playername_avg_cs_share_win', 'playername_avg_kill_share_loss', 'playername_avg_death_share_loss', 'playername_avg_assist_share_loss', 'playername_avg_cs_share_loss']]
31
+
32
+ team_data = raw_display.drop_duplicates(subset = ['playername'])
33
+
34
+ return team_data
35
+
36
+ st.table(init_team_data("T1"))
app.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ runtime: python
2
+ env: flex
3
+
4
+ runtime_config:
5
+ python_version: 3
6
+
7
+ entrypoint: streamlit run streamlit-app.py --server.port $PORT
8
+
9
+ automatic_scaling:
10
+ max_num_instances: 200
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ gspread
3
+ openpyxl
4
+ matplotlib
5
+ pymongo
6
+ pulp
7
+ docker
8
+ plotly
9
+ scipy