James McCool commited on
Commit
c3e002b
·
1 Parent(s): 88d1fe7

Updating to automatically grab opponent map and grid map depending on if it's MMA or NASCAR, even if you don't do a database load.

Browse files
Files changed (2) hide show
  1. app.py +4 -0
  2. update-launch-template.ps1 +71 -0
app.py CHANGED
@@ -1621,6 +1621,10 @@ if selected_tab == 'Data Load':
1621
  st.session_state['projections_loaded'] = False
1622
  if proj_options == 'User Upload':
1623
  projections_file = st.file_uploader("Upload Projections File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
 
 
 
 
1624
  st.session_state['db_projections_file'] = projections_file
1625
  st.session_state['projections_loaded'] = True
1626
  elif proj_options == 'Paydirt DB':
 
1621
  st.session_state['projections_loaded'] = False
1622
  if proj_options == 'User Upload':
1623
  projections_file = st.file_uploader("Upload Projections File (CSV or Excel)", type=['csv', 'xlsx', 'xls'])
1624
+ if sport_var == 'MMA':
1625
+ opp_map = init_mma_baselines(type_var, site_var, slate_var3)[8]
1626
+ elif sport_var == 'NASCAR':
1627
+ grid_map = init_nascar_baselines(type_var, site_var, slate_var3)[8]
1628
  st.session_state['db_projections_file'] = projections_file
1629
  st.session_state['projections_loaded'] = True
1630
  elif proj_options == 'Paydirt DB':
update-launch-template.ps1 ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Update Launch Template to pull from Git
2
+
3
+ # Define the user data bash script
4
+ $userData = @'
5
+ #!/bin/bash
6
+ cd /home/ec2-user
7
+
8
+ # Clone repo if it doesn't exist, otherwise pull latest
9
+ if [ ! -d "AWS_Portfolio_Manager" ]; then
10
+ git clone https://huggingface.co/spaces/Multichem-PD/DFS_Portfolio_Manager AWS_Portfolio_Manager
11
+ cd AWS_Portfolio_Manager
12
+ python3 -m venv venv
13
+ mkdir -p .streamlit
14
+ else
15
+ cd AWS_Portfolio_Manager
16
+ git pull origin main
17
+ fi
18
+
19
+ # Install/update packages
20
+ source venv/bin/activate
21
+ pip install -r requirements.txt
22
+
23
+ # Restart Streamlit
24
+ sudo supervisorctl restart streamlit
25
+ '@
26
+
27
+ # Encode to base64 for AWS
28
+ $userDataBase64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($userData))
29
+
30
+ Write-Host "Creating new launch template version..." -ForegroundColor Cyan
31
+
32
+ # Create properly formatted JSON file with ASCII encoding (no BOM)
33
+ $jsonContent = "{`"UserData`": `"$userDataBase64`"}"
34
+ [System.IO.File]::WriteAllText("$PWD\launch-template-data.json", $jsonContent, [System.Text.Encoding]::ASCII)
35
+
36
+ # Create new launch template version
37
+ aws ec2 create-launch-template-version `
38
+ --launch-template-name portfolio-manager-template `
39
+ --source-version '$Latest' `
40
+ --launch-template-data file://launch-template-data.json
41
+
42
+ if ($LASTEXITCODE -ne 0) {
43
+ Write-Host "Failed to create launch template version" -ForegroundColor Red
44
+ Remove-Item "launch-template-data.json" -ErrorAction SilentlyContinue
45
+ exit 1
46
+ }
47
+
48
+ # Get the latest version number
49
+ $latestVersion = aws ec2 describe-launch-template-versions `
50
+ --launch-template-name portfolio-manager-template `
51
+ --query 'LaunchTemplateVersions[0].VersionNumber' `
52
+ --output text
53
+
54
+ Write-Host "Setting version $latestVersion as default..." -ForegroundColor Cyan
55
+
56
+ # Set the new version as default
57
+ aws ec2 modify-launch-template `
58
+ --launch-template-name portfolio-manager-template `
59
+ --default-version $latestVersion
60
+
61
+ # Clean up temp file
62
+ Remove-Item "launch-template-data.json" -ErrorAction SilentlyContinue
63
+
64
+ if ($LASTEXITCODE -eq 0) {
65
+ Write-Host "Success! Launch template updated to version $latestVersion" -ForegroundColor Green
66
+ Write-Host "New instances will automatically pull code from Git" -ForegroundColor Green
67
+ Write-Host "Don't forget to add secrets.toml to new instances manually!" -ForegroundColor Yellow
68
+ } else {
69
+ Write-Host "Failed to set default version" -ForegroundColor Red
70
+ exit 1
71
+ }