Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to pixi #802

Merged
merged 36 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c9d4cc7
Create draft of pixi.toml
stanmart May 30, 2024
3af4131
Modify contributing docs to reflect new install process
stanmart May 30, 2024
6a7fc6f
Auto-update lockfile
stanmart Jun 1, 2024
1c8f500
Make CI unit tests work with pixi
stanmart Jun 1, 2024
0511e40
Add lockfile
stanmart Jun 1, 2024
5a32c98
Add psutil to test deps
stanmart Jun 1, 2024
d6fc477
Add oldies tests
stanmart Jun 1, 2024
00b6f0a
Fix test environments
stanmart Jun 1, 2024
510cd02
Mske pre-commit hooks use pixi environments
stanmart Jun 1, 2024
203eb88
Only use -nauto in CI
stanmart Jun 1, 2024
03a7bfd
Add doctest
stanmart Jun 1, 2024
865c685
Remove update section from pixi.toml
stanmart Jun 1, 2024
e13f897
Change ci job name
stanmart Jun 1, 2024
a289e69
Remove multiple postinstalls
stanmart Jun 1, 2024
5e5c3a6
Pixify daily tests
stanmart Jun 1, 2024
b62d9bf
Find minimum versions that actually work
stanmart Jun 1, 2024
58b7269
Make lint environment leaner
stanmart Jun 1, 2024
f479a44
Add formlulaic minimum version to oldies
stanmart Jun 1, 2024
dea9397
Only run pre-commit on changes in CI
stanmart Jun 2, 2024
f7d9987
Pin pixi-setup to sha
stanmart Jun 2, 2024
ce533a0
Fix deps
stanmart Jun 2, 2024
bc2dbb7
Minor fixes
stanmart Jun 2, 2024
b8e48dd
Use intel mkl in benchmarks
stanmart Jun 2, 2024
ef2eccd
Try to make docs work
stanmart Jun 2, 2024
9ef2d7c
Make installing nigthlies a pixi task (for local use, too)
stanmart Jun 2, 2024
ad9239c
Fix pyarrow nighly installation
stanmart Jun 2, 2024
b25b6cb
Add test feature to nightly environment
stanmart Jun 2, 2024
982a065
Add environment for simultaneous editable tabmat and glum install
stanmart Jun 5, 2024
05656f0
Update dev dependencies
stanmart Jun 12, 2024
cf2adc2
Merge branch 'main' into switch-to-pixi
stanmart Jun 12, 2024
3139899
fix mypy quirk
MarcAntoineSchmidtQC Jun 12, 2024
14404d3
fix mypy typing errors
MarcAntoineSchmidtQC Jun 12, 2024
13a76aa
Address @pavelzw's comments
stanmart Jun 13, 2024
4faf370
Remove reference to conda/mamba from contributing instructions
stanmart Jun 15, 2024
f73091e
Merge branch 'main' into switch-to-pixi
MarcAntoineSchmidtQC Jun 18, 2024
00a87ef
Merge branch 'main' into switch-to-pixi
MarcAntoineSchmidtQC Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML

65 changes: 22 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,54 @@ on: [push]

jobs:
pre-commit-checks:
name: Linux - pre-commit checks - Python 3.11
name: Linux - pre-commit checks
timeout-minutes: 30
runs-on: ubuntu-latest
env:
PRE_COMMIT_USE_MICROMAMBA: 1
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up micromamba
uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822
- name: Add micromamba to GITHUB_PATH
run: echo "${HOME}/micromamba-bin" >> "$GITHUB_PATH"
- name: Install Python 3.11
uses: actions/setup-python@v5
- name: Set up pixi
uses: prefix-dev/[email protected]
with:
python-version: "3.11"
- name: Run pre-commit checks
uses: pre-commit/[email protected]
environments: lint default
- name: pre-commit
run: pixi run -e lint pre-commit run --color=always --show-diff-on-failure
stanmart marked this conversation as resolved.
Show resolved Hide resolved

