Merge branch 'multithread'

This commit is contained in:
ltcptgeneral 2019-04-02 13:40:02 -05:00
commit d74a63d4e7
2 changed files with 37 additions and 24 deletions

View File

@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "titanscoutandroid",
"private_key_id": "e7cde706a13a6fade555cce2bc46ee53f05a0b11",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCsvdxVu22JVf/B\ntvFNxi7l6IsHUa+ijrDKGP3O2jbQCWjfBS0gNxpx65JXdKw4l+5p1lIyO5xe5b2m\nKOGQQf9Vd3X6xP9ttHD9ILjvdDRGvtR/bkD3e1ZdFSvt1PDddcLLPnIeDgkNQHXd\nzAYv0TIspJe6bUL3a5+HGK7nyfH7dGXZksNB/hiy3WS/eAgAnL6xzCRsdjK40Cf4\nP7B79bCNNnxnOy/GBpXG/CE8H+xGRr1Xuj5pmJFTc6GbaDbLc8bKMvVOzbCPYKgu\nbCaidtDoiMEJqy8AakrvN39DrlUOT3+kbAhJpw/fk9Rq4A2Mo+J2BuApze2hoYET\noI5HysuLAgMBAAECggEAGYkXgTTrxFmKLUC1+yFI3YO6yaIxrH4bdEStgF6Rq784\nWX+SZCjBKAYC5BrDOrp66/pavEJDo2Oi3WU9su2OqTu3nRJyD+2Uplan//3VnH+p\nOg06XVtGMQxoKghIcvRtj03z4K2CeQsGYXs/juIF4MOUCmMMezbVpkrn0CvyMZGM\n5vrFXvOwdKHyZaDXvql8nQIq6b46RC6ozLUBidEW37pHvuZm+QWD0W7VS2na4DKw\n+jIJz8zjsg3vCLpdTOMFxymW/LmusFTubn3evv4/8BLvw69seWPOyNi/PEjZWwgR\npQA7VYkETlZopZ6paHutmD5Yy4N0FjcJ6PMocwgKQQKBgQDnf6oFvZFV/QO1RACi\nhc0skytc7h96ePUWLwIMSMed3Jdr5ANC6tD4OIwGyrCDfKuLvsUCyEjHKhW8tarb\nTioaqgzM8Jwn+HMTyLJjzU4j8KhxgQWoLWri2HgRlqZV2Y1XNO3fRA8Zs3CsT7Fa\nIyEnKylWM6u0kQ2mMQicgQpulQKBgQC/BjSELv43ZGZKBg5m+Ps+PEFxJArvJgqA\nd+lXSHYkALWynyvukAuhmciAEKN1NKL7/DvxzfNRRXB32kmQkcjcsFZnnqbEkpq+\nzCOIJcesYN0k3kiCJuoNENdQXtAKGJrtHF1ilJfpt5Yuw67VC/B/JwkPF2wCsSfU\nHusyguFpnwKBgGKzVaRY7KxC0d/o/HROo+nLXYOjqxwmkihBJphiN2mg8ZZ4gsN3\nJl2OjnUe2h9VejZ8wbar+gugb+AjfJNAQkdYFVkThSCtlzLqMNTIZfaA1vB92BGa\nO6Y4MQkeuBCGTvLNiFXWyLFmhjWRTMZnj+0JQ/iS0zSLW8xtv4QqqG35AoGBAIee\n3zAtsP0gweKyNA11neLMouWx4jVx+6jD+Z2na4EaI+YiTe18xVVBOnF53qM68LAY\nn3KIdsRvmW7uQqZqaoIMi/vbTqlnMIhfpKZntEC1MKyZSD9nY2pNV6DO/8L7Pxsy\ntTZlKwma9vxSn9DQPjn4O91EEsJChnV6Uh+1flYfAoGADfomBP+kLm0jdvKm3Q+u\nA5S4ng3erDbCbZK0ADeVY5H0fNNJihx1yXx12g02T0biH6Efj+VpCeYC6W0wb2A1\nT/HqY1JSSsKQ7cPe1VEPKbbfn6PPrs+HbsHB8DDVPi9pysVfG7351PgNX/tb+iz/\nvJCSRvjRtxyFafuX4YQzWu0=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-wpsvx@titanscoutandroid.iam.gserviceaccount.com",
"client_id": "114864465329268712237",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-wpsvx%40titanscoutandroid.iam.gserviceaccount.com"
}

View File

