Skip to content

Commit

Permalink
Use Poetry (#1346)
Browse files Browse the repository at this point in the history
* start using poetry

* Update pyproject.toml

* update poetry

* Update __version__.py

* Update unit-tests.yml

* make groups optional

* no need to source activate

* Update __version__.py

* Update __version__.py

* bumps

* wip

* wip

* add pytest-xdist[psutil]

* Update pyproject.toml

* Update build.py

* wip

* Update action.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update build.py

* try this

* now try this

* Update unit-tests.yml

* Update sad.py

* Update sad.py

* fix tests

* stuff

* Update action.yml

* Update CONTRIBUTING.md

* Update action.yml

* try adding a build-root param

* wip

* Update unit-tests.yml

* wip

* Update action.yml

* wip

* Update unit-tests.yml
  • Loading branch information
MaxHalford authored Nov 2, 2023
1 parent bc1b7cb commit f514ad0
Show file tree
Hide file tree
Showing 16 changed files with 6,013 additions and 366 deletions.
53 changes: 53 additions & 0 deletions .github/actions/install-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Install env

inputs:
python-version:
description: "Python version to use"
required: true
build-root:
default: "true"
options:
- true
- false

runs:
using: "composite"
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python
id: set-up-python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

- name: Load cached Poetry installation
uses: actions/cache@v3
with:
path: ~/.local # the path depends on the OS
key: poetry-1 # increment to reset cache

- name: Install poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached virtual env
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.set-up-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
shell: bash
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi --no-root

- name: Build
shell: bash
if: ${{ inputs.build-root == 'true' }}
run: poetry install --no-interaction --no-ansi
71 changes: 0 additions & 71 deletions .github/workflows/build-river.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/workflows/ci.yml

This file was deleted.

28 changes: 6 additions & 22 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,13 @@ jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
- name: Build River
uses: ./.github/actions/install-env
with:
python-version: 3.11

- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && rustup show
if: matrix.os == 'ubuntu-latest'

- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -e ".[dev]"
python-version: "3.12"
build-root: false

- name: Run pre-commit on all files
run: pre-commit run --all-files
run: poetry run pre-commit run --all-files
2 changes: 1 addition & 1 deletion .github/workflows/delete-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
my-job:
name: Delete all caches
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Clear caches
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/docs.yml → .github/workflows/dev-docs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: docs

on:
workflow_call:
push:
branches:
- main

jobs:
docs:
Expand All @@ -10,21 +12,25 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Retrieve the environment and the River build
uses: ./.github/actions/retrieve-env
- name: Build River
uses: ./.github/actions/install-env
with:
python: "3.11"
python-version: "3.12"
build-root: false

- name: Install Ubuntu dependencies
- name: Install extra Ubuntu dependencies
run: sudo apt-get install graphviz pandoc

- name: Install extra Python dependencies
run: |
poetry install --with docs
- name: Build docs
run: |
source ~/.venv/bin/activate
make doc
- name: Deploy docs
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ secrets.GitHubToken }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
arch: alt

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: set up rust
if: matrix.os != 'ubuntu-latest'
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ jobs:
ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Ubuntu dependencies
run: sudo apt-get install graphviz pandoc

- name: Set up Python
uses: actions/setup-python@v4
- name: Build River
uses: ./.github/actions/install-env
with:
python-version: "3.9"
python-version: "3.12"

- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=nightly --profile=minimal -y && rustup show
if: matrix.os == 'ubuntu-latest'
- name: Install extra Ubuntu dependencies
run: sudo apt-get install graphviz pandoc

- name: Install Python dependencies
- name: Install extra Python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -e ".[compat,dev,docs]"
poetry install --with compat --with docs
pip install rich
python -m spacy download en_core_web_sm
Expand Down
46 changes: 19 additions & 27 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: unit-tests

on:
workflow_call:
inputs:
python:
type: string
os:
type: string
pull_request:
branches:
- "*"
push:
branches:
- main

jobs:
test:
runs-on: ${{ inputs.os }}
run:
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.12, 3.11, 3.10]

# Instead of using two matrices in the calling Workflow, we can use conditionals here
# if: (inputs.os == 'ubuntu-latest' && inputs.python == '3.11') || github.event_name == 'push'
if: (inputs.python == '3.11') || github.event_name == 'push'
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Retrieve the environment and the River build
uses: ./.github/actions/retrieve-env
- name: Build River
uses: ./.github/actions/install-env
with:
python: ${{ inputs.python }}
python-version: "3.12"

- name: Cache River datasets
uses: actions/cache@v3
Expand All @@ -38,18 +39,9 @@ jobs:

- name: Download datasets
run: |
source ~/.venv/bin/activate
python -c "from river import datasets; datasets.CreditCard().download(); datasets.Elec2().download(); datasets.SMSSpam().download()"
python -c "from river import bandit; bandit.datasets.NewsArticles().download()"
poetry run python -c "from river import datasets; datasets.CreditCard().download(); datasets.Elec2().download(); datasets.SMSSpam().download()"
poetry run python -c "from river import bandit; bandit.datasets.NewsArticles().download()"
- name: pytest [Branch]
if: github.event_name == 'pull_request'
- name: pytest
run: |
source ~/.venv/bin/activate
pytest --durations=10 -n logical # Run pytest on all logical CPU cores
- name: pytest [Main]
if: github.event_name == 'push'
run: |
source ~/.venv/bin/activate
pytest -m "not datasets" --durations=10 -n logical # Run pytest on all logical CPU cores
poetry run pytest -m "not datasets" --durations=10 -n logical # Run pytest on all logical CPU cores
Loading

0 comments on commit f514ad0

Please sign in to comment.