James McCool commited on
Commit ·
6146297
1
Parent(s): fb969e4
Add NBA showdown functionality and update Dockerfile
Browse files- Dockerfile +11 -0
- src/sports/nba_functions.py +37 -8
Dockerfile
CHANGED
|
@@ -12,10 +12,16 @@ RUN go mod download
|
|
| 12 |
# Copy Go source files
|
| 13 |
COPY func/dk_nhl_go ./func/dk_nhl_go
|
| 14 |
COPY func/fd_nhl_go ./func/fd_nhl_go
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# Build the Go programs for Linux
|
| 17 |
RUN CGO_ENABLED=0 GOOS=linux go build -o dk_nhl_seed ./func/dk_nhl_go/NHL_seed_frames.go
|
| 18 |
RUN CGO_ENABLED=0 GOOS=linux go build -o fd_nhl_seed ./func/fd_nhl_go/NHL_seed_frames.go
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
# Python stage
|
| 21 |
FROM python:3.11-slim
|
|
@@ -39,9 +45,14 @@ COPY src/ ./src/
|
|
| 39 |
# Copy compiled Go binaries from builder stage
|
| 40 |
COPY --from=go-builder /go-build/dk_nhl_seed ./dk_nhl_go/NHL_seed_frames
|
| 41 |
COPY --from=go-builder /go-build/fd_nhl_seed ./fd_nhl_go/NHL_seed_frames
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Make Go binaries executable
|
| 44 |
RUN chmod +x ./dk_nhl_go/NHL_seed_frames ./fd_nhl_go/NHL_seed_frames
|
|
|
|
|
|
|
| 45 |
|
| 46 |
# Create .streamlit directory for config
|
| 47 |
RUN mkdir -p .streamlit
|
|
|
|
| 12 |
# Copy Go source files
|
| 13 |
COPY func/dk_nhl_go ./func/dk_nhl_go
|
| 14 |
COPY func/fd_nhl_go ./func/fd_nhl_go
|
| 15 |
+
COPY func/dk_nba_go ./func/dk_nba_go
|
| 16 |
+
COPY func/fd_nba_go ./func/fd_nba_go
|
| 17 |
+
COPY func/showdown_go ./func/showdown_go
|
| 18 |
|
| 19 |
# Build the Go programs for Linux
|
| 20 |
RUN CGO_ENABLED=0 GOOS=linux go build -o dk_nhl_seed ./func/dk_nhl_go/NHL_seed_frames.go
|
| 21 |
RUN CGO_ENABLED=0 GOOS=linux go build -o fd_nhl_seed ./func/fd_nhl_go/NHL_seed_frames.go
|
| 22 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -o dk_nba_seed ./func/dk_nba_go/NBA_seed_frames.go
|
| 23 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -o fd_nba_seed ./func/fd_nba_go/NBA_seed_frames.go
|
| 24 |
+
RUN CGO_ENABLED=0 GOOS=linux go build -o showdown_seed ./func/showdown_go/showdown_seed_frames.go
|
| 25 |
|
| 26 |
# Python stage
|
| 27 |
FROM python:3.11-slim
|
|
|
|
| 45 |
# Copy compiled Go binaries from builder stage
|
| 46 |
COPY --from=go-builder /go-build/dk_nhl_seed ./dk_nhl_go/NHL_seed_frames
|
| 47 |
COPY --from=go-builder /go-build/fd_nhl_seed ./fd_nhl_go/NHL_seed_frames
|
| 48 |
+
COPY --from=go-builder /go-build/dk_nba_seed ./dk_nba_go/NBA_seed_frames
|
| 49 |
+
COPY --from=go-builder /go-build/fd_nba_seed ./fd_nba_go/NBA_seed_frames
|
| 50 |
+
COPY --from=go-builder /go-build/showdown_seed ./showdown_go/showdown_seed_frames
|
| 51 |
|
| 52 |
# Make Go binaries executable
|
| 53 |
RUN chmod +x ./dk_nhl_go/NHL_seed_frames ./fd_nhl_go/NHL_seed_frames
|
| 54 |
+
RUN chmod +x ./dk_nba_go/NBA_seed_frames ./fd_nba_go/NBA_seed_frames
|
| 55 |
+
RUN chmod +x ./showdown_go/showdown_seed_frames
|
| 56 |
|
| 57 |
# Create .streamlit directory for config
|
| 58 |
RUN mkdir -p .streamlit
|
src/sports/nba_functions.py
CHANGED
|
@@ -127,20 +127,28 @@ fd_sd_player_hold: DataFrame = DataFrame(columns=['Player', 'Minutes Proj', 'Pos
|
|
| 127 |
def run_go_showdown_lineup_generator(site="DK", sport="NBA"):
|
| 128 |
"""Run the Go lineup generator after Python data processing"""
|
| 129 |
try:
|
| 130 |
-
st.write(f"Starting Go {sport} lineup generation...")
|
| 131 |
start_time = time.time()
|
| 132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
# Run the Go executable
|
| 134 |
result = subprocess.run(
|
| 135 |
-
[
|
| 136 |
capture_output=True,
|
| 137 |
text=True,
|
| 138 |
check=True,
|
| 139 |
-
cwd=
|
| 140 |
)
|
| 141 |
|
| 142 |
end_time = time.time()
|
| 143 |
-
st.write(f"Go {sport} processing completed in {end_time - start_time:.2f} seconds")
|
| 144 |
|
| 145 |
if result.stdout:
|
| 146 |
st.write("Go output:", result.stdout)
|
|
@@ -156,8 +164,11 @@ def run_go_showdown_lineup_generator(site="DK", sport="NBA"):
|
|
| 156 |
if e.stderr:
|
| 157 |
st.write("Error output:", e.stderr)
|
| 158 |
return False
|
| 159 |
-
except FileNotFoundError:
|
| 160 |
-
st.write("Error:
|
|
|
|
|
|
|
|
|
|
| 161 |
return False
|
| 162 |
|
| 163 |
def run_go_classic_lineup_generator(site="DK", sport="NBA"):
|
|
@@ -1647,8 +1658,17 @@ def DK_NBA_SD_seed_frame(dk_showdown_options, dk_sd_projections):
|
|
| 1647 |
}
|
| 1648 |
output_data["cpt_median"]["players"].append(player)
|
| 1649 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1650 |
# Write JSON data for Go processing
|
| 1651 |
-
|
|
|
|
| 1652 |
json.dump(output_data, f)
|
| 1653 |
|
| 1654 |
st.write("JSON export completed, starting Go processing...")
|
|
@@ -1809,8 +1829,17 @@ def FD_NBA_SD_seed_frame(fd_showdown_options, fd_sd_projections):
|
|
| 1809 |
}
|
| 1810 |
output_data["cpt_median"]["players"].append(player)
|
| 1811 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1812 |
# Write JSON data for Go processing
|
| 1813 |
-
|
|
|
|
| 1814 |
json.dump(output_data, f)
|
| 1815 |
|
| 1816 |
st.write("JSON export completed, starting Go processing...")
|
|
|
|
| 127 |
def run_go_showdown_lineup_generator(site="DK", sport="NBA"):
|
| 128 |
"""Run the Go lineup generator after Python data processing"""
|
| 129 |
try:
|
| 130 |
+
st.write(f"Starting Go {sport} Showdown lineup generation...")
|
| 131 |
start_time = time.time()
|
| 132 |
|
| 133 |
+
# Determine the path to the Go binary
|
| 134 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 135 |
+
project_root = os.path.dirname(os.path.dirname(current_dir))
|
| 136 |
+
|
| 137 |
+
go_binary = os.path.join(project_root, "showdown_go", "showdown_seed_frames")
|
| 138 |
+
|
| 139 |
+
st.write(f"Looking for binary at: {go_binary}")
|
| 140 |
+
|
| 141 |
# Run the Go executable
|
| 142 |
result = subprocess.run(
|
| 143 |
+
[go_binary, site, sport],
|
| 144 |
capture_output=True,
|
| 145 |
text=True,
|
| 146 |
check=True,
|
| 147 |
+
cwd=project_root
|
| 148 |
)
|
| 149 |
|
| 150 |
end_time = time.time()
|
| 151 |
+
st.write(f"Go {sport} Showdown processing completed in {end_time - start_time:.2f} seconds")
|
| 152 |
|
| 153 |
if result.stdout:
|
| 154 |
st.write("Go output:", result.stdout)
|
|
|
|
| 164 |
if e.stderr:
|
| 165 |
st.write("Error output:", e.stderr)
|
| 166 |
return False
|
| 167 |
+
except FileNotFoundError as e:
|
| 168 |
+
st.write(f"Error: Go binary not found at {go_binary}")
|
| 169 |
+
st.write(f"FileNotFoundError: {e}")
|
| 170 |
+
st.write(f"Current working directory: {os.getcwd()}")
|
| 171 |
+
st.write(f"Project root: {project_root}")
|
| 172 |
return False
|
| 173 |
|
| 174 |
def run_go_classic_lineup_generator(site="DK", sport="NBA"):
|
|
|
|
| 1658 |
}
|
| 1659 |
output_data["cpt_median"]["players"].append(player)
|
| 1660 |
|
| 1661 |
+
# Calculate project root for file paths
|
| 1662 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 1663 |
+
project_root = os.path.dirname(os.path.dirname(current_dir))
|
| 1664 |
+
|
| 1665 |
+
# Ensure directory exists
|
| 1666 |
+
showdown_dir = os.path.join(project_root, 'showdown_go')
|
| 1667 |
+
os.makedirs(showdown_dir, exist_ok=True)
|
| 1668 |
+
|
| 1669 |
# Write JSON data for Go processing
|
| 1670 |
+
player_data_path = os.path.join(showdown_dir, 'player_data.json')
|
| 1671 |
+
with open(player_data_path, 'w') as f:
|
| 1672 |
json.dump(output_data, f)
|
| 1673 |
|
| 1674 |
st.write("JSON export completed, starting Go processing...")
|
|
|
|
| 1829 |
}
|
| 1830 |
output_data["cpt_median"]["players"].append(player)
|
| 1831 |
|
| 1832 |
+
# Calculate project root for file paths
|
| 1833 |
+
current_dir = os.path.dirname(os.path.abspath(__file__))
|
| 1834 |
+
project_root = os.path.dirname(os.path.dirname(current_dir))
|
| 1835 |
+
|
| 1836 |
+
# Ensure directory exists
|
| 1837 |
+
showdown_dir = os.path.join(project_root, 'showdown_go')
|
| 1838 |
+
os.makedirs(showdown_dir, exist_ok=True)
|
| 1839 |
+
|
| 1840 |
# Write JSON data for Go processing
|
| 1841 |
+
player_data_path = os.path.join(showdown_dir, 'player_data.json')
|
| 1842 |
+
with open(player_data_path, 'w') as f:
|
| 1843 |
json.dump(output_data, f)
|
| 1844 |
|
| 1845 |
st.write("JSON export completed, starting Go processing...")
|