-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from mrc-ide/python-interface-poc
Add Python interface
- Loading branch information
Showing
82 changed files
with
2,583 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ docker | |
^tmp$ | ||
^README\.Rmd$ | ||
^CPPLINT\.cfg$ | ||
^leapfrog-py$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Build and upload to PyPI | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- published | ||
|
||
defaults: | ||
run: | ||
working-directory: leapfrog-py | ||
|
||
jobs: | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
# macos-13 is an intel runner, macos-14 is apple silicon | ||
os: [ubuntu-latest, windows-latest, macos-13, macos-14] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build wheels | ||
uses: pypa/cibuildwheel@v2.19.1 | ||
with: | ||
package-dir: leapfrog-py | ||
env: | ||
# Issue with compiling pybind11 eigen header as it has an invalid | ||
# conversion from size_t to int | ||
CIBW_SKIP: "pp38-manylinux_i686 pp39-manylinux_i686 pp310-manylinux_i686" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
path: ./wheelhouse/*.whl | ||
|
||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Build sdist | ||
run: pipx run build --sdist | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-sdist | ||
path: dist/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: pypi | ||
permissions: | ||
id-token: write | ||
if: github.event_name == 'release' && github.event.action == 'published' | ||
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | ||
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
|
||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
# To test: repository-url: https://test.pypi.org/legacy/ | ||
repository-url: https://upload.pypi.org/legacy/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: leapfrog-py test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "*" | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
run: | ||
|
||
runs-on: ${{ matrix.config.os }} | ||
|
||
name: ${{matrix.config.os }} (${{ matrix.config.py }}) | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- {os: macos-latest, py: '3.13'} | ||
- {os: ubuntu-latest, py: '3.10'} | ||
- {os: ubuntu-latest, py: '3.11'} | ||
- {os: ubuntu-latest, py: '3.12'} | ||
- {os: ubuntu-latest, py: '3.13'} | ||
- {os: windows-latest, py: '3.13'} | ||
|
||
defaults: | ||
run: | ||
working-directory: leapfrog-py | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v5 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: "leapfrog-py/uv.lock" | ||
|
||
- name: "Set up Python" | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.config.py }} | ||
|
||
- name: Extract test data | ||
shell: bash | ||
run: ../inst/standalone_model/extract_data | ||
|
||
# We need to install R to run the test to compare R and Python output | ||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
extra-repositories: https://mrc-ide.r-universe.dev | ||
working-directory: . | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: docopt, local::. | ||
working-directory: . | ||
|
||
- name: Install the project | ||
run: uv sync --all-extras --dev | ||
|
||
- name: Run tests & coverage | ||
run: uv run pytest --cov --cov-report=xml --cov-config=pyproject.toml | ||
|
||
- name: Lint | ||
run: | | ||
uvx ruff check . | ||
uv run --group check mypy --install-types --non-interactive src tests | ||
- name: Test install | ||
run: | | ||
pip install . | ||
python -c "import leapfrog_py;" | ||
- name: Upload to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
# This can be useful, but the false positive rate is | ||
# annoyingly high. | ||
fail_ci_if_error: false | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/sh | ||
|
||
##$R_HOME/bin/Rscript inst/cpp_generation/generate.R | ||
echo "TODO turn generate back on when generating out state_types needed by Python" | ||
#$R_HOME/bin/Rscript inst/cpp_generation/generate.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.