BraydenMoore commited on
Commit
1ab47cd
1 Parent(s): 7727a49

Add running predictions dict

Browse files
Source/Data/predictions_this_year.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:926248e52d1fa532c317e37da24ed652ae64110f8219cb5e061668bd3091f048
3
+ size 5
Source/Predict/predict.py CHANGED
@@ -6,6 +6,7 @@ import os
6
  import requests
7
  from bs4 import BeautifulSoup
8
 
 
9
  current_directory = os.path.dirname(os.path.abspath(__file__))
10
  parent_directory = os.path.dirname(current_directory)
11
  data_directory = os.path.join(parent_directory, 'Data')
 
6
  import requests
7
  from bs4 import BeautifulSoup
8
 
9
+ # set dirs for other files
10
  current_directory = os.path.dirname(os.path.abspath(__file__))
11
  parent_directory = os.path.dirname(current_directory)
12
  data_directory = os.path.join(parent_directory, 'Data')
main.py CHANGED
@@ -7,12 +7,19 @@ import numpy as np
7
  pd.set_option('display.max_columns', None)
8
  pd.set_option('display.expand_frame_repr', False)
9
 
10
- # load past picks
11
- try:
12
- with open('predictions_this_year.pkl', 'rb') as f:
13
- predictions_this_year = pkl.load(f)
14
- except:
15
- predictions_this_year = {}
 
 
 
 
 
 
 
16
 
17
  # get week, season
18
  week, season = predict.get_week()
@@ -56,8 +63,9 @@ def submit_games():
56
  print('OverUnders')
57
  print(over_unders)
58
 
59
- #with open('predictions_this_year.pkl', 'wb') as f:
60
- # pkl.dump(predictions_this_year, f)
 
61
 
62
  return jsonify({'moneylines': moneylines,
63
  'over_unders': over_unders})
 
7
  pd.set_option('display.max_columns', None)
8
  pd.set_option('display.expand_frame_repr', False)
9
 
10
+ import os
11
+ import json
12
+ from google.cloud import storage
13
+
14
+ # authenticate gcp
15
+ gcp_sa_key = json.loads(os.environ.get('GCP_SA_KEY').replace('\n','\\n'))
16
+ client = storage.Client.from_service_account_info(gcp_sa_key)
17
+ bucket = client.get_bucket('bmllc-marci-data-bucket')
18
+
19
+ # download
20
+ blob = bucket.blob('predictions_this_year.pkl')
21
+ buffer = blob.download_as_bytes()
22
+ predictions_this_year = pkl.loads(buffer)
23
 
24
  # get week, season
25
  week, season = predict.get_week()
 
63
  print('OverUnders')
64
  print(over_unders)
65
 
66
+ # update gcp
67
+ buffer = pkl.dumps(predictions_this_year)
68
+ blob.upload_from_string(buffer, content_type='application/octet-stream')
69
 
70
  return jsonify({'moneylines': moneylines,
71
  'over_unders': over_unders})
requirements.txt CHANGED
@@ -7,4 +7,5 @@ pandas==1.5.3
7
  numpy==1.25.1
8
  matplotlib==3.7.1
9
  tqdm==4.65.0
10
- lxml==4.9.2
 
 
7
  numpy==1.25.1
8
  matplotlib==3.7.1
9
  tqdm==4.65.0
10
+ lxml==4.9.2
11
+ google-cloud-storage==2.10.0