Skip to content

Commit

Permalink
Merge pull request #229 from uberfastman/release/v20.0.0
Browse files Browse the repository at this point in the history
Release/v20.0.0
  • Loading branch information
uberfastman authored Jan 6, 2025
2 parents 5862214 + 747d840 commit 7f5a4e6
Show file tree
Hide file tree
Showing 54 changed files with 4,791 additions and 3,887 deletions.
12 changes: 3 additions & 9 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
**.pytest_cache

# environment
.env*
env*
.venv
venv
*.env*
.venv*/
.python-venv

# auth secrets
**private*.json
!**private.template.json
**token*.json
!**token.template.json
**credentials*.json
!**credentials.template.json

# output
**logs/
Expand Down
18 changes: 4 additions & 14 deletions .github/workflows/python-build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# This workflow will install Python dependencies and run tests with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: CI Build
Expand All @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -31,18 +31,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 bandit pytest
python -m pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors
# flake8 . --count --show-source --statistics
# # exit-zero treats all errors as warnings
# flake8 . --count --exit-zero --statistics
# - name: Security lint with bandit
# run: |
# # stop the build if there are security warnings
# bandit -r yfpy/
- name: Test with pytest
- name: Test with PyTest
run: |
pytest
13 changes: 0 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,11 @@

# environment
*.env*
env*
.venv
venv
.venv*/
venv*/
.python-version
.python-venv

# dependencies
uv.lock

# auth secrets
**private*.json
!**private.template.json
**token*.json
!**token.template.json
**credentials*.json
!**credentials.template.json

# output
**logs/
Expand Down
24 changes: 24 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exclude = [
".git",
".github",
".idea",
".pytest_cache",
".python-venv",
"__pycache__",
]
extend-exclude = [
]
line-length = 120
indent-width = 4

