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

Migrate to pixi #184

Merged
merged 8 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
*.{py,yaml,yml,sh} text eol=lf
*.bat text eol=crlf

src/spox/opset/** linguist-vendored
src/spox/opset/** linguist-vendored
53 changes: 24 additions & 29 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,41 @@ on:
- published

jobs:
build_sdist_and_wheel:
name: Build sdist and wheel on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04 ]

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Build
run: |
pip install build
python -m build

- name: Test install and import
run: |
python -m venv ./env
. ./env/bin/activate
pip install dist/*.whl
python -c "import spox"

- uses: actions/upload-artifact@v4
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environments: build
- name: Build project
run: pixi run -e build build-wheel
- name: Upload package
uses: actions/upload-artifact@v4
with:
name: artifact
path: dist/*

upload_pypi:
name: Upload to PyPI
needs: [build_sdist_and_wheel]
publish:
name: Publish package
if: startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
permissions:
id-token: write
environment: pypi
steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.10.3
- name: Publish package on TestPyPi
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b
85 changes: 37 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,69 @@
name: CI

on: push

defaults:
run:
shell: bash -el {0}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pre-commit-checks:
name: "Linux - pre-commit hooks - Python 3.8"
name: Pre-commit Checks
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v4
- name: Install Python 3.8
uses: actions/setup-python@v5
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
python-version: 3.8
- name: Run pre-commit checks
uses: pre-commit/[email protected]
environments: default lint
- name: pre-commit
run: pixi run pre-commit-run --color=always --show-diff-on-failure

tests:
name: "Linux - unit tests - ${{ matrix.OS }} - Python ${{ matrix.PYTHON_VERSION }}"
runs-on: ${{ matrix.OS }}
env:
CI: True
unit-tests:
name: pytest
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
OS: ["ubuntu-latest"]
PYTHON_VERSION: ['3.8', '3.9', '3.10', '3.11']
include:
- OS: macos-latest-xlarge
PYTHON_VERSION: "3.11"
os:
- ubuntu-latest
- macos-latest
- windows-latest
environment:
- py39
- py310
- py311
- py312
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: mamba-org/setup-micromamba@v1
fetch-depth: 0
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environment-file: environment.yml
create-args: >-
python=${{ matrix.PYTHON_VERSION }}
- name: Run unit tests
shell: bash -l {0}
run: |
pip install .
pytest
environments: ${{ matrix.environment }}
- name: Install repository
run: pixi run -e ${{ matrix.environment }} postinstall
- name: Run pytest
run: pixi run -e ${{ matrix.environment }} test

opset-generation:
name: "Linux - opset generation - ${{ matrix.OS }} - Python ${{ matrix.PYTHON_VERSION }}"
runs-on: ${{ matrix.OS }}
name: "Linux - opset generation"
runs-on: ubuntu-latest
env:
CI: True
strategy:
fail-fast: true
matrix:
OS: ["ubuntu-latest", "macos-latest"]
PYTHON_VERSION: ['3.8']
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: mamba-org/setup-micromamba@v1
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environment-file: environment.yml
create-args: >-
python=${{ matrix.PYTHON_VERSION }}
environments: opset-generation
- name: Run code generation
shell: bash -l {0}
env:
PRE_COMMIT_USE_MICROMAMBA: 1
run: |
pip install .
pre-commit install
python tools/generate_opset.py
git diff --exit-code
run: pixi run -e opset-generation generate-opset
27 changes: 10 additions & 17 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,24 @@ defaults:

jobs:
tests:
name: "Linux - unit tests - ${{ matrix.OS }} - Python ${{ matrix.PYTHON_VERSION }}"
runs-on: ${{ matrix.OS }}
name: "Linux - weekly unit tests - ubuntu-latest"
runs-on: ubuntu-latest
env:
CI: True
strategy:
fail-fast: true
matrix:
OS: ["ubuntu-latest"]
PYTHON_VERSION: ['3.12']
steps:
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: mamba-org/setup-micromamba@v1
fetch-depth: 0
- name: Set up pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659
with:
environment-file: environment.yml
create-args: >-
python=${{ matrix.PYTHON_VERSION }}
- name: Run unit tests
shell: bash -l {0}
run: |
pip install onnx-weekly --pre
pip install .
pytest
environments: opset-generation
- name: Install repository
run: pixi run -e weekly postinstall
- name: Run pytest
run: pixi run -e weekly test
- name: Issue on failure
uses: actions/github-script@v7
if: ${{ failure() && github.ref == 'refs/heads/main' }}
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,6 @@ mlruns

# MacOS
.DS_Store
# pixi environments
.pixi
*.egg-info
70 changes: 50 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
exclude: ^.pixi$
repos:
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff
rev: 0.6.2
- repo: local
hooks:
- id: ruff-conda
- id: ruff-format-conda
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy
rev: "1.10.1"
hooks:
- id: mypy-conda
additional_dependencies: [-c, conda-forge, types-setuptools]
- repo: https://github.com/Quantco/pre-commit-mirrors-pyupgrade
rev: 3.15.2
hooks:
- id: pyupgrade-conda
args:
- --py38
- repo: https://github.com/Quantco/pre-commit-mirrors-prettier
rev: 3.2.5
hooks:
- id: prettier-conda
files: "\\.md$"
# ensure pixi environments are up to date
# workaround for https://github.com/prefix-dev/pixi/issues/1482
- id: pixi-install
name: pixi-install
entry: pixi install -e py39 -e lint
language: system
always_run: true
require_serial: true
pass_filenames: false
# insert-license
- id: insert-license
name: insert-license
entry: >-
pixi run -e lint
insert-license
--license-base64 Q29weXJpZ2h0IChjKSBRdWFudENvIDIwMjMtMjAyNApTUERYLUxpY2Vuc2UtSWRlbnRpZmllcjogQlNELTMtQ2xhdXNlCg==
--dynamic-years
--comment-style "#"
language: system
types: [python]
# ruff
- id: ruff
name: ruff
entry: pixi run -e lint ruff check --fix --exit-non-zero-on-fix --force-exclude --target-version py39
language: system
types_or: [python, pyi]
require_serial: true
- id: ruff-format
name: ruff-format
entry: pixi run -e lint ruff format --force-exclude --target-version py39
language: system
types_or: [python, pyi]
require_serial: true
# mypy
- id: mypy
name: mypy
entry: pixi run -e default mypy
language: system
types: [python]
require_serial: true
exclude: ^(tests|api-coverage-tests)/
# prettier
- id: prettier
name: prettier
entry: pixi run -e lint prettier --write --list-different --ignore-unknown
language: system
types: [text]
files: \.(md|yml|yaml)$
21 changes: 8 additions & 13 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: mambaforge-4.10
sphinx:
configuration: docs/conf.py
python:
install:
- method: pip
path: .
conda:
environment: environment.yml
formats:
- pdf
os: "ubuntu-22.04"
commands:
- curl -fsSL https://pixi.sh/install.sh | bash
- chmod +x ~/.pixi/bin/pixi
- ~/.pixi/bin/pixi run -e docs postinstall
- ~/.pixi/bin/pixi run -e docs build-docs
- mkdir -p $READTHEDOCS_OUTPUT/html/
- cp -r docs/_build/html/** $READTHEDOCS_OUTPUT/html/
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
Change log
==========

0.12.2 (unreleased)
0.13.0 (unreleased)
-------------------

**Support change**

- Support for ``Python 3.8`` has been dropped.

**Bug fix**

- Value propagation of string tensors no longer raises an erroneous ``ValueError`` in some instances.
Expand Down
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) QuantCo 2023-2024
# SPDX-License-Identifier: BSD-3-Clause

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
29 changes: 0 additions & 29 deletions environment.yml

This file was deleted.

Loading