@ -38,7 +38,7 @@ __changelog__ = """changelog:
- added superstructure to code
1.0.0.000:
- added import statements (revolutionary)
"""
"""
__author__ = (
"Arthur Lu <arthurlu@ttic.edu>, "
@ -61,15 +61,15 @@ import tbarequest as tba
import csv
def titanservice():
print("[OK] loading data")
start = time.time()
source_dir = 'data'
file_list = glob.glob(source_dir + '/*.csv') #supposedly sorts by alphabetical order, skips reading teams.csv because of redundancy
data = []
files = [fn for fn in glob.glob('data/*.csv')
files = [fn for fn in glob.glob('data/*.csv')
if not (os.path.basename(fn).startswith('scores') or os.path.basename(fn).startswith('teams') or os.path.basename(fn).startswith('match') or os.path.basename(fn).startswith('notes') or os.path.basename(fn).startswith('observationType') or os.path.basename(fn).startswith('teamDBRef'))] #scores will be handled sperately
for i in files:
@ -107,7 +107,7 @@ def titanservice():
#beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "min_overfit")
#print(eqs, rmss, r2s, overfit)
#ofbest_curve.append(beqs)
#ofbest_curve.append(brmss)
#ofbest_curve.append(br2s)
@ -126,12 +126,12 @@ def titanservice():
#print(r2best_curve)
measure_stats.append(teams[i] + list(analysis.basic_stats(line, 0, 0)) + list(analysis.histo_analysis(line, 1, -3, 3)))
stats.append(list(measure_stats))
nishant = []
for i in range(len(scores)):
#print(scores)
@ -144,7 +144,7 @@ def titanservice():
if len(line) < 4:
nishant.append('no_data')
continue
#print(line)
@ -157,7 +157,7 @@ def titanservice():
beqs, brmss, br2s, boverfit = analysis.select_best_regression(eqs, rmss, r2s, overfit, "min_overfit")
#print(eqs, rmss, r2s, overfit)
ofbest_curve.append(beqs)
ofbest_curve.append(brmss)
ofbest_curve.append(br2s)
@ -175,7 +175,7 @@ def titanservice():
r2best_curve.pop(0)
#print(r2best_curve)
z = len(scores[0]) + 1
nis_num = []
@ -185,7 +185,7 @@ def titanservice():
nis_num.append((eval(ofbest_curve[0]) + eval(r2best_curve[0])) / 2)
nishant.append(teams[i] + nis_num)
json_out = {}
score_out = {}
@ -195,7 +195,7 @@ def titanservice():
location = db.collection(u'stats').document(u'stats-noNN')
for i in range(len(teams)):
general_general_stats = location.collection(teams[i][0])
for j in range(len(files)):
json_out[str(teams[i][0])] = (stats[j][i])
name = os.path.basename(files[j])
@ -217,7 +217,7 @@ def pulldata():
if json_data[match].get('winning_alliance') == "":
#print(json_data[match])
json_data.remove(json_data[match])
json_data = sorted(json_data, key=lambda k: k.get('actual_time', 0), reverse=False)
for j in range(len(json_data)):
if "frc" + teams[i][0] in json_data[j].get('alliances').get('blue').get('team_keys'):
@ -235,7 +235,7 @@ def pulldata():
full=[]
tms=[]
for team in teams:
tms.append(team.id)
reports=db.collection('data').document('team-2022').collection("Central 2019").document(team.id).collection("matches").get()
@ -260,9 +260,9 @@ def pulldata():
for i in range(len(full)):
for j in range(len(full[i])):
for key in list(full[i][j].keys()):
if "Quantitative" in key:
quant_keys.append(key)
#print(full[i][j].get(key).get('teamDBRef')[5:] in list_teams)
@ -272,20 +272,20 @@ def pulldata():
#print(list(full[i][j].keys()))
#print(list_teams)
if full[i][j].get(key).get('teamDBRef')[5:] in list_teams:
var = {}
measured_vars = []
for k in range(len(list(full[i][j].get(key).keys()))):
individual_keys = list(full[i][j].get(key).keys())
var[individual_keys[k]] = full[i][j].get(key).get(individual_keys[k])
out.append(var)
sorted_out = []
for i in out:
@ -328,7 +328,7 @@ def pulldata():
writer = csv.writer(file, delimiter = ',')
writer.writerows(big_out[i])
def service():
while True:
@ -340,7 +340,7 @@ def service():
print("[OK] starting calculations")
fucked = False
for i in range(0, 5):
try:
titanservice()
@ -358,7 +358,7 @@ def service():
break
else:
print("[OK] finished calculations")
print("[OK] waiting: " + str(300 - (end - start)) + " seconds" + "\n")