Compare commits
No commits in common. "b898dfd378b3c0630084d6c2107f7f873251f747" and "072d47a267231657905f0de2e05abdcc2b2cbe3c" have entirely different histories.
b898dfd378
...
072d47a267
|
|
@ -1,64 +0,0 @@
|
||||||
name: Build Python App
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: hub.digitalhippo.tech
|
|
||||||
ORG_NAME: digitalhippo
|
|
||||||
IMAGE_NAME: wffrg
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.11'
|
|
||||||
|
|
||||||
- name: Install requirements
|
|
||||||
run: |
|
|
||||||
python3 -m pip install --upgrade pip
|
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
|
|
||||||
- name: Lint with Ruff
|
|
||||||
run: |
|
|
||||||
pip install ruff
|
|
||||||
ruff format . --target-version=py311
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
- name: Login to Digital Hippo Labs Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DIPPOLABS_USERNAME }}
|
|
||||||
password: ${{ secrets.DIPPOLABS_TOKEN }}
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
|
|
||||||
- name: Build Docker Image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
push: true
|
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.ORG_NAME }}-${{ env.IMAGE_NAME }}:latest
|
|
||||||
|
|
||||||
# - name: Update Service via Webhook
|
|
||||||
# uses: https://github.com/newarifrh/portainer-service-webhook@v1
|
|
||||||
# with:
|
|
||||||
# webhook_url: ${{ secrets.SERVICE_WEBHOOK_URL }}
|
|
||||||
|
|
||||||
# - name: Publish to Portainer
|
|
||||||
# uses: https://github.com/luminos-company/portami@v1.2
|
|
||||||
# with:
|
|
||||||
# endpoint: 'https://portainer.digitalhippo.tech'
|
|
||||||
# access_token: ${{ secrets.PORTAINER_ACCESS_KEY }}
|
|
||||||
# stack_name: ${{ secrets.PORTAINER_STACK_NAME }} # The unique name of the stack like: "cdn_minio"
|
|
||||||
# file_path: 'docker-compose.yml' # The stack file path to use
|
|
||||||
# prune: true # Prune the stack
|
|
||||||
# pull: true # Pull the images
|
|
||||||
20
Dockerfile
20
Dockerfile
|
|
@ -1,20 +0,0 @@
|
||||||
FROM python:3.11
|
|
||||||
|
|
||||||
WORKDIR /deployment
|
|
||||||
|
|
||||||
# Setup virtual environment
|
|
||||||
ENV VIRTUAL_ENV=/opt/venv
|
|
||||||
RUN python3 -m venv $VIRTUAL_ENV
|
|
||||||
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
||||||
|
|
||||||
# Install dependencies:
|
|
||||||
COPY requirements.txt .
|
|
||||||
RUN ["pip", "install", "-r", "requirements.txt"]
|
|
||||||
|
|
||||||
# Copy the application:
|
|
||||||
ADD service.py .
|
|
||||||
ADD config.py .
|
|
||||||
ADD app.py .
|
|
||||||
|
|
||||||
# Run the application:
|
|
||||||
CMD ["huey_consumer.py", "app.huey", "-k", "process", "-w", "2"]
|
|
||||||
22
app.py
22
app.py
|
|
@ -1,17 +1,15 @@
|
||||||
|
from argparse import ArgumentParser
|
||||||
from config import Config as cfg
|
from config import Config as cfg
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from espn_api.football import League
|
from espn_api.football import League
|
||||||
from gspread_dataframe import set_with_dataframe
|
from gspread_dataframe import set_with_dataframe
|
||||||
from huey import crontab, RedisHuey
|
|
||||||
from service import gc
|
from service import gc
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
|
from time import strftime
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
huey = RedisHuey('report-generator', host='redis')
|
|
||||||
|
|
||||||
|
|
||||||
def check_int(s):
|
def check_int(s):
|
||||||
if s is None:
|
if s is None:
|
||||||
return s
|
return s
|
||||||
|
|
@ -53,8 +51,13 @@ def write_to_google_spreadsheet(df: pd.DataFrame):
|
||||||
set_with_dataframe(worksheet, df)
|
set_with_dataframe(worksheet, df)
|
||||||
|
|
||||||
|
|
||||||
@huey.periodic_task(crontab(hour='6'))
|
if __name__ == "__main__":
|
||||||
def process_daily_report():
|
parser = ArgumentParser(description='Weekly Report Generator for Fantasy Football')
|
||||||
|
parser.add_argument('-csv', action='store_true')
|
||||||
|
parser.add_argument('-gs', action='store_true')
|
||||||
|
args = vars(parser.parse_args())
|
||||||
|
timestamp = strftime("%Y%m%d_%H%M%S")
|
||||||
|
|
||||||
league = League(league_id=cfg.LEAGUE_ID,
|
league = League(league_id=cfg.LEAGUE_ID,
|
||||||
year=datetime.now().year,
|
year=datetime.now().year,
|
||||||
espn_s2=cfg.ESPN_S2,
|
espn_s2=cfg.ESPN_S2,
|
||||||
|
|
@ -64,4 +67,11 @@ def process_daily_report():
|
||||||
matchup = extract_matchup_box_scores(league=league)
|
matchup = extract_matchup_box_scores(league=league)
|
||||||
df = pd.DataFrame.from_dict(matchup)
|
df = pd.DataFrame.from_dict(matchup)
|
||||||
print(tabulate(df, headers='keys', tablefmt='psql', showindex=False))
|
print(tabulate(df, headers='keys', tablefmt='psql', showindex=False))
|
||||||
|
|
||||||
|
if args['csv']:
|
||||||
|
print("Saving to CSV...")
|
||||||
|
df.to_csv(f'espn_fantasy_football_weekly_report_{timestamp}.csv', index=False, float_format='%.2f')
|
||||||
|
|
||||||
|
if args['gs']:
|
||||||
|
print("Saving to Google Sheets...")
|
||||||
write_to_google_spreadsheet(df=df)
|
write_to_google_spreadsheet(df=df)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
google-auth-oauthlib==1.2.1
|
google-auth-oauthlib==1.2.1
|
||||||
gspread==6.1.2
|
gspread==6.1.2
|
||||||
gspread-dataframe==4.0.0
|
gspread-dataframe==4.0.0
|
||||||
huey==2.5.2
|
|
||||||
pandas==2.2.3
|
pandas==2.2.3
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
redis==5.1.0
|
|
||||||
tabulate==0.9.0
|
tabulate==0.9.0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue