Skip to content

Commit

Permalink
Merge pull request #577 from alan-turing-institute/develop
Browse files Browse the repository at this point in the history
REG Hack Week Changes
  • Loading branch information
jack89roberts authored Jun 16, 2023
2 parents 678735c + 22c61fd commit 69e1721
Show file tree
Hide file tree
Showing 34 changed files with 6,421 additions and 1,163 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1

on:
pull_request:
branches: [ "main", "develop" ]

push:
branches: [ "main", "develop" ]

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Checkout Code Repository
uses: actions/checkout@main

- name: Build AIrsenal
run: docker build -t airsenal .

- name: Code quality checks
run: |
docker run airsenal poetry run pre-commit run --all-files
- name: Tests
run: |
docker run -e "FPL_TEAM_ID=2779516" airsenal poetry run pytest
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 22.3.0
hooks:
- id: black
language_version: python3.9
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
FROM python:3.8-slim-buster
FROM python:3.9-slim-buster

RUN apt-get update && \
apt-get install build-essential git sqlite3 curl -y && \
pip install -U setuptools pygmo poetry

WORKDIR /airsenal

COPY . /airsenal

RUN apt-get update && apt-get install build-essential git sqlite3 -y && \
pip install pygmo && pip install .
RUN poetry install --extras "api"

CMD ["airsenal_run_pipeline"]
CMD ["poetry", "run", "airsenal_run_pipeline"]
6 changes: 2 additions & 4 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ The database is filled with data from the previous three FPL seasons (stored in

- **TransferSuggestion:** Stores recommended transfers from AIrsenal optimisation runs.


The database schema is defined using `sqlalchemy` in `airsenal.framework.schema.py`.

### Interacting with the FPL API
Expand Down Expand Up @@ -97,12 +96,11 @@ Player points predictions are generated from three main components:

### Team Model

BPL package (written by Angus, one of the original AIrsenal developers): https://github.com/anguswilliams91/bpl

BPL package (written by Angus, one of the original AIrsenal developers): https://github.com/anguswilliams91/bpl-next

### Player Model

Stan model definition: `airsenal/stan/player_forecasts.stan`
NumPyro model definition: `airsenal/framework/player_model.py`

### How Predicted Points are Calculated

Expand Down
48 changes: 38 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ We welcome contributions and comments - if you'd like to join the AIrsenal commu

We have made a mini-league **"Prem-AI League"** for players using this software. To join, login to the FPL website, and navigate to the page to join a league: https://fantasy.premierleague.com/leagues/create-join then click "join a league or cup".
The code to join is: **8wec9c**.
Hope to see your AI team there! :)
Hope to see your AI team there!! :)

Our own AIrsenal team's id for the 2022/23 season is **[2779516](https://fantasy.premierleague.com/entry/2779516/history)**.
Our own AIrsenal team's ID for the 2022/23 season is **[2779516](https://fantasy.premierleague.com/entry/2779516/history)**.

## Installation

Expand Down Expand Up @@ -63,23 +63,51 @@ AIrsenal has an optional optimisation algorithm using the PyGMO package, which i

Build the docker-image:

```shell
docker build -t airsenal .
```console
$ docker build -t airsenal .
```

If `docker build` fails due to a `RuntimeError` like

```console
Unable to find installation candidates for jaxlib (0.4.11)
```

this may be a lack of maintained versions of a package for `m1` on Linux.

A slow solution for this error is to force a `linux/amd64` build like

```console
$ docker build --platform linux/amd64 -t airsenal .
```

If that fails try

```console
$ docker build --platform linux/amd64 --no-cache -t airsenal .
```

See ticket [#547](https://github.com/alan-turing-institute/AIrsenal/issues/574) for latest on this issue.

Create a volume for data persistance:

```shell
docker volume create airsenal_data
```console
$ docker volume create airsenal_data
```

Run commands with your configuration as environment variables, eg:

```shell
docker run -it --rm -v airsenal_data:/tmp/ -e "FPL_TEAM_ID=<your_id>" -e "AIRSENAL_HOME=/tmp" airsenal [airsenal_run_pipeline]
```console
$ docker run -it --rm -v airsenal_data:/tmp/ -e "FPL_TEAM_ID=<your_id>" -e "AIRSENAL_HOME=/tmp" airsenal bash
```

or

```console
$ docker run -it --rm -v airsenal_data:/tmp/ -e "FPL_TEAM_ID=<your_id>" -e "AIRSENAL_HOME=/tmp" airsenal airsenal_run_pipeline
```

```airsenal_run_pipeline``` is the default command.
`airsenal_run_pipeline` is the default command.

## Optional dependencies

Expand Down Expand Up @@ -159,7 +187,7 @@ with more recent data, using the command
airsenal_update_db
```

The next step is to use the team- and player-level Stan models to predict the expected points for all players for the next fixtures. This is done using the command
The next step is to use the team- and player-level NumPyro models to predict the expected points for all players for the next fixtures. This is done using the command

```shell
airsenal_run_prediction --weeks_ahead 3
Expand Down
2 changes: 1 addition & 1 deletion airsenal/data/FPL_2122.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion airsenal/data/fifa_team_ratings_1718.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ Bournemouth,76,74,75,75
Burnley,74,75,75,75
Newcastle United,74,75,75,75
Brighton & Hove Albion,74,74,73,74
Huddersfield Town,73,73,72,73
Huddersfield Town,73,73,72,73
Norwich City,73,73,74,73
Aston Villa,74,73,73,73
Sunderland,81,76,73,76
Hull City,76,74,75,75
Middlesbrough,76,74,74,75
2 changes: 1 addition & 1 deletion airsenal/data/player_details_2122.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion airsenal/data/player_summary_2122.json

Large diffs are not rendered by default.

Loading

0 comments on commit 69e1721

Please sign in to comment.