unit-tests:
name: Tests - ${{ matrix.os }} - Py${{ matrix.python-version }}
name: Tests
runs-on: ${{ matrix.os }}
env:
CI: True
strategy:
fail-fast: true
matrix:
include:
- { os: ubuntu-latest, python-version: '3.9' }
- { os: ubuntu-latest, python-version: '3.10' }
- { os: ubuntu-latest, python-version: '3.11' }
- { os: ubuntu-latest, python-version: '3.12' }
- { os: macos-latest, python-version: '3.12' }
- { os: windows-latest, python-version: '3.12' }
- { os: ubuntu-latest, environment: 'py39' }
- { os: ubuntu-latest, environment: 'py310' }
- { os: ubuntu-latest, environment: 'py311' }
- { os: ubuntu-latest, environment: 'py312' }
- { os: ubuntu-latest, environment: 'oldies' }
- { os: windows-latest, environment: 'py312' }
- { os: macos-latest, environment: 'py312' }
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Set up conda env
uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environment-file: environment.yml
init-shell: ${{ matrix.os == 'windows-latest' && 'powershell' || 'bash' }}
cache-environment: true
create-args: >-
python=${{ matrix.python-version }}
- name: Install repository (unix)
if: matrix.os != 'windows-latest'
shell: bash -el {0}
run: pip install --no-use-pep517 --no-deps --disable-pip-version-check -e .
- name: Install repository (windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: pip install --no-use-pep517 --no-deps --disable-pip-version-check -e .
- name: Run pytest (unix)
if: matrix.os != 'windows-latest'
shell: bash -el {0}
run: pytest -nauto tests/glm --doctest-modules src/glum
- name: Run pytest (windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: pytest -nauto .\tests\glm --doctest-modules .\src\glum
environments: ${{ matrix.environment }}
- name: Install repository
run: pixi run -e ${{ matrix.environment }} postinstall
- name: Run pytest
run: pixi run -e ${{ matrix.environment }} test -nauto
- name: Run doctest
if: matrix.os != 'windows-latest'
shell: bash -el {0}
# Check that the readme example will work by running via doctest.
# We run outside the repo to make the test a bit more similar to
# a user running after installing with conda.
run: |
mkdir ../temp
cp README.md ../temp
cd ../temp
python -m doctest -v README.md
pixi run --manifest-path ../glum/pixi.toml -e ${{ matrix.environment }} python -m doctest -v README.md
44 changes: 12 additions & 32 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,42 @@ on:

jobs:
linux-daily-unittests:
name: "Linux - daily unit tests - Python ${{ matrix.PYTHON_VERSION}} - ${{ matrix.NOTE }}"
name: "Linux - daily unit tests - ${{ matrix.NOTE }}"
runs-on: ubuntu-latest
env:
CI: True
strategy:
fail-fast: false
matrix:
include:
- PYTHON_VERSION: '3.10'
- environment: 'nightly'
NOTE: 'Nightly Builds' # run once with nightlies
- PYTHON_VERSION: '3.10'
NOTE: 'Default Builds' # run once with normal dependencies
- environment: 'py312'
NOTE: 'Python 3.12' # run once with normal dependencies
steps:
- name: Checkout branch
uses: actions/checkout@v4
- uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environment-file: environment.yml
create-args: >-
python=${{ matrix.PYTHON_VERSION }}
environments: ${{ matrix.environment }}
- name: Install nightlies
if: matrix.NOTE == 'Nightly Builds'
shell: bash -el {0}
run: |
# needed for tabmat
echo "Install compilation dependencies"
micromamba install -y c-compiler cxx-compiler 'cython!=3.0.4' jemalloc-local libgomp mako xsimd

PRE_WHEELS="https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/"
for pkg in pandas scikit-learn scipy; do
echo "Installing $pkg nightly"
micromamba remove -y --force $pkg
pip install --pre --no-deps --only-binary :all: --upgrade --timeout=60 -i $PRE_WHEELS $pkg
done
echo Install pyarrow nightly
micromamba remove -y --force pyarrow
pip install --extra-index-url https://pypi.fury.io/arrow-nightlies/ --prefer-binary --pre --no-deps pyarrow
echo Install tabmat nightly
micromamba remove -y --force tabmat
pip install --no-use-pep517 --no-deps git+https://github.com/Quantco/tabmat
run: pixi run -e ${{ matrix.environment }} install-nightlies
- name: Install repository
shell: bash -el {0}
run: pip install --no-use-pep517 --no-deps --disable-pip-version-check -e .
run: pixi run -e ${{ matrix.environment }} postinstall
- name: Run pytest
shell: bash -el {0}
run: pytest -nauto tests/glm --doctest-modules src/glum/
run: pixi run -e ${{ matrix.environment }} test -nauto
- name: Run doctest
shell: bash -el {0}
# Check that the readme example will work by running via doctest.
# We run outside the repo to make the test a bit more similar to
# a user running after installing with conda.
run: |
mkdir ../temp
cp README.md ../temp
cd ../temp
python -m doctest -v README.md
pixi run --manifest-path ../glum/pixi.toml -e ${{ matrix.environment }} python -m doctest -v README.md

- name: Issue on failure
uses: actions/github-script@v7
if: ${{ failure() }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ pkgs/*
*.c
*.cpp
!*tmpl.cpp
# pixi environments
.pixi
*.egg-info

56 changes: 34 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
repos:
stanmart marked this conversation as resolved.
Show resolved Hide resolved
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff
rev: 0.4.7
- repo: local
hooks:
- id: ruff-conda
exclude: ^src/glum_benchmarks/orig_sklearn_fork/
- id: ruff-format-conda
exclude: ^src/glum_benchmarks/orig_sklearn_fork/
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy
rev: "1.10.0"
hooks:
- id: mypy-conda
args:
- --check-untyped-defs
- --ignore-missing-imports
- --namespace-packages
exclude: (^tests/|^src/glum_benchmarks/orig_sklearn_fork/)
additional_dependencies: [-c, conda-forge, types-setuptools=67.5, attrs]
- repo: https://github.com/Quantco/pre-commit-mirrors-cython-lint
rev: 0.16.2
hooks:
- id: cython-lint-conda
args: [--no-pycodestyle]
- id: double-quote-cython-strings-conda
# ruff
stanmart marked this conversation as resolved.
Show resolved Hide resolved
- id: ruff
name: ruff
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
- id: ruff-format
name: ruff-format
entry: pixi run -e lint ruff format --force-exclude
language: system
types_or: [python, pyi]
require_serial: true
# cython-lint
- id: cython-lint
name: cython-lint
entry: pixi run -e lint cython-lint --no-pycodestyle
language: system
types: [cython]
require_serial: true
- id: cython-double-quote
name: cython-double-quote
entry: pixi run -e lint double-quote-cython-strings
language: system
types: [cython]
require_serial: true
# mypy
- id: mypy
name: mypy
entry: pixi run -e default mypy --check-untyped-defs --ignore-missing-imports --namespace-packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry: pixi run -e default mypy --check-untyped-defs --ignore-missing-imports --namespace-packages
entry: pixi run -e default mypy

I would suggest moving --check-untyped-defs and --namespace-packages to the pyproject.toml confiiguration and removing --ignore-missing-imports altogether as it can lead to issues.

Instead, I would suggest installing additional types if needed (like pandas-stubs, types-psutil, ...) to your test feature next to mypy and for dependencies that don't have stubs yet adding an exception to pyproject.toml as follows:

[[tool.mypy.overrides]]
# https://github.com/scikit-learn/scikit-learn/issues/16705
module = ["sklearn.*"]
ignore_missing_imports = true

language: system
types: [python]
require_serial: true
10 changes: 4 additions & 6 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ build:
os: ubuntu-22.04
tools:
python: mambaforge-4.10
commands:
- mamba install -c conda-forge -c nodefaults pixi==0.22.0
- pixi run -e docs postinstall
- pixi run readthedocs
sphinx:
configuration: docs/conf.py
python:
install:
- method: pip
path: .
conda:
environment: environment.yml
formats:
- pdf
48 changes: 27 additions & 21 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,47 @@ Install for development
--------------------------------------------------

The first step is to set up a conda environment and install glum in editable mode.
The project uses [pixi](https://pixi.sh/latest/) for managing the environment. If you don't have pixi installed, start by [installing it](https://pixi.sh/latest/#installation).
We strongly suggest to use ``mamba`` instead of ``conda`` as this provides the same functionality at much greater speed.
stanmart marked this conversation as resolved.
Show resolved Hide resolved

::

# First, make sure you have conda-forge as your primary conda channel:
conda config --add channels conda-forge

# Clone the repository
git clone [email protected]:Quantco/glum.git
cd glum

# Set up a conda environment with name "glum"
mamba env create
# Install the pre-commit hooks
pixi run pre-commit-install

# Install the dependencies, as well as and glum in editable mode
pixi run postinstall

# If you want to install the dependencies necessary for benchmarking against other GLM packages:
mamba env update -n glum --file environment-benchmark.yml
pixi run -e benchmark postinstall

# If you want to work on the tutorial notebooks:
mamba env update -n glum --file environment-tutorial.yml
# If you want to work on the tutorial notebooks or the documentation:
pixi run -e docs postinstall

# Activate the previously created conda environment
conda activate glum
# You can run any command in the pixi environment with `pixi run <command>`. For example:
pixi run [-e ENVIRONMENT] ipython

# Set up our pre-commit hooks for black, mypy, isort and flake8.
pre-commit install
# Alternatively, you can create a shell with the pixi environment activated:
pixi shell

# Install this package in editable mode.
pip install --no-use-pep517 --disable-pip-version-check -e .
# Alternatively, a number of pixi tasks are available for commonly used commands.
# You can run them with `pixi run <task>`.
# To get a list of available tasks, run:
pixi task list


Testing and continuous integration
--------------------------------------------------
The test suite is in ``tests/``.
The test suite is in ``tests/``. A pixi task is available to run the tests:

::

pixi run test


Golden master tests
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -80,12 +88,12 @@ If you want to skip the slow tests, add the ``-m "not slow"`` flag to any pytest
Storing and modifying
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To store the golden master results:
To store the golden master results, use the following pixi tasks:

::

python tests/glm/test_golden_master.py
python tests/glm/test_benchmark_golden_master.py
pixi run store-golden-master
pixi run store-benchmark-golden-master

Add the ``--overwrite`` flag if you want to overwrite already existing golden master results

Expand All @@ -108,9 +116,7 @@ The documentation is built with a mix of Sphinx, autodoc, and nbsphinx. To devel

::

cd docs
make html
python -m http.server --directory _build/html
pixi run serve-docs

Then, navigate to `<http://localhost:8000>`_ to view the documentation.

Expand Down
7 changes: 0 additions & 7 deletions environment-benchmark.yml

This file was deleted.

10 changes: 0 additions & 10 deletions environment-tutorial.yml

This file was deleted.

Loading