[format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true
skip-magic-trailing-comma = false
line-ending = "auto"

[lint]
extend-select = [
"E501"
]
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Determine this makefile's path. Be sure to place this BEFORE `include` directives, if any.
THIS_FILE := $(lastword $(MAKEFILE_LIST))

# help target from https://github.com/cargo-bins/cargo-quickinstall/blob/e17486445f6577c551a35876dca73132cc4c6298/Makefile#L70
help:
@grep -E '^[a-z.A-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: deps dev_deps lint secure test_code test_actions test_actions_amd check test_check help Makefile

deps: ## Install all dependencies.
uv pip install -r requirements.txt

dev_deps: ## Install all development dependencies.
uv pip install -r requirements-dev.txt

lint: ## Lint code with ruff.
ruff check .

secure: ## Check code security with bandit.
$ bandit -r ffmwr -s B113,B310,B311,B608

test_code: ## Run tests with PyTest.
pytest tests

test_actions: ## Test GitHub Actions using act.
act -j build

test_actions_amd: ## Test package GitHub Actions on ARM architecture using act.
act --container-architecture linux/amd64 -j build

check: deps dev_deps lint secure ## Run all code checks.
echo "Code checked."

test_check: check test_code ## Run all code checks and tests.
echo "Code checked and tested."
48 changes: 27 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Project dependencies can be viewed in the [`requirements.txt`](requirements.txt)

The Fantasy Football Metrics Weekly Report requires several sets of setup steps, depending on which platform(s) for which you will be running it. To get the application running locally, you will first need to complete the below setup.

_\* General setup **excludes** Google Drive and Slack integrations. See [Additional Integrations](#additional-integrations) for details on including those add-ons._
_\* General setup **excludes** third-party integrations. See [Additional Integrations](#additional-integrations) for details on including those add-ons._

---

Expand Down Expand Up @@ -452,15 +452,19 @@ CBS has a public API that was once documented, the last version of which can be

1. You should see the following prompts:

1. `Generate report for default league? (y/n) -> `.
1. `Generate report for default platform? (y/n) ->`

Type `y` and hit enter.

2. `Generate report for default week? (y/n) ->`.

Type `y` and hit enter.

3. <ins>**NOTE FOR YAHOO USERS ONLY**</ins>: The ***FIRST*** time you run the app, you will see an `AUTHORIZATION URL` (if you followed the instructions in the [Yahoo Setup](#yahoo-setup) section).
3. `Generate report for default league? (y/n) -> `

Type `y` and hit enter.

4. <ins>**NOTE FOR YAHOO USERS ONLY**</ins>: The ***FIRST*** time you run the app, you will see an `AUTHORIZATION URL` (if you followed the instructions in the [Yahoo Setup](#yahoo-setup) section).

1. Click the link (or copy and paste it into your web browser).

Expand Down Expand Up @@ -527,29 +531,31 @@ In addition to turning on/off the features of the report PDF itself, there are a

After completing the above setup and settings steps, you should now be able to simply run `docker exec -it fantasy-football-metrics-weekly-report_app_1 python main.py` to regenerate a report. The report generator script (`main.py`) also supports several command line options/arguments that allow you to specify the following:

| Flag | Description |
|:----------------------------------------|:--------------------------------------------------------------------------------------------------------------------------|
| `-h`, `--help` | Display command line usage message |
| `-d`, `--use-default` | Automatically run the report using the default settings without user input prompts. |
| `-f`, `--fantasy-platform` `<platform>` | Fantasy football platform on which league for report is hosted. |
| `-l`, `--league-id` `<league_id>` | Fantasy Football league ID |
| `-w`, `--week` `<week>` | Chosen week for which to generate report |
| `-g`, `--game-id` `<game_id>` | Chosen fantasy game id for which to generate report. Defaults to "nfl", interpreted as the current season if using Yahoo. |
| `-y`, `--year` `<year>` | Chosen year (season) of the league for which a report is being generated. |
| `-s`, `--save-data` | Save all retrieved data locally for faster future report generation |
| `-s`, `--refresh-web-data` | Refresh all web data from external APIs (such as bad boy and beef data) |
| `-p`, `--playoff-prob-sims` `<int>` | Number of Monte Carlo playoff probability simulations to run." |
| `-b`, `--break-ties` | Break ties in metric rankings |
| `-q`, `--disqualify-ce` | Automatically disqualify teams ineligible for coaching efficiency metric |
| `-o`, `--offline` | Run ***OFFLINE*** (for development). Must have previously run report with -s option. |
| `-t`, `--test` | Generate TEST report (for development) |
| Flag | Description |
|:-------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------|
| `-h`, `--help` | Display command line usage message |
| `-p`, `--fantasy-platform` `<platform>` | Fantasy football platform on which league for report is hosted |
| `-l`, `--league-id` `<league_id>` | Fantasy Football league ID |
| `-g`, `--yahoo-game-id` `<yahoo_game_id>` | (Yahoo only) Chosen fantasy game id for which to generate report. Defaults to "nfl", which is interpreted as the current season on Yahoo |
| `-y`, `--year` `<year>` | Chosen year (season) of the league for which a report is being generated |
| `-k`, `--start-week` `<league_start_week>` | League start week (if league started later than week |
| `-w`, `--week` `<week>` | Chosen week for which to generate report |
| `-d`, `--use-default` | Run the report using the default settings (in .env file) without user input |
| `-s`, `--save-data` | Save all fantasy league data for faster future report generation |
| `-r`, `--refresh-feature-web-data` | Refresh all feature web data |
| `-m`, `--playoff-prob-sims` `<num_sims>` | Number of Monte Carlo playoff probability simulations to run |
| `-b`, `--break-ties` | Break ties in metric rankings |
| `-q`, `--disqualify-coaching-efficiency` | Automatically disqualify teams ineligible for coaching efficiency metric |
| `-o`, `--offline` | Run ***OFFLINE*** for development (must have previously run report with -s option) |
| `-u`, `--skip-uploads ` | Skip all integration uploads regardless of the configured settings |
| `-t`, `--test` | Generate TEST report |

#### NOTE: all command line arguments <ins>***OVERRIDE***</ins> any settings in the local .env file!

##### Example:

```bash
docker exec -it fantasy-football-metrics-weekly-report_app_1 python main.py -l 140941 -f fleaflicker -y 2020 -w 3 -p 1000 -s -r
docker exec -it fantasy-football-metrics-weekly-report_app_1 python main.py -p fleaflicker -l 140941 -y 2020 -w 3 -m 1000 -s -r
```

The above command runs the report with the following settings (which override anything set in the `.env` file):
Expand All @@ -573,7 +579,7 @@ The above command runs the report with the following settings (which override an
<a name="additional-integrations"></a>
### Additional Integrations

The Fantasy Football Metrics Weekly Report application also supports several additional integrations if you choose to utilize them. Currently, it is capable of uploading your generated reports to Google Drive, and also directly posting your generated reports to the Slack Messenger app.
The Fantasy Football Metrics Weekly Report application also supports several additional integrations if you choose to utilize them.

<a name="google-drive-setup"></a>
#### Google Drive Setup
Expand Down
40 changes: 15 additions & 25 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,17 @@
pip install -r requirements.txt -r requirements-dev.txt
```

4. *(Optional)* Lint code with `flake8`:
```shell
flake8 . --count --show-source --statistics
```

5. *(Optional)* Check code security with `bandit`:
```shell
bandit -r .
```

6. *(Optional)* Run *all* `pytest` tests:
4. *(Optional)* Run *all* `pytest` tests:
```shell
python -m pytest
```

7. *(Optional)* Run *all* `pytest` tests *verbosely*:
5. *(Optional)* Run *all* `pytest` tests *verbosely*:
```shell
python -m pytest -v -s
```

8. *(Optional)* Test Python support using [act](https://github.com/nektos/act) for GitHub Actions:
6. *(Optional)* Test Python support using [act](https://github.com/nektos/act) for GitHub Actions:

```shell
act -j build
Expand All @@ -44,33 +34,33 @@
sudo ln -s "$HOME/.docker/run/docker.sock" /var/run/docker.sock`
```

9. Update the Docker `compose.yaml` file with the latest version of the app.
7. Update the Docker `compose.yaml` file with the latest version of the app.

10. Build and push a new Docker image for the app (see [DEPLOYMENT.md](./docker/DEPLOYMENT.md)).
8. Build and push a new Docker image for the app (see [DEPLOYMENT.md](./docker/DEPLOYMENT.md)).

11. *(Optional)* Create a new git branch if creating a release:
```shell
git checkout -b release/vX.X.X
```
9. *(Optional)* Create a new git branch if creating a release:
```shell
git checkout -b release/vX.X.X
```

12. Create a git commit:
10. Create a git commit:
```shell
git add .
git commit -m 'commit message'
```

13. Update the git tag (format: `git tag -a [tag_name/version] -m [message]`):
11. Update the git tag (format: `git tag -a [tag_name/version] -m [message]`):
```shell
git tag -a v1.0.0 -m 'first release'
git push origin --tags
```

14. *(Optional)* View git tags:
12. *(Optional)* View git tags:
```shell
git tag -l --sort=v:refname -n99
```

15. Update `fantasy-football-metrics-weekly-report` GitHub repository:
13. Update `fantasy-football-metrics-weekly-report` GitHub repository:

* *(Optional)* If creating a release:
```shell
Expand All @@ -82,6 +72,6 @@
git push
```

16. Open a pull request (PR) with the `release/vX.X.X` branch, allow GitHub actions to complete successfully, draft release notes, and merge it.
14. Open a pull request (PR) with the `release/vX.X.X` branch, allow GitHub actions to complete successfully, draft release notes, and merge it.

17. Go to the [FFMWR Releases page](https://github.com/uberfastman/fantasy-football-metrics-weekly-report/releases) and draft a new release using the above git tag.
15. Go to the [FFMWR Releases page](https://github.com/uberfastman/fantasy-football-metrics-weekly-report/releases) and draft a new release using the above git tag.
4 changes: 2 additions & 2 deletions compose.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ services:
dockerfile: docker/Dockerfile
args:
- PYTHON_VERSION_MAJOR=3
- PYTHON_VERSION_MINOR=12
- PYTHON_VERSION_PATCH=7
- PYTHON_VERSION_MINOR=13
- PYTHON_VERSION_PATCH=1
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
services:

app:
image: ghcr.io/uberfastman/fantasy-football-metrics-weekly-report:19.5.0
image: ghcr.io/uberfastman/fantasy-football-metrics-weekly-report:20.0.0
platform: linux/amd64
ports:
- "5001:5000"
Expand Down
2 changes: 0 additions & 2 deletions dao/__init__.py

This file was deleted.

Loading

0 comments on commit 7f5a4e6

Please sign in to comment.